extjs_scaffold 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/.gitignore +9 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +4 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +80 -0
  6. data/Rakefile +28 -0
  7. data/extjs_scaffold.gemspec +27 -0
  8. data/features/scaffold_generator.feature +124 -0
  9. data/features/step_definitions/aruba_ext_steps.rb +6 -0
  10. data/features/support/setup.rb +5 -0
  11. data/lib/extjs_scaffold.rb +1 -0
  12. data/lib/extjs_scaffold/version.rb +3 -0
  13. data/lib/generators/extjs_scaffold.rb +15 -0
  14. data/lib/generators/extjs_scaffold/install/USAGE +28 -0
  15. data/lib/generators/extjs_scaffold/install/install_generator.rb +82 -0
  16. data/lib/generators/extjs_scaffold/install/templates/Actionable.js +27 -0
  17. data/lib/generators/extjs_scaffold/install/templates/App.js +11 -0
  18. data/lib/generators/extjs_scaffold/install/templates/EditWindow.js +135 -0
  19. data/lib/generators/extjs_scaffold/install/templates/FormPanel.js +27 -0
  20. data/lib/generators/extjs_scaffold/install/templates/Format.js +34 -0
  21. data/lib/generators/extjs_scaffold/install/templates/GridPanel.js +289 -0
  22. data/lib/generators/extjs_scaffold/install/templates/ParentComboField.js +39 -0
  23. data/lib/generators/extjs_scaffold/install/templates/Rails.js +162 -0
  24. data/lib/generators/extjs_scaffold/install/templates/ScrollingToolbar.js +170 -0
  25. data/lib/generators/extjs_scaffold/install/templates/SearchField.js +104 -0
  26. data/lib/generators/extjs_scaffold/install/templates/UpdateWindow.js +112 -0
  27. data/lib/generators/extjs_scaffold/install/templates/Updateable.js +31 -0
  28. data/lib/generators/extjs_scaffold/install/templates/ext_auth.html.erb +3 -0
  29. data/lib/generators/extjs_scaffold/install/templates/extjs_scaffold.css.scss +9 -0
  30. data/lib/generators/extjs_scaffold/install/templates/images/README.txt +1 -0
  31. data/lib/generators/extjs_scaffold/install/templates/images/add.gif +0 -0
  32. data/lib/generators/extjs_scaffold/install/templates/images/application_form_edit.png +0 -0
  33. data/lib/generators/extjs_scaffold/install/templates/images/delete.gif +0 -0
  34. data/lib/generators/extjs_scaffold/install/templates/images/tick.png +0 -0
  35. data/lib/generators/extjs_scaffold/scaffold/USAGE +24 -0
  36. data/lib/generators/extjs_scaffold/scaffold/scaffold_generator.rb +19 -0
  37. data/lib/generators/extjs_scaffold/scaffold_controller/USAGE +20 -0
  38. data/lib/generators/extjs_scaffold/scaffold_controller/scaffold_controller_generator.rb +296 -0
  39. data/lib/generators/extjs_scaffold/scaffold_controller/templates/controller.rb +191 -0
  40. data/lib/generators/extjs_scaffold/scaffold_controller/templates/js/Controller.js +53 -0
  41. data/lib/generators/extjs_scaffold/scaffold_controller/templates/js/EditForm.js +17 -0
  42. data/lib/generators/extjs_scaffold/scaffold_controller/templates/js/EditWindow.js +27 -0
  43. data/lib/generators/extjs_scaffold/scaffold_controller/templates/js/Grid.js +26 -0
  44. data/lib/generators/extjs_scaffold/scaffold_controller/templates/js/Model.js +43 -0
  45. data/lib/generators/extjs_scaffold/scaffold_controller/templates/js/ReferenceStore.js +27 -0
  46. data/lib/generators/extjs_scaffold/scaffold_controller/templates/js/Store.js +28 -0
  47. data/lib/generators/extjs_scaffold/scaffold_controller/templates/js/UpdateForm.js +17 -0
  48. data/lib/generators/extjs_scaffold/scaffold_controller/templates/js/UpdateWindow.js +21 -0
  49. data/lib/generators/extjs_scaffold/scaffold_controller/templates/model.rb +57 -0
  50. data/lib/generators/extjs_scaffold/scaffold_controller/templates/tests/controller_spec.rb +197 -0
  51. data/lib/generators/extjs_scaffold/scaffold_controller/templates/tests/controller_test.rb +85 -0
  52. data/lib/generators/extjs_scaffold/scaffold_controller/templates/views/erb/index.html.erb +3 -0
  53. data/lib/generators/extjs_scaffold/scaffold_controller/templates/views/haml/index.html.haml +3 -0
  54. data/spec/dummy/.gitignore +15 -0
  55. data/spec/dummy/README +261 -0
  56. data/spec/dummy/Rakefile +7 -0
  57. data/spec/dummy/app/assets/images/rails.png +0 -0
  58. data/spec/dummy/app/assets/javascripts/application.js +7 -0
  59. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  60. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  61. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  62. data/spec/dummy/app/mailers/.gitkeep +0 -0
  63. data/spec/dummy/app/models/.gitkeep +0 -0
  64. data/spec/dummy/app/views/layouts/application.html.erb +16 -0
  65. data/spec/dummy/config.ru +4 -0
  66. data/spec/dummy/config/application.rb +48 -0
  67. data/spec/dummy/config/boot.rb +7 -0
  68. data/spec/dummy/config/database.yml +25 -0
  69. data/spec/dummy/config/environment.rb +5 -0
  70. data/spec/dummy/config/environments/development.rb +30 -0
  71. data/spec/dummy/config/environments/production.rb +60 -0
  72. data/spec/dummy/config/environments/test.rb +39 -0
  73. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  74. data/spec/dummy/config/initializers/inflections.rb +10 -0
  75. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  76. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  77. data/spec/dummy/config/initializers/session_store.rb +8 -0
  78. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  79. data/spec/dummy/config/locales/en.yml +5 -0
  80. data/spec/dummy/config/routes.rb +58 -0
  81. data/spec/dummy/db/schema.rb +23 -0
  82. data/spec/dummy/db/seeds.rb +7 -0
  83. data/spec/dummy/doc/README_FOR_APP +2 -0
  84. data/spec/dummy/lib/assets/.gitkeep +0 -0
  85. data/spec/dummy/lib/tasks/.gitkeep +0 -0
  86. data/spec/dummy/log/.gitkeep +0 -0
  87. data/spec/dummy/public/404.html +26 -0
  88. data/spec/dummy/public/422.html +26 -0
  89. data/spec/dummy/public/500.html +26 -0
  90. data/spec/dummy/public/favicon.ico +0 -0
  91. data/spec/dummy/public/index.html +241 -0
  92. data/spec/dummy/public/robots.txt +5 -0
  93. data/spec/dummy/script/rails +6 -0
  94. data/spec/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
  95. data/spec/dummy/vendor/plugins/.gitkeep +0 -0
  96. data/spec/generators/install_spec.rb +140 -0
  97. data/spec/generators/scaffold_spec.rb +244 -0
  98. data/spec/spec_helper.rb +26 -0
  99. data/spec/support/App.js +12 -0
  100. data/spec/support/rails_routes.rb +4 -0
  101. metadata +290 -0
@@ -0,0 +1,191 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+ respond_to :html, :json
3
+
4
+ # GET <%= route_url %>
5
+ def index
6
+ params[:page] ||= 1
7
+ params[:limit] ||= 40
8
+ @<%= plural_table_name %> = <%= class_name %>.search(params[:query], params[:page], params[:limit], sort_column, sort_direction)
9
+ respond_with @<%= plural_table_name %> do |format|
10
+ format.json { render :extjs => @<%= plural_table_name %>, :methods => related_attributes }
11
+ end
12
+ end
13
+
14
+ # GET <%= route_url %>/1
15
+ # GET <%= route_url %>/1.js
16
+ def show
17
+ @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
18
+ respond_with @<%= singular_table_name %> do |format|
19
+ format.json { render :extjs => @<%= singular_table_name %>, :methods => related_attributes }
20
+ end
21
+ end
22
+
23
+ # GET <%= route_url %>/new
24
+ def new
25
+ @<%= singular_table_name %> = <%= orm_class.build(class_name) %>
26
+ respond_with @<%= singular_table_name %>
27
+ end
28
+
29
+ # GET <%= route_url %>/1/edit
30
+ def edit
31
+ @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
32
+ respond_with @<%= singular_table_name %> do |format|
33
+ format.json { render :extjs => @<%= singular_table_name %>, :methods => related_attributes }
34
+ end
35
+ end
36
+
37
+ # POST <%= route_url %>
38
+ def create
39
+ params[:<%= singular_table_name %>] = filter_params(params[:<%= singular_table_name %>])
40
+ @<%= singular_table_name %> = <%= orm_class.build(class_name, "params[:#{singular_table_name}]") %>
41
+ if @<%= orm_instance.save %>
42
+ respond_with @<%= singular_table_name %> do |format|
43
+ format.json { render :extjs => @<%= singular_table_name %>, :methods => related_attributes }
44
+ end
45
+ else
46
+ respond_to do |format|
47
+ format.json { render :json => { :success => false, :error_count => @<%= singular_table_name %>.errors.count, :errors => @<%= singular_table_name %>.errors }.to_json, :layout => false }
48
+ format.html
49
+ end
50
+ end
51
+ end
52
+
53
+ # PUT <%= route_url %>/1
54
+ def update
55
+ @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
56
+ params[:<%= singular_table_name %>] = filter_params(params[:<%= singular_table_name %>])
57
+ respond_with @<%= orm_instance.update_attributes("params[:#{singular_table_name}]") %> do |format|
58
+ if @<%= singular_table_name %>.invalid?
59
+ format.json { render :json => { :success => false, :error_count => @<%= singular_table_name %>.errors.count, :errors => @<%= singular_table_name %>.errors }.to_json, :layout => false }
60
+ else
61
+ format.json { render :extjs => @<%= singular_table_name %>, :methods => related_attributes }
62
+ end
63
+ end
64
+ end
65
+
66
+ # DELETE <%= route_url %>/1
67
+ def destroy
68
+ @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
69
+ @<%= orm_instance.destroy %>
70
+ respond_with @<%= singular_table_name %>
71
+ end
72
+
73
+ # json only
74
+ def destroy_all
75
+ @errors = []
76
+ params[:<%= singular_table_name %>] = ActiveSupport::JSON.decode(params[:<%= singular_table_name %>]) if params[:<%= singular_table_name %>] && request.format == 'json'
77
+ # perform deletes in transaction - rollback if any fail
78
+ <%= class_name %>.transaction do
79
+ begin
80
+ params[:<%= singular_table_name %>].each do |<%= singular_table_name %>|
81
+ @<%= singular_table_name %> = <%= orm_class.find(class_name, "#{singular_table_name}[:id]") %>
82
+ if !@<%= orm_instance.destroy %>
83
+ @<%= singular_table_name %>.errors.each_full do |error|
84
+ @errors << "<div><b>#{@<%= singular_table_name %>.id}</b>: #{ error }</div>"
85
+ end
86
+ raise ActiveRecord::Rollback
87
+ break
88
+ end
89
+ end
90
+ rescue ActiveRecord::RecordNotFound
91
+ @errors << "<div>Record Not Found - Changes rolled back</div>"
92
+ raise ActiveRecord::Rollback
93
+ end
94
+ end
95
+ respond_with @errors do |format|
96
+ if @errors.size > 0
97
+ format.json { render :json => { :success => false, :errors => @errors.join }.to_json, :layout => false }
98
+ else
99
+ format.json { render :json => { :success => true }.to_json, :layout => false }
100
+ end
101
+ end
102
+ end
103
+
104
+ # json only
105
+ def update_all
106
+ @errors = []
107
+ params[:<%= singular_table_name %>] = ActiveSupport::JSON.decode(params[:<%= singular_table_name %>]) if params[:<%= singular_table_name %>] && request.format == 'json'
108
+ # perform updates in transaction - rollback if any fail
109
+ <%= class_name %>.transaction do
110
+ begin
111
+ params[:<%= singular_table_name %>].each do |<%= singular_table_name %>|
112
+ @<%= singular_table_name %> = <%= orm_class.find(class_name, "#{singular_table_name}[:id]") %>
113
+ if !@<%= orm_instance.update_attributes("#{singular_table_name}") %>
114
+ @<%= singular_table_name %>.errors.each_full do |error|
115
+ @errors << "<div><b>#{@<%= singular_table_name %>.id}</b>: #{ error }</div>"
116
+ end
117
+ raise ActiveRecord::Rollback
118
+ break
119
+ end
120
+ end
121
+ rescue ActiveRecord::RecordNotFound
122
+ @errors << "<div>Record Not Found - Changes rolled back</div>"
123
+ raise ActiveRecord::Rollback
124
+ end
125
+ end
126
+ respond_with @errors do |format|
127
+ if @errors.size > 0
128
+ format.json { render :json => { :success => false, :errors => @errors.join }.to_json, :layout => false }
129
+ else
130
+ format.json { render :json => { :success => true }.to_json, :layout => false }
131
+ end
132
+ end
133
+ end
134
+
135
+ private
136
+ # set passed sort property or default to first attribute
137
+ def sort_column
138
+ # set defualt sort column
139
+ <% default_sort = ''
140
+ if attributes.first
141
+ default_sort = attributes.first.name
142
+ if attributes.first.reference?
143
+ default_sort += "_#{reference_field(attributes.first)}"
144
+ end
145
+ end
146
+ -%>
147
+ sort = ActiveSupport::JSON.decode(params[:sort]) if params[:sort]
148
+ return sort[0]['property'] if sort && ( <%= class_name %>.column_names.include?(sort[0]['property']) || <%= class_name %>.method_defined?(sort[0]['property']) )
149
+ return '<%= default_sort %>'
150
+ end
151
+
152
+ # set passed sort direction or default to ASC
153
+ def sort_direction
154
+ # set default sort direction
155
+ sort = ActiveSupport::JSON.decode(params[:sort]) if params[:sort]
156
+ return sort[0]['direction'] if sort && %w[ASC DESC].include?(sort[0]['direction'])
157
+ return 'ASC'
158
+ end
159
+
160
+ def filter_dates(datestr)
161
+ # change mm-dd-yyyy to yyyy-mm-dd
162
+ datestr =~ %r{(\d+)(/|:)(\d+)(/|:)(\d+)}
163
+ return "#{$5}-#{$1}-#{$3}"
164
+ end
165
+
166
+ def filter_params(<%= singular_table_name %>)
167
+ # filter booleans and dates
168
+ <% attributes.each do |attribute|
169
+ case attribute.type.to_s
170
+ when 'boolean' -%>
171
+ <%= singular_table_name %>[:<%= attribute.name %>] = <%= singular_table_name %>[:<%= attribute.name %>] ? 'true' : 'false'
172
+ <% when 'date' -%>
173
+ <%= singular_table_name -%>[:<%= attribute.name %>] = filter_dates(<%= singular_table_name %>[:<%= attribute.name %>])
174
+ <% end -%>
175
+ <% end -%>
176
+ return <%= singular_table_name %>
177
+ end
178
+
179
+ <%
180
+ related_attr = []
181
+ attributes.select {|attr| attr.reference? }.each do |attribute|
182
+ related_attr << ":#{attribute.name}_#{reference_field(attribute)}"
183
+ end
184
+ %>
185
+
186
+ # related attributes sent via json
187
+ def related_attributes
188
+ [<%= related_attr.join(",") %>]
189
+ end
190
+
191
+ end
@@ -0,0 +1,53 @@
1
+ Ext.define('<%= app_name %>.controller.<%= plural_table_name.capitalize %>', {
2
+ extend: 'Ext.app.Controller',
3
+
4
+ models: [<%= create_controller_model_list %>],
5
+ stores: [<%= create_controller_store_list %>],
6
+
7
+ init: function() {
8
+ this.control({
9
+ '<%= singular_table_name %>form': {
10
+ actioncomplete: this.onFormActionComplete
11
+ },
12
+ '<%= singular_table_name %>grid': {
13
+ afterrender: this.onGridAfterRender
14
+ },
15
+ '<%= singular_table_name %>updateform checkboxfield': {
16
+ change: this.onToggleUpdateFormField
17
+ }
18
+ })
19
+ },
20
+
21
+ onFormActionComplete: function(form, action){
22
+ if (action.type == 'load') {
23
+
24
+ <% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
25
+ // populate initial <%= attribute.name %> list value for existing records
26
+ var store = this.get<%= singular_table_name.capitalize %><%= attribute.name.capitalize.pluralize %>Store();
27
+ var <%= attribute.name %>_id = action.result.data.<%= attribute.name %>_id;
28
+ var <%= attribute.name %>_<%= reference_field(attribute) %> = action.result.data.<%= attribute.name %>_<%= reference_field(attribute) %>;
29
+ store.removeAll();
30
+ if (<%= attribute.name %>_id > 0) {
31
+ var newModel = Ext.ModelManager.create({id: <%= attribute.name %>_id, <%= reference_field(attribute) %>: <%= attribute.name %>_<%= reference_field(attribute) %>}, this.get<%= attribute.name.capitalize %>Model());
32
+ store.add(newModel);
33
+ form.findField('<%= attribute.name %>_<%= reference_field(attribute) %>').setValue(<%= attribute.name %>_id);
34
+ }
35
+ <% end -%>
36
+
37
+ }
38
+ },
39
+
40
+ onGridAfterRender: function(grid) {
41
+ grid.load();
42
+ },
43
+
44
+ onToggleUpdateFormField: function(checkbox, newValue, oldValue, eOpts) {
45
+ if (checkbox.nextSibling()) {
46
+ if (newValue == true) {
47
+ checkbox.nextSibling().enable();
48
+ } else {
49
+ checkbox.nextSibling().disable();
50
+ }
51
+ }
52
+ }
53
+ })
@@ -0,0 +1,17 @@
1
+ Ext.define('<%= app_name %>.view.<%= singular_table_name %>.EditForm', {
2
+ extend: '<%= app_name %>.ux.form.Panel',
3
+ alias: 'widget.<%= singular_table_name %>form',
4
+
5
+ initComponent: function() {
6
+ this.items = this.buildItems();
7
+ this.callParent(arguments);
8
+ },
9
+
10
+ buildItems: function() {
11
+ return [
12
+ <% attributes.each_with_index do |attribute, index| %>
13
+ <%= index > 0 ? ',' : '' %> <%= create_ext_formfield(attribute) -%>
14
+ <% end %>
15
+ ];
16
+ }
17
+ });
@@ -0,0 +1,27 @@
1
+ Ext.define('<%= app_name %>.view.<%= singular_table_name %>.EditWindow', {
2
+ extend: '<%= app_name %>.ux.window.EditWindow',
3
+
4
+ baseUrl: '/<%= plural_table_name %>',
5
+ model: '<%= app_name %>.model.<%= singular_table_name.capitalize %>',
6
+ formItemId: '<%= singular_table_name %>Form',
7
+
8
+ initComponent: function() {
9
+ this.items = this.buildItems();
10
+ this.callParent(arguments);
11
+ },
12
+
13
+ buildItems: function() {
14
+ var me = this;
15
+ var url = this.recordId > 0 ? me.baseUrl+'/'+this.recordId+'.json' : me.baseUrl+'.json';
16
+ var method = this.recordId > 0 ? 'PUT' : 'POST';
17
+ return [
18
+ {
19
+ xtype: '<%= singular_table_name %>form',
20
+ itemId: me.formItemId,
21
+ url: url,
22
+ method: method,
23
+ waitMsgTarget: true
24
+ }
25
+ ];
26
+ }
27
+ });
@@ -0,0 +1,26 @@
1
+ Ext.define('<%= app_name %>.view.<%= singular_table_name %>.Grid', {
2
+ extend: '<%= app_name %>.ux.grid.Panel',
3
+ alias: 'widget.<%= singular_table_name %>grid',
4
+ requires : ['<%= app_name %>.store.<%= plural_table_name.capitalize %>'],
5
+
6
+ title: '<%= plural_table_name.capitalize %>',
7
+
8
+ entitySingular: '<%= singular_table_name.capitalize %>',
9
+ entityPlural: '<%= plural_table_name.capitalize %>',
10
+ editWindow: '<%= app_name %>.view.<%= singular_table_name %>.EditWindow',
11
+ updateWindow: '<%= app_name %>.view.<%= singular_table_name %>.UpdateWindow',
12
+
13
+ initComponent: function() {
14
+ this.store = <%= app_name %>.store.<%= plural_table_name.capitalize %>;
15
+ this.columns = this.buildColumns();
16
+ this.callParent(arguments);
17
+ },
18
+
19
+ buildColumns: function() {
20
+ return [
21
+ <% attributes.each_with_index do |attribute, index| %>
22
+ <%= index > 0 ? ',' : '' %>{<%= create_ext_column(attribute) -%>}
23
+ <% end %>
24
+ ];
25
+ }
26
+ });
@@ -0,0 +1,43 @@
1
+ Ext.define('<%= app_name %>.model.<%= singular_table_name.capitalize %>', {
2
+ extend: 'Ext.data.Model',
3
+ mixins: {
4
+ updateable: '<%= app_name %>.ux.data.Updateable'
5
+ },
6
+
7
+ fields: [
8
+ { name: 'id', type: 'int' }
9
+ <% attributes.each_with_index do |attribute, index| %>
10
+ ,{<%= create_ext_record(attribute) -%>}
11
+ <% if attribute.reference? -%>
12
+ ,{name: '<%= attribute.name %>_id'}
13
+ <% end %>
14
+ <% end %>
15
+ ],
16
+
17
+ proxy: {
18
+ type: 'rails',
19
+ url: '/<%= plural_table_name %>',
20
+ format: 'json',
21
+ addActions: {
22
+ destroy_all: {
23
+ method: 'POST',
24
+ collection: true
25
+ },
26
+ update_all: {
27
+ method: 'POST',
28
+ collection: true
29
+ }
30
+ },
31
+ reader: {
32
+ type: 'json',
33
+ root: '<%= singular_table_name %>'
34
+ },
35
+ writer: {
36
+ type: 'json',
37
+ root: '<%= singular_table_name %>',
38
+ encode: true,
39
+ writeAllFields: true,
40
+ allowSingle: false
41
+ }
42
+ }
43
+ });
@@ -0,0 +1,27 @@
1
+ Ext.define('<%= app_name %>.store.<%= singular_table_name.capitalize %><%= @reference_attribute.name.capitalize.pluralize %>', {
2
+ extend: 'Ext.data.Store',
3
+
4
+ singleton: true,
5
+ requires: ['<%= app_name %>.model.<%= @reference_attribute.name.capitalize %>'],
6
+ model: '<%= app_name %>.model.<%= @reference_attribute.name.capitalize %>',
7
+
8
+ storeId: '<%= singular_table_name.capitalize %><%= @reference_attribute.name.capitalize.pluralize %>',
9
+ autoLoad: false,
10
+ remoteSort: true,
11
+ sorters: [
12
+ {
13
+ property: '<%= reference_field(@reference_attribute) %>',
14
+ direction: 'ASC'
15
+ }
16
+ ],
17
+
18
+ proxy: {
19
+ type: 'rest',
20
+ url: '/<%= @reference_attribute.name.pluralize %>',
21
+ format: 'json',
22
+ reader: {
23
+ type: 'json',
24
+ root: '<%= @reference_attribute.name %>'
25
+ }
26
+ }
27
+ });
@@ -0,0 +1,28 @@
1
+ <%
2
+ #default sort to first attribute
3
+ sort_column = attributes.first ? attributes.first.name : ''
4
+ if attributes.first && attributes.first.reference?
5
+ sort_column += '_name'
6
+ end -%>
7
+ Ext.define('<%= app_name %>.store.<%= plural_table_name.capitalize %>', {
8
+ extend: 'Ext.data.Store',
9
+ mixins: {
10
+ actionable: '<%= app_name %>.ux.data.Actionable'
11
+ },
12
+
13
+ singleton: true,
14
+ requires: ['<%= app_name %>.model.<%= singular_table_name.capitalize %>'],
15
+ model: '<%= app_name %>.model.<%= singular_table_name.capitalize %>',
16
+
17
+ storeId: '<%= singular_table_name %>Store',
18
+ autoLoad: false,
19
+ remoteSort: true,
20
+ buffered: true,
21
+ pageSize: 200,
22
+ sorters: [
23
+ {
24
+ property: '<%= sort_column %>',
25
+ direction: 'ASC'
26
+ }
27
+ ]
28
+ });
@@ -0,0 +1,17 @@
1
+ Ext.define('<%= app_name %>.view.<%= singular_table_name %>.UpdateForm', {
2
+ extend: '<%= app_name %>.ux.form.Panel',
3
+ alias: 'widget.<%= singular_table_name %>updateform',
4
+
5
+ initComponent: function() {
6
+ this.items = this.buildItems();
7
+ this.callParent(arguments);
8
+ },
9
+
10
+ buildItems: function() {
11
+ return [
12
+ <% attributes.each_with_index do |attribute, index| %>
13
+ <%= index > 0 ? ',' : '' %> <%= create_ext_updateformfield(attribute) -%>
14
+ <% end %>
15
+ ];
16
+ }
17
+ });
@@ -0,0 +1,21 @@
1
+ Ext.define('<%= app_name %>.view.<%= singular_table_name %>.UpdateWindow', {
2
+ extend: '<%= app_name %>.ux.window.UpdateWindow',
3
+
4
+ model: '<%= app_name %>.model.<%= singular_table_name.capitalize %>',
5
+ formItemId: '<%= singular_table_name %>UpdateForm',
6
+
7
+ initComponent: function() {
8
+ this.items = this.buildItems();
9
+ this.callParent(arguments);
10
+ },
11
+
12
+ buildItems: function() {
13
+ var me = this;
14
+ return [
15
+ {
16
+ xtype: '<%= singular_table_name %>updateform',
17
+ itemId: me.formItemId
18
+ }
19
+ ];
20
+ }
21
+ });