From: yasushiito Date: Thu, 5 Sep 2013 22:43:53 +0000 (+0900) Subject: t#31896: X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=commitdiff_plain;h=b29c18d2f37b35b2ef3dd11f49e311cd67db7b01 t#31896: --- diff --git a/app/models/panel.rb b/app/models/panel.rb index 5ad57278..f0ccdd67 100644 --- a/app/models/panel.rb +++ b/app/models/panel.rb @@ -97,6 +97,34 @@ class Panel < ActiveRecord::Base self.tag_id + f.to_s end + def tag_attributes column = nil, opt = {} + { + :id => self.field_tag_id(column), :panel_id => self.tag_panel_id + }.merge(opt) + end + + def select_tag_attributes(selected, column) + [ + :last, :first, + {:html => {:selected => selected}}, + self.field_tag_attributes(column) + ] + end + + def field_tag_attributes column, opt = {} + self.tag_attributes(column).merge( + {:column => column} + ).merge(opt) + end + + def tag_attr column = nil, opt = {} + self.tag_attributes(column, opt).to_attr + end + + def field_tag_attr column, no_attr, opt = {} + self.field_tag_attributes(column, no_attr, opt).to_attr + end + def self.default_page_size 25 end diff --git a/app/views/panels/_element_tab.html.erb b/app/views/panels/_element_tab.html.erb index 525e9e31..c56c1ab8 100644 --- a/app/views/panels/_element_tab.html.erb +++ b/app/views/panels/_element_tab.html.erb @@ -1,8 +1,8 @@ -
  • +
  • >
    <%= render elm.element_face_template, :elm => elm %>
    - +
  • diff --git a/app/views/panels/_form.html.erb b/app/views/panels/_form.html.erb index 06370c0e..85eda0e1 100644 --- a/app/views/panels/_form.html.erb +++ b/app/views/panels/_form.html.erb @@ -12,24 +12,24 @@
    <%= f.label :caption %> - <%= f.text_field :caption, :id => @panel.field_tag_id(:caption), :panel_id => @panel.tag_panel_id, :column => :caption -%> + <%= f.text_field :caption, @panel.field_tag_attributes(:caption) -%>
    <%= f.label :width %> - <%= f.number_field :width, :size => 5, :id => @panel.field_tag_id(:width), :panel_id => @panel.tag_panel_id, :column => :width %> + <%= f.number_field :width, @panel.field_tag_attributes(:width, :size => 5) %> <%= f.label :height %> - <%= f.number_field :height, :size => 5, :id => @panel.field_tag_id(:height), :panel_id => @panel.tag_panel_id, :column => :height %> + <%= f.number_field :height, @panel.field_tag_attributes(:height, :size => 5) %> <%= f.label :border %> - <%= f.number_field :border, :size => 5, :id => @panel.field_tag_id(:border), :panel_id => @panel.tag_panel_id, :column => :border %> + <%= f.number_field :border, @panel.field_tag_attributes(:border, :size => 5) %>
    <%= f.label :publish %> - <%= f.collection_select :publish, t_select_items(MagicNumber['panel_visible_items']), :last, :first, {:html => {:selected => @panel.publish}}, {:id => @panel.field_tag_id(:publish), :panel_id => @panel.tag_panel_id, :column => :publish} %> + <%= f.collection_select :publish, t_select_items(MagicNumber['panel_visible_items']), *@panel.select_tag_attributes(@panel.publish, :publish) %>
    <% unless @panel.new_record? %> - <%= f.hidden_field :id, :id => @panel.field_tag_id(:id), :panel_id => @panel.tag_panel_id, :column => :id %> + <%= f.hidden_field :id, @panel.field_tag_attributes(:id) %> <% end %>
    <%= f.submit 'panels.submit', :class => "submit" %> @@ -44,10 +44,10 @@ <% end %> <% @panel.panel_elements.each do |elm| %> -
    +
    >
    <%= render elm.form_template, :elm => elm, :no_attr => 0 %> - <%= hidden_field_tag '_destroy', '', :id => elm.field_tag_id(:_destroy), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :_destroy %> + <%= hidden_field_tag '_destroy', '', elm.field_tag_attributes(:_destroy, 0) %>
    <% end %> @@ -55,9 +55,9 @@
    -
      +
        > <% @panel.panel_elements.each do |elm| %> -
      • +
      • >
        <%= render elm.path_name + '/element_face', :elm => elm %>
        @@ -65,9 +65,9 @@ <% end %>
    -
    +
    > <% @panel.panel_elements.each do |elm| %> -
    +
    > <%= render elm.scenario_template, :elm => elm, :no_attr => 0 %>
    <% end %> @@ -77,9 +77,9 @@
    -
      +
        > <% @panel.zorderd_elements.each do |elm| %> -
      • +
      • >
        <%= render elm.class.to_s.tableize + '/element_face', :elm => elm %>
        diff --git a/app/views/speech_balloons/_form.html.erb b/app/views/speech_balloons/_form.html.erb deleted file mode 100644 index 6a3f3a66..00000000 --- a/app/views/speech_balloons/_form.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -<%= form_for(speech_balloon) do |f| %> - <%= render 'system/error_explanation', :obj => speech_balloon %> - -
        - <%= f.label :caption %>
        - <%= f.number_field :caption, :id => speech_balloon.field_tag_id(:caption), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :caption, :tree => speech_balloon.field_tree(:caption) %> -
        -
        - <%= f.label :z %>
        - <%= f.number_field :z, :id => speech_balloon.field_tag_id(:z), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :z, :tree => speech_balloon.field_tree(:z) %> -
        -
        - <%= f.label :t %>
        - <%= f.number_field :t, :id => speech_balloon.field_tag_id(:t), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :t, :tree => speech_balloon.field_tree(:t) %> -
        - - <%= f.fields_for(:balloon) do |bf| %> - <%= render 'balloons/form', :f => bf, :balloon => speech_balloon.balloon %> - <% end %> - - <%= f.fields_for(:speech) do |sf| %> - <%= render 'speeches/form', :f => sf, :speech => speech_balloon.speech %> - <% end %> - - <%= f.hidden_field :panel_id, :id => speech_balloon.field_tag_id(:panel_id), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :panel_id, :tree => speech_balloon.field_tree(:panel_id) %> - <%= f.hidden_field :classname, :id => speech_balloon.field_tag_id(:classname), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :classname, :tree => speech_balloon.field_tree(:classname) %> - <%= f.hidden_field :speech_balloon_template_id, :id => speech_balloon.field_tag_id(:speech_balloon_template_id), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :speech_balloon_template_id, :tree => speech_balloon.field_tree(:speech_balloon_template_id) %> - <% unless speech_balloon.new_record? %> - <%= f.hidden_field :id, :id => speech_balloon.field_tag_id(:id), :panel_id => speech_balloon.tag_panel_id, :element_id => speech_balloon.tag_element_id, :element_type => speech_balloon.tag_element_type, :column => :id, :tree => speech_balloon.field_tree(:id) %> - <% end %> - -
        - <%= f.submit t('speech_balloons.submit'), :class => "submit" %> -
        -<% end %>