erp_app 3.0.13 → 3.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/app/controllers/erp_app/desktop/audit_log_viewer/base_controller.rb +1 -1
  2. data/app/controllers/erp_app/desktop/file_manager/base_controller.rb +5 -5
  3. data/app/controllers/erp_app/desktop/scaffold/role_controller.rb +1 -1
  4. data/app/controllers/erp_app/desktop/security_management/base_controller.rb +47 -0
  5. data/app/controllers/erp_app/desktop/security_management/capabilities_controller.rb +129 -0
  6. data/app/controllers/erp_app/desktop/security_management/groups_controller.rb +201 -0
  7. data/app/controllers/erp_app/desktop/security_management/roles_controller.rb +188 -0
  8. data/app/controllers/erp_app/desktop/security_management/users_controller.rb +145 -0
  9. data/app/controllers/erp_app/desktop/user_management/base_controller.rb +2 -2
  10. data/app/controllers/erp_app/desktop/user_management/role_management_controller.rb +6 -6
  11. data/app/controllers/erp_app/public_controller.rb +3 -14
  12. data/app/models/application.rb +1 -10
  13. data/app/models/configuration_item_type.rb +1 -1
  14. data/app/models/configuration_option.rb +1 -1
  15. data/app/models/widget.rb +2 -11
  16. data/config/routes.rb +6 -3
  17. data/db/data_migrations/20110728201729_erp_app_setup.rb +2 -48
  18. data/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.rb +4 -1
  19. data/db/data_migrations/20111108183739_add_default_capabilities.rb +11 -18
  20. data/db/data_migrations/20111108183740_add_new_contact_widgets.rb +4 -13
  21. data/db/data_migrations/20120229160222_add_userinfo_widget.rb +6 -8
  22. data/db/data_migrations/20120418164215_create_configuration_management_desktop_application.rb +4 -0
  23. data/db/data_migrations/20121130201859_upgrade_remove_system_mgmt_app.rb +15 -0
  24. data/db/data_migrations/20121218175028_create_security_management_desktop_application.rb +28 -0
  25. data/lib/erp_app/engine.rb +5 -5
  26. data/lib/erp_app/extensions/railties/action_view/helpers/include_helper.rb +4 -3
  27. data/lib/erp_app/extensions/railties/action_view/helpers/tag_helper.rb +8 -2
  28. data/lib/erp_app/version.rb +1 -1
  29. data/lib/erp_app/widgets/base.rb +4 -0
  30. data/lib/erp_app/widgets/loader.rb +40 -34
  31. data/public/images/icons/add/Thumbs.db +0 -0
  32. data/public/images/icons/calendar/Thumbs.db +0 -0
  33. data/public/images/icons/copy/Thumbs.db +0 -0
  34. data/public/images/icons/cut/Thumbs.db +0 -0
  35. data/public/images/icons/delete/Thumbs.db +0 -0
  36. data/public/images/icons/edit/Thumbs.db +0 -0
  37. data/public/images/icons/folder/Thumbs.db +0 -0
  38. data/public/images/icons/gear/Thumbs.db +0 -0
  39. data/public/images/icons/globe/Thumbs.db +0 -0
  40. data/public/images/icons/grid/Thumbs.db +0 -0
  41. data/public/images/icons/help/Thumbs.db +0 -0
  42. data/public/images/icons/information/Thumbs.db +0 -0
  43. data/public/images/icons/key/Thumbs.db +0 -0
  44. data/public/images/icons/log_out/Thumbs.db +0 -0
  45. data/public/images/icons/mail/Thumbs.db +0 -0
  46. data/public/images/icons/new/Thumbs.db +0 -0
  47. data/public/images/icons/next/Thumbs.db +0 -0
  48. data/public/images/icons/open/Thumbs.db +0 -0
  49. data/public/images/icons/paste/Thumbs.db +0 -0
  50. data/public/images/icons/picture/Thumbs.db +0 -0
  51. data/public/images/icons/presentation/Thumbs.db +0 -0
  52. data/public/images/icons/preview/Thumbs.db +0 -0
  53. data/public/images/icons/previous/Thumbs.db +0 -0
  54. data/public/images/icons/print/Thumbs.db +0 -0
  55. data/public/images/icons/properties/Thumbs.db +0 -0
  56. data/public/images/icons/redo/Thumbs.db +0 -0
  57. data/public/images/icons/refresh/Thumbs.db +0 -0
  58. data/public/images/icons/remove/Thumbs.db +0 -0
  59. data/public/images/icons/rename/Thumbs.db +0 -0
  60. data/public/images/icons/save/Thumbs.db +0 -0
  61. data/public/images/icons/search/Thumbs.db +0 -0
  62. data/public/images/icons/send/Thumbs.db +0 -0
  63. data/public/images/icons/settings/Thumbs.db +0 -0
  64. data/public/images/icons/synchronize/Thumbs.db +0 -0
  65. data/public/images/icons/undo/Thumbs.db +0 -0
  66. data/public/images/icons/upload/Thumbs.db +0 -0
  67. data/public/images/icons/user/Thumbs.db +0 -0
  68. data/public/images/icons/zoom_in/Thumbs.db +0 -0
  69. data/public/images/icons/zoom_out/Thumbs.db +0 -0
  70. data/public/javascripts/erp_app/authentication/compass_user.js +22 -19
  71. data/public/javascripts/erp_app/authentication/widget_manager.js +107 -107
  72. data/public/javascripts/erp_app/ckeditor/plugins/inlineeditsave/plugin.js +23 -23
  73. data/public/javascripts/erp_app/ckeditor/plugins/jwplayer/jwplayer/Thumbs.db +0 -0
  74. data/public/javascripts/erp_app/desktop/applications/file_manager/module.js +2 -2
  75. data/public/javascripts/erp_app/desktop/applications/security_management/capabilities_panel.js +82 -0
  76. data/public/javascripts/erp_app/desktop/applications/security_management/capabilities_widget.js +254 -0
  77. data/public/javascripts/erp_app/desktop/applications/security_management/groups_effective_security.js +98 -0
  78. data/public/javascripts/erp_app/desktop/applications/security_management/groups_panel.js +295 -0
  79. data/public/javascripts/erp_app/desktop/applications/security_management/groups_widget.js +254 -0
  80. data/public/javascripts/erp_app/desktop/applications/security_management/module.js +71 -0
  81. data/public/javascripts/erp_app/desktop/applications/security_management/roles_panel.js +298 -0
  82. data/public/javascripts/erp_app/desktop/applications/security_management/roles_widget.js +254 -0
  83. data/public/javascripts/erp_app/desktop/applications/security_management/users_effective_security.js +125 -0
  84. data/public/javascripts/erp_app/desktop/applications/security_management/users_panel.js +95 -0
  85. data/public/javascripts/erp_app/desktop/applications/security_management/users_widget.js +254 -0
  86. data/public/javascripts/erp_app/desktop/applications/user_management/module.js +38 -58
  87. data/public/javascripts/erp_app/organizer/applications/crm/base.js +698 -698
  88. data/public/javascripts/erp_app/organizer/applications/crm/contact_mechanism_grid.js +1 -4
  89. data/public/javascripts/erp_app/shared/compass_codemirror.js +1 -1
  90. data/public/javascripts/erp_app/shared/dynamic_editable_grid_loader_panel.js +1 -1
  91. data/public/javascripts/erp_app/shared/dynamic_forms/dynamic_form_fields.js +99 -0
  92. data/public/javascripts/erp_app/shared/file_manager_tree.js +1 -2
  93. data/public/javascripts/erp_app/shared/notes_grid.js +4 -13
  94. data/public/stylesheets/erp_app/shared/compass-ext-all.css +5 -0
  95. metadata +70 -20
  96. data/config/environment.rb +0 -0
  97. data/spec/dummy/db/schema.rb +0 -806
  98. data/spec/dummy/db/spec.sqlite3 +0 -0
  99. data/spec/dummy/log/adam.log +0 -1
  100. data/spec/dummy/log/spec.log +0 -92886
@@ -0,0 +1,98 @@
1
+ Ext.define("Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupsEffectiveSecurity",{
2
+ extend:"Ext.panel.Panel",
3
+ alias:'widget.security_management_groupseffectivesecurity',
4
+
5
+ initComponent: function() {
6
+ Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupsEffectiveSecurity.superclass.initComponent.call(this, arguments);
7
+ },
8
+
9
+ updateTitle : function(){
10
+ if (this.assign_to_description){
11
+ this.down('#effective').setTitle('Effective Security for Group '+this.assign_to_description);
12
+ }
13
+ },
14
+
15
+ refreshWidget : function(tab){
16
+ if (tab === undefined) tab = this;
17
+
18
+ if (tab.assign_to_id){
19
+
20
+ Ext.Ajax.request({
21
+ url: '/erp_app/desktop/security_management/groups/effective_security',
22
+ method: 'POST',
23
+ params:{
24
+ id: tab.assign_to_id
25
+ },
26
+ success: function(response) {
27
+ var json_response = Ext.decode(response.responseText);
28
+ if (json_response.success){
29
+ if (json_response.capabilities.length > 0){
30
+ tab.down('#capabilities').update(json_response.capabilities);
31
+ }else{
32
+ tab.down('#capabilities').update("No capabilities.");
33
+ }
34
+ }else{
35
+ Ext.Msg.alert('Error', Ext.decode(response.responseText).message);
36
+ }
37
+ },
38
+ failure: function(response) {
39
+ Ext.Msg.alert('Error', 'Error Retrieving Effective Security');
40
+ }
41
+ });
42
+
43
+ }
44
+ },
45
+
46
+ constructor : function(config) {
47
+ var self = this;
48
+
49
+ var capabilities_tpl = new Ext.XTemplate(
50
+ '<tpl for=".">',
51
+ '{capability_type_iid} {capability_resource_type}<br />',
52
+ '</tpl>'
53
+ );
54
+
55
+ var capabilities = {
56
+ xtype: 'panel',
57
+ itemId: 'capabilities',
58
+ title: 'Capabilities',
59
+ layout: 'hbox',
60
+ autoScroll: true,
61
+ bodyPadding: 10,
62
+ tpl: capabilities_tpl,
63
+ listeners:{
64
+ 'afterrender':function(comp){
65
+ comp.update('Select a Group');
66
+ }
67
+ }
68
+ };
69
+
70
+ var effective = {
71
+ xtype: 'panel',
72
+ itemId: 'effective',
73
+ title: 'Effective Security',
74
+ layout: 'hbox',
75
+ autoScroll: true,
76
+ bodyPadding: 10,
77
+ items:[
78
+ capabilities
79
+ ]
80
+ };
81
+
82
+ config = Ext.apply({
83
+ title:'Effective Security',
84
+ items:[
85
+ effective
86
+ ],
87
+ listeners:{
88
+ activate: function(tab){
89
+ self.refreshWidget(tab);
90
+ self.updateTitle();
91
+ }
92
+ }
93
+
94
+ }, config);
95
+
96
+ Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupsEffectiveSecurity.superclass.constructor.call(this, config);
97
+ }
98
+ });
@@ -0,0 +1,295 @@
1
+ Ext.define("Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupsPanel",{
2
+ extend:"Ext.panel.Panel",
3
+ alias:'widget.security_management_groupspanel',
4
+
5
+ initComponent: function() {
6
+ Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupsPanel.superclass.initComponent.call(this, arguments);
7
+ },
8
+
9
+ setGroup : function(record){
10
+ var assign_to_id = record.get('id');
11
+ var assign_to_description = record.get('description');
12
+
13
+ var security_management_groupspanel = this;
14
+
15
+ var security_management_userswidget = security_management_groupspanel.down('security_management_userswidget');
16
+ security_management_userswidget.assign_to_id = assign_to_id;
17
+ security_management_userswidget.assign_to_description = assign_to_description;
18
+
19
+ var security_management_roleswidget = security_management_groupspanel.down('security_management_roleswidget');
20
+ security_management_roleswidget.assign_to_id = assign_to_id;
21
+ security_management_roleswidget.assign_to_description = assign_to_description;
22
+
23
+ var security_management_capabilitieswidget = security_management_groupspanel.down('security_management_capabilitieswidget');
24
+ security_management_capabilitieswidget.assign_to_id = assign_to_id;
25
+ security_management_capabilitieswidget.assign_to_description = assign_to_description;
26
+
27
+ var security_management_groupseffectivesecurity = security_management_groupspanel.down('security_management_groupseffectivesecurity');
28
+ security_management_groupseffectivesecurity.assign_to_id = assign_to_id;
29
+ security_management_groupseffectivesecurity.assign_to_description = assign_to_description;
30
+ },
31
+
32
+ constructor : function(config) {
33
+ var self = this;
34
+
35
+ config = Ext.apply({
36
+ width:460,
37
+ title:'Groups',
38
+ autoScroll: true,
39
+ tbar:[{
40
+ text:'New Group',
41
+ iconCls:'icon-add',
42
+ handler:function(btn){
43
+ var newWindow = Ext.create("Ext.window.Window",{
44
+ layout:'fit',
45
+ width:375,
46
+ title:'New Group',
47
+ height:100,
48
+ plain: true,
49
+ buttonAlign:'center',
50
+ items: Ext.create('Ext.form.Panel',{
51
+ labelWidth: 110,
52
+ frame:false,
53
+ bodyStyle:'padding:5px 5px 0',
54
+ url:'/erp_app/desktop/security_management/groups/create',
55
+ defaults: {
56
+ width: 225
57
+ },
58
+ items: [
59
+ {
60
+ xtype:'textfield',
61
+ fieldLabel:'Group Name',
62
+ allowBlank:false,
63
+ name:'description',
64
+ listeners:{
65
+ afterrender:function(field){
66
+ field.focus(false, 200);
67
+ },
68
+ specialkey: function(field, e){
69
+ if (e.getKey() == e.ENTER) {
70
+ var button = field.findParentByType('window').down('#submitButton');
71
+ button.fireEvent('click', button);
72
+ }
73
+ }
74
+ }
75
+ }
76
+ ]
77
+ }),
78
+ buttons: [{
79
+ text:'Submit',
80
+ itemId: 'submitButton',
81
+ listeners:{
82
+ 'click':function(button){
83
+ var formPanel = button.findParentByType('window').down('form');
84
+ formPanel.getForm().submit({
85
+ success:function(form, action){
86
+ var obj = Ext.decode(action.response.responseText);
87
+ if(obj.success){
88
+ var all_groups = self.down('#all_groups').down('shared_dynamiceditablegrid');
89
+ all_groups.getStore().load();
90
+ newWindow.close();
91
+ }
92
+ else{
93
+ Ext.Msg.alert("Error", obj.message);
94
+ }
95
+ },
96
+ failure:function(form, action){
97
+ var obj = Ext.decode(action.response.responseText);
98
+ if(obj !== null){
99
+ Ext.Msg.alert("Error", obj.message);
100
+ }
101
+ else{
102
+ Ext.Msg.alert("Error", "Error importing website");
103
+ }
104
+ }
105
+ });
106
+ }
107
+ }
108
+ },{
109
+ text: 'Close',
110
+ handler: function(){
111
+ newWindow.close();
112
+ }
113
+ }]
114
+ });
115
+ newWindow.show();
116
+ }
117
+ },
118
+ {
119
+ text:'Edit Group',
120
+ iconCls:'icon-edit',
121
+ handler:function(btn){
122
+ var all_groups = self.down('#all_groups').down('shared_dynamiceditablegrid');
123
+ var selection = all_groups.getSelectionModel().getSelection().first();
124
+ if (Ext.isEmpty(selection)){
125
+ Ext.Msg.alert('Error','Please make a selection.');
126
+ return false;
127
+ }
128
+ var newWindow = Ext.create("Ext.window.Window",{
129
+ layout:'fit',
130
+ width:375,
131
+ title:'Edit Group',
132
+ height:100,
133
+ plain: true,
134
+ buttonAlign:'center',
135
+ items: Ext.create('Ext.form.Panel',{
136
+ labelWidth: 110,
137
+ frame:false,
138
+ bodyStyle:'padding:5px 5px 0',
139
+ url:'/erp_app/desktop/security_management/groups/update',
140
+ defaults: {
141
+ width: 225
142
+ },
143
+ items: [
144
+ {
145
+ xtype:'textfield',
146
+ fieldLabel:'Group Name',
147
+ allowBlank:false,
148
+ name:'description',
149
+ value: selection.get('description'),
150
+ listeners:{
151
+ afterrender:function(field){
152
+ field.focus(true, 200);
153
+ },
154
+ specialkey: function(field, e){
155
+ if (e.getKey() == e.ENTER) {
156
+ var button = field.findParentByType('window').down('#submitButton');
157
+ button.fireEvent('click', button);
158
+ }
159
+ }
160
+ }
161
+ }
162
+ ]
163
+ }),
164
+ buttons: [{
165
+ text:'Submit',
166
+ itemId: 'submitButton',
167
+ listeners:{
168
+ 'click':function(button){
169
+ var formPanel = button.findParentByType('window').down('form');
170
+ formPanel.getForm().submit({
171
+ params:{
172
+ id: selection.get('id'),
173
+ description: selection.get('description')
174
+ },
175
+ success:function(form, action){
176
+ var obj = Ext.decode(action.response.responseText);
177
+ if(obj.success){
178
+ var all_groups = self.down('#all_groups').down('shared_dynamiceditablegrid');
179
+ all_groups.getStore().load();
180
+ newWindow.close();
181
+ }
182
+ else{
183
+ Ext.Msg.alert("Error", obj.message);
184
+ }
185
+ },
186
+ failure:function(form, action){
187
+ var obj = Ext.decode(action.response.responseText);
188
+ if(obj !== null){
189
+ Ext.Msg.alert("Error", obj.message);
190
+ }
191
+ else{
192
+ Ext.Msg.alert("Error", "Error importing website");
193
+ }
194
+ }
195
+ });
196
+ }
197
+ }
198
+ },{
199
+ text: 'Close',
200
+ handler: function(){
201
+ newWindow.close();
202
+ }
203
+ }]
204
+ });
205
+ newWindow.show();
206
+ }
207
+ },
208
+ {
209
+ text:'Delete Group',
210
+ iconCls:'icon-delete',
211
+ handler:function(btn){
212
+ var all_groups = self.down('#all_groups').down('shared_dynamiceditablegrid');
213
+ var selection = all_groups.getSelectionModel().getSelection().first();
214
+ if (Ext.isEmpty(selection)){
215
+ Ext.Msg.alert('Error','Please make a selection.');
216
+ return false;
217
+ }
218
+ Ext.MessageBox.confirm('Confirm', 'Are you sure?', function(btn){
219
+ if(btn == 'no'){
220
+ return false;
221
+ }
222
+ else if(btn == 'yes'){
223
+ Ext.Ajax.request({
224
+ url: '/erp_app/desktop/security_management/groups/delete',
225
+ method: 'POST',
226
+ params:{
227
+ id: selection.get('id')
228
+ },
229
+ success: function(response) {
230
+ var json_response = Ext.decode(response.responseText);
231
+ if (json_response.success){
232
+ all_groups.getStore().load();
233
+ }else{
234
+ Ext.Msg.alert('Error', Ext.decode(response.responseText).message);
235
+ }
236
+ },
237
+ failure: function(response) {
238
+ Ext.Msg.alert('Error', 'Error Retrieving Effective Security');
239
+ }
240
+ });
241
+ }
242
+ });
243
+ }
244
+ }
245
+ ],
246
+ items:[{
247
+ xtype: 'security_management_group_grid',
248
+ itemId: 'all_groups',
249
+ width: 400,
250
+ setupUrl: '/erp_app/desktop/security_management/groups/available_setup',
251
+ dataUrl: '/erp_app/desktop/security_management/groups/available',
252
+ multiSelect: false,
253
+ grid_listeners:{
254
+ afterrender:function(grid){
255
+ // autoLoad was causing erroneous calls to /erp_app/desktop/true so we manually load here
256
+ grid.getStore().load();
257
+ },
258
+ itemclick: function(grid, record, index, eOpts){
259
+ self.setGroup(record);
260
+
261
+ // get active tabpanel
262
+ var activeTabPanel = grid.findParentByType('security_management_groupspanel').down('tabpanel').getActiveTab();
263
+ activeTabPanel.refreshWidget();
264
+ activeTabPanel.updateTitle();
265
+ }
266
+ }
267
+ },
268
+ {
269
+ xtype: 'tabpanel',
270
+ items:[
271
+ {
272
+ xtype:'security_management_userswidget',
273
+ assign_to: 'Group'
274
+ },
275
+ {
276
+ xtype:'security_management_roleswidget',
277
+ assign_to: 'Group'
278
+ },
279
+ {
280
+ xtype:'security_management_capabilitieswidget',
281
+ assign_to: 'Group'
282
+ },
283
+ {
284
+ xtype:'security_management_groupseffectivesecurity'
285
+ }
286
+
287
+ ]
288
+ }]
289
+
290
+ }, config);
291
+
292
+ Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupsPanel.superclass.constructor.call(this, config);
293
+ }
294
+
295
+ });
@@ -0,0 +1,254 @@
1
+ Ext.define("Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupsWidget",{
2
+ extend:"Ext.panel.Panel",
3
+ alias:'widget.security_management_groupswidget',
4
+
5
+ initComponent: function() {
6
+ Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupsWidget.superclass.initComponent.call(this, arguments);
7
+ },
8
+
9
+ updateTitle : function(){
10
+ if (this.assign_to_description){
11
+ this.down('#assignment').setTitle('Assign Groups to '+this.assign_to+' '+this.assign_to_description);
12
+ }
13
+ },
14
+
15
+ refreshWidget : function(tab){
16
+ if (tab === undefined) tab = this;
17
+
18
+ if (tab.assign_to_id){
19
+ //need a delay to allow for rendering of shared_dynamiceditablegrid
20
+ setTimeout( function() {
21
+ var extraParams = {
22
+ assign_to: tab.assign_to,
23
+ id: tab.assign_to_id
24
+ };
25
+
26
+ var available_grid = tab.down('#available').down('shared_dynamiceditablegrid');
27
+ available_grid.getStore().getProxy().extraParams = extraParams;
28
+ available_grid.getStore().load();
29
+
30
+ var selected_grid = tab.down('#selected').down('shared_dynamiceditablegrid');
31
+ selected_grid.getStore().getProxy().extraParams = extraParams;
32
+ selected_grid.getStore().load();
33
+ }, 500 );
34
+ }
35
+ },
36
+
37
+ constructor : function(config) {
38
+ var self = this;
39
+
40
+ var available_grid = {
41
+ xtype: 'security_management_group_grid',
42
+ itemId: 'available',
43
+ title: 'Available Groups',
44
+ width: 400,
45
+ height: 340,
46
+ region: 'west',
47
+ setupUrl: '/erp_app/desktop/security_management/groups/available_setup',
48
+ dataUrl: '/erp_app/desktop/security_management/groups/available',
49
+ autoLoad: false
50
+ };
51
+
52
+ var selected_grid = {
53
+ xtype: 'security_management_group_grid',
54
+ itemId: 'selected',
55
+ title: 'Selected Groups',
56
+ width: 400,
57
+ height: 340,
58
+ region: 'east',
59
+ setupUrl: '/erp_app/desktop/security_management/groups/selected_setup',
60
+ dataUrl: '/erp_app/desktop/security_management/groups/selected',
61
+ autoLoad: false
62
+ };
63
+
64
+ var assignment = {
65
+ xtype: 'panel',
66
+ itemId: 'assignment',
67
+ title: 'Manage Groups',
68
+ layout: 'table',
69
+ autoScroll: true,
70
+ height: 600,
71
+ bodyPadding: 10,
72
+ items:[
73
+ available_grid,
74
+ {
75
+ xtype: 'container',
76
+ width: 22,
77
+ bodyPadding: 5,
78
+ items:[
79
+ {xtype: 'SecurityManagement-AddGroupButton'},
80
+ {xtype: 'SecurityManagement-RemoveGroupButton'}
81
+ ]
82
+ },
83
+ selected_grid
84
+ ]
85
+ };
86
+
87
+ config = Ext.apply({
88
+ title:'Groups',
89
+ assign_to: (config.assign_to || 'User'),
90
+ items:[
91
+ assignment
92
+ ],
93
+ listeners:{
94
+ activate: function(tab){
95
+ self.refreshWidget(tab);
96
+ self.updateTitle();
97
+ }
98
+ }
99
+
100
+ }, config);
101
+
102
+ Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupsWidget.superclass.constructor.call(this, config);
103
+ }
104
+ });
105
+
106
+ Ext.define("Compass.ErpApp.Desktop.Applications.SecurityManagement.GroupGrid",{
107
+ extend:"Compass.ErpApp.Shared.DynamicEditableGridLoaderPanel",
108
+ alias:'widget.security_management_group_grid',
109
+
110
+ constructor : function(config) {
111
+ config = Ext.apply({
112
+ id:config.id,
113
+ title: config.title,
114
+ editable:false,
115
+ page:true,
116
+ pageSize: 10,
117
+ multiSelect: (config.multiSelect === false ? false : true),
118
+ displayMsg:'Displaying {0} - {1} of {2}',
119
+ emptyMsg:'Empty',
120
+ tbar:[{
121
+ fieldLabel: '<span data-qtitle="Search" data-qwidth="200" data-qtip="">Search</span>',
122
+ labelWidth : 40,
123
+ itemId: 'searchValue',
124
+ xtype: 'textfield',
125
+ width: 180,
126
+ value: '',
127
+ listeners:{
128
+ specialkey: function(field, e){
129
+ if (e.getKey() == e.ENTER) {
130
+ var grid = field.findParentByType('security_management_group_grid');
131
+ var button = grid.query('#searchButton').first();
132
+ button.fireEvent('click', button);
133
+ }
134
+ }
135
+ }
136
+ },
137
+ {xtype: 'tbspacer', width: 1},
138
+ {
139
+ xtype: 'button',
140
+ itemId: 'searchButton',
141
+ iconCls: 'x-btn-icon icon-search',
142
+ listeners:{
143
+ click: function(button) {
144
+ if (button.findParentByType('security_management_groupswidget') && !button.findParentByType('security_management_groupswidget').assign_to_id) return;
145
+ var grid = button.findParentByType('security_management_group_grid');
146
+ var value = grid.query('#searchValue').first().getValue();
147
+ grid.query('shared_dynamiceditablegrid').first().getStore().load({
148
+ params: {query_filter: value}
149
+ });
150
+ }
151
+ }
152
+ }
153
+ ]
154
+ }, config);
155
+
156
+ this.callParent([config]);
157
+ }
158
+ });
159
+
160
+ Ext.define('Compass.ErpApp.Desktop.Applications.SecurityManagement.AddGroupButton',{
161
+ extend: 'Ext.button.Button',
162
+ alias: 'widget.SecurityManagement-AddGroupButton',
163
+ itemId: 'AddGroupButton',
164
+ cls: 'x-btn-text-icon',
165
+ iconCls : 'icon-arrow-right-blue',
166
+ formBind: false,
167
+ tooltip: 'Add to Selected',
168
+ listeners: {
169
+ click: function(button) {
170
+ var security_management_groupswidget = button.findParentByType('security_management_groupswidget');
171
+ var available_grid = security_management_groupswidget.query('#available').first().down('shared_dynamiceditablegrid');
172
+ var selected_grid = security_management_groupswidget.query('#selected').first().down('shared_dynamiceditablegrid');
173
+ var selection = available_grid.getSelectionModel().getSelection();
174
+ if (selection.length > 0){
175
+ var selected_groups = [];
176
+ Ext.each(selection, function(s){
177
+ selected_groups.push(s.data.id);
178
+ });
179
+
180
+ Ext.Ajax.request({
181
+ url: '/erp_app/desktop/security_management/groups/add',
182
+ method: 'POST',
183
+ params:{
184
+ assign_to: security_management_groupswidget.assign_to,
185
+ id: security_management_groupswidget.assign_to_id,
186
+ selection: Ext.encode(selected_groups)
187
+ },
188
+ success: function(response) {
189
+ var json_response = Ext.decode(response.responseText);
190
+ if (json_response.success){
191
+ available_grid.getStore().load();
192
+ selected_grid.getStore().load();
193
+ }else{
194
+ Ext.Msg.alert('Error', Ext.decode(response.responseText).message);
195
+ }
196
+ },
197
+ failure: function(response) {
198
+ Ext.Msg.alert('Error', 'Error Adding Group');
199
+ }
200
+ });
201
+ }else{
202
+ Ext.Msg.alert('Error', 'Please make a selection.');
203
+ }
204
+ }
205
+ }
206
+ });
207
+
208
+ Ext.define('Compass.ErpApp.Desktop.Applications.SecurityManagement.RemoveGroupButton',{
209
+ extend: 'Ext.button.Button',
210
+ alias: 'widget.SecurityManagement-RemoveGroupButton',
211
+ itemId: 'RemoveGroupButton',
212
+ cls: 'x-btn-text-icon',
213
+ iconCls : 'icon-arrow-left-blue',
214
+ formBind: false,
215
+ tooltip: 'Remove from Selected',
216
+ listeners: {
217
+ click: function(button) {
218
+ var security_management_groupswidget = button.findParentByType('security_management_groupswidget');
219
+ var available_grid = security_management_groupswidget.query('#available').first().down('shared_dynamiceditablegrid');
220
+ var selected_grid = security_management_groupswidget.query('#selected').first().down('shared_dynamiceditablegrid');
221
+ var selection = selected_grid.getSelectionModel().getSelection();
222
+ if (selection.length > 0){
223
+ var selected_groups = [];
224
+ Ext.each(selection, function(s){
225
+ selected_groups.push(s.data.id);
226
+ });
227
+
228
+ Ext.Ajax.request({
229
+ url: '/erp_app/desktop/security_management/groups/remove',
230
+ method: 'POST',
231
+ params:{
232
+ assign_to: security_management_groupswidget.assign_to,
233
+ id: security_management_groupswidget.assign_to_id,
234
+ selection: Ext.encode(selected_groups)
235
+ },
236
+ success: function(response) {
237
+ var json_response = Ext.decode(response.responseText);
238
+ if (json_response.success){
239
+ available_grid.getStore().load();
240
+ selected_grid.getStore().load();
241
+ }else{
242
+ Ext.Msg.alert('Error', Ext.decode(response.responseText).message);
243
+ }
244
+ },
245
+ failure: function(response) {
246
+ Ext.Msg.alert('Error', 'Error Removing Group');
247
+ }
248
+ });
249
+ }else{
250
+ Ext.Msg.alert('Error', 'Please make a selection.');
251
+ }
252
+ }
253
+ }
254
+ });