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