OSDN Git Service

fix: show's destroy button
authoryasushiito <yas@pen-chan.jp>
Fri, 5 Jun 2015 01:50:45 +0000 (10:50 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 5 Jun 2015 01:50:45 +0000 (10:50 +0900)
49 files changed:
app/assets/javascripts/controllers.js.coffee
app/assets/javascripts/controllers/original_pictures.js.coffee
app/assets/javascripts/locmare/form.js.coffee
app/assets/javascripts/models/admin.js.coffee
app/assets/javascripts/models/artist.js.coffee
app/assets/javascripts/models/author.js.coffee
app/assets/javascripts/models/balloon.js.coffee
app/assets/javascripts/models/comic.js.coffee
app/assets/javascripts/models/comic_story.js.coffee
app/assets/javascripts/models/folder.js.coffee
app/assets/javascripts/models/ground_color.js.coffee
app/assets/javascripts/models/ground_picture.js.coffee
app/assets/javascripts/models/license.js.coffee
app/assets/javascripts/models/license_group.js.coffee
app/assets/javascripts/models/original_picture.js.coffee
app/assets/javascripts/models/original_picture_license.js.coffee
app/assets/javascripts/models/original_picture_license_group.js.coffee
app/assets/javascripts/models/panel.js.coffee
app/assets/javascripts/models/panel_picture.js.coffee
app/assets/javascripts/models/picture.js.coffee
app/assets/javascripts/models/resource_picture.js.coffee
app/assets/javascripts/models/resource_picture_picture.js.coffee
app/assets/javascripts/models/scroll.js.coffee
app/assets/javascripts/models/scroll_panel.js.coffee
app/assets/javascripts/models/sheet.js.coffee
app/assets/javascripts/models/sheet_panel.js.coffee
app/assets/javascripts/models/speech.js.coffee
app/assets/javascripts/models/speech_balloon.js.coffee
app/assets/javascripts/models/speech_balloon_template.js.coffee
app/assets/javascripts/models/story.js.coffee
app/assets/javascripts/models/story_sheet.js.coffee
app/assets/javascripts/models/system_picture.js.coffee
app/assets/javascripts/models/user.js.coffee
app/assets/javascripts/models/writing_format.js.coffee
app/assets/javascripts/peta/item.js.coffee
app/assets/javascripts/pettanr/proxy.js.coffee
app/assets/javascripts/pettanr/remover.js.coffee [new file with mode: 0644]
app/assets/javascripts/routes.js.coffee
app/assets/javascripts/views/comics/show.js.coffee
app/assets/javascripts/views/original_pictures/show.js.coffee
app/assets/javascripts/views/panels/show.js.coffee
app/assets/javascripts/views/pictures/credit.js.coffee
app/assets/javascripts/views/pictures/history.js.coffee [new file with mode: 0644]
app/assets/javascripts/views/resource_pictures/img.js.coffee [new file with mode: 0644]
app/assets/javascripts/views/resource_pictures/show.js.coffee
app/assets/javascripts/views/scrolls/show.js.coffee
app/assets/javascripts/views/users/account.js.coffee
app/assets/javascripts/work/controllers.js.coffee.erb
app/views/resource_pictures/show.html.erb

index 08f3925..3912215 100644 (file)
@@ -111,7 +111,7 @@ class Pettanr.AppController
     @trigger('fail', response)\r
   \r
   destroy_success: (model, response) ->\r
-    @trigger('redirect', '/home/' + model.path_name())\r
+    @trigger('redirect', 'home/' + model.path_name())\r
     @trigger('success', model, response)\r
   \r
   destroy_fail: (model, response) ->\r
index e63f4bf..a7e6ace 100644 (file)
@@ -83,3 +83,7 @@ class Pettanr.OriginalPicturesController extends Pettanr.AppController
     @listenTo(@item, 'destroy:fail', @destroy_fail)\r
     @item.destroy()\r
   \r
+  destroy_success: (model, response) ->\r
+    @trigger('redirect', model.path_name())\r
+    @trigger('success', model, response)\r
+  \r
index 6c7c147..4e55865 100644 (file)
@@ -189,6 +189,7 @@ class Locmare.Form extends Locmare.FormBase
   success: (model, response) ->\r
     if !Pettanr.cache.restore(model.cache_key())\r
       # item is new\r
+      model.url = model.default_url()\r
       Pettanr.cache.store(model)\r
     else\r
       @item.fix()\r
index a2c168b..b816e2b 100644 (file)
@@ -6,6 +6,4 @@ class Pettanr.Admin extends Backbone.Model
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index af7a2ff..c3b4298 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Artist extends Peta.Owner\r
-  url: '/artists/'\r
   \r
   @singular: () ->\r
     'Artist'\r
@@ -19,6 +18,4 @@ class Pettanr.Artist extends Peta.Owner
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index eab6899..e0e3a68 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Author extends Peta.Owner\r
-  url: '/authors/'\r
   \r
   @singular: () ->\r
     'Author'\r
@@ -19,6 +18,4 @@ class Pettanr.Author extends Peta.Owner
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index acfae1f..d4a5040 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Balloon extends Peta.Element\r
-  url: '/balloons/'\r
   \r
   @singular: () ->\r
     'Balloon'\r
@@ -53,6 +52,4 @@ class Pettanr.Balloon extends Peta.Element
   \r
   initialize: (attr, options) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index beb41f2..70f5c57 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Comic extends Peta.Binder\r
-  url: '/comics/'\r
   \r
   @singular: () ->\r
     'Comic'\r
@@ -34,6 +33,4 @@ class Pettanr.Comic extends Peta.Binder
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 4f65836..e441d26 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.ComicStory extends Peta.Leaf\r
-  url: '/comic_stories/'\r
   \r
   @singular: () ->\r
     'ComicStory'\r
@@ -37,6 +36,4 @@ class Pettanr.ComicStory extends Peta.Leaf
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index a74d565..f6caecc 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Folder extends Peta.Owner\r
-  url: '/folders/'\r
   \r
   @singular: () ->\r
     'Folder'\r
@@ -45,17 +44,23 @@ class Pettanr.Folder extends Peta.Owner
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
 class Pettanr.FolderWatch extends Pettanr.Folder\r
-  initialize: () ->\r
-    super()\r
-    @url = @url + '?ref=1'\r
+  \r
+  initialize: (attr = {}, options = {}) ->\r
+    super(attr, options)\r
+    @url = @default_url() + '?ref=1'\r
+  \r
 class Pettanr.Folder.Root extends Pettanr.Folder\r
   model: Pettanr.Folder\r
-  url: '/folders/root?ref=1'\r
+  \r
+  initialize: (attr = {}, options = {}) ->\r
+    super(attr, options)\r
+    @url = @default_url() + 'root?ref=1'\r
+  \r
 class Pettanr.Folder.Children extends Backbone.Collection\r
   model: Pettanr.Folder\r
+  \r
   initialize: (options) ->\r
     @url = '/folders/' + options.id.toString()\r
+  \r
index eff2800..129c91b 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.GroundColor extends Peta.Element\r
-  url: '/ground_colors/'\r
   \r
   @singular: () ->\r
     'GroundColor'\r
@@ -37,6 +36,4 @@ class Pettanr.GroundColor extends Peta.Element
   \r
   initialize: (attr, options) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 276ffc3..77d074f 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.GroundPicture extends Peta.Element\r
-  url: '/ground_pictures/'\r
   \r
   @singular: () ->\r
     'GroundPicture'\r
@@ -60,8 +59,6 @@ class Pettanr.GroundPicture extends Peta.Element
   \r
   initialize: (attr, options) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
 class Pettanr.GroundPicture.TraceFromPicture\r
   \r
index 70cbff4..e3ba76f 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.License extends Peta.SystemResource\r
-  url: '/licenses/'\r
   \r
   @singular: () ->\r
     'License'\r
@@ -39,6 +38,4 @@ class Pettanr.License extends Peta.SystemResource
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index f5d5531..af8693a 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.LicenseGroup extends Peta.Template\r
-  url: '/license_groups/'\r
   \r
   @singular: () ->\r
     'LicenseGroup'\r
@@ -13,6 +12,4 @@ class Pettanr.LicenseGroup extends Peta.Template
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 66e5f76..e6e457a 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.OriginalPicture extends Peta.Content\r
-  url: '/original_pictures/'\r
   \r
   @singular: () ->\r
     'OriginalPicture'\r
@@ -95,19 +94,17 @@ class Pettanr.OriginalPicture extends Peta.Content
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
 class Pettanr.OriginalPicture.History extends Backbone.Collection\r
-  url: '/original_pictures/'\r
   \r
   initialize: (options) ->\r
     @original_picture = options.original_picture\r
     @model = Pettanr.Picture\r
-    @url = @url + @original_picture.get('id') + '/history'\r
+    @url = @original_picture.default_url() + '/history'\r
   \r
 class Pettanr.OriginalPicture.Head extends Backbone.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
index 5709588..2097816 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.OriginalPictureLicense extends Peta.Item\r
-  url: '/original_picture_licenses/'\r
   \r
   @singular: () ->\r
     'OriginalPictureLicense'\r
index aacc727..531f673 100644 (file)
@@ -11,6 +11,4 @@ class Pettanr.OriginalPictureLicenseGroup extends Peta.Item
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 7b13d47..924c1b7 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Panel extends Peta.Root\r
-  url: '/panels/'\r
   \r
   @singular: () ->\r
     'Panel'\r
@@ -59,27 +58,18 @@ class Pettanr.Panel extends Peta.Root
       r[pid] = elm.picture() if not r[pid]\r
     r\r
   \r
-  my_url: () ->\r
-    s = if @get('id')\r
-      '/' + @get('id')\r
-    else\r
-      ''\r
-    '/' + @path_name() + s\r
-  \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
     @set(attr)\r
-    if @get('id')\r
-      @url = @my_url()\r
   \r
 class Pettanr.Panel.WithElements extends Pettanr.Panel\r
   \r
   fetch: (options) ->\r
-    @url = @my_url() + '?with_elements=true'\r
+    @url = @default_url() + '?with_elements=true'\r
     super(options)\r
   \r
   save: (attrs) ->\r
-    @url = @my_url()\r
+    @url = @default_url()\r
     method = if @isNew()\r
       'create'\r
     else\r
index d46c1ff..12241b2 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.PanelPicture extends Peta.Element\r
-  url: '/panel_pictures/'\r
   \r
   @singular: () ->\r
     'PanelPicture'\r
@@ -79,8 +78,6 @@ class Pettanr.PanelPicture extends Peta.Element
   \r
   initialize: (attr, options) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
 class Pettanr.PanelPicture.TraceFromPicture\r
   \r
index 46e3598..2795754 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Picture extends Peta.Content\r
-  url: '/pictures/'\r
   \r
   @singular: () ->\r
     'Picture'\r
@@ -78,6 +77,9 @@ class Pettanr.Picture extends Peta.Content
     return true if @is_own(operators)\r
     #@is_enable() and @is_head()\r
   \r
+  history_view: () ->\r
+    new Pettanr.Views.Picture.History({item: this})\r
+  \r
   credit_icon_view: () ->\r
     new Pettanr.Views.Picture.CreditIcon({item: this})\r
   \r
@@ -96,6 +98,4 @@ class Pettanr.Picture extends Peta.Content
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index f54e87c..183ebdb 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.ResourcePicture extends Peta.Content\r
-  url: '/resource_pictures/'\r
   \r
   @singular: () ->\r
     'ResourcePicture'\r
@@ -11,6 +10,9 @@ class Pettanr.ResourcePicture extends Peta.Content
     id: null\r
   } \r
   \r
+  original_picture: () ->\r
+    new Pettanr.Cache.Retriever(Pettanr.OriginalPicture, @get('original_picture_id'))\r
+  \r
   picture: () ->\r
     new Pettanr.Cache.Retriever(Pettanr.Picture, @get('picture_id'))\r
   \r
@@ -70,6 +72,4 @@ class Pettanr.ResourcePicture extends Peta.Content
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index c04c9a4..db52252 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.ResourcePicturePicture extends Peta.Item\r
-  url: '/resource_picture_pictures/'\r
   \r
   @singular: () ->\r
     'ResourcePicturePicture'\r
@@ -24,6 +23,4 @@ class Pettanr.ResourcePicturePicture extends Peta.Item
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 2bfb905..a316607 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Scroll extends Peta.Binder\r
-  url: '/scrolls/'\r
   \r
   @singular: () ->\r
     'Scroll'\r
@@ -22,6 +21,4 @@ class Pettanr.Scroll extends Peta.Binder
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 93a6a92..a1fcd70 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.ScrollPanel extends Peta.Leaf\r
-  url: ''\r
   \r
   @singular: () ->\r
     'ScrollPanel'\r
@@ -34,6 +33,4 @@ class Pettanr.ScrollPanel extends Peta.Leaf
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 240d5d3..a25518a 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Sheet extends Peta.Root\r
-  url: '/sheets/'\r
   \r
   @singular: () ->\r
     'Sheet'\r
@@ -32,6 +31,4 @@ class Pettanr.Sheet extends Peta.Root
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index d4c660e..5127427 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.SheetPanel extends Peta.Leaf\r
-  url: '/sheet_panels/'\r
   \r
   @singular: () ->\r
     'SheetPanel'\r
@@ -25,6 +24,4 @@ class Pettanr.SheetPanel extends Peta.Leaf
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 366cd09..c597fd4 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Speech extends Peta.Element\r
-  url: '/speeches/'\r
   \r
   @singular: () ->\r
     'Speech'\r
@@ -63,6 +62,4 @@ class Pettanr.Speech extends Peta.Element
   \r
   initialize: (attr, options) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 359669a..57fd016 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.SpeechBalloon extends Peta.Element\r
-  url: '/speech_balloons/'\r
   \r
   @singular: () ->\r
     'SpeechBalloon'\r
@@ -66,8 +65,6 @@ class Pettanr.SpeechBalloon extends Peta.Element
   \r
   initialize: (attr, options) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
 class Pettanr.SpeechBalloon.TraceFromBalloon\r
   \r
index 9d9d383..8047d0b 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.SpeechBalloonTemplate extends Peta.Template\r
-  url: '/speech_balloon_templates/'\r
   \r
   @singular: () ->\r
     'SpeechBalloonTemplate'\r
@@ -27,6 +26,4 @@ class Pettanr.SpeechBalloonTemplate extends Peta.Template
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
-    \r
+  \r
index dc17136..606df47 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Story extends Peta.Binder\r
-  url: '/stories/'\r
   \r
   @singular: () ->\r
     'Story'\r
@@ -32,6 +31,4 @@ class Pettanr.Story extends Peta.Binder
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index eae6b43..6d367f0 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.StorySheet extends Peta.Leaf\r
-  url: '/story_sheets/'\r
   \r
   @singular: () ->\r
     'StorySheet'\r
@@ -28,6 +27,4 @@ class Pettanr.StorySheet extends Peta.Leaf
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index 36bda58..20168d3 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.SystemPicture extends Peta.SystemResource\r
-  url: '/system_pictures/'\r
   \r
   @singular: () ->\r
     'SystemPicture'\r
@@ -44,6 +43,4 @@ class Pettanr.SystemPicture extends Peta.SystemResource
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index ab62ce1..2b2d1c5 100644 (file)
@@ -1,7 +1,5 @@
 class Pettanr.User extends Backbone.Model\r
   \r
-  url: '/users/'\r
-  \r
   defaults: {\r
   } \r
   \r
index 9921758..834c18a 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.WritingFormat extends Peta.Template\r
-  url: '/writing_formats/'\r
   \r
   @singular: () ->\r
     'WritingFormat'\r
@@ -24,6 +23,4 @@ class Pettanr.WritingFormat extends Peta.Template
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r
index aac9f2d..1c133c5 100644 (file)
@@ -1,6 +1,7 @@
 class Peta.Item extends Backbone.Model\r
   \r
   initialize: (attr = {}, options = {}) ->\r
+    @url = @default_url()\r
     super(attr, options)\r
     @expire_time = options.expire_time\r
     @boosters = {}\r
@@ -14,6 +15,9 @@ class Peta.Item extends Backbone.Model
   \r
   # ClassMethods\r
   \r
+  @default_url: () ->\r
+    '/' + @table_name() + '/'\r
+  \r
   @my_class: () ->\r
     this\r
   \r
@@ -82,6 +86,11 @@ class Peta.Item extends Backbone.Model
   \r
   #InstanceMethods\r
   \r
+  default_url: () ->\r
+    r = @my_class().default_url()\r
+    r = r.concat( @id ) if @id\r
+    r\r
+  \r
   singular: () ->\r
     @my_class().singular()\r
   \r
index 511dc7c..8615937 100644 (file)
@@ -107,6 +107,15 @@ class Pettanr.Proxy
   sign_out: () ->\r
     @trigger('sign_out')\r
   \r
+  @destroy: (item, options = {}) ->\r
+    return if !confirm('remove?')\r
+    proxy = new Pettanr.Proxy({})\r
+    proxy.listenTo(proxy, 'success', options['success'])\r
+    proxy.listenTo(proxy, 'redirect', options['redirect'])\r
+    proxy.listenTo(proxy, 'fail', options['fail'])\r
+    proxy.listenTo(proxy, 'deny', options['deny'])\r
+    proxy.http_post(item.destroy_url())\r
+  \r
 class Pettanr.PickerProxy extends Pettanr.Proxy\r
   \r
   constructor: (options) ->\r
diff --git a/app/assets/javascripts/pettanr/remover.js.coffee b/app/assets/javascripts/pettanr/remover.js.coffee
new file mode 100644 (file)
index 0000000..663af13
--- /dev/null
@@ -0,0 +1,6 @@
+class Pettanr.Remover\r
+  \r
+  constructor: (options) ->\r
+    _.extend(this, Backbone.Events)\r
+    @item = options.item\r
+  \r
index 0267b63..8058b41 100644 (file)
@@ -53,6 +53,7 @@ class Pettanr.Router extends Backbone.Router
     [\r
       {route: '', callback: 'home'}, \r
       {route: 'top/:action', callback: 'top_a'}, \r
+      {route: 'home/:action', callback: 'home_a'}, \r
       {route: 'users/:action', callback: 'users_a'},   # no manifest route\r
       {route: 'user_sessions/:action', callback: 'user_sessions_a'},    # no manifest route\r
       {route: ':controller/:id/:action?*query_string', callback: 'c_i_a'}, \r
@@ -164,6 +165,17 @@ class Pettanr.Router extends Backbone.Router
     params['action'] = action\r
     params\r
   \r
+  home_a: (action, query_string, form) ->\r
+    params = @home_a_params(action, query_string)\r
+    @trigger('go', params, form)\r
+  \r
+  home_a_params: (action, query_string) ->\r
+    params = @parse_query_string(query_string)\r
+    params['controller'] = 'home'\r
+    params['format'] = 'html'\r
+    params['action'] = action\r
+    params\r
+  \r
   user_sessions_a: (action, query_string, form) ->\r
     params = @user_sessions_a_params(action, query_string)\r
     @trigger('go', params, form)\r
index 71bae95..0029175 100644 (file)
@@ -55,7 +55,9 @@ class Pettanr.Views.Comic.Show extends Backbone.View
     @trigger('http_get', @item.edit_url())\r
   \r
   click_destroy: () ->\r
-    @trigger('http_get', @item.destroy_url())\r
+    redirect = (url) =>\r
+      @trigger('http_get', url)\r
+    Pettanr.Proxy.destroy(@item, {redirect: redirect})\r
   \r
   click_pick: () ->\r
     @trigger('pick', @item)\r
index e5293d3..794bbde 100644 (file)
@@ -78,6 +78,29 @@ class Pettanr.Views.OriginalPicture.ShowModule.Owner extends Pettanr.Views.Show.
   footer_class: () ->\r
     Pettanr.Views.OriginalPicture.ShowModule.OwnerFooter\r
   \r
+class Pettanr.Views.OriginalPicture.ShowModule.History extends Backbone.View\r
+  \r
+  initialize: (options) ->\r
+    super(options)\r
+    @item = options.item\r
+    @list = @item.history()\r
+  \r
+  render: () ->\r
+    this.$el.html('')\r
+    h = new Tag.H2({\r
+      content: I18n.t('original_pictures.show.history')\r
+    })\r
+    this.$el.append(h.render().el)\r
+    @list.fetch().done =>\r
+      _.each @list.models, (picture) =>\r
+        view = picture.history_view()\r
+        @listenTo(view, 'http_get', @http_get)\r
+        this.$el.append(view.render().el)\r
+    this\r
+  \r
+  http_get: (url) ->\r
+    @trigger('http_get', url)\r
+  \r
 class Pettanr.Views.OriginalPicture.Show extends Backbone.View\r
   tagName: 'div'\r
   \r
@@ -91,12 +114,14 @@ class Pettanr.Views.OriginalPicture.Show extends Backbone.View
     @artist = new Pettanr.Views.Show.HeaderArtist({item: @item})\r
     @img = new Pettanr.Views.OriginalPicture.Img({item: @item})\r
     @owner = new Pettanr.Views.OriginalPicture.ShowModule.Owner({item: @item})\r
+    @history = new Pettanr.Views.OriginalPicture.ShowModule.History({item: @item})\r
     @listenTo(@header, 'click:icon', @click_show)\r
     @listenTo(@header, 'click:prof', @click_prof)\r
     @listenTo(@artist, 'click:artist', @click_artist)\r
     @listenTo(@owner, 'click:license', @click_license)\r
     @listenTo(@owner, 'click:edit', @click_edit)\r
     @listenTo(@owner, 'click:destroy', @click_destroy)\r
+    @listenTo(@history, 'http_get', @http_get)\r
   \r
   render: () ->\r
     this.$el.html('')\r
@@ -104,6 +129,7 @@ class Pettanr.Views.OriginalPicture.Show extends Backbone.View
     this.$el.append(@artist.render().el)\r
     this.$el.append(@img.render().el)\r
     this.$el.append(@owner.render().el)\r
+    this.$el.append(@history.render().el)\r
     this\r
   \r
   click_show: () ->\r
@@ -126,7 +152,12 @@ class Pettanr.Views.OriginalPicture.Show extends Backbone.View
     @trigger('http_get', @item.edit_url())\r
   \r
   click_destroy: () ->\r
-    @trigger('http_get', @item.destroy_url())\r
+    redirect = (url) =>\r
+      @trigger('http_get', url)\r
+    Pettanr.Proxy.destroy(@item, {redirect: redirect})\r
+  \r
+  http_get: (url) ->\r
+    @trigger('http_get', url)\r
   \r
   create_dialog: () ->\r
     @dialog = new Editor.PicturePublisher.Dialog({\r
index e527a96..0966563 100644 (file)
@@ -1,3 +1,52 @@
+class Pettanr.Views.Panel.ShowModule\r
+class Pettanr.Views.Panel.ShowModule.Header extends Pettanr.Views.Show.Header\r
+  \r
+  initialize: (options) ->\r
+    super(options)\r
+  \r
+class Pettanr.Views.Panel.ShowModule.Owner extends Pettanr.Views.Show.Owner\r
+  \r
+  initialize: (options) ->\r
+    super(options)\r
+  \r
+class Pettanr.Views.Panel.ShowModule.Credits extends Backbone.View\r
+  tagName: 'div'\r
+  className: 'credits'\r
+  \r
+  initialize: (options) ->\r
+    @pictures = options.pictures\r
+    @credited = {}\r
+  \r
+  render: () ->\r
+    this.$el.html('')\r
+    _.each @pictures, (picture, pid) =>\r
+      @add_picture(picture)\r
+    this\r
+  \r
+  add_picture: (retriever) ->\r
+    @listenTo(retriever, 'retrieve', @retrieve_picture)\r
+    retriever.retrieve()\r
+  \r
+  retrieve_picture: (picture) ->\r
+    pid = picture.get('id')\r
+    if not @credited[pid]\r
+      @credited[pid] = picture\r
+      credit = picture.credit_view()\r
+      @listenTo(credit, 'click:icon', @click_credit_icon)\r
+      this.$el.append(credit.render().el)\r
+  \r
+  click_credit_icon: (item) ->\r
+    @trigger('click:credit:icon', item)\r
+  \r
+  click_pick: () ->\r
+    @trigger('pick', @item)\r
+  \r
+  is_pickable: () ->\r
+    true\r
+  \r
+  add_pick: (target_model) ->\r
+    @header.add_pick(target_model)\r
+  \r
 # panel: panel item\r
 # spot: no opacity element\r
 class Pettanr.Views.Panel.Show extends Backbone.View\r
@@ -24,6 +73,7 @@ class Pettanr.Views.Panel.Show extends Backbone.View
     @credits = new Pettanr.Views.Panel.ShowModule.Credits({\r
       pictures: @panel.licensed_pictures()\r
     })\r
+    @owner = new Pettanr.Views.Panel.ShowModule.Owner({item: @panel})\r
     @listenTo(@header, 'click:pick', @click_pick)\r
     @listenTo(@header, 'click:icon', @click_show)\r
     @listenTo(@header, 'click:caption', @click_show)\r
@@ -33,6 +83,8 @@ class Pettanr.Views.Panel.Show extends Backbone.View
     @listenTo(@footer, 'click:edit', @click_edit)\r
     @listenTo(@footer, 'click:inspire', @click_inspire)\r
     @listenTo(@credits, 'click:credit:icon', @click_credit_icon)\r
+    @listenTo(@owner, 'click:edit', @click_edit)\r
+    @listenTo(@owner, 'click:destroy', @click_destroy)\r
   \r
   render: () ->\r
     this.$el.html('')\r
@@ -42,6 +94,7 @@ class Pettanr.Views.Panel.Show extends Backbone.View
     this.$el.append(@credits.render().el)\r
     rb = new Tag.RowBreak()\r
     this.$el.append(rb.render().el)\r
+    this.$el.append(@owner.render().el)\r
     this\r
   \r
   click_show: () ->\r
@@ -53,6 +106,11 @@ class Pettanr.Views.Panel.Show extends Backbone.View
   click_edit: () ->\r
     @trigger('http_get', @panel.edit_url())\r
   \r
+  click_destroy: () ->\r
+    redirect = (url) =>\r
+      @trigger('http_get', url)\r
+    Pettanr.Proxy.destroy(@panel, {redirect: redirect})\r
+  \r
   click_inspire: () ->\r
     inspire = new Pettanr.Inspire({item: @panel})\r
     @listenTo(inspire, 'inspire', @inspire)\r
@@ -76,47 +134,3 @@ class Pettanr.Views.Panel.Show extends Backbone.View
   inspire: (item) ->\r
     @trigger('http_get', item.show_url())\r
   \r
-class Pettanr.Views.Panel.ShowModule\r
-class Pettanr.Views.Panel.ShowModule.Header extends Pettanr.Views.Show.Header\r
-  \r
-  initialize: (options) ->\r
-    super(options)\r
-  \r
-class Pettanr.Views.Panel.ShowModule.Credits extends Backbone.View\r
-  tagName: 'div'\r
-  className: 'credits'\r
-  \r
-  initialize: (options) ->\r
-    @pictures = options.pictures\r
-    @credited = {}\r
-  \r
-  render: () ->\r
-    this.$el.html('')\r
-    _.each @pictures, (picture, pid) =>\r
-      @add_picture(picture)\r
-    this\r
-  \r
-  add_picture: (retriever) ->\r
-    @listenTo(retriever, 'retrieve', @retrieve_picture)\r
-    retriever.retrieve()\r
-  \r
-  retrieve_picture: (picture) ->\r
-    pid = picture.get('id')\r
-    if not @credited[pid]\r
-      @credited[pid] = picture\r
-      credit = picture.credit_view()\r
-      @listenTo(credit, 'click:icon', @click_credit_icon)\r
-      this.$el.append(credit.render().el)\r
-  \r
-  click_credit_icon: (item) ->\r
-    @trigger('click:credit:icon', item)\r
-  \r
-  click_pick: () ->\r
-    @trigger('pick', @item)\r
-  \r
-  is_pickable: () ->\r
-    true\r
-  \r
-  add_pick: (target_model) ->\r
-    @header.add_pick(target_model)\r
-  \r
index a8a9e84..1212440 100644 (file)
@@ -6,7 +6,6 @@ class Pettanr.Views.Picture.Credit extends Backbone.View
     @item = options.item\r
     @with_icon = options.with_icon\r
     @url = @item.url + '/credit'\r
-    @listenTo(@item, 'ready', @render)\r
   \r
   render: () ->\r
     this.$el.html('')\r
@@ -14,8 +13,11 @@ class Pettanr.Views.Picture.Credit extends Backbone.View
       p = @item.credit_icon_view()\r
       @listenTo(p, 'click', @click)\r
       this.$el.append(p.render().el)\r
-    this.$el.append(@item.credit)\r
-    this.$el.append((new Tag.RowBreak()).render().el)\r
+    f = (data, status) =>\r
+      this.$el.append(data)\r
+      rb = new Tag.RowBreak()\r
+      this.$el.append(rb.render().el)\r
+    $.get(@url, null, f, 'html')\r
     this\r
   \r
   click: () ->\r
diff --git a/app/assets/javascripts/views/pictures/history.js.coffee b/app/assets/javascripts/views/pictures/history.js.coffee
new file mode 100644 (file)
index 0000000..9546fe8
--- /dev/null
@@ -0,0 +1,33 @@
+class Pettanr.Views.Picture.History extends Backbone.View\r
+  tagName: 'div'\r
+  \r
+  initialize: (options) ->\r
+    @item = options.item\r
+  \r
+  render: () ->\r
+    this.$el.html('')\r
+    r = new Tag.A({\r
+      attr: {href: '/' + @item.show_url()},\r
+      content: @item.get('revision')\r
+    })\r
+    @listenTo(r, 'click', @click_show)\r
+    h = new Tag.H3({\r
+      content: Pettanr.AppHelper.t_m('Picture.revision') + ':'\r
+    })\r
+    d = new Tag.Div({\r
+      content: Pettanr.AppHelper.t_m('Picture.created_at') + ':' + @item.get('created_at')\r
+    })\r
+    credit = @item.credit_view()\r
+    @listenTo(credit, 'click:icon', @click_icon)\r
+    this.$el.append(h.render().el)\r
+    h.$el.append(r.render().el)\r
+    this.$el.append(d.render().el)\r
+    this.$el.append(credit.render().el)\r
+    this\r
+  \r
+  click_show: () ->\r
+    @trigger('http_get', @item.show_url())\r
+  \r
+  click_icon: () ->\r
+    @trigger('http_get', @item.show_url())\r
+  \r
diff --git a/app/assets/javascripts/views/resource_pictures/img.js.coffee b/app/assets/javascripts/views/resource_pictures/img.js.coffee
new file mode 100644 (file)
index 0000000..1fb5ecd
--- /dev/null
@@ -0,0 +1,18 @@
+class Pettanr.Views.ResourcePicture.Img extends Backbone.View\r
+  tagName: 'img'\r
+  \r
+  initialize: (options) ->\r
+    @item = options.item\r
+  \r
+  render: () ->\r
+    this.$el.html('')\r
+    this.$el.attr(@attr())\r
+    this\r
+  \r
+  attr: () ->\r
+    {\r
+      src: @item.r_url('full'), \r
+      width: Pettanr.to_s(Math.abs(@item.get('width'))) + 'px', \r
+      height: Pettanr.to_s(Math.abs(@item.get('height'))) + 'px', \r
+    }\r
+  \r
index 79d67bf..075573a 100644 (file)
@@ -4,10 +4,84 @@ class Pettanr.Views.ResourcePicture.ShowModule.Header extends Pettanr.Views.Show
   initialize: (options) ->\r
     super(options)\r
   \r
+class Pettanr.Views.ResourcePicture.ShowModule.LinkedReplaceButton extends Tag.A\r
+  \r
+  initialize: (options) ->\r
+    item = options.item\r
+    op = new Pettanr.OriginalPicture({id: item.get('original_picture_id')})\r
+    super({\r
+      attr: {href: '/' + op.edit_url()}, \r
+      content: I18n.t('original_pictures.show.replace')\r
+    })\r
+  \r
+class Pettanr.Views.ResourcePicture.ShowModule.LinkedSourceButton extends Tag.A\r
+  \r
+  initialize: (options) ->\r
+    item = options.item\r
+    op = new Pettanr.OriginalPicture({id: item.get('original_picture_id')})\r
+    super({\r
+      attr: {href: '/' + op.show_url()}, \r
+      content: I18n.t('original_pictures.show.title')\r
+    })\r
+  \r
+class Pettanr.Views.ResourcePicture.ShowModule.LinkedStopButton extends Tag.A\r
+  \r
+  initialize: (options) ->\r
+    item = options.item\r
+    super({\r
+      attr: {href: '/' + item.destroy_url()}, \r
+      content: I18n.t('original_pictures.index.stop')\r
+    })\r
+  \r
+class Pettanr.Views.ResourcePicture.ShowModule.OwnerFooter extends Backbone.View\r
+  tagName: 'div'\r
+  className: 'show-owner-footer'\r
+  \r
+  initialize: (options) ->\r
+    super(options)\r
+    @item = options.item\r
+    @replace = new Pettanr.Views.ResourcePicture.ShowModule.LinkedReplaceButton({item: @item})\r
+    @source = new Pettanr.Views.ResourcePicture.ShowModule.LinkedSourceButton({item: @item})\r
+    @stop = new Pettanr.Views.ResourcePicture.ShowModule.LinkedStopButton({item: @item})\r
+    @listenTo(@replace, 'click', @click_replace)\r
+    @listenTo(@source, 'click', @click_source)\r
+    @listenTo(@stop, 'click', @click_stop)\r
+  \r
+  render: () ->\r
+    super()\r
+    this.$el.append(@replace.render().el)\r
+    this.$el.append(@source.render().el)\r
+    this.$el.append(@stop.render().el)\r
+    this\r
+  \r
+  click_replace: () ->\r
+    @trigger('click:replace')\r
+  \r
+  click_source: () ->\r
+    @trigger('click:source')\r
+  \r
+  click_stop: () ->\r
+    @trigger('click:stop')\r
+  \r
 class Pettanr.Views.ResourcePicture.ShowModule.Owner extends Pettanr.Views.Show.Owner\r
   \r
   initialize: (options) ->\r
     super(options)\r
+    @listenTo(@footer, 'click:replace', @click_replace)\r
+    @listenTo(@footer, 'click:source', @click_source)\r
+    @listenTo(@footer, 'click:stop', @click_stop)\r
+  \r
+  click_replace: () ->\r
+    @trigger('click:replace')\r
+  \r
+  click_source: () ->\r
+    @trigger('click:source')\r
+  \r
+  click_stop: () ->\r
+    @trigger('click:stop')\r
+  \r
+  footer_class: () ->\r
+    Pettanr.Views.ResourcePicture.ShowModule.OwnerFooter\r
   \r
 class Pettanr.Views.ResourcePicture.Show extends Backbone.View\r
   tagName: 'div'\r
@@ -22,15 +96,24 @@ class Pettanr.Views.ResourcePicture.Show extends Backbone.View
       prof_url: @item.prof_url()\r
     })\r
     @artist = new Pettanr.Views.Show.HeaderArtist({item: @item})\r
+    @img = new Pettanr.Views.ResourcePicture.Img({item: @item})\r
+    @credit = @item.credit_view(false)\r
+    @owner = new Pettanr.Views.ResourcePicture.ShowModule.Owner({item: @item, original_picture: @original_picture})\r
     @listenTo(@header, 'click:pick', @click_pick)\r
     @listenTo(@header, 'click:icon', @click_show)\r
     @listenTo(@header, 'click:prof', @click_prof)\r
     @listenTo(@artist, 'click:artist', @click_artist)\r
+    @listenTo(@owner, 'click:replace', @click_replace)\r
+    @listenTo(@owner, 'click:source', @click_source)\r
+    @listenTo(@owner, 'click:stop', @click_stop)\r
   \r
   render: () ->\r
     this.$el.html('')\r
     this.$el.append(@header.render().el)\r
     this.$el.append(@artist.render().el)\r
+    this.$el.append(@img.render().el)\r
+    this.$el.append(@credit.render().el)\r
+    this.$el.append(@owner.render().el)\r
     this\r
   \r
   click_show: () ->\r
@@ -42,6 +125,19 @@ class Pettanr.Views.ResourcePicture.Show extends Backbone.View
   click_artist: () ->\r
     @trigger('http_get', @item.artist().show_url())\r
   \r
+  click_replace: () ->\r
+    op = new Pettanr.OriginalPicture({id: @item.get('original_picture_id')})\r
+    @trigger('http_get', op.edit_url())\r
+  \r
+  click_source: () ->\r
+    op = new Pettanr.OriginalPicture({id: @item.get('original_picture_id')})\r
+    @trigger('http_get', op.show_url())\r
+  \r
+  click_stop: () ->\r
+    redirect = (url) =>\r
+      @trigger('http_get', url)\r
+    Pettanr.Proxy.destroy(@item, {redirect: redirect})\r
+  \r
   click_pick: () ->\r
     @trigger('pick', @item)\r
   \r
index 9a7a82b..e2880c8 100644 (file)
@@ -55,7 +55,9 @@ class Pettanr.Views.Scroll.Show extends Backbone.View
     @trigger('http_get', @item.edit_url())\r
   \r
   click_destroy: () ->\r
-    @trigger('http_get', @item.destroy_url())\r
+    redirect = (url) =>\r
+      @trigger('http_get', url)\r
+    Pettanr.Proxy.destroy(@item, {redirect: redirect})\r
   \r
   click_pick: () ->\r
     @trigger('pick', @item)\r
index 991f90f..e18e054 100644 (file)
@@ -62,14 +62,13 @@ class Pettanr.Views.User.Account.Quick extends Backbone.View
   render: () ->\r
     this.$el.html('')\r
     @home()\r
-    @create()\r
     this\r
   \r
   home: () ->\r
     params = {\r
       controller: 'folders',\r
       action: 'index',\r
-      path: '/my documents/create/'\r
+      path: '/my documents/'\r
     }\r
     list = Locmare.ListGroup.list(\r
       'folders', 'index', params\r
@@ -78,13 +77,14 @@ class Pettanr.Views.User.Account.Quick extends Backbone.View
       if !_.isEmpty(list.items())\r
         @mydoc = list.items()[0]\r
         @add_mydoc()\r
+        @create()\r
     )\r
   \r
   create: () ->\r
     params = {\r
       controller: 'folders',\r
       action: 'index',\r
-      path: '/my documents/'\r
+      path: '/my documents/create/'\r
     }\r
     list = Locmare.ListGroup.list(\r
       'folders', 'index', params\r
index 72358e5..6057f46 100644 (file)
         type: 'show',\r
       },\r
       history: {\r
-        type: 'show',\r
+        type: 'list',\r
+        args: {\r
+        },\r
       },\r
       new: {\r
         type: 'new',\r
index d6720fe..2efb406 100644 (file)
@@ -39,7 +39,7 @@
   
   <p>
     <%= link_to t('original_pictures.show.replace'), edit_original_picture_path(@item.original_picture) %>
-    <%= link_to t('show'), original_picture_path(@item.original_picture) %>
+    <%= link_to t('original_pictures.show.title'), original_picture_path(@item.original_picture) %>
     <%= link_to t('original_pictures.index.stop'), resource_picture_path(@item), :method => :delete %>
   </p>
 <% end -%>