OSDN Git Service

t#31896:refact elm
[pettanr/pettanr.git] / app / models / ground_color.rb
index 9a4a5e3..7f1a3f0 100644 (file)
@@ -1,4 +1,6 @@
 class GroundColor < ActiveRecord::Base
+  include Element
+  include ElementInspire
   belongs_to :panel
   belongs_to :color
   
@@ -16,6 +18,37 @@ class GroundColor < ActiveRecord::Base
     end
   end
   
+  def self.colum_structures
+    @@colum_structures ||= {
+      :code => {
+        :helper => 'panels/color_helper'
+      }
+    }
+  end
+  
+  def self.list_opt_for_panel
+    {
+      :ground_colors => {
+      }
+    }
+  end
+  
+  def self.show_opt_for_panel
+    {
+      :ground_colors => {
+      }
+    }
+  end
+  
+  def self.json_opt_for_panel
+    {
+    }
+  end
+  
+  def self.has_picture?
+    false
+  end
+  
   def supply_default
     self.code ||= 0
     if self.panel
@@ -40,33 +73,16 @@ class GroundColor < ActiveRecord::Base
   
   def opt_div_style spot = nil, opacity = 20
     o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
-    "position: absolute; width:#{self.panel.width}px; height:#{self.panel.height}px; z-index:#{self.z}; background-color:##{format("%06x", self.code)}; #{o}"
+    "position: absolute; width:#{self.get_panel.width}px; height:#{self.get_panel.height}px; z-index:#{self.z}; background-color:##{format("%06x", self.code)}; #{o}"
   end
   
-  def tag_id c = nil
-    'panel' + tag_panel_id + 'ground_color' + tag_element_id + c.to_s
-  end
-  
-  def field_tag_id f
-    self.tag_id + f.to_s
-  end
-  
-  def tag_panel_id
-    self.panel.new_record? ? '0' : self.panel.id.to_s
-  end
-  
-  def tag_element_id
-    self.new_record? ? '0' : self.id.to_s
+  def boost
   end
   
   def tag_element_type
     'ground_color'
   end
   
-  def field_tree f
-    'panels-' + self.tag_panel_id + '-ground_colors_attributes-' + self.tag_element_id + '-' + f.to_s
-  end
-  
   def self.default_page_size
     25
   end
@@ -167,14 +183,6 @@ class GroundColor < ActiveRecord::Base
     self.panel.remove_element(self, au)
   end
   
-  def copy from_panel
-    r = GroundColor.new self.attributes
-    r.panel_id = from_panel.id
-    r.t = r.panel.new_t 
-    r.z = r.panel.new_z 
-    r
-  end
-  
   def scenario
     if caption.blank?
       ''