netzke-basepack-zh 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (268) hide show
  1. data/.autotest +1 -0
  2. data/.travis.yml +11 -0
  3. data/CHANGELOG.rdoc +445 -0
  4. data/LICENSE +1 -0
  5. data/README.md +94 -0
  6. data/Rakefile +44 -0
  7. data/TODO.rdoc +8 -0
  8. data/config/ci/before-travis.sh +28 -0
  9. data/init.rb +1 -0
  10. data/install.rb +1 -0
  11. data/javascripts/basepack.js +139 -0
  12. data/javascripts/xdatetime.js +196 -0
  13. data/lib/generators/netzke/basepack_generator.rb +10 -0
  14. data/lib/generators/netzke/templates/assets/ts-checkbox.gif +0 -0
  15. data/lib/generators/netzke/templates/create_netzke_field_lists.rb +18 -0
  16. data/lib/netzke-basepack.rb +26 -0
  17. data/lib/netzke/active_record.rb +20 -0
  18. data/lib/netzke/active_record/attributes.rb +256 -0
  19. data/lib/netzke/active_record/combobox_options.rb +16 -0
  20. data/lib/netzke/active_record/relation_extensions.rb +37 -0
  21. data/lib/netzke/basepack.rb +45 -0
  22. data/lib/netzke/basepack/accordion_panel.rb +39 -0
  23. data/lib/netzke/basepack/action_column.rb +68 -0
  24. data/lib/netzke/basepack/action_column/javascripts/action_column.js +61 -0
  25. data/lib/netzke/basepack/auth_app.rb +159 -0
  26. data/lib/netzke/basepack/basic_app.rb +7 -0
  27. data/lib/netzke/basepack/border_layout_panel.rb +53 -0
  28. data/lib/netzke/basepack/border_layout_panel/javascripts/border_layout_panel.js +40 -0
  29. data/lib/netzke/basepack/data_accessor.rb +53 -0
  30. data/lib/netzke/basepack/data_adapters/abstract_adapter.rb +164 -0
  31. data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +279 -0
  32. data/lib/netzke/basepack/data_adapters/data_mapper_adapter.rb +264 -0
  33. data/lib/netzke/basepack/data_adapters/sequel_adapter.rb +260 -0
  34. data/lib/netzke/basepack/form_panel.rb +144 -0
  35. data/lib/netzke/basepack/form_panel/fields.rb +208 -0
  36. data/lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js +51 -0
  37. data/lib/netzke/basepack/form_panel/javascripts/form_panel.js +225 -0
  38. data/lib/netzke/basepack/form_panel/javascripts/misc.js +4 -0
  39. data/lib/netzke/basepack/form_panel/javascripts/n_radio_group.js +43 -0
  40. data/lib/netzke/basepack/form_panel/javascripts/readonly_mode.js +35 -0
  41. data/lib/netzke/basepack/form_panel/services.rb +142 -0
  42. data/lib/netzke/basepack/form_panel/stylesheets/readonly_mode.css +14 -0
  43. data/lib/netzke/basepack/grid_panel.rb +440 -0
  44. data/lib/netzke/basepack/grid_panel/columns.rb +394 -0
  45. data/lib/netzke/basepack/grid_panel/javascripts/advanced_search.js +27 -0
  46. data/lib/netzke/basepack/grid_panel/javascripts/check_column_fix.js +6 -0
  47. data/lib/netzke/basepack/grid_panel/javascripts/edit_in_form.js +51 -0
  48. data/lib/netzke/basepack/grid_panel/javascripts/event_handling.js +179 -0
  49. data/lib/netzke/basepack/grid_panel/javascripts/grid_panel.js +438 -0
  50. data/lib/netzke/basepack/grid_panel/javascripts/misc.js +4 -0
  51. data/lib/netzke/basepack/grid_panel/javascripts/rows-dd.js +281 -0
  52. data/lib/netzke/basepack/grid_panel/record_form_window.rb +41 -0
  53. data/lib/netzke/basepack/grid_panel/services.rb +235 -0
  54. data/lib/netzke/basepack/paging_form_panel.rb +72 -0
  55. data/lib/netzke/basepack/paging_form_panel/javascripts/paging_form_panel.js +76 -0
  56. data/lib/netzke/basepack/panel.rb +11 -0
  57. data/lib/netzke/basepack/query_builder.rb +107 -0
  58. data/lib/netzke/basepack/query_builder/javascripts/query_builder.js +153 -0
  59. data/lib/netzke/basepack/search_panel.rb +79 -0
  60. data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +160 -0
  61. data/lib/netzke/basepack/search_panel/javascripts/search_panel.js +65 -0
  62. data/lib/netzke/basepack/search_window.rb +66 -0
  63. data/lib/netzke/basepack/simple_app.rb +104 -0
  64. data/lib/netzke/basepack/simple_app/javascripts/simple_app.js +64 -0
  65. data/lib/netzke/basepack/simple_app/javascripts/statusbar_ext.js +8 -0
  66. data/lib/netzke/basepack/tab_panel.rb +21 -0
  67. data/lib/netzke/basepack/tab_panel/javascripts/tab_panel.js +11 -0
  68. data/lib/netzke/basepack/version.rb +11 -0
  69. data/lib/netzke/basepack/window.rb +29 -0
  70. data/lib/netzke/basepack/window/javascripts/window.js +20 -0
  71. data/lib/netzke/basepack/wrap_lazy_loaded.rb +28 -0
  72. data/lib/netzke/basepack/wrapper.rb +28 -0
  73. data/lib/netzke/data_mapper.rb +18 -0
  74. data/lib/netzke/data_mapper/attributes.rb +273 -0
  75. data/lib/netzke/data_mapper/combobox_options.rb +11 -0
  76. data/lib/netzke/data_mapper/relation_extensions.rb +38 -0
  77. data/lib/netzke/sequel.rb +18 -0
  78. data/lib/netzke/sequel/attributes.rb +274 -0
  79. data/lib/netzke/sequel/combobox_options.rb +10 -0
  80. data/lib/netzke/sequel/relation_extensions.rb +40 -0
  81. data/lib/tasks/netzke_basepack_tasks.rake +4 -0
  82. data/locales/de.yml +79 -0
  83. data/locales/en.yml +79 -0
  84. data/netzke-basepack.gemspec +306 -0
  85. data/stylesheets/basepack.css +72 -0
  86. data/stylesheets/datetimefield.css +54 -0
  87. data/test/basepack_test_app/.gitignore +6 -0
  88. data/test/basepack_test_app/.rvmrc +1 -0
  89. data/test/basepack_test_app/Gemfile +59 -0
  90. data/test/basepack_test_app/Gemfile.lock +196 -0
  91. data/test/basepack_test_app/Guardfile +46 -0
  92. data/test/basepack_test_app/README +1 -0
  93. data/test/basepack_test_app/Rakefile +7 -0
  94. data/test/basepack_test_app/app/components/author_form.rb +32 -0
  95. data/test/basepack_test_app/app/components/author_grid.rb +3 -0
  96. data/test/basepack_test_app/app/components/book_form.rb +38 -0
  97. data/test/basepack_test_app/app/components/book_form_with_custom_fields.rb +21 -0
  98. data/test/basepack_test_app/app/components/book_form_with_defaults.rb +8 -0
  99. data/test/basepack_test_app/app/components/book_form_with_nested_attributes.rb +18 -0
  100. data/test/basepack_test_app/app/components/book_grid.rb +12 -0
  101. data/test/basepack_test_app/app/components/book_grid_filtering.rb +10 -0
  102. data/test/basepack_test_app/app/components/book_grid_loader.rb +24 -0
  103. data/test/basepack_test_app/app/components/book_grid_with_column_actions.rb +15 -0
  104. data/test/basepack_test_app/app/components/book_grid_with_custom_columns.rb +27 -0
  105. data/test/basepack_test_app/app/components/book_grid_with_default_values.rb +9 -0
  106. data/test/basepack_test_app/app/components/book_grid_with_extra_feedback.rb +8 -0
  107. data/test/basepack_test_app/app/components/book_grid_with_extra_filters.rb +14 -0
  108. data/test/basepack_test_app/app/components/book_grid_with_nested_attributes.rb +13 -0
  109. data/test/basepack_test_app/app/components/book_grid_with_overridden_columns.rb +15 -0
  110. data/test/basepack_test_app/app/components/book_grid_with_paging.rb +10 -0
  111. data/test/basepack_test_app/app/components/book_grid_with_persistence.rb +8 -0
  112. data/test/basepack_test_app/app/components/book_grid_with_scoped_authors.rb +8 -0
  113. data/test/basepack_test_app/app/components/book_grid_with_virtual_attributes.rb +21 -0
  114. data/test/basepack_test_app/app/components/book_paging_form_panel.rb +22 -0
  115. data/test/basepack_test_app/app/components/book_query_builder.rb +8 -0
  116. data/test/basepack_test_app/app/components/book_search_panel.rb +5 -0
  117. data/test/basepack_test_app/app/components/book_search_panel/javascripts/i18n_de.js +6 -0
  118. data/test/basepack_test_app/app/components/book_with_custom_primary_key_grid.rb +10 -0
  119. data/test/basepack_test_app/app/components/books_bound_to_author.rb +10 -0
  120. data/test/basepack_test_app/app/components/double_book_grid.rb +18 -0
  121. data/test/basepack_test_app/app/components/extras/book_presentation.rb +27 -0
  122. data/test/basepack_test_app/app/components/form_without_model.rb +21 -0
  123. data/test/basepack_test_app/app/components/generic_user_form.rb +12 -0
  124. data/test/basepack_test_app/app/components/lockable_book_form.rb +17 -0
  125. data/test/basepack_test_app/app/components/lockable_user_form.rb +7 -0
  126. data/test/basepack_test_app/app/components/paging_form_with_search.rb +40 -0
  127. data/test/basepack_test_app/app/components/simple_accordion.rb +11 -0
  128. data/test/basepack_test_app/app/components/simple_panel.rb +17 -0
  129. data/test/basepack_test_app/app/components/simple_tab_panel.rb +11 -0
  130. data/test/basepack_test_app/app/components/simple_window.rb +10 -0
  131. data/test/basepack_test_app/app/components/simple_wrapper.rb +7 -0
  132. data/test/basepack_test_app/app/components/some_accordion_panel.rb +22 -0
  133. data/test/basepack_test_app/app/components/some_auth_app.rb +32 -0
  134. data/test/basepack_test_app/app/components/some_border_layout.rb +28 -0
  135. data/test/basepack_test_app/app/components/some_simple_app.rb +35 -0
  136. data/test/basepack_test_app/app/components/some_tab_panel.rb +20 -0
  137. data/test/basepack_test_app/app/components/user_form.rb +25 -0
  138. data/test/basepack_test_app/app/components/user_form_with_default_fields.rb +8 -0
  139. data/test/basepack_test_app/app/components/user_grid.rb +8 -0
  140. data/test/basepack_test_app/app/components/user_grid_with_customized_form_fields.rb +18 -0
  141. data/test/basepack_test_app/app/components/window_component_loader.rb +27 -0
  142. data/test/basepack_test_app/app/controllers/application_controller.rb +9 -0
  143. data/test/basepack_test_app/app/controllers/components_controller.rb +10 -0
  144. data/test/basepack_test_app/app/controllers/welcome_controller.rb +9 -0
  145. data/test/basepack_test_app/app/helpers/application_helper.rb +8 -0
  146. data/test/basepack_test_app/app/helpers/embedded_components_helper.rb +2 -0
  147. data/test/basepack_test_app/app/models/address.rb +29 -0
  148. data/test/basepack_test_app/app/models/author.rb +38 -0
  149. data/test/basepack_test_app/app/models/book.rb +49 -0
  150. data/test/basepack_test_app/app/models/book_with_custom_primary_key.rb +26 -0
  151. data/test/basepack_test_app/app/models/role.rb +24 -0
  152. data/test/basepack_test_app/app/models/user.rb +29 -0
  153. data/test/basepack_test_app/app/presenters/forms/generic_user.rb +6 -0
  154. data/test/basepack_test_app/app/views/components/loadable_window.html.erb +9 -0
  155. data/test/basepack_test_app/app/views/components/simple_panel.html.erb +1 -0
  156. data/test/basepack_test_app/app/views/layouts/application.html.erb +12 -0
  157. data/test/basepack_test_app/app/views/layouts/components.html.erb +13 -0
  158. data/test/basepack_test_app/app/views/layouts/nested.html.erb +5 -0
  159. data/test/basepack_test_app/app/views/welcome/index.html.erb +10 -0
  160. data/test/basepack_test_app/config.ru +4 -0
  161. data/test/basepack_test_app/config/application.rb +57 -0
  162. data/test/basepack_test_app/config/boot.rb +13 -0
  163. data/test/basepack_test_app/config/cucumber.yml +8 -0
  164. data/test/basepack_test_app/config/database.yml.sample +41 -0
  165. data/test/basepack_test_app/config/database.yml.travis +15 -0
  166. data/test/basepack_test_app/config/environment.rb +6 -0
  167. data/test/basepack_test_app/config/environments/development.rb +22 -0
  168. data/test/basepack_test_app/config/environments/production.rb +49 -0
  169. data/test/basepack_test_app/config/environments/test.rb +35 -0
  170. data/test/basepack_test_app/config/initializers/backtrace_silencers.rb +7 -0
  171. data/test/basepack_test_app/config/initializers/data_mapper_logging.rb +3 -0
  172. data/test/basepack_test_app/config/initializers/inflections.rb +10 -0
  173. data/test/basepack_test_app/config/initializers/mime_types.rb +5 -0
  174. data/test/basepack_test_app/config/initializers/netzke.rb +9 -0
  175. data/test/basepack_test_app/config/initializers/secret_token.rb +7 -0
  176. data/test/basepack_test_app/config/initializers/sequel.rb +26 -0
  177. data/test/basepack_test_app/config/initializers/session_store.rb +8 -0
  178. data/test/basepack_test_app/config/locales/de.yml +35 -0
  179. data/test/basepack_test_app/config/locales/es.yml +96 -0
  180. data/test/basepack_test_app/config/routes.rb +68 -0
  181. data/test/basepack_test_app/db/development_structure.sql +88 -0
  182. data/test/basepack_test_app/db/migrate/20100914104207_create_users.rb +15 -0
  183. data/test/basepack_test_app/db/migrate/20100914104236_create_roles.rb +13 -0
  184. data/test/basepack_test_app/db/migrate/20101026185816_create_authors.rb +14 -0
  185. data/test/basepack_test_app/db/migrate/20101026190021_create_books.rb +19 -0
  186. data/test/basepack_test_app/db/migrate/20110101143818_create_addresses.rb +17 -0
  187. data/test/basepack_test_app/db/migrate/20110213213050_create_netzke_component_states.rb +20 -0
  188. data/test/basepack_test_app/db/migrate/20110701070052_create_book_with_custom_primary_keys.rb +15 -0
  189. data/test/basepack_test_app/db/migrate/20110901114016_add_last_read_at_to_books.rb +9 -0
  190. data/test/basepack_test_app/db/migrate/20110909071740_add_published_on_to_books.rb +5 -0
  191. data/test/basepack_test_app/db/schema.rb +81 -0
  192. data/test/basepack_test_app/db/seeds.rb +44 -0
  193. data/test/basepack_test_app/features/accordion_panel.feature +12 -0
  194. data/test/basepack_test_app/features/components_in_view.feature +11 -0
  195. data/test/basepack_test_app/features/form_panel.feature +142 -0
  196. data/test/basepack_test_app/features/grid_panel.feature +277 -0
  197. data/test/basepack_test_app/features/grid_panel_filters.feature +73 -0
  198. data/test/basepack_test_app/features/grid_panel_with_custom_primary_key.feature +15 -0
  199. data/test/basepack_test_app/features/grid_sorting.feature +47 -0
  200. data/test/basepack_test_app/features/i18n.feature +18 -0
  201. data/test/basepack_test_app/features/nested_attributes.feature +26 -0
  202. data/test/basepack_test_app/features/paging_form_panel.feature +43 -0
  203. data/test/basepack_test_app/features/search_in_grid.feature +49 -0
  204. data/test/basepack_test_app/features/simple_app.feature +15 -0
  205. data/test/basepack_test_app/features/simple_panel.feature +11 -0
  206. data/test/basepack_test_app/features/step_definitions/accordion_steps.rb +5 -0
  207. data/test/basepack_test_app/features/step_definitions/ext_steps.rb +16 -0
  208. data/test/basepack_test_app/features/step_definitions/form_panel_steps.rb +46 -0
  209. data/test/basepack_test_app/features/step_definitions/generic_steps.rb +44 -0
  210. data/test/basepack_test_app/features/step_definitions/grid_panel_steps.rb +186 -0
  211. data/test/basepack_test_app/features/step_definitions/pickle_steps.rb +100 -0
  212. data/test/basepack_test_app/features/step_definitions/web_steps.rb +219 -0
  213. data/test/basepack_test_app/features/support/env.rb +81 -0
  214. data/test/basepack_test_app/features/support/paths.rb +65 -0
  215. data/test/basepack_test_app/features/support/pickle.rb +24 -0
  216. data/test/basepack_test_app/features/support/selectors.rb +39 -0
  217. data/test/basepack_test_app/features/tab_panel.feature +12 -0
  218. data/test/basepack_test_app/features/validations_in_grid.feature +13 -0
  219. data/test/basepack_test_app/features/virtual_attributes.feature +16 -0
  220. data/test/basepack_test_app/features/window.feature +11 -0
  221. data/test/basepack_test_app/lib/tasks/.gitkeep +0 -0
  222. data/test/basepack_test_app/lib/tasks/cucumber.rake +71 -0
  223. data/test/basepack_test_app/lib/tasks/travis.rake +7 -0
  224. data/test/basepack_test_app/public/404.html +26 -0
  225. data/test/basepack_test_app/public/422.html +26 -0
  226. data/test/basepack_test_app/public/500.html +26 -0
  227. data/test/basepack_test_app/public/favicon.ico +0 -0
  228. data/test/basepack_test_app/public/images/header-deco.gif +0 -0
  229. data/test/basepack_test_app/public/images/rails.png +0 -0
  230. data/test/basepack_test_app/public/javascripts/application.js +2 -0
  231. data/test/basepack_test_app/public/javascripts/controls.js +965 -0
  232. data/test/basepack_test_app/public/javascripts/dragdrop.js +974 -0
  233. data/test/basepack_test_app/public/javascripts/effects.js +1123 -0
  234. data/test/basepack_test_app/public/javascripts/prototype.js +6001 -0
  235. data/test/basepack_test_app/public/javascripts/rails.js +175 -0
  236. data/test/basepack_test_app/public/robots.txt +5 -0
  237. data/test/basepack_test_app/public/stylesheets/.gitkeep +0 -0
  238. data/test/basepack_test_app/script/cucumber +10 -0
  239. data/test/basepack_test_app/script/rails +6 -0
  240. data/test/basepack_test_app/spec/components/form_panel_spec.rb +53 -0
  241. data/test/basepack_test_app/spec/components/grid_panel_spec.rb +10 -0
  242. data/test/basepack_test_app/spec/data_adapter/adapter_spec.rb +68 -0
  243. data/test/basepack_test_app/spec/data_adapter/attributes_spec.rb +56 -0
  244. data/test/basepack_test_app/spec/data_adapter/relation_extensions_spec.rb +125 -0
  245. data/test/basepack_test_app/spec/factories.rb +28 -0
  246. data/test/basepack_test_app/spec/spec_helper.rb +39 -0
  247. data/test/basepack_test_app/test/performance/browsing_test.rb +9 -0
  248. data/test/basepack_test_app/test/test_helper.rb +13 -0
  249. data/test/basepack_test_app/vendor/plugins/.gitkeep +0 -0
  250. data/test/console_with_fixtures.rb +4 -0
  251. data/test/fixtures/books.yml +11 -0
  252. data/test/fixtures/categories.yml +7 -0
  253. data/test/fixtures/cities.yml +21 -0
  254. data/test/fixtures/continents.yml +7 -0
  255. data/test/fixtures/countries.yml +9 -0
  256. data/test/fixtures/genres.yml +9 -0
  257. data/test/fixtures/roles.yml +8 -0
  258. data/test/fixtures/users.yml +11 -0
  259. data/test/schema.rb +10 -0
  260. data/test/test_helper.rb +21 -0
  261. data/test/unit/accordion_panel_test.rb +20 -0
  262. data/test/unit/active_record_basepack_test.rb +54 -0
  263. data/test/unit/fields_configuration_test.rb +18 -0
  264. data/test/unit/grid_panel_test.rb +52 -0
  265. data/test/unit/netzke_basepack_test.rb +4 -0
  266. data/test/unit/tab_panel_test.rb +21 -0
  267. data/uninstall.rb +1 -0
  268. metadata +332 -0
@@ -0,0 +1,160 @@
1
+ Ext.define('Netzke.classes.Basepack.SearchPanel.ConditionField', {
2
+ extend: 'Ext.form.FieldContainer',
3
+ alias: 'widget.netzkebasepacksearchpanelconditionfield',
4
+
5
+ hideLabel: true,
6
+ layout: 'hbox',
7
+
8
+ // Config refinements for the value field
9
+ valueFieldConfigs: {
10
+ string: {
11
+ xtype : 'textfield'
12
+ },
13
+ datetime: {
14
+ xtype : 'datefield'
15
+ },
16
+ integer: {
17
+ xtype: 'numberfield'
18
+ }
19
+ },
20
+
21
+ initComponent: function(){
22
+ if (!this.attrType) this.attrType = 'string';
23
+
24
+ var items = [
25
+ // attribute combo
26
+ {
27
+ xtype : 'combo',
28
+ store: this.ownerCt.attrs,
29
+ allowBlank: true,
30
+ // store: [],
31
+ name: this.attr + '_attr',
32
+ itemId: 'attrCombo',
33
+ emptyText: 'Attribute',
34
+ triggerAction: 'all',
35
+ value: this.attr ? this.attr.underscore() : "",
36
+ listeners: {
37
+ select: this.onAttributeChange,
38
+ scope: this
39
+ }
40
+ }
41
+ ];
42
+
43
+ if (this.attr) {
44
+
45
+ var operators = this.ownerCt.attributeOperatorsMap[this.attrType] || [[]];
46
+
47
+ if (this.attrType === 'boolean') {
48
+ items.push({
49
+ xtype : 'tricheckbox',
50
+ width: 100,
51
+ name: this.attr + '_value',
52
+ itemId: 'valueField',
53
+ checked: this.value
54
+ });
55
+
56
+ items.push({
57
+ flex: 1,
58
+ xtype: 'displayfield'
59
+ });
60
+ } else {
61
+ // operator combo
62
+ items.push(
63
+ {
64
+ width: 100,
65
+ xtype: 'combo',
66
+ fieldLabel: 'Operator',
67
+ hideLabel: true,
68
+ store: operators,
69
+ name: this.attr + '_operator',
70
+ value: this.operator || operators[0][0],
71
+ autoSelect: true,
72
+ triggerAction: 'all',
73
+ emptyText: "Operator",
74
+ itemId: "operatorCombo"
75
+ }
76
+ );
77
+
78
+ // value field
79
+ items.push(Ext.apply(
80
+ {
81
+ xtype: 'textfield',
82
+ emptyText: "Value",
83
+ flex: 1,
84
+ name: this.attr + '_value',
85
+ value: this.value,
86
+ itemId: "valueField"
87
+ },
88
+ this.valueFieldConfigs[this.attrType] // refining the config dependent on the attr type
89
+ ));
90
+ }
91
+
92
+ // delete button
93
+ items.push({
94
+ xtype: 'button',
95
+ cls: 'x-btn-icon',
96
+ icon: Netzke.RelativeUrlRoot + "/images/icons/cross.png",
97
+ handler: this.removeSelf,
98
+ scope: this
99
+ });
100
+ }
101
+
102
+ this.items = items;
103
+
104
+ // Why on Earth is this not working? Netzke.classes.Basepack.SearchPanel.ConditionField undefined???
105
+ // Netzke.classes.Basepack.SearchPanel.ConditionField.superclass.initComponent.call(this);
106
+ // Ext.form.CompositeField.prototype.initComponent.call(this); // workaround
107
+ this.callParent();
108
+
109
+ this.attrCombo = this.getComponent('attrCombo');
110
+ this.operatorCombo = this.getComponent('operatorCombo');
111
+ this.valueField = this.getComponent('valueField');
112
+
113
+ this.addEvents('configured'); // user selects the attribute from the attribute combo
114
+ },
115
+
116
+ isConfigured: function() {
117
+ return !!this.attrCombo.getValue();
118
+ },
119
+
120
+ removeSelf: function(){
121
+ var ownerCt = this.ownerCt;
122
+ this.destroy();
123
+ ownerCt.fireEvent('fieldsnumberchange');
124
+ },
125
+
126
+ onAttributeChange: function(e){
127
+ this.fireEvent('configured');
128
+ this.changeAttribute(e.value.camelize(true));
129
+ },
130
+
131
+ // Dynamically replace self with a field with different attrType
132
+ changeAttribute: function(attr){
133
+ var attrType = this.ownerCt.attrsHash[attr];
134
+ var idx = this.ownerCt.items.indexOf(this);
135
+ var owner = this.ownerCt;
136
+ var newSelf = Ext.createByAlias('widget.netzkebasepacksearchpanelconditionfield', Ext.apply(this.initialConfig, {name: attr, attrType: attrType, attr: attr.underscore(), ownerCt: this.ownerCt, operator: null}));
137
+ owner.remove(this);
138
+ owner.insert(idx, newSelf);
139
+ owner.doLayout();
140
+ },
141
+
142
+ // Returns true if it should be in the query
143
+ valueIsSet: function(){
144
+ return !!(this.attrCombo.getValue() && (this.attrType === 'boolean' || this.operatorCombo.getValue()) && !Ext.isEmpty(this.valueField.getValue()));
145
+ },
146
+
147
+ // Returns the query object
148
+ buildValue: function(){
149
+ var res = {attr: this.attrCombo.getValue(), value: this.valueField.getValue()};
150
+ if (this.attrType !== 'boolean') {
151
+ res.operator = this.operatorCombo.getValue();
152
+ }
153
+ return res;
154
+ },
155
+
156
+ clearValue: function() {
157
+ this.valueField.reset();
158
+ }
159
+
160
+ });
@@ -0,0 +1,65 @@
1
+ {
2
+ initComponent: function() {
3
+ this.callParent();
4
+ this.buildFormFromQuery(this.presetQuery);
5
+
6
+ this.onAddCondition();
7
+
8
+ },
9
+
10
+ // Will probably need to be performance-optimized in the future, as recreating the fields is expensive
11
+ buildFormFromQuery: function(query) {
12
+ this.onClearAll();
13
+ Ext.each(query, function(f){
14
+ f.ownerCt = this;
15
+ this.insert(this.items.length - 1, Ext.createByAlias('widget.netzkebasepacksearchpanelconditionfield', f));
16
+ }, this);
17
+ this.doLayout();
18
+ },
19
+
20
+ onAddCondition: function() {
21
+ var condField = Ext.createByAlias('widget.netzkebasepacksearchpanelconditionfield', {ownerCt: this});
22
+ condField.on('configured', function() {
23
+ this.onAddCondition();
24
+ }, this, {single: true});
25
+ this.add(condField);
26
+ this.doLayout();
27
+ this.fireEvent('fieldsnumberchange');
28
+ },
29
+
30
+ onReset: function() {
31
+ this.items.each(function(f){
32
+ if (f.valueField) {f.clearValue();}
33
+ });
34
+ },
35
+
36
+ onClearAll: function() {
37
+ this.eachConfiguredField(function(f) {
38
+ this.remove(f);
39
+ }, this);
40
+
41
+ this.fireEvent('fieldsnumberchange');
42
+ },
43
+
44
+ // Returns each condition field which has attribute selected
45
+ eachConfiguredField: function(fn, scope) {
46
+ this.items.each(function(f, i) {
47
+ if (this.items.last() !== f) {
48
+ fn.call(scope || f, f);
49
+ }
50
+ }, this);
51
+ },
52
+
53
+ // When "all" is "true", also includes the fields with empty values
54
+ getQuery: function(all) {
55
+ var query = [];
56
+ this.eachConfiguredField(function(f){
57
+ if (f.valueIsSet() || all) {
58
+ var cond = f.buildValue();
59
+ if (all) {cond.attrType = f.attrType;}
60
+ query.push(cond);
61
+ }
62
+ });
63
+ return query;
64
+ }
65
+ }
@@ -0,0 +1,66 @@
1
+ module Netzke
2
+ module Basepack
3
+ class SearchWindow < Netzke::Basepack::Window
4
+
5
+ action :search do
6
+ { :text => I18n.t('netzke.basepack.search_window.action.search') }
7
+ end
8
+
9
+ action :cancel do
10
+ { :text => I18n.t('netzke.basepack.search_window.action.cancel') }
11
+ end
12
+
13
+ js_properties :width => "50%",
14
+ :auto_height => true,
15
+ :close_action => "hide",
16
+ :buttons => [:search.action, :cancel.action],
17
+ :modal => true
18
+
19
+ def configuration
20
+ super.tap do |s|
21
+ s[:items] = [:search_panel.component(:prevent_header => true)]
22
+ s[:title] = I18n.t('netzke.basepack.search_window.title')
23
+ s[:persistence] = false
24
+ end
25
+ end
26
+
27
+ component :search_panel do
28
+ {
29
+ :class_name => "Netzke::Basepack::QueryBuilder",
30
+ :model => config[:model],
31
+ :fields => config[:fields]
32
+ }
33
+ end
34
+
35
+ js_method :init_component, <<-JS
36
+ function(){
37
+ this.callParent();
38
+
39
+ this.on('show', function(){
40
+ this.closeRes = 'cancel';
41
+ });
42
+ }
43
+ JS
44
+
45
+ js_method :get_query, <<-JS
46
+ function(){
47
+ return this.items.first().getQuery();
48
+ }
49
+ JS
50
+
51
+ js_method :on_search, <<-JS
52
+ function(){
53
+ this.closeRes = 'search';
54
+ this.hide();
55
+ }
56
+ JS
57
+
58
+ js_method :on_cancel, <<-JS
59
+ function(){
60
+ this.hide();
61
+ }
62
+ JS
63
+
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,104 @@
1
+ module Netzke
2
+ module Basepack
3
+ # Basis for a Ext.container.Viewport-based one-page application.
4
+ #
5
+ # == Features:
6
+ # * dynamic loading of components
7
+ # * browser history support (press the "Back"-button to go to the previously loaded component)
8
+ # * AJAX activity indicator
9
+ #
10
+ # == Extending SimpleApp
11
+ # You may want to extend SimpleApp to provide a custom layout. Make sure you create three regions with predefined itemId's that will be used by SimpleApp. You can use the following methods defined by SimpleApp: main_panel_config, status_bar_config, and menu_bar_config, e.g.:
12
+ #
13
+ # class MySimpleApp < Netzke::Basepack::SimpleApp
14
+ #
15
+ # def configuration
16
+ # super.merge(
17
+ # :items => [my_custom_navigation_config, main_panel_config, menu_bar_config, status_bar_config]
18
+ # )
19
+ # end
20
+ #
21
+ # def my_custom_navigation_config
22
+ # {
23
+ # :item_id => 'navigation',
24
+ # :region => :east,
25
+ # :width => 200
26
+ # }
27
+ # end
28
+ #
29
+ # ...
30
+ # end
31
+ #
32
+ # The JS side of the component will have those regions referenced as this.mainPanel, this.statusBar, and this.menuBar.
33
+ class SimpleApp < Base
34
+
35
+ js_base_class "Ext.container.Viewport"
36
+
37
+ js_property :layout, :border
38
+ #js_include "#{File.dirname(__FILE__)}/../../../../../../public/extjs/examples/ux/statusbar/StatusBar.js"
39
+ js_include Netzke::Core.ext_path.join("examples", "ux/statusbar/StatusBar.js"), :statusbar_ext
40
+
41
+ js_mixin :simple_app
42
+
43
+ # In Ext 4.1 calling `render` on a viewport causes an error
44
+ def js_component_render
45
+ ""
46
+ end
47
+
48
+ def configuration
49
+ super.merge(
50
+ :items => [main_panel_config, menu_bar_config, status_bar_config]
51
+ )
52
+ end
53
+
54
+ # Override for custom menu
55
+ def menu
56
+ []
57
+ end
58
+
59
+ # Config for the main panel, which will contain dynamically loaded components.
60
+ def main_panel_config(overrides = {})
61
+ {
62
+ :itemId => 'main_panel',
63
+ :region => 'center',
64
+ :layout => 'fit'
65
+ }.merge(overrides)
66
+ end
67
+
68
+ # Config for the status bar
69
+ def status_bar_config(overrides = {})
70
+ {
71
+ :itemId => 'status_bar',
72
+ :xtype => 'statusbar',
73
+ :region => 'south',
74
+ :height => 22,
75
+ :statusAlign => 'right',
76
+ :busyText => 'Busy...',
77
+ :default_text => "Ready",
78
+ :default_icon_cls => ""
79
+ }.merge(overrides)
80
+ end
81
+
82
+ # Config for the menu bar
83
+ def menu_bar_config(overrides = {})
84
+ {
85
+ :itemId => 'menu_bar',
86
+ :xtype => 'toolbar',
87
+ :region => 'north',
88
+ :height => 28,
89
+ :items => menu
90
+ }.merge(overrides)
91
+ end
92
+
93
+ # Html required for Ext.History to work
94
+ def js_component_html
95
+ super << %Q{
96
+ <form id="history-form" class="x-hidden">
97
+ <input type="hidden" id="x-history-field" />
98
+ <iframe id="x-history-frame"></iframe>
99
+ </form>
100
+ }
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,64 @@
1
+ {
2
+ initComponent: function(){
3
+ this.callParent();
4
+
5
+ this.mainPanel = this.down('panel[itemId="main_panel"]');
6
+ this.menuBar = this.down('container[itemId="menu_bar"]');
7
+ var statusBar = this.statusBar = this.down('container[itemId="status_bar"]');
8
+
9
+ Ext.util.History.on('change', this.processHistory, this);
10
+
11
+ // Setting the "busy" indicator for Ajax requests
12
+ Ext.Ajax.on('beforerequest', function(){ statusBar.showBusy(); });
13
+ Ext.Ajax.on('requestcomplete', function(){ statusBar.hideBusy(); });
14
+ Ext.Ajax.on('requestexception', function(){ statusBar.hideBusy(); });
15
+
16
+ // Initialize history
17
+ Ext.util.History.init();
18
+ },
19
+
20
+ afterRender: function(){
21
+ this.callParent();
22
+
23
+ // If we are given a token, load the corresponding component, otherwise load the last loaded component
24
+ var currentToken = Ext.util.History.getToken();
25
+ if (currentToken != "") {
26
+ this.processHistory(currentToken);
27
+ } else {
28
+ var lastLoaded = this.initialConfig.componentToLoad; // passed from the server
29
+ if (lastLoaded) Ext.util.History.add(lastLoaded);
30
+ }
31
+ },
32
+
33
+ processHistory: function(token){
34
+ if (token){
35
+ this.mainPanel.removeAll();
36
+ this.loadNetzkeComponent({name: token, container: this.mainPanel});
37
+ } else {
38
+ this.mainPanel.removeAll();
39
+ }
40
+ },
41
+
42
+ // instantiateComponent: function(config){
43
+ // this.mainPanel.instantiateChild(config);
44
+ // },
45
+
46
+ appLoadComponent: function(name){
47
+ Ext.util.History.add(name);
48
+ },
49
+
50
+ loadNetzkeComponentByAction: function(action){
51
+ var componentName = action.component || action.name;
52
+ if (componentName) this.appLoadComponent(componentName);
53
+ },
54
+
55
+ // DEPRECATED
56
+ loadComponentByAction: function(action) {
57
+ Netzke.deprecationWarning("loadComponentByAction is deprecated in favor of loadNetzkeComponentByAction");
58
+ this.loadNetzkeComponentByAction(action);
59
+ },
60
+
61
+ onToggleConfigMode: function(params){
62
+ this.toggleConfigMode();
63
+ }
64
+ }