Parent

Netzke::JsonArrayEditor

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.

Public Class Methods

new(*args) click to toggle source
    # File lib/netzke/json_array_editor.rb, line 8
 8:     def initialize(*args)
 9:       super
10:       data_class.configure(:owner => global_id, :columns => dynamic_fields, :initial_data => initial_data)
11:     end

Public Instance Methods

before_load() click to toggle source

Don’t show the config tool def config_tool_needed?

  false

end

    # File lib/netzke/json_array_editor.rb, line 47
47:     def before_load
48:       data_class.rebuild_table
49:       super
50:     end
data_class() click to toggle source
    # File lib/netzke/json_array_editor.rb, line 13
13:     def data_class
14:       NetzkePersistentArrayAutoModel
15:     end
default_columns() click to toggle source

Default predifined columns (override if needed)

    # File lib/netzke/json_array_editor.rb, line 29
29:     def default_columns
30:       [{
31:         :name => :id,
32:         :attr_type => :integer
33:       },{
34:         :name => :name,
35:         :attr_type => :string
36:       },{
37:         :name => :position,
38:         :attr_type => :integer
39:       }]
40:     end
dynamic_fields() click to toggle source

Fields for NetzkePersistentArrayAutoModel (override it)

    # File lib/netzke/json_array_editor.rb, line 18
18:     def dynamic_fields
19:       default_columns.collect do |c|
20:         {
21:           :name => c[:name],
22:           :type => c[:attr_type] == :json ? :text : c[:attr_type], # store :json columns as :text
23:           :default => c[:default_value]
24:         }
25:       end
26:     end

Private Instance Methods

initial_data() click to toggle source

Override this

    # File lib/netzke/json_array_editor.rb, line 57
57:       def initial_data
58:         []
59:       end
on_data_changed() click to toggle source

This is an override of GridPanel#on_data_changed

    # File lib/netzke/json_array_editor.rb, line 62
62:       def on_data_changed
63:         store_data(data_class.all_columns)
64:       end
store_data(data) click to toggle source

Override this

    # File lib/netzke/json_array_editor.rb, line 54
54:       def store_data(data); end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.