OSDN Git Service

t#31868:refact element form
authoryasushiito <yas@pen-chan.jp>
Sun, 11 Aug 2013 06:20:40 +0000 (15:20 +0900)
committeryasushiito <yas@pen-chan.jp>
Sun, 11 Aug 2013 06:20:40 +0000 (15:20 +0900)
app/models/speech_balloon.rb
app/views/ground_colors/_form.html.erb
app/views/ground_colors/_scenario.html.erb
app/views/ground_pictures/_form.html.erb
app/views/ground_pictures/_scenario.html.erb
app/views/panel_pictures/_form.html.erb
app/views/panel_pictures/_scenario.html.erb
app/views/panels/_element_tab.html.erb [new file with mode: 0644]
app/views/panels/_form.html.erb
lib/element.rb

index e19eca1..f3f9108 100644 (file)
@@ -283,6 +283,35 @@ class SpeechBalloon < ActiveRecord::Base
     @parts ||= [self.balloon, self.speech]
   end
   
+  def engine_path_name 
+    self.speech_balloon_template.engine_name + '/'
+  end
+  
+  def path_name with_engine = false
+    (with_engine ? self.engine_path_name : '') + 
+      self.class.path_name
+  end
+  
+  def form_template with_engine = false
+    self.path_name(true) + '/form'
+  end
+  
+  def speech_form_template with_engine = false
+    self.engine_path_name + 'speeches/form'
+  end
+  
+  def balloon_form_template with_engine = false
+    self.engine_path_name + 'balloons/form'
+  end
+  
+  def scenario_template with_engine = false
+    self.path_name(true) + '/scenario'
+  end
+  
+  def element_face_template with_engine = false
+    self.path_name(false) + '/element_face'
+  end
+  
   def scenario
     ERB::Util.html_escape(self.caption.to_s) + self.balloon.scenario.to_s + 
     self.speech.scenario.to_s
index b8ea0d2..de78d17 100644 (file)
@@ -1,44 +1,44 @@
-<%= form_for(ground_color) do |f| %>
-  <%= render 'system/error_explanation', :obj => ground_color %>
+<%= form_for(elm) do |f| %>
+  <%= render 'system/error_explanation', :obj => elm %>
 
   <div class="field">
     <%= f.label :caption %>
-    <%= f.text_field :caption, :id => ground_color.field_tag_id(:caption), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :caption, :no_attr => no_attr %>
+    <%= f.text_field :caption, :id => elm.field_tag_id(:caption), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :caption, :no_attr => no_attr %>
   </div>
   <div class="field">
     <%= f.label :code %>
-    <%= f.text_field :code, :size => 8, :id => ground_color.tag_id(:code), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :code, :no_attr => no_attr %>
+    <%= f.text_field :code, :size => 8, :id => elm.tag_id(:code), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :code, :no_attr => no_attr %>
     <div class="colorpicker-wrap">
-      <div class="colorpicker" style="float: left;" id="<%= ground_color.tag_id(:code_picker) -%>" panel_id="<%= ground_color.tag_panel_id -%>" element_id="<%= ground_color.tag_element_id -%>" element_type="<%= ground_color.tag_element_type -%>">
-        <div id="<%= ground_color.tag_id(:code_red) -%>" class="colorpicker-red"></div>
-        <div id="<%= ground_color.tag_id(:code_green) -%>" class="colorpicker-green"></div>
-        <div id="<%= ground_color.tag_id(:code_blue) -%>" class="colorpicker-blue"></div>
+      <div class="colorpicker" style="float: left;" id="<%= elm.tag_id(:code_picker) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
+        <div id="<%= elm.tag_id(:code_red) -%>" class="colorpicker-red"></div>
+        <div id="<%= elm.tag_id(:code_green) -%>" class="colorpicker-green"></div>
+        <div id="<%= elm.tag_id(:code_blue) -%>" class="colorpicker-blue"></div>
       </div>
       <div style="float: left;">
-        <div id="<%= ground_color.tag_id(:code_swatch) -%>" class="ui-widget-content ui-corner-all code_swatch"></div>
+        <div id="<%= elm.tag_id(:code_swatch) -%>" class="ui-widget-content ui-corner-all code_swatch"></div>
       </div>
       <div style="float: left;">
-        <div id="<%= ground_color.tag_id(:code_hex) -%>"></div>
-        <div id="<%= ground_color.tag_id(:code_rgb) -%>"></div>
+        <div id="<%= elm.tag_id(:code_hex) -%>"></div>
+        <div id="<%= elm.tag_id(:code_rgb) -%>"></div>
       </div>
       <div style="clear: both;"></div>
     </div>
   </div>
   <div class="field">
     <%= f.label :z %>
-    <%= f.number_field :z, :size => 5, :id => ground_color.field_tag_id(:z), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :z, :no_attr => no_attr %>
+    <%= f.number_field :z, :size => 5, :id => elm.field_tag_id(:z), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :z, :no_attr => no_attr %>
 
     <%= f.label :t %>
-    <%= f.number_field :t, :size => 5, :id => ground_color.field_tag_id(:t), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :t, :no_attr => no_attr %>
+    <%= f.number_field :t, :size => 5, :id => elm.field_tag_id(:t), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :t, :no_attr => no_attr %>
   </div>
 
-  <%= f.hidden_field :panel_id, :id => ground_color.field_tag_id(:panel_id), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :panel_id, :no_attr => no_attr %>
-  <% unless ground_color.new_record?  %>
-    <%= f.hidden_field :id, :id => ground_color.field_tag_id(:id), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :id, :no_attr => no_attr %>
+  <%= f.hidden_field :panel_id, :id => elm.field_tag_id(:panel_id), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :panel_id, :no_attr => no_attr %>
+  <% unless elm.new_record?  %>
+    <%= f.hidden_field :id, :id => elm.field_tag_id(:id), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :id, :no_attr => no_attr %>
   <% end %>
 
   <div class="actions">
     <%= f.submit t('ground_colors.submit'), :class => "submit" %>
   </div>
-  <div class="submit-new-form" panel_id="<%= ground_color.tag_panel_id -%>" element_type="<%= ground_color.tag_element_type -%>"></div>
+  <div class="submit-new-form" panel_id="<%= elm.tag_panel_id -%>" element_type="<%= elm.tag_element_type -%>"></div>
 <% end %>
index 5e4094d..74c1236 100644 (file)
@@ -1,3 +1,3 @@
-<div id="<%= ground_color.tag_id('scenario') -%>" class="ground_color-scenario">
-  <%= h(ground_color.caption) %>
+<div id="<%= elm.tag_id('scenario') -%>" class="ground_color-scenario">
+  <%= h(elm.caption) %>
 </div>
index 9b3fe5c..c76233f 100644 (file)
@@ -1,33 +1,33 @@
-<%= form_for(ground_picture) do |f| %>
-  <%= render 'system/error_explanation', :obj => ground_picture %>
+<%= form_for(elm) do |f| %>
+  <%= render 'system/error_explanation', :obj => elm %>
 
   <div class="field">
     <%= f.label :caption %>
-    <%= f.text_field :caption, :id => ground_picture.field_tag_id(:caption), :panel_id => ground_picture.tag_panel_id, :element_id => ground_picture.tag_element_id, :element_type => ground_picture.tag_element_type, :column => :caption %>
+    <%= f.text_field :caption, :id => elm.field_tag_id(:caption), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :caption %>
   </div>
   <div class="field">
     <%= f.label :repeat %>
-    <%= f.collection_select :repeat, t_select_items(MagicNumber['ground_picture_repeat_items']), :last, :first, {:html => {:selected => ground_picture.repeat}}, {:id => ground_picture.field_tag_id(:repeat), :panel_id => ground_picture.tag_panel_id, :element_id => ground_picture.tag_element_id, :element_type => ground_picture.tag_element_type, :column => :repeat} %>
+    <%= f.collection_select :repeat, t_select_items(MagicNumber['ground_picture_repeat_items']), :last, :first, {:html => {:selected => elm.repeat}}, {:id => elm.field_tag_id(:repeat), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :repeat} %>
   </div>
   <div class="field">
     <%= f.label :x %>
-    <%= f.number_field :x, :size => 5, :id => ground_picture.field_tag_id(:x), :panel_id => ground_picture.tag_panel_id, :element_id => ground_picture.tag_element_id, :element_type => ground_picture.tag_element_type, :column => :x %>
+    <%= f.number_field :x, :size => 5, :id => elm.field_tag_id(:x), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :x %>
 
     <%= f.label :y %>
-    <%= f.number_field :y, :size => 5, :id => ground_picture.field_tag_id(:y), :panel_id => ground_picture.tag_panel_id, :element_id => ground_picture.tag_element_id, :element_type => ground_picture.tag_element_type, :column => :y %>
+    <%= f.number_field :y, :size => 5, :id => elm.field_tag_id(:y), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :y %>
   </div>
   <div class="field">
     <%= f.label :z %>
-    <%= f.number_field :z, :size => 5, :id => ground_picture.field_tag_id(:z), :panel_id => ground_picture.tag_panel_id, :element_id => ground_picture.tag_element_id, :element_type => ground_picture.tag_element_type, :column => :z %>
+    <%= f.number_field :z, :size => 5, :id => elm.field_tag_id(:z), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :z %>
 
     <%= f.label :t %>
-    <%= f.number_field :t, :size => 5, :id => ground_picture.field_tag_id(:t), :panel_id => ground_picture.tag_panel_id, :element_id => ground_picture.tag_element_id, :element_type => ground_picture.tag_element_type, :column => :t %>
+    <%= f.number_field :t, :size => 5, :id => elm.field_tag_id(:t), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :t %>
   </div>
   
-  <%= f.hidden_field :panel_id, :id => ground_picture.field_tag_id(:panel_id), :panel_id => ground_picture.tag_panel_id, :element_id => ground_picture.tag_element_id, :element_type => ground_picture.tag_element_type, :column => :panel_id %>
-  <%= f.hidden_field :picture_id, :id => ground_picture.field_tag_id(:picture_id), :panel_id => ground_picture.tag_panel_id, :element_id => ground_picture.tag_element_id, :element_type => ground_picture.tag_element_type, :column => :picture_id %>
-  <% unless ground_picture.new_record?  %>
-    <%= f.hidden_field :id, :id => ground_picture.field_tag_id(:id), :panel_id => ground_picture.tag_panel_id, :element_id => ground_picture.tag_element_id, :element_type => ground_picture.tag_element_type, :column => :id %>
+  <%= f.hidden_field :panel_id, :id => elm.field_tag_id(:panel_id), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :panel_id %>
+  <%= f.hidden_field :picture_id, :id => elm.field_tag_id(:picture_id), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :picture_id %>
+  <% unless elm.new_record?  %>
+    <%= f.hidden_field :id, :id => elm.field_tag_id(:id), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :id %>
   <% end %>
 
   <div class="actions">
index e43f04e..26d2be7 100644 (file)
@@ -1,3 +1,3 @@
-<div id="<%= ground_picture.tag_id('scenario') -%>" class="ground_picture-scenario">
-  <%= h(ground_picture.caption) %>
+<div id="<%= elm.tag_id('scenario') -%>" class="ground_picture-scenario">
+  <%= h(elm.caption) %>
 </div>
index b94cc2f..db28c1b 100644 (file)
@@ -1,42 +1,42 @@
-<%= form_for(panel_picture) do |f| %>
-  <%= render 'system/error_explanation', :obj => panel_picture %>
+<%= form_for(elm) do |f| %>
+  <%= render 'system/error_explanation', :obj => elm %>
 
   <div class="field">
     <%= f.label :caption %>
-    <%= f.text_field :caption, :id => panel_picture.field_tag_id(:caption), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :caption, :new_index => panel_picture.new_index %>
+    <%= f.text_field :caption, :id => elm.field_tag_id(:caption), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :caption, :new_index => elm.new_index %>
   </div>
   <div class="field">
     <%= f.label :x %>
-    <%= f.number_field :x, :size => 5, :id => panel_picture.field_tag_id(:x), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :x, :new_index => panel_picture.new_index %>
+    <%= f.number_field :x, :size => 5, :id => elm.field_tag_id(:x), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :x, :new_index => elm.new_index %>
 
     <%= f.label :y %>
-    <%= f.number_field :y, :size => 5, :id => panel_picture.field_tag_id(:y), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :y, :new_index => panel_picture.new_index %>
+    <%= f.number_field :y, :size => 5, :id => elm.field_tag_id(:y), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :y, :new_index => elm.new_index %>
   </div>
   <div class="field">
     <%= f.label :z %>
-    <%= f.number_field :z, :size => 5, :id => panel_picture.field_tag_id(:z), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :z, :new_index => panel_picture.new_index %>
+    <%= f.number_field :z, :size => 5, :id => elm.field_tag_id(:z), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :z, :new_index => elm.new_index %>
 
     <%= f.label :t %>
-    <%= f.number_field :t, :size => 5, :id => panel_picture.field_tag_id(:t), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :t, :new_index => panel_picture.new_index %>
+    <%= f.number_field :t, :size => 5, :id => elm.field_tag_id(:t), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :t, :new_index => elm.new_index %>
   </div>
   <div class="field">
     <%= f.label :width %>
-    <%= f.number_field :width, :size => 5, :id => panel_picture.field_tag_id(:width), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :width, :new_index => panel_picture.new_index %>
-    <%= content_tag :span, '', :class => "panel_picture_width_tool", :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type %>
+    <%= f.number_field :width, :size => 5, :id => elm.field_tag_id(:width), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :width, :new_index => elm.new_index %>
+    <%= content_tag :span, '', :class => "panel_picture_width_tool", :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type %>
   </div>
   <div class="field">
     <%= f.label :height %>
-    <%= f.number_field :height, :size => 5, :id => panel_picture.field_tag_id(:height), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :height, :new_index => panel_picture.new_index %>
-    <%= content_tag :span, '', :class => "panel_picture_height_tool", :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type %>
+    <%= f.number_field :height, :size => 5, :id => elm.field_tag_id(:height), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :height, :new_index => elm.new_index %>
+    <%= content_tag :span, '', :class => "panel_picture_height_tool", :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type %>
   </div>
   <div class="field">
     <%= f.label :link %>
-    <%= f.text_field :link, :id => panel_picture.field_tag_id(:link), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :link, :new_index => panel_picture.new_index %>
+    <%= f.text_field :link, :id => elm.field_tag_id(:link), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :link, :new_index => elm.new_index %>
   </div>
-  <%= f.hidden_field :panel_id, :id => panel_picture.field_tag_id(:panel_id), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :panel_id, :new_index => panel_picture.new_index %>
-  <%= f.hidden_field :picture_id, :id => panel_picture.field_tag_id(:picture_id), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :picture_id, :new_index => panel_picture.new_index %>
-  <% unless panel_picture.new_record?  %>
-    <%= f.hidden_field :id, :id => panel_picture.field_tag_id(:id), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :id %>
+  <%= f.hidden_field :panel_id, :id => elm.field_tag_id(:panel_id), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :panel_id, :new_index => elm.new_index %>
+  <%= f.hidden_field :picture_id, :id => elm.field_tag_id(:picture_id), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :picture_id, :new_index => elm.new_index %>
+  <% unless elm.new_record?  %>
+    <%= f.hidden_field :id, :id => elm.field_tag_id(:id), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :id %>
   <% end %>
 
   <div class="actions">
index 912d76f..0fe65d6 100644 (file)
@@ -1,3 +1,3 @@
-<div id="<%= panel_picture.tag_id('scenario') -%>" class="panel_picture-scenario">
-  <%= h(panel_picture.caption) %>
+<div id="<%= elm.tag_id('scenario') -%>" class="panel_picture-scenario">
+  <%= h(elm.caption) %>
 </div>
diff --git a/app/views/panels/_element_tab.html.erb b/app/views/panels/_element_tab.html.erb
new file mode 100644 (file)
index 0000000..525e9e3
--- /dev/null
@@ -0,0 +1,8 @@
+<li id="<%= elm.field_tag_id(:element_tab) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
+  <a href="#elements-tabs-<%= elm.t -%>">
+    <div class="elements-tab">
+      <%= render elm.element_face_template, :elm => elm %>
+    </div>
+  </a>
+  <button class="ui-icon-destroy" id="<%= elm.field_tag_id(:_destroy_button) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>"></button>
+</li>
index bee3579..768bbd8 100644 (file)
     <div id="elements-tabs">
       <ul>
         <% @panel.panel_elements.each do |elm| %>
-          <li id="<%= elm.field_tag_id(:element_tab) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
-            <a href="#elements-tabs-<%= elm.t -%>">
-              <div class="elements-tab">
-                <%= render elm.class.to_s.tableize + '/element_face', :elm => elm %>
-              </div>
-            </a>
-            <button class="ui-icon-destroy" id="<%= elm.field_tag_id(:_destroy_button) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>"></button>
-          </li>
+          <%= render 'element_tab', :elm => elm %>
         <% end %>
       </ul>
       <% @panel.panel_elements.each do |elm| %>
         <div id="<%= elm.field_tag_id(:tab_panel) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
           <div id="elements-tabs-<%= elm.t -%>">
-            <% case elm.class.to_s %>
-            <% when 'PanelPicture' %>
-              <%= render 'panel_pictures/form', :panel_picture => elm, :no_attr => 0 %>
-            <% when 'SpeechBalloon' %>
-              <% elm.boost %>
-              <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/form', :speech_balloon => elm, :no_attr => 0 %>
-            <% when 'GroundPicture' %>
-              <%= render 'ground_pictures/form', :ground_picture => elm, :no_attr => 0 %>
-            <% when 'GroundColor' %>
-              <%= render 'ground_colors/form', :ground_color => elm, :no_attr => 0 %>
-            <% end %>
+            <%= 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 %>
           </div>
         </div>
@@ -76,7 +59,7 @@
         <% @panel.panel_elements.each do |elm| %>
           <li id="<%= elm.field_tag_id(:tsort) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
             <div class="elements-tab">
-              <%= render elm.class.to_s.tableize + '/element_face', :elm => elm %>
+              <%= render elm.path_name + '/element_face', :elm => elm %>
             </div>
           </li>
         <% end %>
     <div id="<%= @panel.tag_id -%>scenario" class="scenario" panel_id="<%= @panel.tag_panel_id -%>">
       <% @panel.panel_elements.each do |elm| %>
         <div panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>">
-          <% case elm.class.to_s %>
-          <% when 'PanelPicture' %>
-            <%= render 'panel_pictures/scenario', :panel_picture => elm %>
-          <% when 'SpeechBalloon' %>
-            <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/scenario', :speech_balloon => elm %>
-          <% when 'GroundPicture' %>
-            <%= render 'ground_pictures/scenario', :ground_picture => elm %>
-          <% when 'GroundColor' %>
-            <%= render 'ground_colors/scenario', :ground_color => elm %>
-          <% end %>
+          <%= render elm.scenario_template, :elm => elm, :no_attr => 0 %>
         </div>
       <% end %>
     </div>
                       elm.get_balloon.supply_default 
                       elm.get_speech.supply_default 
                     %>
-                    <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/form', :speech_balloon => elm, :no_attr => 1 %>
+                    <%= render elm.form_template, :elm => elm, :no_attr => 1 %>
                   </div>
                 <% end %>
             <% when 'GroundPicture' %>
             <% when 'GroundColor' %>
               <% elm = GroundColor.new :panel_id => @panel.id %>
               <% elm.supply_default %>
-              <%= render k.to_s.tableize + '/form', :ground_color => elm, :no_attr => 1 %>
+              <%= render elm.form_template, :elm => elm, :no_attr => 1 %>
             <% end %>
           </div>
         </div>
index aef0d2b..b332e00 100644 (file)
@@ -16,6 +16,11 @@ module Element
     def json_opt_for_panel
       {}
     end
+    
+    def path_name with_engine = false
+      self.to_s.tableize
+    end
+    
   end
   
   module InstanceMethods
@@ -27,6 +32,22 @@ module Element
       false
     end
     
+    def path_name with_engine = false
+      self.class.path_name(with_engine)
+    end
+    
+    def form_template with_engine = false
+      self.path_name(with_engine) + '/form'
+    end
+    
+    def scenario_template with_engine = false
+      self.path_name(with_engine) + '/scenario'
+    end
+    
+    def element_face_template with_engine = false
+      self.path_name(with_engine) + '/element_face'
+    end
+    
   end
 end