OSDN Git Service

fix: scenario
[pettanr/pettanr.git] / app / assets / javascripts / views / original_pictures / publish.js.coffee
1 # filer's edit box\r
2 class Pettanr.Views.OriginalPicture.Publish extends Pettanr.View\r
3   \r
4   initialize: (options) ->\r
5     super(options)\r
6     @file_item = options.file_item\r
7     @my_manifest = options.my_manifest\r
8     @item = options.item\r
9   \r
10   render: () ->\r
11     this.$el.html('')\r
12     if @is_own()\r
13       @item.get_child('resource_picture', this, {\r
14         success: (@resource_picture) =>\r
15           if @resource_picture\r
16             @stop_button = new Pettanr.View.Button.ItemAction(@resource_picture, 'destroy', 'original_pictures.index.stop', {\r
17               context: this, \r
18               click: () =>\r
19                 return if !confirm('remove?')\r
20                 proxy = new Pettanr.Proxy({})\r
21                 @listenTo(proxy, 'success', @remove_success)\r
22                 @listenTo(proxy, 'fail', @remove_fail)\r
23                 @listenTo(proxy, 'deny', @remove_deny)\r
24                 proxy.http_post(@resource_picture.destroy_url())\r
25             })\r
26             this.$el.append(@stop_button.render().el)\r
27           @edit_button = @item.mini_edit_button({\r
28             context: this, \r
29             click: () ->\r
30               @trigger('http_get', @item.edit_url())\r
31           })\r
32           @destroy_button = @item.mini_destroy_button({\r
33             context: this, \r
34             click: () ->\r
35               @trigger('remove')\r
36           })\r
37           this.$el.append(@edit_button.render().el)\r
38           this.$el.append(@destroy_button.render().el)\r
39       })\r
40     this\r
41   \r
42   is_own: () ->\r
43     if @item.is_own()\r
44       true\r
45     else\r
46       false\r
47    \r
48   filer: () ->\r
49     @file_item.filer()\r
50   \r
51   manifest: () ->\r
52     @filer().manifest\r
53   \r
54   item_name: () ->\r
55     @filer().item_name\r
56   \r
57   remove_success: () ->\r
58     @trigger('update')\r
59   \r
60   remove_fail: () ->\r
61     # no update\r
62   \r
63   remove_deny: () ->\r
64   \r