erp_forms 2.0.6 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/erp_forms/erp_app/desktop/dynamic_forms/base_controller.rb +4 -37
- data/app/controllers/erp_forms/erp_app/desktop/dynamic_forms/data_controller.rb +348 -82
- data/app/controllers/erp_forms/erp_app/desktop/dynamic_forms/forms_controller.rb +110 -15
- data/app/controllers/erp_forms/erp_app/desktop/dynamic_forms/models_controller.rb +19 -3
- data/app/mailers/dynamic_form_mailer.rb +35 -0
- data/app/models/dynamic_datum.rb +97 -22
- data/app/models/dynamic_form.rb +172 -98
- data/app/models/dynamic_form_document.rb +4 -11
- data/app/models/dynamic_form_model.rb +46 -22
- data/app/models/ticket.rb +4 -0
- data/app/views/dynamic_form_mailer/widget_email_with_attachments.html.erb +3 -0
- data/app/views/dynamic_form_mailer/widget_email_with_attachments.text.erb +3 -0
- data/app/widgets/dynamic_forms/base.rb +101 -19
- data/app/widgets/dynamic_forms/javascript/dynamic_forms.js +40 -38
- data/app/widgets/dynamic_forms/views/error.html.erb +1 -0
- data/db/data_migrations/20110608185830_create_default_dynamic_models_and_forms.rb +2 -0
- data/db/data_migrations/20120824013449_create_ticket_form.rb +1 -0
- data/db/data_migrations/20121026013449_update_ticket_form.rb +64 -0
- data/db/data_migrations/{20120904191738_update_contact_form.rb → 20121026191738_update_contact_form.rb} +4 -0
- data/db/migrate/20110530193446_dynamic_forms.rb +12 -0
- data/db/migrate/20121007022323_upgrade_dynamic_forms_table.rb +31 -0
- data/lib/erp_forms.rb +4 -0
- data/lib/erp_forms/dynamic_form_field.rb +31 -28
- data/lib/erp_forms/dynamic_grid_column.rb +2 -2
- data/lib/erp_forms/engine.rb +5 -0
- data/lib/erp_forms/extensions/active_record/acts_as_commentable.rb +33 -0
- data/lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb +80 -0
- data/lib/erp_forms/extensions/active_record/has_dynamic_forms.rb +4 -4
- data/lib/erp_forms/extensions/extensions.rb +2 -0
- data/lib/erp_forms/extensions/railties/action_view.rb +2 -2
- data/lib/erp_forms/version.rb +2 -2
- data/public/javascripts/erp_app/desktop/applications/dynamic_forms/center_region.js +2 -1
- data/public/javascripts/erp_app/desktop/applications/dynamic_forms/dynamic_data_grid.js +264 -82
- data/public/javascripts/erp_app/desktop/applications/dynamic_forms/form_builder.js +1476 -58
- data/public/javascripts/erp_app/desktop/applications/dynamic_forms/module.js +24 -1
- data/public/javascripts/erp_app/desktop/applications/dynamic_forms/west_region.js +493 -210
- data/public/javascripts/erp_app/shared/dynamic_forms/dynamic_form_fields.js +82 -20
- data/public/javascripts/erp_app/shared/dynamic_forms/dynamic_forms_validation.js +23 -3
- data/spec/dummy/config/application.rb +6 -2
- data/spec/dummy/config/environments/spec.rb +3 -0
- data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +15 -0
- data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20110608185830_create_default_dynamic_models_and_forms.erp_forms.rb +33 -0
- data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
- data/spec/dummy/db/data_migrations/20110728201729_erp_app_setup.erp_app.rb +252 -0
- data/spec/dummy/db/data_migrations/20110728201733_update_preferences.erp_app.rb +53 -0
- data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +16 -0
- data/spec/dummy/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.erp_app.rb +21 -0
- data/spec/dummy/db/data_migrations/20110817160743_add_file_manager_application.erp_app.rb +32 -0
- data/spec/dummy/db/data_migrations/20110828190913_create_desktop_app_dynamic_forms.erp_forms.rb +19 -0
- data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20111108183739_add_default_capabilities.erp_app.rb +23 -0
- data/spec/dummy/db/data_migrations/20111108183740_add_new_contact_widgets.erp_app.rb +42 -0
- data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +22 -0
- data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +14 -0
- data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +29 -0
- data/spec/dummy/db/data_migrations/20120405193721_create_party_and_role_type_for_communication_events.erp_app.rb +11 -0
- data/spec/dummy/db/data_migrations/20120411180756_create_user_management_mobile_application.erp_app.rb +19 -0
- data/spec/dummy/db/data_migrations/20120418164215_create_configuration_management_desktop_application.erp_app.rb +23 -0
- data/spec/dummy/db/data_migrations/20120824013449_create_ticket_form.erp_forms.rb +67 -0
- data/spec/dummy/db/data_migrations/20121026013449_update_ticket_form.erp_forms.rb +65 -0
- data/spec/dummy/db/data_migrations/20121026191738_update_contact_form.erp_forms.rb +27 -0
- data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +20 -0
- data/spec/dummy/db/data_migrations/20121130201859_upgrade_remove_system_mgmt_app.erp_app.rb +16 -0
- data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +24 -0
- data/spec/dummy/db/data_migrations/20121218175028_create_security_management_desktop_application.erp_app.rb +23 -0
- data/spec/dummy/db/migrate/20121213234847_base_erp_services.erp_base_erp_svcs.rb +461 -0
- data/spec/dummy/db/migrate/20121213234848_base_tech_services.erp_tech_svcs.rb +255 -0
- data/spec/dummy/db/migrate/20121213234849_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
- data/spec/dummy/db/migrate/20121213234850_base_app_framework.erp_app.rb +276 -0
- data/spec/dummy/db/migrate/20121213234851_dynamic_forms.erp_forms.rb +95 -0
- data/spec/dummy/db/migrate/20121213234852_create_tickets.erp_forms.rb +19 -0
- data/spec/dummy/db/migrate/20121213234853_upgrade_dynamic_forms_table.erp_forms.rb +32 -0
- data/spec/dummy/db/migrate/20130107181041_create_groups.erp_tech_svcs.rb +19 -0
- data/spec/dummy/db/migrate/20130107181042_upgrade_security.erp_tech_svcs.rb +54 -0
- data/spec/dummy/db/migrate/20130107181043_upgrade_security2.erp_tech_svcs.rb +270 -0
- data/spec/dummy/db/schema.rb +879 -0
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/spec.log +13580 -0
- data/spec/models/dynamic_form_model_spec.rb +1 -1
- data/spec/spec_helper.rb +11 -3
- metadata +136 -14
@@ -1,3 +1,26 @@
|
|
1
|
+
Ext.define("Compass.ErpForms.DynamicForms.DynamicFormPanel",{
|
2
|
+
extend:"Ext.form.Panel",
|
3
|
+
alias:'widget.dynamic_form_panel',
|
4
|
+
|
5
|
+
// CALLBACK USAGE EXAMPLE:
|
6
|
+
// 'afterrender':function(panel){
|
7
|
+
// panel.query('dynamic_form_panel').first().addListener('afterupdate', function(){
|
8
|
+
// console.log('afterupdate');
|
9
|
+
// });
|
10
|
+
// }
|
11
|
+
initComponent: function() {
|
12
|
+
this.callParent(arguments);
|
13
|
+
this.addEvents(
|
14
|
+
'aftercreate',
|
15
|
+
'afterupdate'
|
16
|
+
);
|
17
|
+
},
|
18
|
+
|
19
|
+
constructor : function(config) {
|
20
|
+
this.callParent([config]);
|
21
|
+
}
|
22
|
+
});
|
23
|
+
|
1
24
|
Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms",{
|
2
25
|
extend:"Ext.ux.desktop.Module",
|
3
26
|
id:'dynamic_forms-win',
|
@@ -7,7 +30,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms",{
|
|
7
30
|
iconCls:'icon-document',
|
8
31
|
handler: this.createWindow,
|
9
32
|
scope: this
|
10
|
-
}
|
33
|
+
};
|
11
34
|
},
|
12
35
|
|
13
36
|
createWindow : function(){
|
@@ -24,15 +24,15 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
24
24
|
url: '/erp_forms/erp_app/desktop/dynamic_forms/models/delete',
|
25
25
|
method: 'POST',
|
26
26
|
params:{
|
27
|
-
id:node.data.
|
27
|
+
id:node.data.formModelId
|
28
28
|
},
|
29
29
|
success: function(response) {
|
30
30
|
self.clearWindowStatus();
|
31
31
|
var obj = Ext.decode(response.responseText);
|
32
32
|
if(obj.success){
|
33
33
|
//node.remove(true); // remove node causing a reload of entire tree with error, so we are going to simply reload tree for now
|
34
|
-
self.
|
35
|
-
node: self.
|
34
|
+
self.formsTree.getStore().load({
|
35
|
+
node: self.formsTree.getRootNode()
|
36
36
|
});
|
37
37
|
}
|
38
38
|
else{
|
@@ -68,7 +68,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
68
68
|
self.clearWindowStatus();
|
69
69
|
var obj = Ext.decode(response.responseText);
|
70
70
|
if(obj.success){
|
71
|
-
node.remove(
|
71
|
+
node.remove(false);
|
72
72
|
}
|
73
73
|
else{
|
74
74
|
Ext.Msg.alert('Error', 'Error deleting form');
|
@@ -91,17 +91,17 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
91
91
|
method: 'POST',
|
92
92
|
params:{
|
93
93
|
id:node.data.formId,
|
94
|
-
model_name:node.data.
|
94
|
+
model_name:node.data.formModelName
|
95
95
|
},
|
96
96
|
success: function(response) {
|
97
97
|
self.clearWindowStatus();
|
98
98
|
var obj = Ext.decode(response.responseText);
|
99
99
|
if(obj.success){
|
100
100
|
//reload model tree node
|
101
|
-
self.
|
101
|
+
self.formsTree.getStore().load({
|
102
102
|
// node:node.parentNode
|
103
103
|
});
|
104
|
-
node.parentNode.expand();
|
104
|
+
//node.parentNode.expand();
|
105
105
|
}
|
106
106
|
else{
|
107
107
|
Ext.Msg.alert('Error', 'Error setting default form');
|
@@ -114,40 +114,215 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
114
114
|
});
|
115
115
|
},
|
116
116
|
|
117
|
-
|
117
|
+
addDynamicForm : function(record){
|
118
118
|
var self = this;
|
119
|
-
|
120
|
-
Ext.
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
119
|
+
|
120
|
+
var newFormWindow = Ext.create("Ext.window.Window",{
|
121
|
+
layout:'fit',
|
122
|
+
width:375,
|
123
|
+
title:'New Dynamic Form',
|
124
|
+
height:100,
|
125
|
+
plain: true,
|
126
|
+
buttonAlign:'center',
|
127
|
+
items: Ext.create("Ext.form.Panel",{
|
128
|
+
labelWidth: 110,
|
129
|
+
frame:false,
|
130
|
+
bodyStyle:'padding:5px 5px 0',
|
131
|
+
defaults: {
|
132
|
+
width: 225
|
133
|
+
},
|
134
|
+
items: [
|
135
|
+
{
|
136
|
+
xtype:'textfield',
|
137
|
+
fieldLabel:'Form Title',
|
138
|
+
allowBlank:false,
|
139
|
+
name:'form_name',
|
140
|
+
listeners:{
|
141
|
+
afterrender:function(field){
|
142
|
+
field.focus(false, 200);
|
143
|
+
},
|
144
|
+
'specialkey': function(field, e){
|
145
|
+
if (e.getKey() == e.ENTER) {
|
146
|
+
var button = field.findParentByType('window').query('#submitButton').first();
|
147
|
+
button.fireEvent('click', button);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
139
151
|
}
|
152
|
+
]
|
153
|
+
}),
|
154
|
+
buttons: [{
|
155
|
+
itemId: 'submitButton',
|
156
|
+
text:'Submit',
|
157
|
+
listeners:{
|
158
|
+
'click':function(button){
|
159
|
+
var window = button.findParentByType('window');
|
160
|
+
var formPanel = window.query('form')[0];
|
161
|
+
var form_name = formPanel.getForm().findField('form_name').getValue();
|
140
162
|
|
141
|
-
|
163
|
+
var form_tab = Ext.getCmp('formBuilder_'+form_name);
|
164
|
+
if (form_tab){
|
165
|
+
this.centerRegion.workArea.setActiveTab(form_tab);
|
166
|
+
return;
|
167
|
+
}
|
168
|
+
|
169
|
+
var formBuilder = Ext.create('Compass.ErpApp.Desktop.Applications.DynamicForms.FormBuilder', {
|
170
|
+
title: form_name,
|
171
|
+
model_name: record.get('text')
|
172
|
+
});
|
173
|
+
self.centerRegion.workArea.add(formBuilder);
|
174
|
+
self.centerRegion.workArea.setActiveTab(self.centerRegion.workArea.items.length - 1);
|
175
|
+
|
176
|
+
var form_props = formBuilder.query('#form_props').first().getForm();
|
177
|
+
form_props.findField('description').setValue(form_name);
|
178
|
+
form_props.findField('widget_action').setValue('save');
|
179
|
+
form_props.findField('submit_button_label').setValue('Submit');
|
180
|
+
form_props.findField('cancel_button_label').setValue('Cancel');
|
181
|
+
Ext.getCmp('dynamic_forms_westregion').setActiveTab('field_types');
|
182
|
+
var east_tabs = formBuilder.query('#east_tabs').first();
|
183
|
+
east_tabs.setActiveTab('form_props');
|
184
|
+
|
185
|
+
newFormWindow.close();
|
186
|
+
}
|
187
|
+
}
|
188
|
+
},
|
189
|
+
{
|
190
|
+
text: 'Close',
|
191
|
+
handler: function(){
|
192
|
+
newFormWindow.close();
|
193
|
+
}
|
194
|
+
}]
|
195
|
+
});
|
196
|
+
newFormWindow.show();
|
197
|
+
},
|
198
|
+
|
199
|
+
configureFormModel : function(record){
|
200
|
+
var self = this;
|
201
|
+
|
202
|
+
var configureModelWindow = Ext.create("Ext.window.Window",{
|
203
|
+
layout:'fit',
|
204
|
+
width:375,
|
205
|
+
title:'Configure Dynamic Form Model',
|
206
|
+
plain: true,
|
207
|
+
buttonAlign:'center',
|
208
|
+
items: Ext.create("Ext.form.Panel",{
|
209
|
+
itemId:'configureModelForm',
|
210
|
+
labelWidth: 110,
|
211
|
+
frame:false,
|
212
|
+
bodyStyle:'padding:5px 5px 0',
|
213
|
+
url:'/erp_forms/erp_app/desktop/dynamic_forms/models/update',
|
214
|
+
defaults: {
|
215
|
+
width: 225
|
216
|
+
},
|
217
|
+
items: [
|
218
|
+
{
|
219
|
+
xtype: 'checkbox',
|
220
|
+
fieldLabel: 'Allow Comments',
|
221
|
+
name: 'allow_comments',
|
222
|
+
inputValue: true,
|
223
|
+
uncheckedValue:false,
|
224
|
+
plugins: [new helpQtip("Do you want to allow comments on this model's records?")]
|
225
|
+
},
|
226
|
+
{
|
227
|
+
xtype: 'checkbox',
|
228
|
+
fieldLabel: 'Allow Files',
|
229
|
+
name: 'allow_files',
|
230
|
+
inputValue: true,
|
231
|
+
uncheckedValue:false,
|
232
|
+
plugins: [new helpQtip("Do you want to allow files to be attached to this model's records?")]
|
233
|
+
},
|
234
|
+
{
|
235
|
+
xtype:'combobox',
|
236
|
+
fieldLabel:'File Security Default',
|
237
|
+
name:'file_security_default',
|
238
|
+
allowBlank:false,
|
239
|
+
editable: false,
|
240
|
+
forceSelection:true,
|
241
|
+
store:[
|
242
|
+
['private','Private'],
|
243
|
+
['public','Public']
|
244
|
+
],
|
245
|
+
plugins: [new helpQtip("Should attached files be automatically secured? If so, select Private. If not, select Public.")]
|
246
|
+
}]
|
247
|
+
}),
|
248
|
+
buttons: [{
|
249
|
+
text:'Submit',
|
250
|
+
listeners:{
|
251
|
+
'click':function(button){
|
252
|
+
var formPanel = button.findParentByType('window').query('form').first();
|
253
|
+
self.setWindowStatus('Updating dynamic form model ...');
|
254
|
+
var form = formPanel.getForm();
|
255
|
+
if (form.isValid()){
|
256
|
+
form.submit({
|
257
|
+
params:{
|
258
|
+
id: record.get("formModelId")
|
259
|
+
},
|
260
|
+
success:function(form, action){
|
261
|
+
self.clearWindowStatus();
|
262
|
+
var obj = Ext.decode(action.response.responseText);
|
263
|
+
if(obj.success){
|
264
|
+
self.formsTree.getStore().load({
|
265
|
+
node: self.formsTree.getRootNode()
|
266
|
+
});
|
267
|
+
configureModelWindow.close();
|
268
|
+
}else{
|
269
|
+
Ext.Msg.alert("Error", obj.message);
|
270
|
+
}
|
271
|
+
},
|
272
|
+
failure:function(form, action){
|
273
|
+
self.clearWindowStatus();
|
274
|
+
var obj = Ext.decode(action.response.responseText);
|
275
|
+
if(obj !== null){
|
276
|
+
Ext.Msg.alert("Error", obj.message);
|
277
|
+
}else{
|
278
|
+
Ext.Msg.alert("Error", "Error updating form model");
|
279
|
+
}
|
280
|
+
}
|
281
|
+
});
|
142
282
|
}
|
143
|
-
}
|
144
|
-
|
145
|
-
},
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
283
|
+
}
|
284
|
+
}
|
285
|
+
},{
|
286
|
+
text: 'Close',
|
287
|
+
handler: function(){
|
288
|
+
configureModelWindow.close();
|
289
|
+
}
|
290
|
+
}]
|
291
|
+
});
|
292
|
+
configureModelWindow.query('#configureModelForm').first().loadRecord(record);
|
293
|
+
configureModelWindow.show();
|
294
|
+
},
|
295
|
+
|
296
|
+
openFormTab : function(record){
|
297
|
+
var formBuilder = Ext.create('Compass.ErpApp.Desktop.Applications.DynamicForms.FormBuilder', {
|
298
|
+
title: record.get('description'),
|
299
|
+
model_name: record.get('model_name'),
|
300
|
+
form_id: record.get('id'),
|
301
|
+
form_definition: Ext.decode(record.get('definition')),
|
302
|
+
msg_target: record.get('msg_target')
|
150
303
|
});
|
304
|
+
this.centerRegion.workArea.add(formBuilder);
|
305
|
+
this.centerRegion.workArea.setActiveTab(this.centerRegion.workArea.items.length - 1);
|
306
|
+
|
307
|
+
var form_props = formBuilder.query('#form_props').first().getForm();
|
308
|
+
form_props.loadRecord(record);
|
309
|
+
Ext.getCmp('dynamic_forms_westregion').setActiveTab('field_types');
|
310
|
+
var east_tabs = formBuilder.query('#east_tabs').first();
|
311
|
+
east_tabs.setActiveTab('form_props');
|
312
|
+
},
|
313
|
+
|
314
|
+
getDynamicForm : function(record){
|
315
|
+
var self = this;
|
316
|
+
form_tab = Ext.getCmp('formBuilder_'+record.get('text'));
|
317
|
+
|
318
|
+
if (form_tab){
|
319
|
+
this.centerRegion.workArea.setActiveTab(form_tab);
|
320
|
+
return;
|
321
|
+
}
|
322
|
+
|
323
|
+
self.setWindowStatus('Loading dynamic form...');
|
324
|
+
Ext.getStore('dynamicFormStore').load({ params:{ id:record.get('formId') }});
|
325
|
+
self.clearWindowStatus();
|
151
326
|
},
|
152
327
|
|
153
328
|
getDynamicData : function(record, title){
|
@@ -192,18 +367,31 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
192
367
|
success: function(response) {
|
193
368
|
self.clearWindowStatus();
|
194
369
|
form_definition = Ext.decode(response.responseText);
|
195
|
-
if (form_definition.success
|
370
|
+
if (form_definition.success === false){
|
196
371
|
Ext.Msg.alert('Error', form_definition.error);
|
197
372
|
}else{
|
198
|
-
var
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
373
|
+
var newRecordPanel = Ext.create('Ext.panel.Panel',{
|
374
|
+
itemId: record.get("text")+'-new',
|
375
|
+
layout: 'border',
|
376
|
+
title: 'New '+record.get("text"),
|
377
|
+
closable: true,
|
378
|
+
autoScroll: true,
|
379
|
+
items: [form_definition],
|
380
|
+
listeners:{
|
381
|
+
'afterrender':function(panel){
|
382
|
+
panel.query('dynamic_form_panel').first().addListener('aftercreate', function(args){
|
383
|
+
// close and reopen tab
|
384
|
+
var tabPanel = panel.findParentByType('tabpanel');
|
385
|
+
tabPanel.remove(panel);
|
386
|
+
Ext.getCmp(record.data.text).editRecord(args.record);
|
387
|
+
// reload grid
|
388
|
+
tabPanel.query('#'+record.get("text")).first().query('shared_dynamiceditablegrid').first().getStore().load({});
|
389
|
+
});
|
390
|
+
}
|
391
|
+
}
|
205
392
|
});
|
206
|
-
|
393
|
+
self.centerRegion.workArea.add(newRecordPanel);
|
394
|
+
self.centerRegion.workArea.setActiveTab(self.centerRegion.workArea.items.length - 1);
|
207
395
|
}
|
208
396
|
},
|
209
397
|
failure: function(response) {
|
@@ -212,6 +400,65 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
212
400
|
}
|
213
401
|
});
|
214
402
|
}
|
403
|
+
},
|
404
|
+
{
|
405
|
+
text: "Edit Selected Record",
|
406
|
+
iconCls:'icon-edit',
|
407
|
+
handler:function(btn){
|
408
|
+
var rec = Ext.getCmp(record.data.text).query('shared_dynamiceditablegrid').first().getSelectionModel().getSelection().first();
|
409
|
+
if (rec) {
|
410
|
+
Ext.getCmp(record.data.text).editRecord(rec);
|
411
|
+
}else{
|
412
|
+
Ext.Msg.alert('Error', 'No record selected.');
|
413
|
+
}
|
414
|
+
}
|
415
|
+
},
|
416
|
+
{
|
417
|
+
text: "Delete Selected Record",
|
418
|
+
iconCls:'icon-delete',
|
419
|
+
handler:function(btn){
|
420
|
+
var rec = Ext.getCmp(record.data.text).query('shared_dynamiceditablegrid').first().getSelectionModel().getSelection().first();
|
421
|
+
if (rec){
|
422
|
+
var messageBox = Ext.MessageBox.confirm('Confirm', 'Are you sure?', function(btn){
|
423
|
+
if (btn == 'yes') Ext.getCmp(record.data.text).deleteRecord(rec, record.data.text);
|
424
|
+
});
|
425
|
+
}else{
|
426
|
+
Ext.Msg.alert('Error', 'No record selected.');
|
427
|
+
}
|
428
|
+
}
|
429
|
+
},
|
430
|
+
{xtype: 'tbspacer', width: 10},
|
431
|
+
{
|
432
|
+
fieldLabel: '<span data-qtitle="Search" data-qwidth="200" data-qtip="">Search</span>',
|
433
|
+
labelWidth : 40,
|
434
|
+
itemId: 'dynamicDataSearchValue',
|
435
|
+
xtype: 'textfield',
|
436
|
+
width: 180,
|
437
|
+
value: '',
|
438
|
+
listeners:{
|
439
|
+
specialkey: function(field, e){
|
440
|
+
if (e.getKey() == e.ENTER) {
|
441
|
+
var grid = field.findParentByType('tabpanel').query('#centerRegionLayout_'+record.data.text).first();
|
442
|
+
var button = grid.query('#searchButton').first();
|
443
|
+
button.fireEvent('click', button);
|
444
|
+
}
|
445
|
+
}
|
446
|
+
}
|
447
|
+
},
|
448
|
+
{xtype: 'tbspacer', width: 1},
|
449
|
+
{
|
450
|
+
xtype: 'button',
|
451
|
+
itemId: 'searchButton',
|
452
|
+
iconCls: 'x-btn-icon icon-search',
|
453
|
+
listeners:{
|
454
|
+
click: function(button) {
|
455
|
+
var grid = button.findParentByType('tabpanel').query('#centerRegionLayout_'+record.data.text).first();
|
456
|
+
var value = grid.query('#dynamicDataSearchValue').first().getValue();
|
457
|
+
grid.query('shared_dynamiceditablegrid').first().getStore().load({
|
458
|
+
params: {query_filter: value}
|
459
|
+
});
|
460
|
+
}
|
461
|
+
}
|
215
462
|
}
|
216
463
|
]
|
217
464
|
}
|
@@ -222,95 +469,186 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
222
469
|
},
|
223
470
|
|
224
471
|
initComponent: function() {
|
472
|
+
this.callParent(arguments);
|
473
|
+
},
|
474
|
+
|
475
|
+
constructor : function(config) {
|
225
476
|
var self = this;
|
226
|
-
|
477
|
+
|
478
|
+
Ext.define('FormsTreeNode', {
|
479
|
+
extend: 'Ext.data.Model',
|
480
|
+
fields: [
|
481
|
+
{name: 'id', type: 'string'},
|
482
|
+
{name: 'text', type: 'string'},
|
483
|
+
{name: 'iconCls', type: 'string'},
|
484
|
+
{name: 'isFormModel', type: 'boolean'},
|
485
|
+
{name: 'allow_comments', type: 'boolean'},
|
486
|
+
{name: 'allow_files', type: 'boolean'},
|
487
|
+
{name: 'file_security_default', type: 'string'},
|
488
|
+
{name: 'show_in_multitask', type: 'boolean'},
|
489
|
+
{name: 'formModelName', type: 'string'},
|
490
|
+
{name: 'isDefaultForm', type: 'boolean'},
|
491
|
+
{name: 'isForm', type: 'boolean'},
|
492
|
+
{name: 'formModelId', type: 'int'},
|
493
|
+
{name: 'formId', type: 'int'},
|
494
|
+
{name: 'leaf', type: 'boolean'}
|
495
|
+
]
|
496
|
+
});
|
497
|
+
|
227
498
|
var store = Ext.create('Ext.data.TreeStore', {
|
499
|
+
storeId: 'formsTreeStore',
|
500
|
+
model: 'FormsTreeNode',
|
501
|
+
folderSort: true,
|
502
|
+
autoLoad: false,
|
503
|
+
sorters: [{
|
504
|
+
property:'text',
|
505
|
+
direction: 'ASC'
|
506
|
+
}],
|
228
507
|
proxy:{
|
229
508
|
type: 'ajax',
|
230
509
|
url: '/erp_forms/erp_app/desktop/dynamic_forms/forms/get_tree'
|
231
|
-
},
|
510
|
+
},
|
232
511
|
root: {
|
233
512
|
text: 'Dynamic Forms',
|
234
513
|
expanded: true
|
235
|
-
},
|
236
|
-
fields:[
|
237
|
-
{
|
238
|
-
name:'id'
|
239
|
-
},
|
240
|
-
{
|
241
|
-
name:'iconCls'
|
242
|
-
},
|
243
|
-
{
|
244
|
-
name:'text',
|
245
|
-
sortDir: 'ASC'
|
246
|
-
},
|
247
|
-
{
|
248
|
-
name:'isModel'
|
249
|
-
},
|
250
|
-
{
|
251
|
-
name:'modelName'
|
252
|
-
},
|
253
|
-
{
|
254
|
-
name:'isDefault'
|
255
|
-
},
|
256
|
-
{
|
257
|
-
name:'isForm'
|
258
|
-
},
|
259
|
-
{
|
260
|
-
name:'modelId'
|
261
|
-
},
|
262
|
-
{
|
263
|
-
name:'formId'
|
264
|
-
},
|
265
|
-
{
|
266
|
-
name:'leaf'
|
267
|
-
},
|
268
|
-
{
|
269
|
-
name:'children'
|
270
|
-
}
|
271
|
-
],
|
272
|
-
listeners:{
|
273
|
-
// these listeners are a workaround for a extjs 4.0.7 bug
|
274
|
-
// reference: http://www.sencha.com/forum/showthread.php?151211-Reloading-TreeStore-adds-all-records-to-store-getRemovedRecords&p=661157#post661157
|
275
|
-
'beforeload': function()
|
276
|
-
{
|
277
|
-
this.clearOnLoad = false;
|
278
|
-
this.getRootNode().removeAll();
|
279
|
-
},
|
280
|
-
'afterload': function()
|
281
|
-
{
|
282
|
-
this.removed = [];
|
283
|
-
}
|
284
514
|
}
|
285
515
|
});
|
286
516
|
|
287
|
-
this.
|
517
|
+
this.formsTree = Ext.create("Ext.tree.Panel",{
|
518
|
+
title: 'Models & Forms',
|
288
519
|
store:store,
|
289
|
-
dataUrl: '/erp_forms/erp_app/desktop/dynamic_forms/forms/get_tree',
|
290
|
-
region: 'center',
|
291
520
|
rootVisible:false,
|
292
|
-
|
521
|
+
autoScroll: true,
|
522
|
+
tbar:{
|
523
|
+
items:[
|
524
|
+
{
|
525
|
+
text:'New Form Model',
|
526
|
+
iconCls:'icon-add',
|
527
|
+
handler:function(btn){
|
528
|
+
var newModelWindow = Ext.create("Ext.window.Window",{
|
529
|
+
layout:'fit',
|
530
|
+
width:375,
|
531
|
+
title:'New Dynamic Form Model',
|
532
|
+
//height:100,
|
533
|
+
plain: true,
|
534
|
+
buttonAlign:'center',
|
535
|
+
items: Ext.create("Ext.form.Panel",{
|
536
|
+
labelWidth: 110,
|
537
|
+
frame:false,
|
538
|
+
bodyStyle:'padding:5px 5px 0',
|
539
|
+
url:'/erp_forms/erp_app/desktop/dynamic_forms/models/create',
|
540
|
+
defaults: {
|
541
|
+
width: 225
|
542
|
+
},
|
543
|
+
items: [{
|
544
|
+
xtype:'textfield',
|
545
|
+
fieldLabel:'Model Name',
|
546
|
+
allowBlank:false,
|
547
|
+
name:'model_name',
|
548
|
+
plugins: [new helpQtip('This should be a camel case class name.<br /> Example: WebsiteInquiry')],
|
549
|
+
vtype: 'alphanum',
|
550
|
+
listeners:{
|
551
|
+
afterrender:function(field){
|
552
|
+
field.focus(false, 200);
|
553
|
+
},
|
554
|
+
'specialkey': function(field, e){
|
555
|
+
if (e.getKey() == e.ENTER) {
|
556
|
+
var button = field.findParentByType('window').query('#submitButton').first();
|
557
|
+
button.fireEvent('click', button);
|
558
|
+
}
|
559
|
+
}
|
560
|
+
}
|
561
|
+
},
|
562
|
+
{
|
563
|
+
xtype: 'checkbox',
|
564
|
+
fieldLabel: 'Allow Comments',
|
565
|
+
name: 'allow_comments',
|
566
|
+
inputValue: true,
|
567
|
+
uncheckedValue:false,
|
568
|
+
plugins: [new helpQtip("Do you want to allow comments on this model's records?")]
|
569
|
+
},
|
570
|
+
{
|
571
|
+
xtype: 'checkbox',
|
572
|
+
fieldLabel: 'Allow Files',
|
573
|
+
name: 'allow_files',
|
574
|
+
inputValue: true,
|
575
|
+
uncheckedValue:false,
|
576
|
+
plugins: [new helpQtip("Do you want to allow files to be attached to this model's records?")]
|
577
|
+
},
|
578
|
+
{
|
579
|
+
xtype:'combobox',
|
580
|
+
fieldLabel:'File Security Default',
|
581
|
+
allowBlank:false,
|
582
|
+
name:'file_security_default',
|
583
|
+
value: 'private',
|
584
|
+
store:[
|
585
|
+
['private','Private'],
|
586
|
+
['public','Public']
|
587
|
+
]
|
588
|
+
}]
|
589
|
+
}),
|
590
|
+
buttons: [{
|
591
|
+
text:'Submit',
|
592
|
+
listeners:{
|
593
|
+
'click':function(button){
|
594
|
+
var formPanel = button.findParentByType('window').query('form').first();
|
595
|
+
self.setWindowStatus('Adding new dynamic form model ...');
|
596
|
+
if (formPanel.getForm().isValid()){
|
597
|
+
formPanel.getForm().submit({
|
598
|
+
success:function(form, action){
|
599
|
+
self.clearWindowStatus();
|
600
|
+
var obj = Ext.decode(action.response.responseText);
|
601
|
+
if(obj.success){
|
602
|
+
self.formsTree.getStore().load({
|
603
|
+
node: self.formsTree.getRootNode()
|
604
|
+
});
|
605
|
+
newModelWindow.close();
|
606
|
+
}else{
|
607
|
+
Ext.Msg.alert("Error", obj.message);
|
608
|
+
}
|
609
|
+
},
|
610
|
+
failure:function(form, action){
|
611
|
+
self.clearWindowStatus();
|
612
|
+
var obj = Ext.decode(action.response.responseText);
|
613
|
+
if(obj !== null){
|
614
|
+
Ext.Msg.alert("Error", obj.message);
|
615
|
+
}else{
|
616
|
+
Ext.Msg.alert("Error", "Error adding form model");
|
617
|
+
}
|
618
|
+
}
|
619
|
+
});
|
620
|
+
}
|
621
|
+
}
|
622
|
+
}
|
623
|
+
},{
|
624
|
+
text: 'Close',
|
625
|
+
handler: function(){
|
626
|
+
newModelWindow.close();
|
627
|
+
}
|
628
|
+
}]
|
629
|
+
});
|
630
|
+
newModelWindow.show();
|
631
|
+
}
|
632
|
+
}
|
633
|
+
]
|
634
|
+
},
|
293
635
|
listeners:{
|
294
|
-
'load':function(){
|
295
|
-
self.sitesTree.getStore().sort('text', 'ASC');
|
296
|
-
},
|
297
636
|
'itemclick':function(view, record, item, index, e){
|
298
637
|
e.stopEvent();
|
299
|
-
if(record.data['
|
638
|
+
if(record.data['isFormModel']){
|
300
639
|
if (record.data['children'].length > 0){
|
301
640
|
self.getDynamicData(record);
|
302
641
|
}
|
303
642
|
}
|
304
643
|
else if(record.data['isForm']){
|
305
|
-
|
306
|
-
Ext.Msg.alert('Info', 'Form Builder not yet implemented');
|
644
|
+
self.getDynamicForm(record);
|
307
645
|
}
|
308
646
|
},
|
309
647
|
'itemcontextmenu':function(view, record, htmlItem, index, e){
|
310
648
|
e.stopEvent();
|
311
649
|
var items = [];
|
312
650
|
|
313
|
-
if(record.data['
|
651
|
+
if(record.data['isFormModel']){
|
314
652
|
|
315
653
|
// can only display data if there is a form to provide a definition
|
316
654
|
if (record.data['children'].length > 0){
|
@@ -326,19 +664,28 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
326
664
|
}
|
327
665
|
|
328
666
|
items.push({
|
329
|
-
text:'
|
667
|
+
text:'New Dynamic Form',
|
668
|
+
iconCls:'icon-add',
|
669
|
+
listeners:{
|
670
|
+
'click':function(){
|
671
|
+
self.addDynamicForm(record);
|
672
|
+
}
|
673
|
+
}
|
674
|
+
});
|
675
|
+
|
676
|
+
items.push({
|
677
|
+
text:'Configure',
|
330
678
|
iconCls:'icon-add',
|
331
679
|
listeners:{
|
332
680
|
'click':function(){
|
333
|
-
|
334
|
-
Ext.Msg.alert('Info', 'Form Builder not yet implemented');
|
681
|
+
self.configureFormModel(record);
|
335
682
|
}
|
336
683
|
}
|
337
684
|
});
|
338
685
|
|
339
686
|
if(record.data['text'] != 'DynamicFormDocument'){
|
340
687
|
items.push({
|
341
|
-
text:'Delete Model',
|
688
|
+
text:'Delete Form Model',
|
342
689
|
iconCls:'icon-delete',
|
343
690
|
listeners:{
|
344
691
|
'click':function(){
|
@@ -355,31 +702,28 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
355
702
|
iconCls:'icon-edit',
|
356
703
|
listeners:{
|
357
704
|
'click':function(){
|
358
|
-
|
359
|
-
Ext.Msg.alert('Info', 'Form Builder not yet implemented');
|
705
|
+
self.getDynamicForm(record);
|
360
706
|
}
|
361
707
|
}
|
362
708
|
});
|
363
|
-
if(!record.data['
|
709
|
+
if(!record.data['isDefaultForm']){
|
364
710
|
items.push({
|
365
|
-
text:'Set As Default',
|
711
|
+
text:'Set As Default Form',
|
366
712
|
iconCls:'icon-edit',
|
367
713
|
listeners:{
|
368
714
|
'click':function(){
|
369
|
-
|
370
|
-
Ext.Msg.alert('Info', 'Form Builder not yet implemented');
|
715
|
+
self.setDefaultForm(record);
|
371
716
|
}
|
372
717
|
}
|
373
718
|
});
|
374
719
|
}
|
375
720
|
|
376
721
|
items.push({
|
377
|
-
text:'Delete',
|
722
|
+
text:'Delete Dynamic Form',
|
378
723
|
iconCls:'icon-delete',
|
379
724
|
listeners:{
|
380
725
|
'click':function(){
|
381
|
-
|
382
|
-
Ext.Msg.alert('Info', 'Form Builder not yet implemented');
|
726
|
+
self.deleteForm(record);
|
383
727
|
}
|
384
728
|
}
|
385
729
|
});
|
@@ -393,102 +737,41 @@ Ext.define("Compass.ErpApp.Desktop.Applications.DynamicForms.WestRegion",{
|
|
393
737
|
}
|
394
738
|
});
|
395
739
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
frame:false,
|
417
|
-
fileUpload: true,
|
418
|
-
bodyStyle:'padding:5px 5px 0',
|
419
|
-
url:'/erp_forms/erp_app/desktop/dynamic_forms/models/create',
|
420
|
-
defaults: {
|
421
|
-
width: 225
|
422
|
-
},
|
423
|
-
items: [
|
424
|
-
{
|
425
|
-
xtype:'textfield',
|
426
|
-
fieldLabel:'Model Name',
|
427
|
-
allowBlank:false,
|
428
|
-
name:'model_name'
|
429
|
-
}
|
430
|
-
]
|
431
|
-
}),
|
432
|
-
buttons: [{
|
433
|
-
text:'Submit',
|
434
|
-
listeners:{
|
435
|
-
'click':function(button){
|
436
|
-
var window = button.findParentByType('window');
|
437
|
-
var formPanel = window.query('form')[0];
|
438
|
-
self.setWindowStatus('Adding new dynamic form model ...');
|
439
|
-
formPanel.getForm().submit({
|
440
|
-
success:function(form, action){
|
441
|
-
self.clearWindowStatus();
|
442
|
-
var obj = Ext.decode(action.response.responseText);
|
443
|
-
if(obj.success){
|
444
|
-
self.sitesTree.getStore().load({
|
445
|
-
node: self.sitesTree.getRootNode()
|
446
|
-
});
|
447
|
-
newModelWindow.close();
|
448
|
-
}
|
449
|
-
else{
|
450
|
-
Ext.Msg.alert("Error", obj.message);
|
451
|
-
}
|
452
|
-
},
|
453
|
-
failure:function(form, action){
|
454
|
-
self.clearWindowStatus();
|
455
|
-
var obj = Ext.decode(action.response.responseText);
|
456
|
-
if(obj != null){
|
457
|
-
Ext.Msg.alert("Error", obj.message);
|
458
|
-
}
|
459
|
-
else{
|
460
|
-
Ext.Msg.alert("Error", "Error importing website");
|
461
|
-
}
|
462
|
-
}
|
463
|
-
});
|
464
|
-
}
|
465
|
-
}
|
466
|
-
},{
|
467
|
-
text: 'Close',
|
468
|
-
handler: function(){
|
469
|
-
newModelWindow.close();
|
470
|
-
}
|
471
|
-
}]
|
472
|
-
});
|
473
|
-
newModelWindow.show();
|
740
|
+
this.fieldTypes = {
|
741
|
+
xtype: 'treepanel',
|
742
|
+
viewConfig: {
|
743
|
+
plugins: {
|
744
|
+
ptype: 'treeviewdragdrop',
|
745
|
+
ddGroup: 'fieldsDDGroup',
|
746
|
+
enableDrop: false
|
747
|
+
}
|
748
|
+
},
|
749
|
+
itemId: 'field_types',
|
750
|
+
title: 'Field Types',
|
751
|
+
root: fieldTreeRootNode,
|
752
|
+
rootVisible: true,
|
753
|
+
autoScroll: true,
|
754
|
+
listeners:{
|
755
|
+
beforerender:function(){
|
756
|
+
// we have to set this qtip this way so that we have access to ErpTechSvcs.Config
|
757
|
+
var filefield = fieldTreeRootNode.findChild('field_xtype','filefield');
|
758
|
+
var valid_types = ErpTechSvcs.Config.file_upload_types.replace(/,/g,', ');
|
759
|
+
filefield.data.qtip = 'Model must be enabled with has_file_assets. Use limited to one upload field per form. Compass AE is currently configured with a max file upload size of '+ErpTechSvcs.Config.max_file_size_in_mb+'MB and limited to file types '+valid_types+". Be sure to configure your web and/or mail servers accordingly.";
|
474
760
|
}
|
475
761
|
}
|
476
|
-
|
477
|
-
}
|
478
|
-
});
|
762
|
+
};
|
479
763
|
|
480
|
-
this.items = [layout];
|
481
|
-
this.callParent(arguments);
|
482
|
-
this.setActiveTab(0);
|
483
|
-
},
|
484
|
-
|
485
|
-
constructor : function(config) {
|
486
764
|
config = Ext.apply({
|
487
|
-
id: '
|
765
|
+
id: 'dynamic_forms_westregion',
|
488
766
|
region:'west',
|
489
767
|
split:true,
|
490
|
-
width:
|
491
|
-
|
768
|
+
width:235,
|
769
|
+
header: false,
|
770
|
+
hideCollapseTool: true,
|
771
|
+
collapsible: true,
|
772
|
+
collapseMode: 'mini',
|
773
|
+
items: [this.formsTree, this.fieldTypes],
|
774
|
+
activeTab: 0
|
492
775
|
}, config);
|
493
776
|
|
494
777
|
this.callParent([config]);
|