show_html: () -> \r
@trigger('title', @params)\r
show = new Pettanr.Views.OriginalPicture.Show(@item, {\r
+ context: this, \r
+ click_license: (dialog) =>\r
+ @trigger('lock', @params, dialog)\r
+ publish: (dialog) =>\r
+ @trigger('unlock', @params, dialog)\r
+ close_dialog: (dialog) =>\r
+ @trigger('unlock', @params, dialog)\r
})\r
- @listenTo(show, 'click:license', @click_license)\r
- @listenTo(show, 'success', @publish)\r
- @listenTo(show, 'click:close', @close_dialog)\r
show.render()\r
@trigger('ready', show)\r
@trigger('done', @params)\r
@trigger('ready', @form)\r
@trigger('lock', @params, @form)\r
\r
- click_license: (dialog) ->\r
- @trigger('lock', @params, dialog)\r
- \r
- publish: (dialog) ->\r
- @trigger('unlock', @params, dialog)\r
- \r
- close_dialog: (dialog) ->\r
- @trigger('unlock', @params, dialog)\r
- \r
create: () ->\r
@listenTo(@form, 'success', @post_success)\r
@listenTo(@form, 'fail', @post_fail)\r
success: (items) => \r
pager = Locmare.ListGroupModule.LibModule.PlayPager.factory(@list.page_status, @params)\r
@trigger('title', @params, @item.get('title'))\r
- show = new Pettanr.Views.Scroll.Play({\r
- item: @item,\r
+ show = new Pettanr.Views.Scroll.Play(@item,{\r
list: @list,\r
pager: pager\r
})\r
click_update: () ->\r
# do fetch / update item\r
Pettanr.cache.refresh(@item)\r
- @remove()\r
@render()\r
\r
module: () ->\r
\r
ready_caption: (caption) ->\r
el = if @has_link()\r
- linked_caption = new Tag.A({\r
- attr: {href: '/' + @link.url()}, \r
- content: caption\r
- })\r
- @listenTo(linked_caption, 'click', @click)\r
- linked_caption.render().el\r
+ @link.button(caption, this).render().el\r
else\r
caption\r
this.$el.html(el)\r
this\r
\r
- click: () ->\r
- @trigger('click:caption')\r
- @trigger('http_get', @link.url())\r
- false\r
- \r
mdl: () ->\r
Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.CaptionItemColumnModule.DefaultModule\r
\r
render: () ->\r
this\r
\r
- replace_empty: () ->\r
- if Pettanr.is_blank(@caption())\r
- empty = new Pettanr.View.EmptyDiv()\r
- this.$el.html(empty.render().el)\r
- else\r
- this.$el.html(@caption())\r
- this\r
- \r
filer: () ->\r
@default_caption.filer()\r
\r
this.$el.html(@face.el)\r
this\r
\r
+ button: (caption, context) ->\r
+ url = @url()\r
+ new Pettanr.View.Button(url, caption, {\r
+ context: context,\r
+ click: () ->\r
+ @trigger('click:caption')\r
+ @trigger('http_get', url)\r
+ false\r
+ })\r
+ \r
url: () ->\r
controller = Manifest.manifest().controllers[@item.table_name()]\r
action = controller.actions[@my_manifest.action_name]\r
this.$el.html(@face.el)\r
this\r
\r
- js_url: () ->\r
- "javascript:void(0)"\r
+ button: (caption, context) ->\r
+ url = @url()\r
+ new Tag.A_({\r
+ attr: {href: url}, \r
+ content: caption\r
+ })\r
\r
url: () ->\r
@item.get(@my_manifest.column_name)\r
\r
initialize: (options) ->\r
super(options)\r
- @edit_icon = new Pettanr.Image.SymbolImg({\r
- attr: {'src': @edit_img_file_name()}, \r
- half: true\r
+ @edit_button = @item.mini_edit_button({\r
+ context: this, \r
+ click: () ->\r
+ @trigger('http_get', @item.edit_url())\r
})\r
- @edit_btn = new Tag.A({\r
- attr: {href: '/' + @item.edit_url()}, \r
- content: @edit_icon.render().el\r
+ @destroy_button = @item.mini_destroy_button({\r
+ context: this, \r
+ click: () ->\r
+ @trigger('remove')\r
})\r
- @remove_icon = new Pettanr.Image.SymbolImg({\r
- attr: {'src': @remove_img_file_name()}, \r
- half: true\r
- })\r
- @remove_btn = new Tag.A({\r
- attr: {href: '/' + @item.destroy_url()}, \r
- content: @remove_icon.render().el\r
- })\r
- @listenTo(@edit_btn, 'click', @click_edit)\r
- @listenTo(@remove_btn, 'click', @click_remove)\r
\r
render: () ->\r
this.$el.html('')\r
if @is_own()\r
- this.$el.append(@edit_btn.render().el)\r
- this.$el.append(@remove_btn.render().el)\r
+ this.$el.append(@edit_button.render().el)\r
+ this.$el.append(@destroy_button.render().el)\r
this\r
\r
is_own: () ->\r
true\r
else\r
false\r
- \r
- edit_img_file_name: () ->\r
- @image_dir() + 'edit.png'\r
- \r
- remove_img_file_name: () ->\r
- @image_dir() + 'remove.png'\r
- \r
- click_edit: () ->\r
- @trigger('http_get', @item.edit_url())\r
- \r
- click_remove: () ->\r
- @trigger('remove')\r
\r
})\r
\r
filer_caption: (context, options) ->\r
- history = @history()\r
- history.fetch({cache: true}).done =>\r
- caption = if _.isEmpty(history.models)\r
- 'unpublished'\r
- else\r
- head = _.first(history.models)\r
- Pettanr.to_s(head.get('revision'))\r
- options.success.call(context, caption)\r
- \r
- revision: () ->\r
- new Pettanr.OriginalPicture.Head({original_picture: this})\r
- \r
- history: () ->\r
- new Pettanr.OriginalPicture.History({original_picture: this})\r
+ controller = Manifest.manifest().controllers['original_pictures']\r
+ action = controller.actions['history']\r
+ list = action.find(id: @get('id'))\r
+ list.open(this, {\r
+ success: (pictures) => \r
+ caption = if _.isEmpty(pictures)\r
+ 'unpublished'\r
+ else\r
+ head = _.first(pictures)\r
+ Pettanr.to_s(head.get('revision'))\r
+ options.success.call(context, caption)\r
+ })\r
\r
is_unpublished: () ->\r
@get('published_at') == null and @get('stopped_at') == null\r
initialize: (attr = {}, options = {}) ->\r
super(attr, options)\r
\r
-class Pettanr.OriginalPicture.History extends Backbone.Collection\r
- \r
- initialize: (options) ->\r
- @original_picture = options.original_picture\r
- @model = Pettanr.Picture\r
- @url = @original_picture.default_url() + '/history'\r
- \r
-class Pettanr.OriginalPicture.Head extends Pettanr.View\r
- tagName: 'span'\r
- \r
- initialize: (options) ->\r
- @original_picture = options.original_picture\r
- @pictures = new Pettanr.OriginalPicture.History({id: @original_picture.get('id')})\r
- \r
- render: () ->\r
- @pictures.fetch({cache: true}).done =>\r
- head = @pictures.models[0]\r
- value = if head\r
- head.get('revision')\r
- else\r
- 'unpublished'\r
- this.$el.html(value)\r
- this\r
- \r
else\r
@item_name()\r
\r
- _label: (label_column_name, shorten_length = null) ->\r
- shorten_length ||= @constructor.default_label_shorten_length\r
- Pettanr.truncate(@get(label_column_name), shorten_length)\r
+ _label: (label_column_name, options) ->\r
+ shorten = options.shorten\r
+ l = if _.isBoolean(shorten)\r
+ if shorten\r
+ # supply default shorten_length\r
+ @constructor.default_label_shorten_length\r
+ else\r
+ # False be no shorten\r
+ null\r
+ else\r
+ # numeric\r
+ shorten\r
+ Pettanr.truncate(@get(label_column_name), l)\r
\r
- label: (shorten_length = null) ->\r
+ label: (options) ->\r
''\r
\r
get_association: (routes, context, options) ->\r
mini_symbol_button: (options) ->\r
Pettanr.View.mini_face_button(this, @symbol_file(), options)\r
\r
- label_button: (options) ->\r
- url = options.url || @show_url()\r
- new Pettanr.View.Button(url, _.escape(@label()), options)\r
+ # pencil button\r
+ edit_button: (options) ->\r
+ icon = new Pettanr.View.Icon(Pettanr.View.Image.icon_edit_file())\r
+ Pettanr.View.any_button(this, @edit_url(), icon, options)\r
+ \r
+ mini_edit_button: (options) ->\r
+ icon = new Pettanr.View.Minicon(Pettanr.View.Image.icon_edit_file())\r
+ Pettanr.View.mini_any_button(this, @edit_url(), icon, options)\r
+ \r
+ # x button\r
+ destroy_button: (options) ->\r
+ icon = new Pettanr.View.Icon(Pettanr.View.Image.icon_destroy_file())\r
+ Pettanr.View.any_button(this, @destroy_url(), icon, options)\r
+ \r
+ mini_destroy_button: (options) ->\r
+ icon = new Pettanr.View.Minicon(Pettanr.View.Image.icon_destroy_file())\r
+ Pettanr.View.mini_any_button(this, @destroy_url(), icon, options)\r
+ \r
+ label_button: (label_options, button_options) ->\r
+ url = button_options.url || @show_url()\r
+ new Pettanr.View.Button(url, _.escape(@label(label_options)), button_options)\r
\r
- # faced_label({\r
+ # faced_label_button({\r
+ # shorten: true\r
+ # }, {\r
# url: @show_url(),\r
# context: this,\r
# click: () =>\r
# # ...\r
# })\r
- faced_label: (options) ->\r
- new Pettanr.View.FacedLabel(this, options)\r
+ faced_label_button: (label_options, button_options) ->\r
+ new Pettanr.View.FacedLabelButton(this, label_options, button_options)\r
\r
- mini_faced_label: (options) ->\r
- new Pettanr.View.MiniFacedLabel(this, options)\r
+ mini_faced_label_button: (label_options, button_options) ->\r
+ new Pettanr.View.MiniFacedLabelButton(this, label_options, button_options)\r
\r
summary: (context, options) ->\r
klass = Pettanr.Views[@singular()].Summary\r
operators.is_admin() \r
\r
label: (shorten_length) ->\r
- @_label('name', shorten_length)\r
+ @_label('caption', shorten_length)\r
\r
else\r
caption\r
\r
+ @any_button: (item, url, icon, options = {}) ->\r
+ new Pettanr.View.Button(url, icon.render().el, options)\r
+ \r
+ @mini_any_button: (item, url, icon, options = {}) ->\r
+ new Pettanr.View.Button(url, icon.render().el, options)\r
+ \r
@face_button: (item, image, options = {}) ->\r
icon = new Pettanr.View.Icon(image)\r
- new Pettanr.View.Button(item.show_url(), icon.render().el, options)\r
+ @any_button(item, item.show_url(), icon, options)\r
\r
@mini_face_button: (item, image, options = {}) ->\r
icon = new Pettanr.View.Minicon(image)\r
- new Pettanr.View.Button(item.show_url(), icon.render().el, options)\r
+ @any_button(item, item.show_url(), icon, options)\r
\r
@prof_button: (url, options = {}) ->\r
file = Pettanr.View.Image.icon_prof_file()\r
+++ /dev/null
-class Pettanr.View.FacedLabel extends Pettanr.View\r
- tagName: 'span'\r
- \r
- constructor: (@item, options) ->\r
- super(options)\r
- \r
- initialize: (options) ->\r
- @face_button = @item[@face_button_method_name()](options)\r
- @label_button = @item.label_button(options)\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.append(@face_button.render().el)\r
- this.$el.append(@label_button.render().el)\r
- this\r
- \r
- face_button_method_name: () ->\r
- 'face_button'\r
- \r
-class Pettanr.View.MiniFacedLabel extends Pettanr.View.FacedLabel\r
- \r
- face_button_method_name: () ->\r
- 'mini_face_button'\r
- \r
--- /dev/null
+class Pettanr.View.FacedLabelButton extends Pettanr.View\r
+ tagName: 'span'\r
+ \r
+ constructor: (@item, @label_options, @button_options) ->\r
+ super()\r
+ \r
+ initialize: () ->\r
+ @face_button = @item[@face_button_method_name()](@button_options)\r
+ @label_button = @item.label_button(@label_options, @button_options)\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ this.$el.append(@face_button.render().el)\r
+ this.$el.append(@label_button.render().el)\r
+ this\r
+ \r
+ face_button_method_name: () ->\r
+ 'face_button'\r
+ \r
+class Pettanr.View.MiniFacedLabelButton extends Pettanr.View.FacedLabelButton\r
+ \r
+ face_button_method_name: () ->\r
+ 'mini_face_button'\r
+ \r
@icon_prof_file: () ->\r
new Pettanr.ImageFile(@image_dir() + 'prof.gif')\r
\r
+ @icon_edit_file: () ->\r
+ new Pettanr.ImageFile(@image_dir() + 'edit.png')\r
+ \r
+ @icon_destroy_file: () ->\r
+ new Pettanr.ImageFile(@image_dir() + 'remove.png')\r
+ \r
@icon_inspire_file: () ->\r
new Pettanr.ImageFile(@image_dir() + 'inspire.gif')\r
\r
\r
@pick = null\r
@face_button = @item.mini_face_button(@face_options)\r
- @label_button = @item.label_button(@label_options)\r
+ @label_button = @item.label_button(false, @label_options)\r
@prof_button = @item.mini_prof_button(@prof_options)\r
\r
render: () ->\r
+# options: {\r
+# label: { label_options ... }\r
+# button: { button_options ... }\r
+# }\r
class Pettanr.View.Show.AuthoredBy extends Pettanr.View\r
tagName: 'div'\r
\r
constructor: (@content, options) ->\r
super(options)\r
\r
- initialize: (@options = {}) ->\r
+ initialize: (options = {}) ->\r
+ @label_options = options.label || {shorten: false}\r
\r
render: () ->\r
this.$el.html('')\r
author_item_name = @content.my_class().owner_type()\r
@content.get_parent(author_item_name, this, {\r
success: (author) => # author or artist\r
- label_button = author.label_button({\r
+ label_button = author.label_button(@label_options, {\r
context: this,\r
click: () =>\r
@trigger('click', author)\r
})\r
@item.get_parent('author', this, {\r
success: (@author) =>\r
- @author_mini_faced_label = @author.mini_faced_label({\r
+ @author_faced_label_button = @author.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
context: @context,\r
click: () =>\r
@trigger('http_get', @author.show_url())\r
})\r
this.$el.html('')\r
this.$el.append(@visible.render().el)\r
- this.$el.append(@author_mini_faced_label.render().el)\r
+ this.$el.append(@author_faced_label_button.render().el)\r
})\r
this\r
\r
})\r
@binder.get_parent('author', this, {\r
success: (@author) =>\r
- @author_mini_faced_label = @author.mini_faced_label({\r
+ @author_faced_label_button = @author.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
context: @context,\r
click: () =>\r
@trigger('http_get', @author.show_url())\r
})\r
this.$el.html('')\r
this.$el.append(@face_button.render().el)\r
- this.$el.append(@author_mini_faced_label.render().el)\r
+ this.$el.append(@author_faced_label_button.render().el)\r
})\r
})\r
this\r
})\r
@destination.get_parent('author', this, {\r
success: (@author) =>\r
- @author_mini_faced_label = @author.mini_faced_label({\r
+ @author_faced_label_button = @author.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
context: @context,\r
click: () =>\r
@trigger('http_get', @author.show_url())\r
})\r
this.$el.html('')\r
this.$el.append(@face_button.render().el)\r
- this.$el.append(@author_mini_faced_label.render().el)\r
+ this.$el.append(@author_faced_label_button.render().el)\r
})\r
})\r
this\r
})\r
@panel.get_parent('author', this, {\r
success: (@author) =>\r
- @author_faced_label = @author.mini_faced_label({\r
- context: this, \r
- click: () =>\r
- @trigger('http_get', @author.show_url())\r
- })\r
+ @author_faced_label_button = @author.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
+ context: this, \r
+ click: () =>\r
+ @trigger('http_get', @author.show_url())\r
+ })\r
this.$el.html('')\r
this.$el.append(@panel_face_button.render().el)\r
- this.$el.append(@author_faced_label.render().el)\r
+ this.$el.append(@author_faced_label_button.render().el)\r
})\r
})\r
})\r
})\r
@panel.get_parent('author', this, {\r
success: (@author) =>\r
- @author_faced_label = @author.mini_faced_label({\r
- context: this, \r
- click: () =>\r
- @trigger('http_get', @author.show_url())\r
+ @author_faced_label_button = @author.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
+ context: this, \r
+ click: () =>\r
+ @trigger('http_get', @author.show_url())\r
})\r
this.$el.html('')\r
this.$el.append(@panel_face_button.render().el)\r
- this.$el.append(@author_faced_label.render().el)\r
+ this.$el.append(@author_faced_label_button.render().el)\r
})\r
})\r
this\r
class Pettanr.Views.LicenseGroup.Show extends Pettanr.View.Show\r
\r
initialize: (options) ->\r
- @header = new Pettanr.View.Show.Header(@item, this, @binder_header_options())\r
+ @header = new Pettanr.View.Show.Header(@item, this, @default_header_options())\r
\r
render: () ->\r
this.$el.html('')\r
class Pettanr.Views.License.Show extends Pettanr.View.Show\r
\r
initialize: (options) ->\r
- @header = new Pettanr.View.Show.Header(@item, this, @binder_header_options())\r
+ @header = new Pettanr.View.Show.Header(@item, this, @default_header_options())\r
\r
render: () ->\r
this.$el.html('')\r
sel.insertBefore(opt.render().el, opt1st)\r
\r
select: () ->\r
- f = (license_group) => \r
- @fields['license_group_id'].tag.$el.attr('disabled', 'disabled')\r
- attr = {\r
- original_picture_id: @item.get('original_picture_id'),\r
- license_group_id: license_group.get('id'),\r
- license_id: null,\r
- license_group_module_name: license_group.get('module_name')\r
- }\r
- opl = new Pettanr.OriginalPictureLicense(attr)\r
- opl.boosts 'post'\r
- @trigger('next', opl)\r
- @item.get_parent('license_group', f, this)\r
+ @item.get_parent('license_group', this, {\r
+ success: (license_group) => \r
+ @fields['license_group_id'].tag.$el.attr('disabled', 'disabled')\r
+ attr = {\r
+ original_picture_id: @item.get('original_picture_id'),\r
+ license_group_id: license_group.get('id'),\r
+ license_id: null,\r
+ license_group_module_name: license_group.get('module_name')\r
+ }\r
+ opl = new Pettanr.OriginalPictureLicense(attr)\r
+ opl.boosts 'post'\r
+ @trigger('next', opl)\r
+ })\r
\r
attr[field.field_name] = val\r
@item.set(attr)\r
@item.unset('id') # isNew use flag that id attr set\r
- f = (license) => \r
- @listenTo(@item, 'save:success', @success)\r
- @listenTo(@item, 'save:fail', @fail)\r
- @item.save()\r
- @item.get_parent('license', f, this)\r
+ @item.get_parent('license', this, {\r
+ success: (license) => \r
+ @listenTo(@item, 'save:success', @success)\r
+ @listenTo(@item, 'save:fail', @fail)\r
+ @item.save()\r
+ })\r
return false\r
\r
success: (model, response) ->\r
+# filer's edit box\r
class Pettanr.Views.OriginalPicture.Publish extends Pettanr.View\r
\r
initialize: (options) ->\r
@item.get_child('resource_picture', this, {\r
success: (@resource_picture) =>\r
if @resource_picture\r
- @stop_btn = new Tag.A({\r
- attr: {href: '/' + @resource_picture.destroy_url()}, \r
- content: I18n.t('original_pictures.index.stop')\r
+ @stop_button = new Pettanr.View.Button.ItemAction(@resource_picture, 'destroy', 'original_pictures.index.stop', {\r
+ context: this, \r
+ click: () =>\r
+ return if !confirm('remove?')\r
+ proxy = new Pettanr.Proxy({})\r
+ @listenTo(proxy, 'success', @remove_success)\r
+ @listenTo(proxy, 'fail', @remove_fail)\r
+ @listenTo(proxy, 'deny', @remove_deny)\r
+ proxy.http_post(@resource_picture.destroy_url())\r
})\r
- @listenTo(@stop_btn, 'click', @click_stop)\r
- this.$el.append(@stop_btn.render().el)\r
- @edit_icon = new Pettanr.Image.SymbolImg({\r
- attr: {'src': @edit_img_file_name()}, \r
- half: true\r
+ this.$el.append(@stop_button.render().el)\r
+ @edit_button = @item.mini_edit_button({\r
+ context: this, \r
+ click: () ->\r
+ @trigger('http_get', @item.edit_url())\r
})\r
- @edit_btn = new Tag.A({\r
- attr: {href: '/' + @item.edit_url()}, \r
- content: @edit_icon.render().el\r
+ @destroy_button = @item.mini_destroy_button({\r
+ context: this, \r
+ click: () ->\r
+ @trigger('remove')\r
})\r
- @remove_icon = new Pettanr.Image.SymbolImg({\r
- attr: {'src': @remove_img_file_name()}, \r
- half: true\r
- })\r
- @remove_btn = new Tag.A({\r
- attr: {href: '/' + @item.destroy_url()}, \r
- content: @remove_icon.render().el\r
- })\r
- @listenTo(@edit_btn, 'click', @click_edit)\r
- @listenTo(@remove_btn, 'click', @click_remove)\r
- this.$el.append(@edit_btn.render().el)\r
- this.$el.append(@remove_btn.render().el)\r
+ this.$el.append(@edit_button.render().el)\r
+ this.$el.append(@destroy_button.render().el)\r
})\r
this\r
\r
item_name: () ->\r
@filer().item_name\r
\r
- image_dir: () ->\r
- @filer().image_dir()\r
- \r
- edit_img_file_name: () ->\r
- @image_dir() + 'edit.png'\r
- \r
- remove_img_file_name: () ->\r
- @image_dir() + 'remove.png'\r
- \r
- click_stop: () ->\r
- return if !confirm('remove?')\r
- proxy = new Pettanr.Proxy({})\r
- @listenTo(proxy, 'success', @remove_success)\r
- @listenTo(proxy, 'fail', @remove_fail)\r
- @listenTo(proxy, 'deny', @remove_deny)\r
- proxy.http_post(@resource_picture.destroy_url())\r
- \r
remove_success: () ->\r
@trigger('update')\r
\r
\r
remove_deny: () ->\r
\r
- click_edit: () ->\r
- @trigger('http_get', @item.edit_url())\r
- \r
- click_remove: () ->\r
- @trigger('remove')\r
- \r
@authored_by = @item.authored_by()\r
@listenTo(@header, 'click:pick', @click_pick)\r
@listenTo(@authored_by, 'click', @click_authored_by)\r
- @body = new Pettanr.Views.OriginalPicture.Show.Body(@item, {})\r
+ @body = new Pettanr.Views.OriginalPicture.Show.Body(@item, options)\r
+ @listenTo(@body, 'http_get', @http_get)\r
@history = new Pettanr.Views.OriginalPicture.Show.History(@item, {})\r
@listenTo(@history, 'http_get', @http_get)\r
\r
constructor: (@item, options) ->\r
super(options)\r
\r
- initialize: (options) ->\r
+ initialize: (@options) ->\r
@img = @item.real_picture()\r
@owner = new Pettanr.View.Show.Footer(@item, this, {\r
actions: {\r
dic_name: 'original_pictures.show.select', \r
click: () =>\r
@create_dialog()\r
- @trigger('click:license', @dialog)\r
+ @options.click_license.call(@options.context, @dialog)\r
}, \r
replace: {\r
url: @item.edit_url(),\r
\r
success: (resource_picture) ->\r
#Pettanr.cache.fix(@item)\r
- @trigger('success', @params, @dialog)\r
+ @options.publish.call(@options.context, @dialog)\r
@trigger('http_get', resource_picture.show_url())\r
Pettanr.cache.refresh(@item)\r
\r
close_dialog: () ->\r
#Pettanr.cache.release(@item)\r
- @trigger('click:close', @dialog)\r
+ @options.close_dialog.call(@options.context, @dialog)\r
\r
class Pettanr.Views.OriginalPicture.Show.History extends Pettanr.View\r
className: 'op-history'\r
@visible = new Tag.Div({\r
content: Pettanr.AppHelper.t_selected_item(@visible_t, @item.get(@visible_column_name))\r
})\r
- @author_mini_faced_label = @author.mini_faced_label({\r
- context: @context,\r
- click: () =>\r
- @trigger('http_get', @author.show_url())\r
+ @author_faced_label_button = @author.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
+ context: @context,\r
+ click: () =>\r
+ @trigger('http_get', @author.show_url())\r
})\r
this.$el.html('')\r
this.$el.append(@visible.render().el)\r
- this.$el.append(@author_mini_faced_label.render().el)\r
+ this.$el.append(@author_faced_label_button.render().el)\r
})\r
this\r
\r
class Pettanr.Views.Picture.History extends Pettanr.View\r
tagName: 'div'\r
\r
+ constructor: (@item, options) ->\r
+ super(options)\r
+ \r
initialize: (options) ->\r
- @item = options.item\r
+ super(options)\r
\r
render: () ->\r
this.$el.html('')\r
\r
class Pettanr.Views.Scroll.Play extends Pettanr.View.Show\r
\r
- initialize: (@item, options) ->\r
+ initialize: (options) ->\r
@list = options.list\r
@pager = options.pager\r
@header = new Pettanr.View.Show.Header(@item, this, @binder_header_options())\r
class Pettanr.Views.SpeechBalloonTemplate.Show extends Pettanr.View.Show\r
\r
initialize: (options) ->\r
- @header = new Pettanr.View.Show.Header(@item, this, @binder_header_options())\r
+ @header = new Pettanr.View.Show.Header(@item, this, @default_header_options())\r
@listenTo(@header, 'click:pick', @click_pick)\r
\r
render: () ->\r
})\r
@panel.get_parent('author', this, {\r
success: (@author) =>\r
- @author_faced_label = @author.mini_faced_label({\r
- context: this, \r
- click: () =>\r
- @trigger('http_get', @author.show_url())\r
+ @author_faced_label_button = @author.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
+ context: this, \r
+ click: () =>\r
+ @trigger('http_get', @author.show_url())\r
})\r
this.$el.html('')\r
this.$el.append(@panel_face_button.render().el)\r
- this.$el.append(@author_faced_label.render().el)\r
+ this.$el.append(@author_faced_label_button.render().el)\r
})\r
})\r
this\r
})\r
@panel.get_parent('author', this, {\r
success: (@author) =>\r
- @author_faced_label = @author.mini_faced_label({\r
- context: this, \r
- click: () =>\r
- @trigger('http_get', @author.show_url())\r
+ @author_faced_label_button = @author.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
+ context: this, \r
+ click: () =>\r
+ @trigger('http_get', @author.show_url())\r
})\r
this.$el.html('')\r
this.$el.append(@panel_face_button.render().el)\r
- this.$el.append(@author_faced_label.render().el)\r
+ this.$el.append(@author_faced_label_button.render().el)\r
})\r
})\r
})\r
class Pettanr.Views.SystemPicture.Show extends Pettanr.View.Show\r
\r
initialize: (options) ->\r
- @header = new Pettanr.View.Show.Header(@item, this, @binder_header_options())\r
+ @header = new Pettanr.View.Show.Header(@item, this, @default_header_options())\r
\r
render: () ->\r
this.$el.html('')\r
})\r
this.$el.append(@logo.render().el)\r
if @author\r
- @author_mini_faced_label = @author.mini_faced_label({\r
+ @author_faced_label_button = @author.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
context: this,\r
click: () =>\r
@trigger('http_get', @author.show_url())\r
})\r
- this.$el.append(@author_mini_faced_label.render().el)\r
+ this.$el.append(@author_faced_label_button.render().el)\r
if @artist\r
- @artist_mini_faced_label = @artist.mini_faced_label({\r
+ @artist_faced_label_button = @artist.mini_faced_label_button({\r
+ shorten: true\r
+ }, {\r
context: this,\r
click: () =>\r
@trigger('http_get', @artist.show_url())\r
})\r
- this.$el.append(@artist_mini_faced_label.render().el)\r
+ this.$el.append(@artist_faced_label_button.render().el)\r
if @author\r
@quick = new Pettanr.Views.User.Account.Quick()\r
@listenTo(@quick, 'click:mydoc', @click_mydoc)\r
class Pettanr.Views.WritingFormat.Show extends Pettanr.View.Show\r
\r
initialize: (options) ->\r
- @header = new Pettanr.View.Show.Header(@item, this, @binder_header_options())\r
+ @header = new Pettanr.View.Show.Header(@item, this, @default_header_options())\r
\r
render: () ->\r
this.$el.html('')\r
history: {\r
type: 'list',\r
args: {\r
+ return_item_name: 'picture',\r
+ max_page_size: -1,\r
+ order: 'revision',\r
+ direction: 1\r
},\r
},\r
new: {\r
show_json_format format
end
end
-
+
def history
set_show
- @history = @item.history
+ @finder = @my_action.finder(param: params[:id]).page(1).per(-1)
respond_to do |format|
format.html
- format.json { render json: @history.to_json }
+ list_json_format @finder, format
end
end
where(artist_id: operators.artist.id)
end
+ scope :find_history, -> (id) do
+ Picture.find_by_original_picture(id).order(Picture.arel_table[:revision].desc)
+ end
+
def supply_default
self.artist_id = nil
end
self.published_at != nil
end
- def history
- Picture.where(original_picture_id: self.id).order(revision: :desc)
- end
-
def self.show_opt
{:include => {:resource_picture => {}, :pictures => {}}}
end
find_index.where(artist_id: artist_id)
end
+ scope :find_by_original_picture, -> (original_picture_id) do
+ find_index.where(original_picture_id: original_picture_id)
+ end
+
def supply_default
end
# ClassMethods
def self.edit owner_id, operators
- owner = self.find owner_id, self.show_opt
+ owner = self.find owner_id
raise ActiveRecord::Forbidden unless owner.own?(operators)
owner
end
},\r
"history": {\r
"type": "list",\r
- "args": {}\r
+ "args": {\r
+ "return_item_name": "picture",\r
+ "max_page_size": -1,\r
+ "order": "revision",\r
+ "direction": 1\r
+ }\r
},\r
"new": {\r
"type": "new"\r