OSDN Git Service

fix changing WithElements
authoryasushiito <yas@pen-chan.jp>
Fri, 6 Feb 2015 01:27:05 +0000 (10:27 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 6 Feb 2015 01:27:05 +0000 (10:27 +0900)
app/assets/javascripts/controllers/panels.js.coffee
app/assets/javascripts/locmare/form.js.coffee
app/assets/javascripts/models/panel.js.coffee
app/assets/javascripts/models/scroll_panel.js.coffee
app/assets/javascripts/views/balloons/show.js.coffee
app/assets/javascripts/views/ground_colors/show.js.coffee
app/assets/javascripts/views/ground_pictures/show.js.coffee
app/assets/javascripts/views/panel_pictures/show.js.coffee
app/assets/javascripts/views/speech_balloons/show.js.coffee
app/assets/javascripts/views/speeches/show.js.coffee

index 9223df7..c48a0e2 100644 (file)
@@ -21,7 +21,7 @@ class Pettanr.PanelsController extends Pettanr.AppController
     @filer_list()\r
   \r
   show_html: () ->\r
-    @item = new Pettanr.Panel({id: @item.get('id')}, {with_elements: true}) # retake panel for 'with_elements' mode\r
+    @item = new Pettanr.Panel.WithElements({id: @item.get('id')}) # retake panel for 'with_elements' mode\r
     @item.fetch({cache: false}).done =>\r
       @trigger('retitle', @params, @item.get('caption'))\r
       show = new Pettanr.Views.Panel.Show({\r
index a61f467..11a73b9 100644 (file)
@@ -139,9 +139,11 @@ class Locmare.Form extends Locmare.FormBase
     _.each @fields, (field) =>\r
       @item.set(field.field_name, field.val())\r
     if @item.save()\r
-      window.router.navigate('/' + @item.table_name() + '/' + Pettanr.to_s(@item.get('id')), true)\r
+      # redirect_to show\r
+      @trigger('navigate', @item.show_url())\r
       return false\r
     else\r
+      # render_form\r
       alert('invalid')\r
   \r
   put: () ->\r
@@ -155,7 +157,7 @@ class Locmare.Form extends Locmare.FormBase
   \r
   save: (attrs = null, options = null) ->\r
     if attrs\r
-      @item.save_with_elements(attrs, options)\r
+      @item.save(attrs, options)\r
     else\r
       @item.save()\r
   \r
index 745944d..c347941 100644 (file)
@@ -19,6 +19,9 @@ class Pettanr.Panel extends Peta.Root
   pp: () ->\r
     new Pettanr.PanelPicture({id: @get('pp_id')})\r
   \r
+  with_elements: () ->\r
+    new Pettanr.Panel.WithElements({id: @get('id')})\r
+  \r
   is_visible: (operators) ->\r
     switch super(operators)\r
       when null # super return\r
@@ -52,7 +55,25 @@ class Pettanr.Panel extends Peta.Root
       r[pid] = elm.picture() if not r[pid]\r
     r\r
   \r
-  save_with_elements: (attrs, options = {}) ->\r
+  my_url: () ->\r
+    '/' + @path_name() + '/' + @get('id')\r
+  \r
+  initialize: (attr = {}, options = {}) ->\r
+    @set(attr)\r
+    if @get('id')\r
+      @url = @my_url()\r
+    @bind('change:width', () ->\r
+      console.log('cng')\r
+    )\r
+  \r
+class Pettanr.Panel.WithElements extends Pettanr.Panel\r
+  \r
+  fetch: (options) ->\r
+    @url = @my_url() + '?with_elements=true'\r
+    super(options)\r
+  \r
+  save: (attrs, options = {}) ->\r
+    @url = @my_url()\r
     options.attrs = {panel: attrs}\r
     method = if @isNew()\r
       'create'\r
@@ -61,13 +82,7 @@ class Pettanr.Panel extends Peta.Root
     xhr = @sync(method, this, options)\r
     xhr\r
   \r
-  initialize: (attr = {}, options = {}) ->\r
-    @set(attr)\r
-    if @get('id')\r
-      @url = @url + @get('id')\r
-    if options.with_elements\r
-      @url = @url + '?with_elements=true'\r
-    @bind('change:width', () ->\r
-      console.log('cng')\r
-    )\r
+  destroy: (options) ->\r
+    @url = @my_url()\r
+    super(options)\r
   \r
index a861680..c5d83cd 100644 (file)
@@ -24,7 +24,8 @@ class Pettanr.ScrollPanel extends Peta.Leaf
     new Pettanr.Scroll({id: @get('scroll_id')})\r
   \r
   panel: () ->\r
-    new Pettanr.Panel({id: @get('panel_id')}, {with_elements: true})\r
+    # get with elm in case play mode\r
+    new Pettanr.Panel.WithElements({id: @get('panel_id')})\r
   \r
   has_panel: () ->\r
     if @get('panel_id')\r
index b9ad79a..89989e4 100644 (file)
@@ -25,7 +25,7 @@ class Pettanr.Views.Balloon.Show extends Backbone.View
     @listenTo(this, 'ready', @ready)\r
     @speech_balloon = @item.speech_balloon()\r
     @speech_balloon.fetch({cache: true}).done =>\r
-      @panel = @speech_balloon.panel({with_elements: true})\r
+      @panel = @speech_balloon.panel().with_elements()\r
       @panel.fetch({cache: false}).done =>  # with elements\r
         @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
         @body = new Pettanr.Views.Panel.Body({\r
index c00b29c..c0cc3ca 100644 (file)
@@ -23,7 +23,7 @@ class Pettanr.Views.GroundColor.Show extends Backbone.View
       prof_url: prof_url\r
     })\r
     @listenTo(this, 'ready', @ready)\r
-    @panel = @item.panel({with_elements: true})\r
+    @panel = @item.panel().with_elements()\r
     @panel.fetch({cache: false}).done =>  # with elements\r
       @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
       @body = new Pettanr.Views.Panel.Body({\r
index 1e1ff9a..833dcb0 100644 (file)
@@ -23,7 +23,7 @@ class Pettanr.Views.GroundPicture.Show extends Backbone.View
       prof_url: prof_url\r
     })\r
     @listenTo(this, 'ready', @ready)\r
-    @panel = @item.panel({with_elements: true})\r
+    @panel = @item.panel().with_elements()\r
     @panel.fetch({cache: false}).done =>  # with elements\r
       @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
       @body = new Pettanr.Views.Panel.Body({\r
index 6fd71d9..4882564 100644 (file)
@@ -23,7 +23,7 @@ class Pettanr.Views.PanelPicture.Show extends Backbone.View
       prof_url: prof_url\r
     })\r
     @listenTo(this, 'ready', @ready)\r
-    @panel = @item.panel({with_elements: true})\r
+    @panel = @item.panel().with_elements()\r
     @panel.fetch({cache: false}).done =>  # with elements\r
       @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
       @body = new Pettanr.Views.Panel.Body({\r
index 0ebfbaf..334538d 100644 (file)
@@ -23,7 +23,7 @@ class Pettanr.Views.SpeechBalloon.Show extends Backbone.View
       prof_url: prof_url\r
     })\r
     @listenTo(this, 'ready', @ready)\r
-    @panel = @item.panel({with_elements: true})\r
+    @panel = @item.panel().with_elements()\r
     @panel.fetch({cache: false}).done =>  # with elements\r
       @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
       @body = new Pettanr.Views.Panel.Body({\r
index 445afd0..c75897a 100644 (file)
@@ -25,7 +25,7 @@ class Pettanr.Views.Speech.Show extends Backbone.View
     @listenTo(this, 'ready', @ready)\r
     @speech_balloon = @item.speech_balloon()\r
     @speech_balloon.fetch({cache: true}).done =>\r
-      @panel = @speech_balloon.panel({with_elements: true})\r
+      @panel = @speech_balloon.panel().with_elements()\r
       @panel.fetch({cache: false}).done =>  # with elements\r
         @author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
         @body = new Pettanr.Views.Panel.Body({\r