Sha256: 56b8e9f4a958b541e86a101f9a44be325980e83513b5fe945b0de2070d1f0dc5
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 KB
Contents
module Netzke # Abstract GridPanel-based editor for a JSON array of homogenious objects. # Inherit from it in order to override: # <tt>store_data</p> - passes the data to be saved (e.g. to the persistant storage) # <tt>initial_data</p> - should return initial data (e.g. from the persistant storage) # For an example of an implementation, see Netzke::FieldsConfigurator. class JsonArrayEditor < GridPanel def initialize(*args) super data_class.configure(:owner => global_id, :columns => dynamic_fields, :initial_data => initial_data) end def data_class NetzkePersistentArrayAutoModel end # Fields for NetzkePersistentArrayAutoModel (override it) def dynamic_fields default_columns.collect do |c| { :name => c[:name], :type => c[:attr_type] == :json ? :text : c[:attr_type], # store :json columns as :text :default => c[:default_value] } end end # Default predifined columns (override if needed) def default_columns [{ :name => :id, :attr_type => :integer },{ :name => :name, :attr_type => :string },{ :name => :position, :attr_type => :integer }] end # Don't show the config tool # def config_tool_needed? # false # end def before_load data_class.rebuild_table super end private # Override this def store_data(data); end # Override this def initial_data [] end # This is an override of GridPanel#on_data_changed def on_data_changed store_data(data_class.all_columns) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
netzke-basepack-0.6.3 | lib/netzke/json_array_editor.rb |
netzke-basepack-0.6.2 | lib/netzke/json_array_editor.rb |
netzke-basepack-0.6.1 | lib/netzke/json_array_editor.rb |