netzke-basepack 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +15 -10
- data/{CHANGELOG.rdoc → CHANGELOG.md} +146 -110
- data/LICENSE +7 -1
- data/README.md +47 -56
- data/Rakefile +5 -5
- data/config/before-travis.sh +10 -0
- data/javascripts/basepack.js +0 -130
- data/javascripts/netzkeremotecombo.js +59 -0
- data/lib/netzke/basepack.rb +9 -14
- data/lib/netzke/basepack/accordion.rb +45 -0
- data/lib/netzke/basepack/active_record.rb +12 -0
- data/lib/netzke/basepack/active_record/relation_extensions.rb +27 -0
- data/lib/netzke/basepack/columns.rb +309 -0
- data/lib/netzke/basepack/data_accessor.rb +22 -12
- data/lib/netzke/basepack/data_adapters/abstract_adapter.rb +75 -11
- data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +154 -49
- data/lib/netzke/basepack/fields.rb +162 -0
- data/lib/netzke/basepack/form.rb +136 -0
- data/lib/netzke/basepack/{form_panel → form}/javascripts/comma_list_cbg.js +0 -1
- data/lib/netzke/basepack/{form_panel/javascripts/form_panel.js → form/javascripts/form.js} +20 -26
- data/lib/netzke/basepack/{form_panel → form}/javascripts/n_radio_group.js +0 -1
- data/lib/netzke/basepack/{form_panel → form}/javascripts/readonly_mode.js +0 -0
- data/lib/netzke/basepack/form/services.rb +115 -0
- data/lib/netzke/basepack/{form_panel → form}/stylesheets/readonly_mode.css +0 -0
- data/lib/netzke/basepack/grid.rb +355 -0
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/advanced_search.js +1 -1
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/check_column_fix.js +0 -0
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/edit_in_form.js +3 -3
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/event_handling.js +5 -2
- data/lib/netzke/basepack/{grid_panel/javascripts/grid_panel.js → grid/javascripts/grid.js} +120 -132
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/misc.js +0 -0
- data/lib/netzke/basepack/grid/services.rb +216 -0
- data/lib/netzke/basepack/item_persistence.rb +44 -0
- data/lib/netzke/basepack/item_persistence/events_plugin.rb +47 -0
- data/lib/netzke/basepack/{paging_form_panel.rb → paging_form.rb} +24 -30
- data/lib/netzke/basepack/{paging_form_panel/javascripts/paging_form_panel.js → paging_form/javascripts/paging_form.js} +2 -4
- data/lib/netzke/basepack/query_builder.rb +44 -73
- data/lib/netzke/basepack/query_builder/javascripts/query_builder.js +16 -2
- data/lib/netzke/basepack/record_form_window.rb +67 -0
- data/lib/netzke/basepack/search_panel.rb +22 -24
- data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +2 -2
- data/lib/netzke/basepack/search_window.rb +47 -53
- data/lib/netzke/basepack/simple_app.rb +10 -13
- data/lib/netzke/basepack/simple_app/javascripts/simple_app.js +2 -8
- data/lib/netzke/basepack/tab_panel.rb +5 -4
- data/lib/netzke/basepack/tab_panel/javascripts/tab_panel.js +5 -5
- data/lib/netzke/basepack/version.rb +2 -2
- data/lib/netzke/basepack/viewport.rb +16 -0
- data/lib/netzke/basepack/window.rb +27 -18
- data/lib/netzke/basepack/window/javascripts/window.js +7 -1
- data/lib/netzke/basepack/wrap_lazy_loaded.rb +18 -18
- data/locales/en.yml +40 -24
- data/netzke-basepack.gemspec +51 -82
- data/stylesheets/basepack.css +0 -41
- data/test/basepack_test_app/Gemfile +9 -46
- data/test/basepack_test_app/Gemfile.lock +61 -96
- data/test/basepack_test_app/app/components/author_form.rb +8 -5
- data/test/basepack_test_app/app/components/author_grid.rb +2 -2
- data/test/basepack_test_app/app/components/book_form.rb +34 -31
- data/test/basepack_test_app/app/components/book_form_with_defaults.rb +6 -7
- data/test/basepack_test_app/app/components/book_form_with_file_upload.rb +10 -0
- data/test/basepack_test_app/app/components/book_form_with_nested_attributes.rb +5 -6
- data/test/basepack_test_app/app/components/book_grid.rb +19 -8
- data/test/basepack_test_app/app/components/book_grid_filtering.rb +4 -7
- data/test/basepack_test_app/app/components/book_grid_loader.rb +28 -15
- data/test/basepack_test_app/app/components/book_grid_with_custom_columns.rb +45 -21
- data/test/basepack_test_app/app/components/book_grid_with_default_values.rb +26 -8
- data/test/basepack_test_app/app/components/book_grid_with_excluded_columns.rb +11 -0
- data/test/basepack_test_app/app/components/book_grid_with_extra_feedback.rb +2 -2
- data/test/basepack_test_app/app/components/book_grid_with_extra_filters.rb +7 -6
- data/test/basepack_test_app/app/components/book_grid_with_mass_assignment_security.rb +9 -0
- data/test/basepack_test_app/app/components/book_grid_with_nested_attributes.rb +9 -9
- data/test/basepack_test_app/app/components/book_grid_with_overridden_columns.rb +5 -3
- data/test/basepack_test_app/app/components/book_grid_with_paging.rb +6 -8
- data/test/basepack_test_app/app/components/book_grid_with_persistence.rb +6 -4
- data/test/basepack_test_app/app/components/book_grid_with_scope.rb +6 -0
- data/test/basepack_test_app/app/components/book_grid_with_scoped_authors.rb +10 -7
- data/test/basepack_test_app/app/components/book_grid_with_virtual_attributes.rb +21 -13
- data/test/basepack_test_app/app/components/book_paging_form.rb +21 -0
- data/test/basepack_test_app/app/components/book_query_builder.rb +7 -6
- data/test/basepack_test_app/app/components/book_with_custom_primary_key_grid.rb +6 -7
- data/test/basepack_test_app/app/components/books_bound_to_author.rb +9 -7
- data/test/basepack_test_app/app/components/border_layout_panel_with_persistence.rb +12 -0
- data/test/basepack_test_app/app/components/double_book_grid.rb +19 -14
- data/test/basepack_test_app/app/components/form_without_model.rb +15 -16
- data/test/basepack_test_app/app/components/grid_with_initial_sorting.rb +7 -0
- data/test/basepack_test_app/app/components/grid_with_inline_data.rb +7 -0
- data/test/basepack_test_app/app/components/paging_form_with_search.rb +2 -2
- data/test/basepack_test_app/app/components/panel_with_persistent_regions.rb +35 -0
- data/test/basepack_test_app/app/components/query_builder.rb +7 -0
- data/test/basepack_test_app/app/components/simple_panel.rb +16 -11
- data/test/basepack_test_app/app/components/simple_window.rb +7 -6
- data/test/basepack_test_app/app/components/some_accordion.rb +18 -0
- data/test/basepack_test_app/app/components/some_auth_app.rb +5 -5
- data/test/basepack_test_app/app/components/some_border_layout.rb +20 -20
- data/test/basepack_test_app/app/components/some_search_panel.rb +6 -0
- data/test/basepack_test_app/app/components/some_simple_app.rb +30 -16
- data/test/basepack_test_app/app/components/some_tab_panel.rb +18 -15
- data/test/basepack_test_app/app/components/user_form.rb +18 -16
- data/test/basepack_test_app/app/components/user_form_with_default_fields.rb +5 -6
- data/test/basepack_test_app/app/components/user_grid.rb +11 -6
- data/test/basepack_test_app/app/components/user_grid_with_customized_form_fields.rb +5 -3
- data/test/basepack_test_app/app/components/window_component_loader.rb +25 -21
- data/test/basepack_test_app/app/models/address.rb +0 -26
- data/test/basepack_test_app/app/models/author.rb +0 -31
- data/test/basepack_test_app/app/models/book.rb +1 -42
- data/test/basepack_test_app/app/models/book_with_custom_primary_key.rb +1 -23
- data/test/basepack_test_app/app/models/role.rb +0 -21
- data/test/basepack_test_app/app/models/user.rb +0 -24
- data/test/basepack_test_app/app/views/layouts/components.html.erb +1 -1
- data/test/basepack_test_app/config/application.rb +1 -1
- data/test/basepack_test_app/config/database.yml.travis +2 -6
- data/test/basepack_test_app/config/initializers/netzke.rb +1 -6
- data/test/basepack_test_app/db/schema.rb +14 -14
- data/test/basepack_test_app/features/accordion_panel.feature +2 -2
- data/test/basepack_test_app/features/form_panel.feature +7 -7
- data/test/basepack_test_app/features/grid_panel.feature +93 -39
- data/test/basepack_test_app/features/grid_panel_with_custom_primary_key.feature +2 -1
- data/test/basepack_test_app/features/grid_sorting.feature +30 -6
- data/test/basepack_test_app/features/paging_form_panel.feature +7 -7
- data/test/basepack_test_app/features/persistent_regions.feature +30 -0
- data/test/basepack_test_app/features/search_in_grid.feature +5 -5
- data/test/basepack_test_app/features/simple_app.feature +6 -7
- data/test/basepack_test_app/features/step_definitions/form_panel_steps.rb +1 -1
- data/test/basepack_test_app/features/step_definitions/generic_steps.rb +109 -4
- data/test/basepack_test_app/features/step_definitions/grid_panel_steps.rb +8 -10
- data/test/basepack_test_app/features/step_definitions/window_steps.rb +27 -0
- data/test/basepack_test_app/features/tab_panel.feature +1 -1
- data/test/basepack_test_app/features/window.feature +17 -0
- data/test/unit/accordion_panel_test.rb +2 -2
- data/test/unit/grid_panel_test.rb +4 -4
- metadata +57 -83
- data/TODO.rdoc +0 -8
- data/lib/generators/netzke/basepack_generator.rb +0 -10
- data/lib/generators/netzke/templates/assets/ts-checkbox.gif +0 -0
- data/lib/generators/netzke/templates/create_netzke_field_lists.rb +0 -18
- data/lib/netzke/active_record.rb +0 -20
- data/lib/netzke/active_record/attributes.rb +0 -259
- data/lib/netzke/active_record/combobox_options.rb +0 -16
- data/lib/netzke/active_record/relation_extensions.rb +0 -37
- data/lib/netzke/basepack/accordion_panel.rb +0 -39
- data/lib/netzke/basepack/action_column.rb +0 -68
- data/lib/netzke/basepack/action_column/javascripts/action_column.js +0 -61
- data/lib/netzke/basepack/auth_app.rb +0 -159
- data/lib/netzke/basepack/basic_app.rb +0 -7
- data/lib/netzke/basepack/border_layout_panel.rb +0 -53
- data/lib/netzke/basepack/border_layout_panel/javascripts/border_layout_panel.js +0 -40
- data/lib/netzke/basepack/data_adapters/data_mapper_adapter.rb +0 -264
- data/lib/netzke/basepack/data_adapters/sequel_adapter.rb +0 -260
- data/lib/netzke/basepack/form_panel.rb +0 -144
- data/lib/netzke/basepack/form_panel/fields.rb +0 -208
- data/lib/netzke/basepack/form_panel/javascripts/misc.js +0 -4
- data/lib/netzke/basepack/form_panel/services.rb +0 -142
- data/lib/netzke/basepack/grid_panel.rb +0 -441
- data/lib/netzke/basepack/grid_panel/columns.rb +0 -400
- data/lib/netzke/basepack/grid_panel/javascripts/rows-dd.js +0 -281
- data/lib/netzke/basepack/grid_panel/record_form_window.rb +0 -41
- data/lib/netzke/basepack/grid_panel/services.rb +0 -235
- data/lib/netzke/basepack/panel.rb +0 -11
- data/lib/netzke/basepack/wrapper.rb +0 -28
- data/lib/netzke/data_mapper.rb +0 -18
- data/lib/netzke/data_mapper/attributes.rb +0 -273
- data/lib/netzke/data_mapper/combobox_options.rb +0 -11
- data/lib/netzke/data_mapper/relation_extensions.rb +0 -38
- data/lib/netzke/sequel.rb +0 -18
- data/lib/netzke/sequel/attributes.rb +0 -274
- data/lib/netzke/sequel/combobox_options.rb +0 -10
- data/lib/netzke/sequel/relation_extensions.rb +0 -40
- data/locales/zh-cn.yml +0 -79
- data/test/basepack_test_app/app/components/book_form_with_custom_fields.rb +0 -21
- data/test/basepack_test_app/app/components/book_grid_with_column_actions.rb +0 -15
- data/test/basepack_test_app/app/components/book_grid_with_defaults.rb +0 -6
- data/test/basepack_test_app/app/components/book_paging_form_panel.rb +0 -22
- data/test/basepack_test_app/app/components/generic_user_form.rb +0 -12
- data/test/basepack_test_app/app/components/simple_accordion.rb +0 -11
- data/test/basepack_test_app/app/components/simple_tab_panel.rb +0 -11
- data/test/basepack_test_app/app/components/simple_wrapper.rb +0 -7
- data/test/basepack_test_app/app/components/some_accordion_panel.rb +0 -22
- data/test/basepack_test_app/app/presenters/forms/generic_user.rb +0 -6
- data/test/basepack_test_app/app/views/components/loadable_window.html.erb +0 -9
- data/test/basepack_test_app/app/views/components/simple_panel.html.erb +0 -1
- data/test/basepack_test_app/features/components_in_view.feature +0 -11
- data/test/basepack_test_app/features/simple_panel.feature +0 -11
- data/test/basepack_test_app/features/validations_in_grid.feature +0 -13
- data/test/basepack_test_app/features/virtual_attributes.feature +0 -16
- data/test/basepack_test_app/spec/components/form_panel_spec.rb +0 -53
- data/test/basepack_test_app/spec/components/grid_panel_spec.rb +0 -10
- data/test/basepack_test_app/spec/data_adapter/adapter_spec.rb +0 -68
- data/test/basepack_test_app/spec/data_adapter/attributes_spec.rb +0 -56
- data/test/basepack_test_app/spec/data_adapter/relation_extensions_spec.rb +0 -125
- data/test/basepack_test_app/spec/factories.rb +0 -28
- data/test/basepack_test_app/spec/spec_helper.rb +0 -39
@@ -0,0 +1,44 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
# When mixed into a component with resizable layout (e.g. border layout), this module enables persistence for regions size and collapsed/expanded state.
|
4
|
+
module ItemPersistence
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
# this plugins does the job of assigning resize/collapse events for the component
|
9
|
+
plugin :events_plugin do |c|
|
10
|
+
c.klass = EventsPlugin
|
11
|
+
end
|
12
|
+
|
13
|
+
# Added endpoints
|
14
|
+
endpoint :region_resized do |params, this|
|
15
|
+
state[:"#{params[:item]}_width"] = params[:width].to_i if params[:width]
|
16
|
+
state[:"#{params[:item]}_height"] = params[:height].to_i if params[:height]
|
17
|
+
end
|
18
|
+
|
19
|
+
endpoint :region_collapsed do |params, this|
|
20
|
+
state[:"#{params[:item]}_collapsed"] = true
|
21
|
+
end
|
22
|
+
|
23
|
+
endpoint :region_expanded do |params, this|
|
24
|
+
state[:"#{params[:item]}_collapsed"] = false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def extend_item(item)
|
29
|
+
item = super
|
30
|
+
item_id = item[:netzke_component] || item[:item_id] # identify regions by item_id
|
31
|
+
|
32
|
+
if item_id
|
33
|
+
item[:width] = state[:"#{item_id}_width"] if state[:"#{item_id}_width"]
|
34
|
+
item[:height] = state[:"#{item_id}_height"] if state[:"#{item_id}_height"]
|
35
|
+
if state[:"#{item_id}_collapsed"].present?
|
36
|
+
item[:collapsed] = state[:"#{item_id}_collapsed"]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
item
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
module ItemPersistence
|
4
|
+
class EventsPlugin < Netzke::Plugin
|
5
|
+
js_configure do |c|
|
6
|
+
c.init = <<-JS
|
7
|
+
function(){
|
8
|
+
this.callParent(arguments);
|
9
|
+
|
10
|
+
this.cmp.on('afterlayout', function(){
|
11
|
+
|
12
|
+
// scope of the parent panel
|
13
|
+
this.items.each(function(item, index, length){
|
14
|
+
if (!item.oldSize) item.oldSize = item.getSize(); // remember initial size
|
15
|
+
|
16
|
+
item.on('resize', function(panel, w, h){
|
17
|
+
var params = {item: panel.itemId};
|
18
|
+
|
19
|
+
if ((panel.region == 'west' || panel.region == 'east') && panel.oldSize.width != w) {
|
20
|
+
params.width = w;
|
21
|
+
this.regionResized(params);
|
22
|
+
} else if (panel.region == 'north' || panel.region == 'south' && panel.oldSize.height != h){
|
23
|
+
params.height = h;
|
24
|
+
this.regionResized(params);
|
25
|
+
}
|
26
|
+
|
27
|
+
panel.oldSize = panel.getSize();
|
28
|
+
}, this);
|
29
|
+
|
30
|
+
item.on('collapse', function(panel){
|
31
|
+
this.regionCollapsed({item: panel.itemId});
|
32
|
+
}, this);
|
33
|
+
|
34
|
+
item.on('expand', function(panel){
|
35
|
+
this.regionExpanded({item: panel.itemId});
|
36
|
+
}, this);
|
37
|
+
|
38
|
+
}, this);
|
39
|
+
|
40
|
+
}, this.cmp, {single: true});
|
41
|
+
}
|
42
|
+
JS
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Netzke
|
2
2
|
module Basepack
|
3
|
-
# A
|
3
|
+
# A Form with paging toolbar. Allows browsing and editing records one-by-one.
|
4
4
|
#
|
5
5
|
# == Configuration
|
6
|
-
# Besides +Netzke::Basepack::
|
6
|
+
# Besides +Netzke::Basepack::Form+ config options, accepts:
|
7
7
|
# * +scope+ - specifies how the data should be filtered.
|
8
8
|
# When it's a symbol, it's used as a scope name.
|
9
9
|
# When it's a string, it's a SQL statement (passed directly to +ActiveRecord::Relation#where+).
|
@@ -18,55 +18,49 @@ module Netzke
|
|
18
18
|
#
|
19
19
|
# == ToDo
|
20
20
|
# * Update the number of records after form submit
|
21
|
-
class
|
22
|
-
|
21
|
+
class PagingForm < Form
|
22
|
+
js_configure do |c|
|
23
|
+
c.mixin
|
24
|
+
end
|
23
25
|
|
24
26
|
# override
|
25
27
|
def record
|
26
28
|
@record ||= data_adapter.first
|
27
29
|
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
})
|
31
|
+
def js_configure(c)
|
32
|
+
super
|
33
|
+
# Pass total records amount and the first record to the JS constructor
|
34
|
+
c.total_records = total_records
|
34
35
|
end
|
35
36
|
|
36
|
-
endpoint :get_data do |params|
|
37
|
+
endpoint :get_data do |params, this|
|
37
38
|
@record = data_adapter.get_records(params).first
|
38
39
|
record_hash = @record && js_record_data
|
39
|
-
|
40
|
+
this.merge!(:records => record_hash && [record_hash] || [], :total => total_records(params))
|
40
41
|
end
|
41
42
|
|
42
|
-
action :search do
|
43
|
-
|
44
|
-
|
45
|
-
:tooltip => I18n.t('netzke.basepack.paging_form_panel.actions.search_tooltip'),
|
46
|
-
:icon => :find,
|
47
|
-
:select => true
|
48
|
-
}
|
43
|
+
action :search do |a|
|
44
|
+
a.icon = :find
|
45
|
+
a.select = true
|
49
46
|
end
|
50
47
|
|
51
48
|
def configure_bbar(c)
|
52
49
|
super
|
53
|
-
c[:bbar] << :search
|
50
|
+
c[:bbar] << :search
|
54
51
|
end
|
55
52
|
|
56
|
-
component :search_form do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
:model => config[:model]
|
61
|
-
}
|
53
|
+
component :search_form do |c|
|
54
|
+
c.klass = SearchWindow
|
55
|
+
c.model = config[:model]
|
56
|
+
c.fields = fields
|
62
57
|
end
|
63
58
|
|
64
|
-
|
65
|
-
|
66
|
-
def total_records(params = {})
|
67
|
-
@total_records ||= data_adapter.count_records(params, [])
|
68
|
-
end
|
59
|
+
protected
|
69
60
|
|
61
|
+
def total_records(params = {})
|
62
|
+
@total_records ||= data_adapter.count_records(params, [])
|
63
|
+
end
|
70
64
|
end
|
71
65
|
end
|
72
66
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
if (this.searchWindow) {
|
4
4
|
this.searchWindow.show();
|
5
5
|
} else {
|
6
|
-
this.
|
6
|
+
this.netzkeLoadComponent('search_form', {callback: function(win){
|
7
7
|
this.searchWindow = win;
|
8
8
|
win.show();
|
9
9
|
|
@@ -30,15 +30,13 @@
|
|
30
30
|
},
|
31
31
|
|
32
32
|
afterRender: function() {
|
33
|
-
// delete this.record so our parent
|
33
|
+
// delete this.record so our parent Form doesn't have to load it - we do it ourselves
|
34
34
|
var record = this.record;
|
35
35
|
delete (this.record);
|
36
36
|
|
37
37
|
this.callParent();
|
38
38
|
|
39
39
|
if (record) this.store.loadRawData({records: [record], total: this.totalRecords});
|
40
|
-
|
41
|
-
new Ext.LoadMask(this, Ext.apply(this.applyMask, {store: this.store}));
|
42
40
|
},
|
43
41
|
|
44
42
|
initComponent: function() {
|
@@ -1,87 +1,60 @@
|
|
1
1
|
module Netzke
|
2
2
|
module Basepack
|
3
|
+
# Search query builder used in Grid's advanced search
|
3
4
|
class QueryBuilder < Netzke::Base
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
js_mixin :query_builder
|
5
|
+
js_configure do |c|
|
6
|
+
c.extend = "Ext.tab.Panel"
|
7
|
+
c.active_tab = 0
|
8
|
+
c.translate :overwrite_confirm, :overwrite_confirm_title, :delete_confirm, :delete_confirm_title
|
9
|
+
c.mixin
|
10
|
+
end
|
11
11
|
|
12
|
-
component :search_panel do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
}
|
12
|
+
component :search_panel do |c|
|
13
|
+
c.klass = SearchPanel
|
14
|
+
c.model = config[:model]
|
15
|
+
c.fields = config[:fields]
|
16
|
+
c.preset_query = config[:query]
|
17
|
+
c.auto_scroll = config[:auto_scroll]
|
18
|
+
c.eager_loading = true
|
20
19
|
end
|
21
20
|
|
22
|
-
action :clear_all do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
:icon => :cross
|
27
|
-
}
|
21
|
+
action :clear_all do |a|
|
22
|
+
a.text = I18n.t('netzke.basepack.query_builder.actions.clear_all')
|
23
|
+
a.tooltip = I18n.t('netzke.basepack.query_builder.actions.clear_all_tooltip')
|
24
|
+
a.icon = :cross
|
28
25
|
end
|
29
26
|
|
30
|
-
action :reset do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
:icon => :application_form
|
35
|
-
}
|
27
|
+
action :reset do |a|
|
28
|
+
a.text = I18n.t('netzke.basepack.query_builder.actions.reset')
|
29
|
+
a.tooltip = I18n.t('netzke.basepack.query_builder.actions.reset_tooltip')
|
30
|
+
a.icon = :application_form
|
36
31
|
end
|
37
32
|
|
38
|
-
action :save_preset do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
:icon => :disk
|
43
|
-
}
|
33
|
+
action :save_preset do |a|
|
34
|
+
a.text = I18n.t('netzke.basepack.query_builder.actions.save_preset')
|
35
|
+
a.tooltip = I18n.t('netzke.basepack.query_builder.actions.save_preset_tooltip')
|
36
|
+
a.icon = :disk
|
44
37
|
end
|
45
38
|
|
46
|
-
action :delete_preset do
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
:icon => :cross
|
51
|
-
}
|
39
|
+
action :delete_preset do |a|
|
40
|
+
a.text = I18n.t('netzke.basepack.query_builder.actions.delete_preset')
|
41
|
+
a.tooltip = I18n.t('netzke.basepack.query_builder.actions.delete_preset_tooltip')
|
42
|
+
a.icon = :cross
|
52
43
|
end
|
53
44
|
|
54
|
-
action :apply do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
:icon => :accept
|
59
|
-
}
|
45
|
+
action :apply do |a|
|
46
|
+
a.text = I18n.t('netzke.basepack.query_builder.actions.apply')
|
47
|
+
a.tooltip = I18n.t('netzke.basepack.query_builder.actions.apply_tooltip')
|
48
|
+
a.icon = :accept
|
60
49
|
end
|
61
50
|
|
62
|
-
def
|
63
|
-
super
|
64
|
-
|
65
|
-
|
66
|
-
{
|
67
|
-
:itemId => "presetsCombo",
|
68
|
-
:xtype => "combo",
|
69
|
-
:triggerAction => "all",
|
70
|
-
:value => super[:load_last_preset] && last_preset.try(:fetch, "name"),
|
71
|
-
:store => state[:presets].blank? ? [[[], ""]] : state[:presets].map{ |s| [s["query"], s["name"]] },
|
72
|
-
:ref => "../presetsCombo",
|
73
|
-
:listeners => {:before_select => {
|
74
|
-
:fn => "function(combo, record){
|
75
|
-
var form = Ext.getCmp('#{global_id}');
|
76
|
-
form.buildFormFromQuery(record.data.value);
|
77
|
-
}".l
|
78
|
-
}}
|
79
|
-
}, :save_preset.action, :delete_preset.action
|
80
|
-
]
|
81
|
-
end
|
51
|
+
def js_configure(c)
|
52
|
+
super
|
53
|
+
c.preset_store = state[:presets].blank? ? [[[], ""]] : state[:presets].map{ |s| [s["query"], s["name"]] }
|
54
|
+
c.bbar = (config[:bbar] || []) + [:clear_all, :reset, "->", I18n.t('netzke.basepack.query_builder.presets'), :preset_selector, :save_preset, :delete_preset ]
|
82
55
|
end
|
83
56
|
|
84
|
-
endpoint :save_preset do |params|
|
57
|
+
endpoint :save_preset do |params, this|
|
85
58
|
saved_searches = state[:presets] || []
|
86
59
|
existing = saved_searches.detect{ |s| s["name"] == params[:name] }
|
87
60
|
query = ActiveSupport::JSON.decode(params[:query])
|
@@ -90,18 +63,16 @@ module Netzke
|
|
90
63
|
else
|
91
64
|
saved_searches << {"name" => params[:name], "query" => query}
|
92
65
|
end
|
93
|
-
|
94
|
-
|
66
|
+
state[:presets] = saved_searches
|
67
|
+
this.netzke_feedback(I18n.t('netzke.basepack.query_builder.preset_saved'))
|
95
68
|
end
|
96
69
|
|
97
|
-
endpoint :delete_preset do |params|
|
70
|
+
endpoint :delete_preset do |params, this|
|
98
71
|
saved_searches = state[:presets]
|
99
72
|
saved_searches.delete_if{ |s| s["name"] == params[:name] }
|
100
|
-
|
101
|
-
|
73
|
+
state[:presets] = saved_searches
|
74
|
+
this.netzke_feedback(I18n.t('netzke.basepack.query_builder.preset_deleted'))
|
102
75
|
end
|
103
|
-
|
104
|
-
|
105
76
|
end
|
106
77
|
end
|
107
78
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
initComponent: function() {
|
3
3
|
this.callParent();
|
4
4
|
|
5
|
-
this.presetsCombo = this.
|
5
|
+
this.presetsCombo = this.down("combo[itemId='presets-combo']");
|
6
6
|
|
7
7
|
this.add({title: "+"});
|
8
8
|
|
@@ -38,7 +38,7 @@
|
|
38
38
|
addTab: function(activate, closable){
|
39
39
|
var newTabConfig = Ext.apply({}, this.netzkeComponents.searchPanel);
|
40
40
|
newTabConfig.id = Ext.id(); // We need a unique ID every time
|
41
|
-
newTabConfig.
|
41
|
+
newTabConfig.header = false;
|
42
42
|
newTabConfig.border = false;
|
43
43
|
|
44
44
|
var newTab = this.insert(
|
@@ -149,5 +149,19 @@
|
|
149
149
|
var presetsComboStore = this.presetsCombo.getStore();
|
150
150
|
presetsComboStore.removeAt(presetsComboStore.find('text', name));
|
151
151
|
this.presetsCombo.reset();
|
152
|
+
},
|
153
|
+
|
154
|
+
presetSelectorConfig: function(config) {
|
155
|
+
return {
|
156
|
+
itemId: 'presets-combo',
|
157
|
+
xtype: "combo",
|
158
|
+
triggerAction: "all",
|
159
|
+
store: config.presetStore,
|
160
|
+
listeners: {
|
161
|
+
beforeselect: function(self, record) {
|
162
|
+
this.netzkeParent.buildFormFromQuery(record.get('field1'));
|
163
|
+
}
|
164
|
+
},
|
165
|
+
}
|
152
166
|
}
|
153
167
|
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Netzke
|
2
|
+
module Basepack
|
3
|
+
class RecordFormWindow < Netzke::Basepack::Window
|
4
|
+
|
5
|
+
component :add_form do |c|
|
6
|
+
preconfigure_form(c)
|
7
|
+
end
|
8
|
+
|
9
|
+
component :edit_form do |c|
|
10
|
+
preconfigure_form(c)
|
11
|
+
end
|
12
|
+
|
13
|
+
component :multi_edit_form do |c|
|
14
|
+
preconfigure_form(c)
|
15
|
+
c.multi_edit = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def configure(c)
|
19
|
+
super
|
20
|
+
c.fbar = [:ok, :cancel]
|
21
|
+
end
|
22
|
+
|
23
|
+
js_configure do |c|
|
24
|
+
c.button_align = :right
|
25
|
+
c.width = 400
|
26
|
+
c.auto_height = true
|
27
|
+
c.modal = true
|
28
|
+
c.init_component = <<-JS
|
29
|
+
function(params){
|
30
|
+
this.callParent();
|
31
|
+
this.items.first().on("submitsuccess", function(){ this.closeRes = "ok"; this.close(); }, this);
|
32
|
+
}
|
33
|
+
JS
|
34
|
+
|
35
|
+
c.on_ok = <<-JS
|
36
|
+
function(params){
|
37
|
+
this.items.first().onApply();
|
38
|
+
}
|
39
|
+
JS
|
40
|
+
|
41
|
+
c.on_cancel = <<-JS
|
42
|
+
function(params){
|
43
|
+
this.close();
|
44
|
+
}
|
45
|
+
JS
|
46
|
+
end
|
47
|
+
|
48
|
+
action :ok
|
49
|
+
|
50
|
+
action :cancel
|
51
|
+
|
52
|
+
protected
|
53
|
+
|
54
|
+
def self.server_side_config_options
|
55
|
+
[:form_config, *super]
|
56
|
+
end
|
57
|
+
|
58
|
+
def preconfigure_form(c)
|
59
|
+
c.klass = Form
|
60
|
+
c.border = true
|
61
|
+
c.bbar = false
|
62
|
+
c.prevent_header = true
|
63
|
+
c.merge! config.form_config
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|