OSDN Git Service

t#31896:refact elm
[pettanr/pettanr.git] / lib / element.rb
index 4f7a4ec..dc9b2c6 100644 (file)
@@ -5,6 +5,10 @@ module Element
   end
   
   module ClassMethods
+    def colum_structures
+      raise
+    end
+    
     def list_opt_for_panel
       {}
     end
@@ -40,6 +44,10 @@ module Element
       @parts ||= []
     end
     
+    def has_helper? column_name
+      self.class.colum_structures[column_name] and self.class.colum_structures[column_name][:helper]
+    end
+    
     def new_index
       @new_index
     end
@@ -100,6 +108,10 @@ module Element
       self.path_name(with_engine) + '/element_face'
     end
     
+    def form_helper_template(colum_name)
+      self.class.colum_structures[colum_name][:helper]
+    end
+    
     def tag_attributes column = nil, opt = {}
       {
         :id => self.field_tag_id(column), :panel_id => self.tag_panel_id, 
@@ -122,6 +134,14 @@ module Element
       r.merge(opt)
     end
     
+    def select_tag_attributes(selected, column, no_attr)
+      [
+        :last, :first, 
+        {:html => {:selected => selected}}, 
+        self.field_tag_attributes(column, no_attr)
+      ]
+    end
+    
     def tag_attr column = nil, opt = {}
       self.tag_attributes(column, opt).to_attr
     end