netzke-basepack 0.6.0 → 0.6.1
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 +14 -6
- data/README.rdoc +16 -31
- data/Rakefile +22 -16
- data/TODO.rdoc +1 -1
- data/app/models/netzke_field_list.rb +29 -29
- data/app/models/netzke_model_attr_list.rb +4 -4
- data/app/models/netzke_persistent_array_auto_model.rb +9 -9
- data/config/database.yml +2 -35
- data/features/accordion_panel.feature +1 -1
- data/features/form_panel.feature +2 -2
- data/features/grid_panel.feature +15 -3
- data/features/search_in_grid.feature +4 -4
- data/features/simple_panel.feature +4 -4
- data/features/step_definitions/pickle_steps.rb +2 -2
- data/features/step_definitions/web_steps.rb +5 -5
- data/features/support/env.rb +6 -6
- data/features/tab_panel.feature +1 -1
- data/javascripts/basepack.js +28 -28
- data/lib/netzke-basepack.rb +5 -5
- data/lib/netzke/active_record.rb +1 -1
- data/lib/netzke/active_record/association_attributes.rb +9 -9
- data/lib/netzke/active_record/attributes.rb +24 -23
- data/lib/netzke/active_record/combobox_options.rb +3 -3
- data/lib/netzke/active_record/relation_extensions.rb +4 -4
- data/lib/netzke/basepack.rb +4 -4
- data/{app/components → lib}/netzke/basepack/accordion_panel.rb +7 -7
- data/{app/components → lib}/netzke/basepack/basic_app.rb +18 -18
- data/{app/components → lib}/netzke/basepack/basic_app/statusbar_ext.js +0 -0
- data/lib/netzke/basepack/border_layout_panel.rb +101 -0
- data/{app/components → lib}/netzke/basepack/form_panel.rb +21 -21
- data/{app/components → lib}/netzke/basepack/form_panel/fields.rb +29 -36
- data/{app/components → lib}/netzke/basepack/form_panel/javascripts/netzkefileupload.js +0 -0
- data/{app/components → lib}/netzke/basepack/form_panel/javascripts/pre.js +9 -9
- data/{app/components → lib}/netzke/basepack/form_panel/javascripts/xcheckbox.js +1 -1
- data/{app/components → lib}/netzke/basepack/form_panel/services.rb +11 -11
- data/{app/components → lib}/netzke/basepack/grid_panel.rb +74 -92
- data/{app/components → lib}/netzke/basepack/grid_panel/columns.rb +34 -36
- data/{app/components → lib}/netzke/basepack/grid_panel/javascript.rb +7 -7
- data/{app/components → lib}/netzke/basepack/grid_panel/javascripts/advanced_search.js +10 -10
- data/{app/components → lib}/netzke/basepack/grid_panel/javascripts/edit_in_form.js +2 -2
- data/{app/components → lib}/netzke/basepack/grid_panel/javascripts/pre.js +31 -31
- data/{app/components → lib}/netzke/basepack/grid_panel/javascripts/rows-dd.js +1 -1
- data/{app/components → lib}/netzke/basepack/grid_panel/multi_edit_form.rb +2 -2
- data/{app/components → lib}/netzke/basepack/grid_panel/record_form_window.rb +3 -3
- data/{app/components → lib}/netzke/basepack/grid_panel/search_window.rb +11 -11
- data/{app/components → lib}/netzke/basepack/grid_panel/services.rb +28 -28
- data/{app/components → lib}/netzke/basepack/panel.rb +0 -0
- data/{app/components → lib}/netzke/basepack/search_panel.rb +11 -11
- data/{app/components → lib}/netzke/basepack/tab_panel.rb +7 -7
- data/lib/netzke/basepack/version.rb +1 -1
- data/{app/components → lib}/netzke/basepack/window.rb +14 -14
- data/{app/components → lib}/netzke/basepack/wrapper.rb +6 -6
- data/lib/netzke/data_accessor.rb +18 -18
- data/lib/netzke/fields_configurator.rb +30 -30
- data/lib/netzke/json_array_editor.rb +9 -9
- data/lib/netzke/masquerade_selector.rb +5 -5
- data/locale/en.yml +1 -1
- data/netzke-basepack.gemspec +252 -240
- data/spec/active_record/attributes_spec.rb +6 -1
- data/spec/active_record/relation_extensions_spec.rb +11 -11
- data/spec/components/form_panel_spec.rb +13 -19
- data/spec/components/grid_panel_spec.rb +1 -1
- data/test/rails_app/Gemfile +4 -3
- data/test/rails_app/Gemfile.lock +42 -50
- data/test/rails_app/app/components/book_grid.rb +4 -0
- data/test/rails_app/app/components/generic_user_form.rb +2 -2
- data/test/rails_app/app/components/simple_basic_app.rb +3 -3
- data/test/rails_app/app/components/simple_panel.rb +1 -1
- data/test/rails_app/app/components/some_border_layout.rb +12 -11
- data/test/rails_app/app/components/some_search_panel.rb +5 -5
- data/test/rails_app/app/components/user_form.rb +1 -1
- data/test/rails_app/app/components/window_component_loader.rb +2 -2
- data/test/rails_app/app/models/author.rb +7 -0
- data/test/rails_app/app/models/book.rb +3 -0
- data/test/rails_app/app/models/user.rb +1 -1
- data/test/rails_app/config/locales/es.yml +0 -1
- data/test/rails_app/config/routes.rb +2 -2
- data/test/rails_app/db/development_structure.sql +28 -3
- data/test/rails_app/db/migrate/20101026185816_create_authors.rb +14 -0
- data/test/rails_app/db/migrate/20101026190021_create_books.rb +17 -0
- data/test/rails_app/db/schema.rb +18 -1
- data/test/rails_app/public/javascripts/effects.js +1 -1
- data/test/rails_app/spec/models/author_spec.rb +5 -0
- data/test/rails_app/spec/models/book_spec.rb +5 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/accordion_panel_test.rb +2 -2
- data/test/unit/active_record_basepack_test.rb +9 -9
- data/test/unit/fields_configuration_test.rb +4 -4
- data/test/unit/grid_panel_test.rb +8 -8
- data/test/unit/tab_panel_test.rb +2 -2
- metadata +49 -36
- data/.gitignore +0 -10
- data/app/components/netzke/basepack/border_layout_panel.rb +0 -39
|
@@ -2,14 +2,14 @@ module Netzke
|
|
|
2
2
|
module Basepack
|
|
3
3
|
class GridPanel < Netzke::Base
|
|
4
4
|
class MultiEditForm < FormPanel
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
# Replace checkbox for boolean fields with tristate checkbox
|
|
7
7
|
def attr_type_to_xtype_map
|
|
8
8
|
super.merge({
|
|
9
9
|
:boolean => :tricheckbox
|
|
10
10
|
})
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -3,12 +3,12 @@ module Netzke
|
|
|
3
3
|
class GridPanel < Netzke::Base
|
|
4
4
|
class RecordFormWindow < Window
|
|
5
5
|
js_properties :button_align => "right"
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
config :modal => true,
|
|
8
8
|
:width => "50%",
|
|
9
9
|
:auto_height => true,
|
|
10
10
|
:fbar => [:ok.action, :cancel.action]
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
action :ok, :text => 'OK'
|
|
13
13
|
action :cancel
|
|
14
14
|
|
|
@@ -24,7 +24,7 @@ module Netzke
|
|
|
24
24
|
this.getNetzkeComponent().onApply();
|
|
25
25
|
}
|
|
26
26
|
JS
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
js_method :on_cancel, <<-JS
|
|
29
29
|
function(params){
|
|
30
30
|
this.close();
|
|
@@ -6,18 +6,18 @@ module Netzke
|
|
|
6
6
|
action :search
|
|
7
7
|
action :cancel
|
|
8
8
|
action :clear, :icon => :application_form
|
|
9
|
-
|
|
10
|
-
js_properties :title => "Advanced Search",
|
|
9
|
+
|
|
10
|
+
js_properties :title => "Advanced Search",
|
|
11
11
|
:width => "50%",
|
|
12
12
|
:auto_height => true,
|
|
13
13
|
:buttons => [:search.action, :cancel.action],
|
|
14
14
|
:tbar => [:clear.action]
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
config :items => [js_component(:search_panel)]
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
component :search_panel do
|
|
19
19
|
{
|
|
20
|
-
:class_name => "Basepack::SearchPanel",
|
|
20
|
+
:class_name => "Basepack::SearchPanel",
|
|
21
21
|
:model => config[:model],
|
|
22
22
|
:items => config[:fields]
|
|
23
23
|
}
|
|
@@ -32,24 +32,24 @@ module Netzke
|
|
|
32
32
|
js_method :on_search, <<-JS
|
|
33
33
|
function(){
|
|
34
34
|
this.conditions = this.items.first().getForm().getValues();
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
// do not send values of empty values
|
|
37
37
|
for (var cond in this.conditions) {
|
|
38
38
|
if (this.conditions[cond] == "") delete this.conditions[cond];
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
this.closeRes = 'OK';
|
|
40
|
+
|
|
41
|
+
this.closeRes = 'OK';
|
|
42
42
|
this.close();
|
|
43
43
|
}
|
|
44
44
|
JS
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
js_method :on_cancel, <<-JS
|
|
47
47
|
function(){
|
|
48
|
-
this.closeRes = 'cancel';
|
|
48
|
+
this.closeRes = 'cancel';
|
|
49
49
|
this.close();
|
|
50
50
|
}
|
|
51
51
|
JS
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
end
|
|
@@ -7,9 +7,9 @@ module Netzke
|
|
|
7
7
|
class GridPanel < Netzke::Base
|
|
8
8
|
module Services
|
|
9
9
|
extend ActiveSupport::Concern
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
included do
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
endpoint :get_data do |*args|
|
|
14
14
|
params = args.first || {} # params are optional
|
|
15
15
|
if !config[:prohibit_read]
|
|
@@ -30,9 +30,9 @@ module Netzke
|
|
|
30
30
|
mod_records[operation] = nil if mod_records[operation].empty?
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
on_data_changed
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
{
|
|
37
37
|
:update_new_records => mod_records[:create],
|
|
38
38
|
:update_mod_records => mod_records[:update] || {},
|
|
@@ -103,16 +103,16 @@ module Netzke
|
|
|
103
103
|
end
|
|
104
104
|
{}
|
|
105
105
|
end
|
|
106
|
-
|
|
106
|
+
|
|
107
107
|
end
|
|
108
108
|
#
|
|
109
109
|
# Some components' overridden API
|
|
110
110
|
#
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
## Edit in form specific API
|
|
113
113
|
def add_form__form_panel0__netzke_submit(params)
|
|
114
114
|
res = component_instance(:add_form__form_panel0).netzke_submit(params)
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
if res[:set_form_values]
|
|
117
117
|
# successful creation
|
|
118
118
|
on_data_changed
|
|
@@ -128,21 +128,21 @@ module Netzke
|
|
|
128
128
|
on_data_changed
|
|
129
129
|
res[:set_form_values] = nil
|
|
130
130
|
end
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
res.to_nifty_json
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
def multi_edit_form__multi_edit_form0__netzke_submit(params)
|
|
136
136
|
ids = ActiveSupport::JSON.decode(params.delete(:ids))
|
|
137
137
|
data = ids.collect{ |id| ActiveSupport::JSON.decode(params[:data]).merge("id" => id) }
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
data.map!{|el| el.delete_if{ |k,v| v.blank? }} # only interested in set values
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
mod_records_count = process_data(data, :update).count
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
# remove duplicated flash messages
|
|
144
144
|
@flash = @flash.inject([]){ |r,hsh| r.include?(hsh) ? r : r.push(hsh) }
|
|
145
|
-
|
|
145
|
+
|
|
146
146
|
if mod_records_count > 0
|
|
147
147
|
on_data_changed
|
|
148
148
|
flash :notice => "Updated #{mod_records_count} records."
|
|
@@ -151,17 +151,17 @@ module Netzke
|
|
|
151
151
|
{:feedback => @flash}.to_nifty_json
|
|
152
152
|
end
|
|
153
153
|
end
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
# When providing the edit_form component, fill in the form with the requested record
|
|
156
156
|
def deliver_component(params)
|
|
157
157
|
components[:edit_form][:items].first.merge!(:record_id => params[:record_id].to_i) if params[:name] == 'edit_form'
|
|
158
158
|
super
|
|
159
159
|
end
|
|
160
|
-
|
|
160
|
+
|
|
161
161
|
protected
|
|
162
|
-
|
|
162
|
+
|
|
163
163
|
def get_records(params)
|
|
164
|
-
|
|
164
|
+
|
|
165
165
|
# Restore params from component_session if requested
|
|
166
166
|
if params[:with_last_params]
|
|
167
167
|
params = component_session[:last_params]
|
|
@@ -169,10 +169,10 @@ module Netzke
|
|
|
169
169
|
# remember the last params
|
|
170
170
|
component_session[:last_params] = params
|
|
171
171
|
end
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
# build initial relation based on passed params
|
|
174
174
|
relation = get_relation(params)
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
# addressing the n+1 query problem
|
|
177
177
|
columns.each do |c|
|
|
178
178
|
assoc, method = c[:name].split('__')
|
|
@@ -207,27 +207,27 @@ module Netzke
|
|
|
207
207
|
relation.all
|
|
208
208
|
end
|
|
209
209
|
end
|
|
210
|
-
|
|
210
|
+
|
|
211
211
|
# An ActiveRecord::Relation instance encapsulating all the necessary conditions
|
|
212
212
|
def get_relation(params)
|
|
213
213
|
# make params coming from Ext grid filters understandable by meta_where
|
|
214
214
|
conditions = params[:filter] && convert_filters(params[:filter]) || {}
|
|
215
|
-
|
|
215
|
+
|
|
216
216
|
relation = data_class.where(conditions)
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
if params[:extra_conditions]
|
|
219
219
|
extra_conditions = normalize_extra_conditions(ActiveSupport::JSON.decode(params[:extra_conditions]))
|
|
220
220
|
relation = relation.extend_with_netzke_conditions(extra_conditions) if params[:extra_conditions]
|
|
221
221
|
end
|
|
222
|
-
|
|
222
|
+
|
|
223
223
|
relation = relation.extend_with(config[:scope]) if config[:scope]
|
|
224
|
-
|
|
224
|
+
|
|
225
225
|
relation
|
|
226
226
|
end
|
|
227
|
-
|
|
227
|
+
|
|
228
228
|
# Override this method to react on each operation that caused changing of data
|
|
229
229
|
def on_data_changed; end
|
|
230
|
-
|
|
230
|
+
|
|
231
231
|
# Given an index of a column among enabled (non-excluded) columns, provides the index (position) in the table
|
|
232
232
|
def normalize_index(index)
|
|
233
233
|
norm_index = 0
|
|
@@ -266,7 +266,7 @@ module Netzke
|
|
|
266
266
|
break
|
|
267
267
|
end
|
|
268
268
|
end
|
|
269
|
-
|
|
269
|
+
|
|
270
270
|
# try to save
|
|
271
271
|
# modified_records += 1 if success && record.save
|
|
272
272
|
mod_records[id] = record.to_array(columns) if success && record.save
|
|
@@ -314,10 +314,10 @@ module Netzke
|
|
|
314
314
|
if method
|
|
315
315
|
assoc = data_class.reflect_on_association(assoc.to_sym)
|
|
316
316
|
field = [assoc.klass.table_name, method].join('.').to_sym
|
|
317
|
-
else
|
|
317
|
+
else
|
|
318
318
|
field = assoc.to_sym
|
|
319
319
|
end
|
|
320
|
-
|
|
320
|
+
|
|
321
321
|
value = v["data"]["value"]
|
|
322
322
|
case v["data"]["type"]
|
|
323
323
|
when "string"
|
|
File without changes
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
module Netzke
|
|
2
2
|
module Basepack
|
|
3
3
|
class SearchPanel < FormPanel
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
js_properties :header => false,
|
|
6
6
|
:bbar => false
|
|
7
7
|
|
|
8
8
|
# An override
|
|
9
9
|
def normalize_field(f)
|
|
10
|
-
f = if f.is_a?(Symbol) || f.is_a?(String)
|
|
10
|
+
f = if f.is_a?(Symbol) || f.is_a?(String)
|
|
11
11
|
{:name => f.to_s, :operator => default_operator}
|
|
12
|
-
else
|
|
12
|
+
else
|
|
13
13
|
search_condition = f[:name]
|
|
14
14
|
if search_condition.is_a?(MetaWhere::Column)
|
|
15
15
|
{:name => search_condition.column, :operator => search_condition.method}
|
|
@@ -17,17 +17,17 @@ module Netzke
|
|
|
17
17
|
{:name => search_condition.to_s}
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
f = super(f)
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
f[:disabled] = primary_key_attr?(f)
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
# Association field
|
|
26
26
|
if f[:name].to_s.index("__")
|
|
27
27
|
f[:xtype] ||= xtype_for_attr_type(:string)
|
|
28
28
|
f[:attr_type] = :string
|
|
29
29
|
end
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
f[:operator] ||= "gt" if [:datetime, :integer, :date].include?(f[:attr_type])
|
|
32
32
|
f[:operator] ||= "eq" if f[:attr_type] == :boolean
|
|
33
33
|
f[:operator] ||= default_operator
|
|
@@ -35,25 +35,25 @@ module Netzke
|
|
|
35
35
|
f[:field_label] = [f[:field_label], f[:operator]].join(" ")
|
|
36
36
|
f.merge(:name => [f[:name], f[:operator]].join("__"))
|
|
37
37
|
end
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
private
|
|
40
40
|
def default_operator
|
|
41
41
|
"like"
|
|
42
42
|
end
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
# we need to correct the queries to cut off the condition suffixes, otherwise the FormPanel gets confused
|
|
45
45
|
def get_combobox_options(params)
|
|
46
46
|
column_name = params[:column]
|
|
47
47
|
CONDITIONS.each { |c| column_name.sub!(/_#{c}$/, "") }
|
|
48
48
|
super(:column => column_name)
|
|
49
49
|
end
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
def attr_type_to_xtype_map
|
|
52
52
|
super.merge({
|
|
53
53
|
:boolean => :tricheckbox
|
|
54
54
|
})
|
|
55
55
|
end
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
module Netzke
|
|
2
2
|
module Basepack
|
|
3
3
|
# = TabPanel
|
|
4
|
-
#
|
|
4
|
+
#
|
|
5
5
|
# Features:
|
|
6
6
|
# * Dynamically loads components for the tabs that get activated for the first time
|
|
7
7
|
# * Is loaded along with the active component - saves a request to the server
|
|
8
8
|
# * (TODO) Provides the method markTabsOutdated to mark all inactive tabs as 'outdated', and calls "update" method on components in tabs when they get activated
|
|
9
9
|
# * (TODO) Stores the last active tab in persistent_config
|
|
10
|
-
#
|
|
10
|
+
#
|
|
11
11
|
# ToDo:
|
|
12
12
|
# * Introduce a second or two delay before informing the server about a tab switched
|
|
13
13
|
class TabPanel < Netzke::Base
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
include WrapLazyLoaded
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
js_base_class "Ext.TabPanel"
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
js_method :init_component, <<-JS
|
|
20
20
|
function(params){
|
|
21
21
|
#{js_full_class_name}.superclass.initComponent.call(this);
|
|
22
22
|
this.on('tabchange', function(self, i){
|
|
23
|
-
if (i.wrappedComponent && !i.items.first()) {
|
|
23
|
+
if (i && i.wrappedComponent && !i.items.first()) {
|
|
24
24
|
this.loadComponent({name: i.wrappedComponent, container: i.id});
|
|
25
25
|
}
|
|
26
26
|
}, this);
|
|
27
27
|
}
|
|
28
28
|
JS
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -2,34 +2,34 @@ module Netzke
|
|
|
2
2
|
module Basepack
|
|
3
3
|
# == Window
|
|
4
4
|
# Ext.Window-based component able to nest other Netzke components
|
|
5
|
-
#
|
|
5
|
+
#
|
|
6
6
|
# == Features
|
|
7
7
|
# * Persistent position and dimensions
|
|
8
|
-
#
|
|
8
|
+
#
|
|
9
9
|
# == Instance configuration
|
|
10
10
|
# <tt>:item</tt> - nested Netzke component, e.g.:
|
|
11
|
-
#
|
|
11
|
+
#
|
|
12
12
|
# netzke :window, :item => {:class_name => "GridPanel", :model => "User"}
|
|
13
13
|
class Window < Netzke::Base
|
|
14
14
|
# Based on Ext.Window, naturally
|
|
15
15
|
def self.js_base_class
|
|
16
16
|
"Ext.Window"
|
|
17
17
|
end
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
js_properties(
|
|
20
20
|
# we nest component inside the "fit" layout
|
|
21
21
|
:layout => "fit"
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
# default width and height
|
|
24
|
-
# :width => 300,
|
|
24
|
+
# :width => 300,
|
|
25
25
|
# :height => 200
|
|
26
26
|
)
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
js_method :init_component, <<-END_OF_JAVASCRIPT
|
|
29
29
|
function(){
|
|
30
30
|
// superclass' initComponent
|
|
31
31
|
#{js_full_class_name}.superclass.initComponent.call(this);
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
// set the move and resize events after window is shown, so that they don't fire at initial rendering
|
|
34
34
|
this.on("show", function(){
|
|
35
35
|
this.on("move", this.onMoveResize, this);
|
|
@@ -42,7 +42,7 @@ module Netzke
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
END_OF_JAVASCRIPT
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
js_method :on_move_resize, <<-END_OF_JAVASCRIPT
|
|
47
47
|
function(){
|
|
48
48
|
var x = this.getPosition()[0], y = this.getPosition()[1], w = this.getSize().width, h = this.getSize().height;
|
|
@@ -50,20 +50,20 @@ module Netzke
|
|
|
50
50
|
// Don't bother the server twice when both move and resize events are fired at the same time
|
|
51
51
|
// (which happens when the left or upper window border is dragged)
|
|
52
52
|
if (this.moveResizeTimer) {clearTimeout(this.moveResizeTimer)};
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
this.moveResizeTimer = (function(sizeAndPosition){
|
|
55
55
|
this.setSizeAndPosition(sizeAndPosition); // API call
|
|
56
56
|
}).defer(10, this, [{x:x, y:y, w:w, h:h}]); // 10ms should be enough
|
|
57
57
|
}
|
|
58
58
|
END_OF_JAVASCRIPT
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
# Processing API calls from client
|
|
61
61
|
endpoint :set_size_and_position do |params|
|
|
62
62
|
Rails.logger.debug "!!! IMPLEMENT ME (set_size_and_position)\n"
|
|
63
63
|
# update_persistent_ext_config(
|
|
64
|
-
# :x => params[:x].to_i,
|
|
65
|
-
# :y => params[:y].to_i,
|
|
66
|
-
# :width => params[:w].to_i,
|
|
64
|
+
# :x => params[:x].to_i,
|
|
65
|
+
# :y => params[:y].to_i,
|
|
66
|
+
# :width => params[:w].to_i,
|
|
67
67
|
# :height => params[:h].to_i
|
|
68
68
|
# )
|
|
69
69
|
{}
|