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
@@ -1,119 +1,119 @@
1
- Ext.ns("ErpApp.CompassAccessNegotiator");
1
+ // Ext.ns("ErpApp.CompassAccessNegotiator");
2
2
 
3
- /**
4
- * @class ErpApp.CompassAccessNegotiator.ApplicationRoleManager
5
- **/
3
+ // /**
4
+ // * @class ErpApp.CompassAccessNegotiator.ApplicationRoleManager
5
+ // **/
6
6
 
7
- ErpApp.CompassAccessNegotiator.ApplicationRoleManager = function(applications){
8
- /**
9
- * array to hold all application data
10
- *
11
- */
12
- this.applications = applications,
13
- this.registeredXtypes = [],
7
+ // ErpApp.CompassAccessNegotiator.ApplicationRoleManager = function(roles, capabilities){
8
+ // /**
9
+ // * array to hold all application data
10
+ // *
11
+ // */
12
+ // this.applications = applications,
13
+ // this.registeredXtypes = [],
14
14
 
15
- this.findWidget = function(xtype){
16
- var widget = null;
17
- for(var a=0; a < this.applications.length; a++){
18
- var application = this.applications[a];
19
- widget = application.widgets.find("xtype == '"+xtype+"'");
20
- if(!Ext.isEmpty(widget))
21
- break;
22
- }
23
- return widget;
24
- },
15
+ // this.findWidget = function(xtype){
16
+ // var widget = null;
17
+ // for(var a=0; a < this.applications.length; a++){
18
+ // var application = this.applications[a];
19
+ // widget = application.widgets.find("xtype == '"+xtype+"'");
20
+ // if(!Ext.isEmpty(widget))
21
+ // break;
22
+ // }
23
+ // return widget;
24
+ // },
25
25
 
26
- /**
27
- * Checks if user has application capability
28
- * xtypes.
29
- * @param {String} application iid
30
- * @param {Object} containing capability_type_iid and resource
31
- * @param {ErpApp.CompassAccessNegotiator.User} user
32
- */
33
- this.hasApplicationCapability = function(application_iid, capability, user){
34
- var application = this.applications.find("iid == '"+application_iid+"'");
35
- for(var i = 0; i < application.capabilities.length; i++){
36
- var app_capability = application.capabilities[i];
37
- if(app_capability.resource == capability.resource && app_capability.capability_type_iid == capability.capability_type_iid){
38
- return user.hasRole(app_capability.roles);
39
- }
40
- }
41
- throw "Capability "+capability.capability_type_iid+", "+capability.resource+" does not exist for application " + application_iid
42
- },
26
+ // /**
27
+ // * Checks if user has application capability
28
+ // * xtypes.
29
+ // * @param {String} application iid
30
+ // * @param {Object} containing capability_type_iid and resource
31
+ // * @param {ErpApp.CompassAccessNegotiator.User} user
32
+ // */
33
+ // this.hasApplicationCapability = function(application_iid, capability, user){
34
+ // var application = this.applications.find("iid == '"+application_iid+"'");
35
+ // for(var i = 0; i < application.capabilities.length; i++){
36
+ // var app_capability = application.capabilities[i];
37
+ // if(app_capability.resource == capability.resource && app_capability.capability_type_iid == capability.capability_type_iid){
38
+ // return user.hasRole(app_capability.roles);
39
+ // }
40
+ // }
41
+ // throw "Capability "+capability.capability_type_iid+", "+capability.resource+" does not exist for application " + application_iid;
42
+ // },
43
43
 
44
- /**
45
- * Checks if user has widget capability
46
- * xtypes.
47
- * @param {String} widget xtype
48
- * @param {Object} containing capability_type_iid and resource
49
- * @param {ErpApp.CompassAccessNegotiator.User} user
50
- */
51
- this.hasWidgetCapability = function(xtype, capability, user){
52
- var widget = this.findWidget(xtype);
53
- if(Compass.ErpApp.Utility.isBlank(widget)){
54
- throw "Widget xtype does not exist"
55
- }
44
+ // /**
45
+ // * Checks if user has widget capability
46
+ // * xtypes.
47
+ // * @param {String} widget xtype
48
+ // * @param {Object} containing capability_type_iid and resource
49
+ // * @param {ErpApp.CompassAccessNegotiator.User} user
50
+ // */
51
+ // this.hasWidgetCapability = function(xtype, capability, user){
52
+ // var widget = this.findWidget(xtype);
53
+ // if(Compass.ErpApp.Utility.isBlank(widget)){
54
+ // throw "Widget xtype does not exist";
55
+ // }
56
56
 
57
- for(var i = 0; i < widget.capabilities.length; i++){
58
- var widget_capability = widget.capabilities[i];
59
- if(widget_capability.resource == capability.resource && widget_capability.capability_type_iid == capability.capability_type_iid){
60
- return user.hasRole(widget_capability.roles);
61
- }
62
- }
63
- throw "Capability "+capability.capability_type_iid+", "+capability.resource+" does not exist for widget " + xtype
64
- },
57
+ // for(var i = 0; i < widget.capabilities.length; i++){
58
+ // var widget_capability = widget.capabilities[i];
59
+ // if(widget_capability.resource == capability.resource && widget_capability.capability_type_iid == capability.capability_type_iid){
60
+ // return user.hasRole(widget_capability.roles);
61
+ // }
62
+ // }
63
+ // throw "Capability "+capability.capability_type_iid+", "+capability.resource+" does not exist for widget " + xtype;
64
+ // },
65
65
 
66
- /**
67
- * Checks to user has access to widget
68
- * xtypes.
69
- * @param {String} widget xtype
70
- * @param {ErpApp.CompassAccessNegotiator.User} user
71
- */
72
- this.hasAccessToWidget = function(xtype, user){
73
- var widget = this.findWidget(xtype);
74
- if(Compass.ErpApp.Utility.isBlank(widget)){
75
- throw "Widget xtype does not exist"
76
- }
77
- else{
78
- return user.hasRole(widget.roles);
79
- }
80
- },
66
+ // /**
67
+ // * Checks to user has access to widget
68
+ // * xtypes.
69
+ // * @param {String} widget xtype
70
+ // * @param {ErpApp.CompassAccessNegotiator.User} user
71
+ // */
72
+ // this.hasAccessToWidget = function(xtype, user){
73
+ // var widget = this.findWidget(xtype);
74
+ // if(Compass.ErpApp.Utility.isBlank(widget)){
75
+ // throw "Widget xtype does not exist";
76
+ // }
77
+ // else{
78
+ // return user.hasRole(widget.roles);
79
+ // }
80
+ // },
81
81
 
82
- /**
83
- * Checks to find valid widegts and returns their
84
- * xtypes.
85
- * @param {String} application iid
86
- * @param {ErpApp.CompassAccessNegotiator.User} user
87
- */
88
- this.validWidgets = function(application_iid, filter, user){
89
- this.getRegisteredXtypes();
90
- var validXtypes = [];
91
- var application = this.applications.find("iid == '"+application_iid+"'");
92
- var xtypes = application.widgets.collect('xtype');
93
- for(var i = 0; i < xtypes.length; i++){
94
- if(this.hasAccessToWidget(xtypes[i], user)){
95
- if(filter[xtypes[i]] != true){
96
- if(this.registeredXtypes.contains(xtypes[i])){
97
- validXtypes.push(xtypes[i]);
98
- }
99
- }
100
- }
101
- }
82
+ // /**
83
+ // * Checks to find valid widegts and returns their
84
+ // * xtypes.
85
+ // * @param {String} application iid
86
+ // * @param {ErpApp.CompassAccessNegotiator.User} user
87
+ // */
88
+ // this.validWidgets = function(application_iid, filter, user){
89
+ // this.getRegisteredXtypes();
90
+ // var validXtypes = [];
91
+ // var application = this.applications.find("iid == '"+application_iid+"'");
92
+ // var xtypes = application.widgets.collect('xtype');
93
+ // for(var i = 0; i < xtypes.length; i++){
94
+ // if(this.hasAccessToWidget(xtypes[i], user)){
95
+ // if(filter[xtypes[i]] !== true){
96
+ // if(this.registeredXtypes.contains(xtypes[i])){
97
+ // validXtypes.push(xtypes[i]);
98
+ // }
99
+ // }
100
+ // }
101
+ // }
102
102
 
103
- return validXtypes;
104
- }
103
+ // return validXtypes;
104
+ // };
105
105
 
106
- this.getRegisteredXtypes = function(){
107
- var self = this;
108
- if(this.registeredXtypes.length < 1){
109
- Ext.Object.each(Ext.ClassManager.maps.aliasToName,function(key,value){
110
- var xtype = key.split(".")[1];
106
+ // this.getRegisteredXtypes = function(){
107
+ // var self = this;
108
+ // if(this.registeredXtypes.length < 1){
109
+ // Ext.Object.each(Ext.ClassManager.maps.aliasToName,function(key,value){
110
+ // var xtype = key.split(".")[1];
111
111
 
112
- if(!self.registeredXtypes.contains(xtype)){
113
- self.registeredXtypes.push(xtype);
114
- }
115
- });
116
- }
117
- }
118
- };
112
+ // if(!self.registeredXtypes.contains(xtype)){
113
+ // self.registeredXtypes.push(xtype);
114
+ // }
115
+ // });
116
+ // }
117
+ // };
118
+ // };
119
119
 
@@ -1,32 +1,32 @@
1
1
  (function(){
2
2
  //Section 1 : Code to execute when the toolbar button is pressed
3
3
  var a = {
4
- exec:function(editor){
5
- if(editor.checkDirty()){
6
- content = editor.getData();
7
- Knitkit.InlineEditing.contentDiv.html(content);
4
+ exec:function(editor){
5
+ if(editor.checkDirty()){
6
+ content = editor.getData();
7
+ Knitkit.InlineEditing.contentDiv.html(content);
8
8
 
9
- jQuery.ajax({
10
- type:'POST',
11
- url: "/knitkit/erp_app/desktop/content/update",
12
- data: {
13
- html:content,
14
- authenticity_token:Compass.ErpApp.AuthentictyToken,
15
- site_id:Knitkit.InlineEditing.websiteId,
16
- id:Knitkit.InlineEditing.contentId
17
- },
18
- success:function(result, status, xhr){
19
- Knitkit.InlineEditing.saved(editor, result, status, xhr);
20
- },
21
- error:function(xhr, status, error){
22
- Knitkit.InlineEditing.error(xhr, status, error);
23
- }
24
- });
9
+ jQuery.ajax({
10
+ type:'POST',
11
+ url: "/knitkit/erp_app/desktop/content/update",
12
+ data: {
13
+ html:content,
14
+ authenticity_token:Compass.ErpApp.AuthentictyToken,
15
+ site_id:Knitkit.InlineEditing.websiteId,
16
+ id:Knitkit.InlineEditing.contentId
17
+ },
18
+ success:function(result, status, xhr){
19
+ Knitkit.InlineEditing.saved(editor, result, status, xhr);
20
+ },
21
+ error:function(xhr, status, error){
22
+ Knitkit.InlineEditing.error(xhr, status, error);
23
+ }
24
+ });
25
+ }
25
26
  }
26
- }
27
- },
27
+ },
28
28
  //Section 2 : Create the button and add the functionality to it
29
- b = 'inlineeditsave';
29
+ b = 'inlineeditsave';
30
30
  CKEDITOR.plugins.add(b,{
31
31
  init:function(editor){
32
32
  editor.addCommand(b,a);
@@ -15,7 +15,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.FileManager",{
15
15
  iconCls:'icon-folders',
16
16
  handler : this.createWindow,
17
17
  scope: this
18
- }
18
+ };
19
19
  },
20
20
  createWindow : function(){
21
21
  var self = this;
@@ -29,7 +29,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.FileManager",{
29
29
  frame:false,
30
30
  border:false,
31
31
  region:'center'
32
- })
32
+ });
33
33
 
34
34
  var fileTreePanel = new Compass.ErpApp.Shared.FileManagerTree({
35
35
  allowDownload:true,
@@ -0,0 +1,82 @@
1
+ Ext.define("Compass.ErpApp.Desktop.Applications.SecurityManagement.CapabilitiesPanel",{
2
+ extend:"Ext.panel.Panel",
3
+ alias:'widget.security_management_capabilitiespanel',
4
+
5
+ initComponent: function() {
6
+ Compass.ErpApp.Desktop.Applications.SecurityManagement.CapabilitiesPanel.superclass.initComponent.call(this, arguments);
7
+ },
8
+
9
+ setCapability : function(record){
10
+ var assign_to_id = record.get('id');
11
+ var assign_to_description = record.get('description');
12
+
13
+ var security_management_capabilitiespanel = this;
14
+
15
+ var security_management_userswidget = security_management_capabilitiespanel.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_capabilitiespanel.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_roleswidget = security_management_capabilitiespanel.down('security_management_roleswidget');
24
+ security_management_roleswidget.assign_to_id = assign_to_id;
25
+ security_management_roleswidget.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:'Capabilities',
34
+ autoScroll: true,
35
+ tbar:[
36
+ ],
37
+ items:[{
38
+ xtype: 'security_management_capability_grid',
39
+ itemId: 'all_capabilities',
40
+ width: 400,
41
+ setupUrl: '/erp_app/desktop/security_management/capabilities/available_setup',
42
+ dataUrl: '/erp_app/desktop/security_management/capabilities/available',
43
+ multiSelect: false,
44
+ grid_listeners:{
45
+ afterrender:function(grid){
46
+ // autoLoad was causing erroneous calls to /erp_app/desktop/true so we manually load here
47
+ grid.getStore().load();
48
+ },
49
+ itemclick: function(grid, record, index, eOpts){
50
+ self.setCapability(record);
51
+
52
+ // get active tabpanel
53
+ var activeTabPanel = grid.findParentByType('security_management_capabilitiespanel').down('tabpanel').getActiveTab();
54
+ activeTabPanel.refreshWidget();
55
+ activeTabPanel.updateTitle();
56
+ }
57
+ }
58
+ },
59
+ {
60
+ xtype: 'tabpanel',
61
+ items:[
62
+ {
63
+ xtype:'security_management_userswidget',
64
+ assign_to: 'Capability'
65
+ },
66
+ {
67
+ xtype:'security_management_groupswidget',
68
+ assign_to: 'Capability'
69
+ },
70
+ {
71
+ xtype:'security_management_roleswidget',
72
+ assign_to: 'Capability'
73
+ }
74
+ ]
75
+ }]
76
+
77
+ }, config);
78
+
79
+ Compass.ErpApp.Desktop.Applications.SecurityManagement.CapabilitiesPanel.superclass.constructor.call(this, config);
80
+ }
81
+
82
+ });
@@ -0,0 +1,254 @@
1
+ Ext.define("Compass.ErpApp.Desktop.Applications.SecurityManagement.CapabilitiesWidget",{
2
+ extend:"Ext.panel.Panel",
3
+ alias:'widget.security_management_capabilitieswidget',
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 Capabilities 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
+ }, 600 );
34
+ }
35
+ },
36
+
37
+ constructor : function(config) {
38
+ var self = this;
39
+
40
+ var available_grid = {
41
+ xtype: 'security_management_capability_grid',
42
+ itemId: 'available',
43
+ title: 'Available Capabilities',
44
+ width: 400,
45
+ height: 340,
46
+ region: 'west',
47
+ setupUrl: '/erp_app/desktop/security_management/capabilities/available_setup',
48
+ dataUrl: '/erp_app/desktop/security_management/capabilities/available',
49
+ autoLoad: false
50
+ };
51
+
52
+ var selected_grid = {
53
+ xtype: 'security_management_capability_grid',
54
+ itemId: 'selected',
55
+ title: 'Selected Capabilities',
56
+ width: 400,
57
+ height: 340,
58
+ region: 'east',
59
+ setupUrl: '/erp_app/desktop/security_management/capabilities/selected_setup',
60
+ dataUrl: '/erp_app/desktop/security_management/capabilities/selected',
61
+ autoLoad: false
62
+ };
63
+
64
+ var assignment = {
65
+ xtype: 'panel',
66
+ itemId: 'assignment',
67
+ title: 'Manage Capabilities',
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-AddCapabilityButton'},
80
+ {xtype: 'SecurityManagement-RemoveCapabilityButton'}
81
+ ]
82
+ },
83
+ selected_grid
84
+ ]
85
+ };
86
+
87
+ config = Ext.apply({
88
+ title:'Capabilities',
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.CapabilityGrid",{
107
+ extend:"Compass.ErpApp.Shared.DynamicEditableGridLoaderPanel",
108
+ alias:'widget.security_management_capability_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_capability_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_capabilitieswidget') && !button.findParentByType('security_management_capabilitieswidget').assign_to_id) return;
145
+ var grid = button.findParentByType('security_management_capability_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.AddCapabilityButton',{
161
+ extend: 'Ext.button.Button',
162
+ alias: 'widget.SecurityManagement-AddCapabilityButton',
163
+ itemId: 'AddCapabilityButton',
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_capabilitieswidget = button.findParentByType('security_management_capabilitieswidget');
171
+ var available_grid = security_management_capabilitieswidget.query('#available').first().down('shared_dynamiceditablegrid');
172
+ var selected_grid = security_management_capabilitieswidget.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/capabilities/add',
182
+ method: 'POST',
183
+ params:{
184
+ assign_to: security_management_capabilitieswidget.assign_to,
185
+ id: security_management_capabilitieswidget.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 Capability');
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.RemoveCapabilityButton',{
209
+ extend: 'Ext.button.Button',
210
+ alias: 'widget.SecurityManagement-RemoveCapabilityButton',
211
+ itemId: 'RemoveCapabilityButton',
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_capabilitieswidget = button.findParentByType('security_management_capabilitieswidget');
219
+ var available_grid = security_management_capabilitieswidget.query('#available').first().down('shared_dynamiceditablegrid');
220
+ var selected_grid = security_management_capabilitieswidget.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/capabilities/remove',
230
+ method: 'POST',
231
+ params:{
232
+ assign_to: security_management_capabilitieswidget.assign_to,
233
+ id: security_management_capabilitieswidget.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 Capability');
247
+ }
248
+ });
249
+ }else{
250
+ Ext.Msg.alert('Error', 'Please make a selection.');
251
+ }
252
+ }
253
+ }
254
+ });