• R/O
  • HTTP
  • SSH
  • HTTPS

pettanr: コミット

サーバ側、Railsシステム本体


コミットメタ情報

リビジョンf522407ab18ef79c237ed4dfe2f3bbb590d1b42e (tree)
日時2015-10-01 09:56:36
作者yasushiito <yas@pen-...>
コミッターyasushiito

ログメッセージ

fix:element remove func failed

変更サマリ

差分

--- a/app/assets/javascripts/editor/panel_editor/element.js.coffee
+++ b/app/assets/javascripts/editor/panel_editor/element.js.coffee
@@ -125,7 +125,7 @@ class Editor.EditorModule.DockModule.ElementBay extends Editor.EditorModule.Dock
125125 _.each @removed_elements, (element) ->
126126 name = element.table_name() + '_attributes'
127127 attrs[name] ||= []
128- attrs[name].push({id: element.get('id'), _destroy: true})
128+ attrs[name].push({id: element.get('id'), _destroy: 1})
129129 attrs
130130
131131 pick: (new_item) ->
--- a/app/assets/javascripts/locmare/form.js.coffee
+++ b/app/assets/javascripts/locmare/form.js.coffee
@@ -187,12 +187,15 @@ class Locmare.Form extends Locmare.FormBase
187187 @item.save()
188188
189189 success: (model, response) ->
190+ # strip element's attributes
191+ m = @item.my_class().my_manifest().classify()
192+ pure_item = new m(model.pure_attributes())
190193 if !Pettanr.cache.restore(model.cache_key())
191194 # item is new
192- model.url = model.default_url()
193- Pettanr.cache.store(model)
195+ pure_item.url = model.default_url()
196+ Pettanr.cache.store(pure_item)
194197 else
195- @item.fix()
198+ pure_item.fix()
196199 @trigger('success', model, response)
197200
198201 fail: (model, response) ->
--- a/app/assets/javascripts/peta/item.js.coffee
+++ b/app/assets/javascripts/peta/item.js.coffee
@@ -127,6 +127,12 @@ class Peta.Item extends Backbone.Model
127127 else
128128 @item_name()
129129
130+ pure_attributes: () ->
131+ r = {}
132+ _.each @my_class().my_manifest().attributes, (v, name) =>
133+ r[name] = @get(name)
134+ r
135+
130136 _label: (label_column_name, options) ->
131137 shorten = options.shorten
132138 l = if _.isBoolean(shorten)
--- a/app/assets/javascripts/views/scrolls/play.js.coffee
+++ b/app/assets/javascripts/views/scrolls/play.js.coffee
@@ -285,6 +285,7 @@ class Pettanr.Views.Scroll.PlayModule.Panels extends Pettanr.View
285285 scroll: @binder, scroll_panel: scroll_panel,
286286 })
287287 @listenTo(panel_view, 'ready', @ready)
288+ @listenTo(panel_view, 'http_get', @http_get)
288289 @listenTo(panel_view, 'click:insert', @click_insert)
289290 @listenTo(panel_view, 'click:move', @click_move)
290291 @listenTo(panel_view, 'click:destroy', @click_destroy)
@@ -295,6 +296,9 @@ class Pettanr.Views.Scroll.PlayModule.Panels extends Pettanr.View
295296 ready: (panel) ->
296297 this.credits.push(panel.licensed_pictures())
297298
299+ http_get: (url) ->
300+ @trigger('http_get', url)
301+
298302 click_insert: (panel_view = null) ->
299303 @dialog = new Editor.Player.PanelInsertDialog({
300304 parent: this, binder: @binder, target_model: Pettanr.ScrollPanel,
@@ -472,6 +476,7 @@ class Pettanr.Views.Scroll.PlayModule.Body extends Pettanr.View
472476 credits: credits,
473477 })
474478 @listenTo(credits, 'click:credit:icon', @click_credit_icon)
479+ @listenTo(@panels, 'http_get', @http_get)
475480 @listenTo(@panels, 'click:insert', @click_insert)
476481 @listenTo(@panels, 'click:move', @click_move)
477482 @listenTo(@panels, 'dialog:close', @close_dialog)
@@ -495,6 +500,9 @@ class Pettanr.Views.Scroll.PlayModule.Body extends Pettanr.View
495500 click_append: () ->
496501 @panels.click_insert()
497502
503+ http_get: (url) ->
504+ @trigger('http_get', url)
505+
498506 click_insert: (dialog) ->
499507 @appender.hide()
500508 @trigger('click:insert', dialog)
--- a/app/controllers/panels_controller.rb
+++ b/app/controllers/panels_controller.rb
@@ -141,7 +141,7 @@ class PanelsController < ApplicationController
141141 @prm = if params[:panel] == nil or params[:panel].empty?
142142 jsn
143143 else
144- @item.permit_params(params)
144+ @item.permit_params(params, [:_destroy])
145145 end
146146 @item.class.fold_extend_settings @prm
147147 # @item.refresh
--- a/lib/peta/element_nestable_content.rb
+++ b/lib/peta/element_nestable_content.rb
@@ -21,6 +21,17 @@ module Peta
2121
2222 # Class Methods
2323
24+ def self.permit_attributes default_permit_attributes = []
25+ attrs = super
26+ self.child_models.each do |element_model|
27+ name = self.my_manifest.associations.child_element_name(element_model) + '_attributes'
28+ child_attrs = {}
29+ child_attrs[name] = element_model.permit_attributes(default_permit_attributes)
30+ attrs.push child_attrs
31+ end
32+ attrs
33+ end
34+
2435 # Instance Methods
2536
2637 def boosts level
--- a/lib/peta/item.rb
+++ b/lib/peta/item.rb
@@ -255,19 +255,14 @@ module Peta
255255 true
256256 end
257257
258- def permit_params params
259- attrs = self.class.permit_attributes
258+ def permit_params params, default_permit_attributes = []
259+ attrs = self.class.permit_attributes(default_permit_attributes)
260260 params.require(self.item_name.to_sym).permit(attrs)
261261 end
262262
263- def self.permit_attributes
263+ def self.permit_attributes default_permit_attributes = []
264264 attrs = self.my_manifest.attributes.keys
265- self.child_models.each do |element_model|
266- name = self.my_manifest.associations.child_element_name(element_model) + '_attributes'
267- child_attrs = {}
268- child_attrs[name] = element_model.permit_attributes
269- attrs.push child_attrs
270- end
265+ attrs.concat(default_permit_attributes)
271266 attrs
272267 end
273268
旧リポジトリブラウザで表示