netzke-basepack 0.5.5.1 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +16 -1
- data/README.rdoc +31 -56
- data/Rakefile +2 -2
- data/TODO.rdoc +3 -0
- data/javascripts/basepack.js +70 -30
- data/lib/app/models/netzke_auto_column.rb +1 -53
- data/lib/app/models/netzke_auto_field.rb +4 -0
- data/lib/app/models/netzke_auto_table.rb +61 -0
- data/lib/netzke-basepack.rb +13 -7
- data/lib/netzke/active_record/basepack.rb +28 -0
- data/lib/netzke/active_record/data_accessor.rb +2 -0
- data/lib/netzke/basic_app.rb +3 -4
- data/lib/netzke/{basic_app_extras → basic_app}/statusbar_ext.js +0 -0
- data/lib/netzke/data_accessor.rb +2 -0
- data/lib/netzke/ext.rb +1 -1
- data/lib/netzke/fields_configurator.rb +22 -6
- data/lib/netzke/form_panel.rb +20 -11
- data/lib/netzke/form_panel/form_panel_api.rb +78 -0
- data/lib/netzke/form_panel/form_panel_js.rb +143 -0
- data/lib/netzke/{form_panel_extras → form_panel}/javascripts/netzkefileupload.js +0 -0
- data/lib/netzke/{form_panel_extras → form_panel}/javascripts/xcheckbox.js +0 -0
- data/lib/netzke/grid_panel.rb +33 -24
- data/lib/netzke/grid_panel/grid_panel_api.rb +358 -0
- data/lib/netzke/grid_panel/grid_panel_js.rb +747 -0
- data/lib/netzke/{grid_panel_extras → grid_panel}/javascripts/filters.js +0 -0
- data/lib/netzke/{grid_panel_extras → grid_panel}/javascripts/rows-dd.js +0 -0
- data/lib/netzke/grid_panel/record_form_window.rb +44 -0
- data/lib/netzke/panel.rb +1 -3
- data/lib/netzke/property_editor.rb +2 -0
- data/lib/netzke/{property_editor_extras → property_editor}/helper_model.rb +2 -2
- data/lib/netzke/search_panel.rb +3 -3
- data/lib/netzke/window.rb +9 -3
- data/test/unit/grid_panel_test.rb +0 -2
- data/test/unit/helper_model_test.rb +2 -2
- metadata +16 -15
- data/lib/netzke/field_model.rb +0 -131
- data/lib/netzke/form_panel_api.rb +0 -78
- data/lib/netzke/form_panel_js.rb +0 -141
- data/lib/netzke/grid_panel_api.rb +0 -356
- data/lib/netzke/grid_panel_extras/record_form_window.rb +0 -46
- data/lib/netzke/grid_panel_js.rb +0 -725
File without changes
|
File without changes
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Netzke
|
2
|
+
class GridPanel < Base
|
3
|
+
class RecordFormWindow < Window
|
4
|
+
def initial_config
|
5
|
+
super.deep_merge({
|
6
|
+
:ext_config => {
|
7
|
+
:modal => true,
|
8
|
+
:width => "60%",
|
9
|
+
:height => "90%",
|
10
|
+
:fbar => [:ok, :cancel]
|
11
|
+
}
|
12
|
+
})
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.js_extend_properties
|
16
|
+
{
|
17
|
+
:button_align => "right",
|
18
|
+
|
19
|
+
:init_component => <<-END_OF_JAVASCRIPT.l,
|
20
|
+
function(){
|
21
|
+
#{js_full_class_name}.superclass.initComponent.call(this);
|
22
|
+
this.getWidget().on("submitsuccess", function(){this.closeRes = "ok"; this.close();}, this);
|
23
|
+
}
|
24
|
+
END_OF_JAVASCRIPT
|
25
|
+
|
26
|
+
:on_ok => <<-END_OF_JAVASCRIPT.l,
|
27
|
+
function(){
|
28
|
+
this.getWidget().onApply();
|
29
|
+
// this.closeRes = "ok",
|
30
|
+
// this.close();
|
31
|
+
}
|
32
|
+
END_OF_JAVASCRIPT
|
33
|
+
|
34
|
+
:on_cancel => <<-END_OF_JAVASCRIPT.l,
|
35
|
+
function(){
|
36
|
+
this.close();
|
37
|
+
}
|
38
|
+
END_OF_JAVASCRIPT
|
39
|
+
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/netzke/panel.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Netzke
|
2
|
-
|
2
|
+
class PropertyEditor < FormPanel
|
3
3
|
class HelperModel
|
4
4
|
def self.widget=(w)
|
5
5
|
@@widget = w
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.widget
|
9
|
-
@@widget ||= raise RuntimeError, "No widget specified for
|
9
|
+
@@widget ||= raise RuntimeError, "No widget specified for PropertyEditor::HelperModel"
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.reflect_on_all_associations
|
data/lib/netzke/search_panel.rb
CHANGED
@@ -4,8 +4,8 @@ module Netzke
|
|
4
4
|
# FormPanel-based widget that allows create configurable searchlogic-compatible searches.
|
5
5
|
# Pretty much work in progress.
|
6
6
|
class SearchPanel < FormPanel
|
7
|
-
|
8
|
-
CONDITIONS = [:COMPARISON_CONDITIONS, :WILDCARD_CONDITIONS, :BOOLEAN_CONDITIONS].inject([]){|r, c| r + Searchlogic::NamedScopes::Conditions.const_get(c).keys}
|
7
|
+
|
8
|
+
CONDITIONS = [:COMPARISON_CONDITIONS, :WILDCARD_CONDITIONS, :BOOLEAN_CONDITIONS].inject([]){|r, c| r + Searchlogic::NamedScopes::Conditions.const_get(c).keys} # Something like [:equals, :greater_than_or_equal_to, :does_not_equal, :less_than, :less_than_or_equal_to, :greater_than, :ends_with, :like, :begins_with, :empty, :null]
|
9
9
|
|
10
10
|
def default_config
|
11
11
|
super.merge({
|
@@ -21,7 +21,7 @@ module Netzke
|
|
21
21
|
norm_column.merge!({
|
22
22
|
:condition => "equals"
|
23
23
|
})
|
24
|
-
norm_column.merge!(:hidden => true) if norm_column[:name].to_s.index("__")
|
24
|
+
norm_column.merge!(:hidden => true) if norm_column[:name].to_s.index("__") || norm_column[:xtype] == :xcheckbox
|
25
25
|
|
26
26
|
norm_column
|
27
27
|
end
|
data/lib/netzke/window.rb
CHANGED
@@ -18,13 +18,16 @@ module Netzke
|
|
18
18
|
|
19
19
|
# Set the passed item as the only aggregatee
|
20
20
|
def initial_aggregatees
|
21
|
-
|
21
|
+
res = {}
|
22
|
+
res.merge!(:item => config[:item]) if config[:item]
|
23
|
+
res
|
22
24
|
end
|
23
25
|
|
24
26
|
# Extends the JavaScript class
|
25
27
|
def self.js_extend_properties
|
26
28
|
{
|
27
29
|
:layout => "fit",
|
30
|
+
|
28
31
|
:init_component => <<-END_OF_JAVASCRIPT.l,
|
29
32
|
function(){
|
30
33
|
// Width and height may be specified as percentage of available space, e.g. "60%".
|
@@ -41,9 +44,12 @@ module Netzke
|
|
41
44
|
// Set the move and resize events after window is shown, so that they don't fire at initial rendering
|
42
45
|
this.on("show", function(){
|
43
46
|
this.on("move", this.onMove, this);
|
44
|
-
this.on("resize", this.onSelfResize, this
|
47
|
+
this.on("resize", this.onSelfResize, this); // Work around firing "resize" event twice (currently a bug in ExtJS)
|
45
48
|
}, this);
|
46
|
-
|
49
|
+
|
50
|
+
if (this.itemConfig){
|
51
|
+
this.instantiateChild(this.itemConfig);
|
52
|
+
}
|
47
53
|
}
|
48
54
|
END_OF_JAVASCRIPT
|
49
55
|
|
@@ -12,8 +12,8 @@ class HelperModelTest < ActiveSupport::TestCase
|
|
12
12
|
},
|
13
13
|
})
|
14
14
|
form = Netzke::FormPanel.new(:data_class_name => "Book")
|
15
|
-
Netzke::
|
16
|
-
helper_model = Netzke::
|
15
|
+
Netzke::PropertyEditor::HelperModel.widget = form
|
16
|
+
helper_model = Netzke::PropertyEditor::HelperModel.new
|
17
17
|
|
18
18
|
assert(true, helper_model.ext_config__config_tool)
|
19
19
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netzke-basepack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergei Kozlov
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-21 00:00:00 -03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.5.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: searchlogic
|
@@ -64,34 +64,35 @@ files:
|
|
64
64
|
- install.rb
|
65
65
|
- javascripts/basepack.js
|
66
66
|
- lib/app/models/netzke_auto_column.rb
|
67
|
+
- lib/app/models/netzke_auto_field.rb
|
68
|
+
- lib/app/models/netzke_auto_table.rb
|
67
69
|
- lib/netzke-basepack.rb
|
68
70
|
- lib/netzke/accordion_panel.rb
|
69
71
|
- lib/netzke/active_record/basepack.rb
|
70
72
|
- lib/netzke/active_record/data_accessor.rb
|
71
73
|
- lib/netzke/basic_app.rb
|
72
|
-
- lib/netzke/
|
74
|
+
- lib/netzke/basic_app/statusbar_ext.js
|
73
75
|
- lib/netzke/border_layout_panel.rb
|
74
76
|
- lib/netzke/configuration_panel.rb
|
75
77
|
- lib/netzke/data_accessor.rb
|
76
78
|
- lib/netzke/ext.rb
|
77
|
-
- lib/netzke/field_model.rb
|
78
79
|
- lib/netzke/fields_configurator.rb
|
79
80
|
- lib/netzke/form_panel.rb
|
80
|
-
- lib/netzke/form_panel_api.rb
|
81
|
-
- lib/netzke/
|
82
|
-
- lib/netzke/
|
83
|
-
- lib/netzke/
|
81
|
+
- lib/netzke/form_panel/form_panel_api.rb
|
82
|
+
- lib/netzke/form_panel/form_panel_js.rb
|
83
|
+
- lib/netzke/form_panel/javascripts/netzkefileupload.js
|
84
|
+
- lib/netzke/form_panel/javascripts/xcheckbox.js
|
84
85
|
- lib/netzke/grid_panel.rb
|
85
|
-
- lib/netzke/grid_panel_api.rb
|
86
|
-
- lib/netzke/
|
87
|
-
- lib/netzke/
|
88
|
-
- lib/netzke/
|
89
|
-
- lib/netzke/
|
86
|
+
- lib/netzke/grid_panel/grid_panel_api.rb
|
87
|
+
- lib/netzke/grid_panel/grid_panel_js.rb
|
88
|
+
- lib/netzke/grid_panel/javascripts/filters.js
|
89
|
+
- lib/netzke/grid_panel/javascripts/rows-dd.js
|
90
|
+
- lib/netzke/grid_panel/record_form_window.rb
|
90
91
|
- lib/netzke/masquerade_selector.rb
|
91
92
|
- lib/netzke/panel.rb
|
92
93
|
- lib/netzke/plugins/configuration_tool.rb
|
93
94
|
- lib/netzke/property_editor.rb
|
94
|
-
- lib/netzke/
|
95
|
+
- lib/netzke/property_editor/helper_model.rb
|
95
96
|
- lib/netzke/search_panel.rb
|
96
97
|
- lib/netzke/tab_panel.rb
|
97
98
|
- lib/netzke/table_editor.rb
|
data/lib/netzke/field_model.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
module Netzke
|
2
|
-
class FieldModel < Hash
|
3
|
-
include BasepackActiveRecord
|
4
|
-
|
5
|
-
def self.new_from_hash(hsh)
|
6
|
-
self.new.replace(hsh)
|
7
|
-
end
|
8
|
-
|
9
|
-
# def self.json=(str)
|
10
|
-
# @@data = ActiveSupport::JSON.decode(str)
|
11
|
-
# process_data
|
12
|
-
# end
|
13
|
-
|
14
|
-
def self.widget_name=(w)
|
15
|
-
@@widget_name = w
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.data_storage=(ds)
|
19
|
-
@@storage = ds
|
20
|
-
process_data
|
21
|
-
end
|
22
|
-
|
23
|
-
# def self.data=(data)
|
24
|
-
# @@raw_data = data
|
25
|
-
# process_data
|
26
|
-
# end
|
27
|
-
|
28
|
-
def self.column_names
|
29
|
-
@@data.inject([]){|res, record| (res + record.keys).uniq}
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.columns
|
33
|
-
column_names
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.all(params={})
|
37
|
-
@@data
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.first
|
41
|
-
@@data[0]
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.find(id)
|
45
|
-
@@data[id-1]
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.count(params = {})
|
49
|
-
@@data.size
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.columns_hash
|
53
|
-
@@columns_hash
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.reflect_on_all_associations
|
57
|
-
[]
|
58
|
-
end
|
59
|
-
|
60
|
-
# instance methods
|
61
|
-
def id
|
62
|
-
self[:id] || self["id"]
|
63
|
-
end
|
64
|
-
|
65
|
-
def errors
|
66
|
-
[]
|
67
|
-
end
|
68
|
-
|
69
|
-
def save
|
70
|
-
true
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
def self.process_data
|
75
|
-
@@columns_hash = {}
|
76
|
-
|
77
|
-
@@data = []
|
78
|
-
|
79
|
-
# convert array of hashes into array of FieldModel instances
|
80
|
-
@@storage.each do |hsh|
|
81
|
-
@@data << new_from_hash(hsh)
|
82
|
-
end
|
83
|
-
|
84
|
-
@@data.each do |record|
|
85
|
-
record.keys.each do |k|
|
86
|
-
|
87
|
-
if @@columns_hash[k.to_s].nil?
|
88
|
-
|
89
|
-
# calculate column type
|
90
|
-
puts record[k].class.to_s
|
91
|
-
column_type = case record[k].class.to_s
|
92
|
-
when "TrueClass"
|
93
|
-
:boolean
|
94
|
-
when "FalseClass"
|
95
|
-
:boolean
|
96
|
-
when "String"
|
97
|
-
:string
|
98
|
-
when "Fixnum"
|
99
|
-
:integer
|
100
|
-
else
|
101
|
-
:string
|
102
|
-
end
|
103
|
-
|
104
|
-
column = {:type => column_type}
|
105
|
-
|
106
|
-
# workaround for the "type" method
|
107
|
-
class << column
|
108
|
-
def type
|
109
|
-
self[:type]
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
@@columns_hash[k.to_s] = column
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# # Testing
|
120
|
-
# @@data = [
|
121
|
-
# self.new_from_hash({"id" => 1, "name" => "col1", "column_type" => "text", "read_only" => true}),
|
122
|
-
# self.new_from_hash({"id" => 2, "name" => "col2", "column_type" => "string", "read_only" => false})
|
123
|
-
# ]
|
124
|
-
#
|
125
|
-
# process_data
|
126
|
-
# end testing
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
module Netzke
|
2
|
-
module FormPanelApi
|
3
|
-
# API handling form submission
|
4
|
-
def netzke_submit(params)
|
5
|
-
success = create_or_update_record(params)
|
6
|
-
|
7
|
-
if success
|
8
|
-
{:set_form_values => array_of_values, :set_result => "ok"}
|
9
|
-
else
|
10
|
-
# flash eventual errors
|
11
|
-
@record.errors.each_full do |msg|
|
12
|
-
flash :error => msg
|
13
|
-
end
|
14
|
-
{:feedback => @flash}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# Creates/updates a record from hash
|
19
|
-
def create_or_update_record(params)
|
20
|
-
hsh = ActiveSupport::JSON.decode(params[:data])
|
21
|
-
hsh.merge!(config[:strong_default_attrs]) if config[:strong_default_attrs]
|
22
|
-
klass = config[:data_class_name].constantize
|
23
|
-
@record ||= klass.find_by_id(hsh.delete("id")) # only pick up the record specified in the params if it was not provided in the configuration
|
24
|
-
success = true
|
25
|
-
|
26
|
-
@record = klass.new if @record.nil?
|
27
|
-
|
28
|
-
hsh.each_pair do |k,v|
|
29
|
-
begin
|
30
|
-
@record.send("#{k}=",v)
|
31
|
-
rescue StandardError => exc
|
32
|
-
logger.debug "!!! FormPanelApi#create_or_update_record exception: #{exc.inspect}\n"
|
33
|
-
flash :error => exc.message
|
34
|
-
success = false
|
35
|
-
break
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# did we have complete success?
|
40
|
-
success && @record.save
|
41
|
-
end
|
42
|
-
|
43
|
-
# API handling form load
|
44
|
-
# def load(params)
|
45
|
-
# klass = config[:data_class_name].constantize
|
46
|
-
# case params[:neighbour]
|
47
|
-
# when "previous" then @record = klass.previous(params[:id])
|
48
|
-
# when "next" then @record = klass.next(params[:id])
|
49
|
-
# else @record = klass.find(params[:id])
|
50
|
-
# end
|
51
|
-
# {:data => [array_of_values]}
|
52
|
-
# end
|
53
|
-
|
54
|
-
def netzke_load(params)
|
55
|
-
@record = data_class && data_class.find_by_id(params[:id])
|
56
|
-
{:set_form_values => array_of_values}
|
57
|
-
end
|
58
|
-
|
59
|
-
# API that returns options for a combobox
|
60
|
-
def get_combobox_options(params)
|
61
|
-
column = params[:column]
|
62
|
-
query = params[:query]
|
63
|
-
|
64
|
-
{:data => config[:data_class_name].constantize.options_for(column, query).map{|s| [s]}}
|
65
|
-
end
|
66
|
-
|
67
|
-
def configuration_panel__fields__get_combobox_options(params)
|
68
|
-
query = params[:query]
|
69
|
-
{:data => (predefined_columns.map{ |c| c[:name].to_s }).grep(/^#{query}/).map{ |n| [n] }}.to_nifty_json
|
70
|
-
end
|
71
|
-
|
72
|
-
# Returns array of form values according to the configured columns
|
73
|
-
def array_of_values
|
74
|
-
@record && @record.to_array(columns, self)
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|