+ retriever: () ->\r
+ new Pettanr.Cache.Retriever(@my_class(), @get('id'))\r
+ \r
+ retrieve: (context, options = {}) ->\r
+ retriever = new Pettanr.Cache.Retriever(@my_class(), @get('id'))\r
+ @listenTo(retriever, 'retrieve', (item) =>\r
+ callback = options.success\r
+ callback.call(context, item)\r
+ )\r
+ @listenTo(retriever, 'fail', (response, opt) =>\r
+ callback = options.fail\r
+ callback.call(context, response, opt)\r
+ )\r
+ retriever.retrieve(options.force)\r
+ \r
+ @pick_item_name: () ->\r
+ null\r
+ \r
+ @pick_model: () ->\r
+ Manifest.item_name_to_model(@pick_item_name())\r
+ \r
+ @traceable_item_names: () ->\r
+ []\r
+ \r
+ @is_traceable: (item_name) ->\r
+ _.contains(@traceable_item_names(), item_name)\r
+ \r
+ @is_picker_inspire: (item_name) ->\r
+ item_name == @item_name()\r
+ \r
+ @is_picker_trace: (item_name) ->\r
+ @is_traceable(item_name)\r
+ \r
+ @is_picker_pick: (item_name) ->\r
+ item_name == @pick_item_name()\r
+ \r
+ @pick_type: (item_name) ->\r
+ if @is_picker_inspire(item_name)\r
+ 'inspire'\r
+ else if @is_picker_trace(item_name)\r
+ 'trace'\r
+ else if @is_picker_pick(item_name)\r
+ 'pick'\r
+ else\r
+ 'none'\r
+ \r
+ symbol_option: (context, options) ->\r
+ @trace_to('symbol', this, {\r
+ success: (symbol_item) => \r
+ options.success.call(context, symbol_item.symbol_file())\r
+ fail: (response, opt) =>\r
+ options.fail.call(context, response, opt)\r
+ })\r
+ \r
+ @face_file: () ->\r
+ new Pettanr.ImageFile('/images/' + @item_name() + '.gif')\r
+ \r
+ face_file: () ->\r
+ @my_class().face_file()\r
+ \r
+ # thumbnail size picture\r
+ symbol_file: (subdir) ->\r
+ new Pettanr.PictureFile(this, subdir)\r
+ \r
+ # real size picture\r
+ picture_file: (subdir = null) ->\r
+ new Pettanr.PictureFile(this, subdir)\r
+ \r
+ real_picture: (subdir = null) ->\r
+ new Pettanr.View.RealIcon(@picture_file(subdir))\r
+ \r
+ # item.face_button({\r
+ # context: this, \r
+ # click: () ->\r
+ # # ...\r
+ # })\r
+ face_button: (options) ->\r
+ Pettanr.View.face_button(this, @face_file(), options)\r
+ \r
+ mini_face_button: (options) ->\r
+ Pettanr.View.mini_face_button(this, @face_file(), options)\r
+ \r
+ prof_button: (options) ->\r
+ Pettanr.View.prof_button(@prof_url(), options)\r
+ \r
+ mini_prof_button: (options) ->\r
+ Pettanr.View.mini_prof_button(@prof_url(), options)\r
+ \r
+ symbol_button: (options) ->\r
+ Pettanr.View.face_button(this, @symbol_file(), options)\r
+ \r
+ mini_symbol_button: (options) ->\r
+ Pettanr.View.mini_face_button(this, @symbol_file(), options)\r
+ \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_button({\r
+ # shorten: true\r
+ # }, {\r
+ # url: @show_url(),\r
+ # context: this,\r
+ # click: () =>\r
+ # # ...\r
+ # })\r
+ faced_label_button: (label_options, button_options) ->\r
+ new Pettanr.View.FacedLabelButton(this, label_options, button_options)\r
+ \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
+ new klass(this, context, options)\r
+ \r
+ @index_url: () ->\r
+ Pettanr.url(@table_name(), 'index', {id: null})\r
+ \r
+ index_url: () ->\r
+ @my_class().index_url()\r
+ \r
+ list_url: (action_name = 'index') ->\r
+ Pettanr.url(@table_name(), action_name, {id: @get('id')})\r
+ \r
+ show_url: () ->\r
+ Pettanr.url(@table_name(), 'show', {id: @get('id')})\r
+ \r
+ prof_url: () ->\r
+ Pettanr.url(@table_name(), 'show', {id: @get('id'), format: 'prof'})\r
+ \r
+ new_url: () ->\r
+ Pettanr.url(@table_name(), 'new', {})\r
+ \r
+ create_url: () ->\r
+ Pettanr.url(@table_name(), 'create', {})\r
+ \r
+ edit_url: () ->\r
+ Pettanr.url(@table_name(), 'edit', {id: @get('id')})\r
+ \r
+ update_url: () ->\r
+ Pettanr.url(@table_name(), 'update', {id: @get('id')})\r
+ \r
+ destroy_url: () ->\r
+ Pettanr.url(@table_name(), 'destroy', {id: @get('id')})\r
+ \r
+ hold: () ->\r
+ Pettanr.cache.hold(this)\r
+ \r
+ fix: () ->\r
+ Pettanr.cache.fix(this)\r
+ \r
+ release: () ->\r
+ Pettanr.cache.release(this)\r
+ \r
+ free: () ->\r
+ Pettanr.cache.free(this)\r
+ \r
+ save: (model_attr) ->\r
+ super(model_attr || @attributes, {\r
+ success: (model, response, options) =>\r
+ @trigger('save:success', model, response)\r
+ error: (model, response, options) =>\r
+ @trigger('save:fail', model, response)\r
+ })\r
+ \r
+ destroy: () ->\r
+ super({\r
+ success: (model, response, options) =>\r
+ @free()\r
+ @trigger('destroy:success', model, response)\r
+ error: (model, response, options) =>\r
+ @trigger('destroy:fail', model, response)\r
+ })\r