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
@@ -2,19 +2,17 @@ class AddNewContactWidgets
2
2
 
3
3
  def self.up
4
4
  crm_app = OrganizerApplication.find_by_internal_identifier('crm')
5
+
5
6
  unless crm_app.nil?
6
7
  Widget.find_by_internal_identifier('party_contact_management').destroy
7
8
 
8
- phone_number_managementt_widget = ::Widget.create(
9
+ phone_number_managementt_widget = ::Widget.create(
9
10
  :description => 'Phone Number Management',
10
- :icon => 'icon-grid',
11
+ :icon => 'icon-grid',
11
12
  :xtype => 'phonenumbergrid',
12
13
  :internal_identifier => 'phone_number_management'
13
14
  )
14
15
 
15
- phone_number_managementt_widget.add_role('admin')
16
- phone_number_managementt_widget.add_role('employee')
17
-
18
16
  email_address_management_widget = ::Widget.create(
19
17
  :description => 'Email Address Management',
20
18
  :icon => 'icon-grid',
@@ -22,9 +20,6 @@ class AddNewContactWidgets
22
20
  :internal_identifier => 'email_address_management'
23
21
  )
24
22
 
25
- email_address_management_widget.add_role('admin')
26
- email_address_management_widget.add_role('employee')
27
-
28
23
  postal_address_management_widget = ::Widget.create(
29
24
  :description => 'Postal Address Management',
30
25
  :icon => 'icon-grid',
@@ -32,19 +27,15 @@ class AddNewContactWidgets
32
27
  :internal_identifier => 'postal_address_management'
33
28
  )
34
29
 
35
- postal_address_management_widget.add_role('admin')
36
- postal_address_management_widget.add_role('employee')
37
-
38
30
  crm_app.widgets << phone_number_managementt_widget
39
31
  crm_app.widgets << email_address_management_widget
40
32
  crm_app.widgets << postal_address_management_widget
41
-
42
33
  crm_app.save
34
+
43
35
  end
44
36
  end
45
37
 
46
38
  def self.down
47
- #remove data here
48
39
  end
49
40
 
50
41
  end
@@ -6,19 +6,17 @@ class AddUserinfoWidget
6
6
  app = Application.find_by_internal_identifier('crm')
7
7
 
8
8
  user = Widget.create(
9
- :description => 'User Info',
10
- :internal_identifier => 'userinfo',
11
- :icon => 'icon-user',
12
- :xtype => 'userinfo'
13
- )
9
+ :description => 'User Info',
10
+ :internal_identifier => 'userinfo',
11
+ :icon => 'icon-user',
12
+ :xtype => 'userinfo'
13
+ )
14
14
 
15
15
  unless app.nil?
16
16
  app.widgets << user
17
17
  app.save
18
18
  end
19
-
20
- user.roles << Role.find_by_internal_identifier('admin')
21
- user.save
19
+
22
20
  end
23
21
  end
24
22
 
@@ -14,6 +14,10 @@ class CreateConfigurationManagementDesktopApplication
14
14
  pt2 = PreferenceType.iid('autoload_application')
15
15
  pt2.preferenced_records << app
16
16
  pt2.save
17
+
18
+ admin_user = User.find_by_username('admin')
19
+ admin_user.desktop.applications << app
20
+ admin_user.desktop.save
17
21
  end
18
22
 
19
23
  def self.down
@@ -0,0 +1,15 @@
1
+ class UpgradeRemoveSystemMgmtApp
2
+
3
+ def self.up
4
+ #insert data here
5
+ widget = Widget.find_by_xtype('systemmanagement_applicationrolemanagment')
6
+ widget.destroy unless widget.nil?
7
+ app = Application.find_by_internal_identifier('system_management')
8
+ app.destroy unless app.nil?
9
+ end
10
+
11
+ def self.down
12
+ #remove data here
13
+ end
14
+
15
+ end
@@ -0,0 +1,28 @@
1
+ class CreateSecurityManagementDesktopApplication
2
+ def self.up
3
+ app = DesktopApplication.create(
4
+ :description => 'Security Management',
5
+ :icon => 'icon-key',
6
+ :javascript_class_name => 'Compass.ErpApp.Desktop.Applications.SecurityManagement',
7
+ :internal_identifier => 'security_management',
8
+ :shortcut_id => 'security_management-win'
9
+ )
10
+ pt1 = PreferenceType.iid('desktop_shortcut')
11
+ pt1.preferenced_records << app
12
+ pt1.save
13
+
14
+ pt2 = PreferenceType.iid('autoload_application')
15
+ pt2.preferenced_records << app
16
+ pt2.save
17
+
18
+ admin_user = User.find_by_username('admin')
19
+ if admin_user
20
+ admin_user.desktop.applications << app
21
+ admin_user.desktop.save
22
+ end
23
+ end
24
+
25
+ def self.down
26
+ DesktopApplication.destroy_all(['internal_identifier = ?','security_management'])
27
+ end
28
+ end
@@ -24,13 +24,13 @@ module ErpApp
24
24
  #this is ugly need a better way
25
25
  (config.active_record.observers.nil?) ? config.active_record.observers = [:user_app_container_observer] : config.active_record.observers << :user_app_container_observer
26
26
 
27
- engine = self
28
- config.to_prepare do
29
- ErpBaseErpSvcs.register_compass_ae_engine(engine)
30
- ::ErpApp::Widgets::Loader.load_root_widgets
27
+ ErpBaseErpSvcs.register_as_compass_ae_engine(config, self)
28
+ ::ErpApp::Widgets::Loader.load_root_widgets(config)
31
29
 
30
+ config.to_prepare do
32
31
  #will_paginate patch
33
32
  require 'erp_app/extensions/will_paginate_patch'
34
- end
33
+ end
34
+
35
35
  end
36
36
  end
@@ -83,12 +83,13 @@ module ErpApp
83
83
  :lastActivityAt => user.last_activity_at,
84
84
  :failedLoginCount => user.failed_logins_count,
85
85
  :email => user.email,
86
- :roles => user.roles.collect{|role| role.internal_identifier},
86
+ :roles => user.all_roles.collect{|role| role.internal_identifier},
87
+ :capabilities => user.class_capabilities_to_hash,
87
88
  :id => user.id,
88
89
  :description => user.party.to_s
89
90
  }
90
- js_string = static_javascript_include_tag('erp_app/authentication/compass_user.js', 'erp_app/authentication/widget_manager.js')
91
- js_string << (raw "<script type='text/javascript'>var applicationRoleManager = new ErpApp.CompassAccessNegotiator.ApplicationRoleManager(#{app_container.applications.collect{|application| application.to_access_hash}.to_json});var currentUser = new ErpApp.CompassAccessNegotiator.CompassUser(#{current_user.to_json}, applicationRoleManager);</script>")
91
+ js_string = static_javascript_include_tag('erp_app/authentication/compass_user.js')
92
+ js_string << (raw "<script type='text/javascript'>var currentUser = new ErpApp.CompassAccessNegotiator.CompassUser(#{current_user.to_json});</script>")
92
93
  js_string
93
94
  end
94
95
 
@@ -8,12 +8,18 @@ module ErpApp
8
8
  include ::ActionView::Helpers::TagHelper
9
9
 
10
10
  def link_to_remote(name, url, options={})
11
- options.merge!({:class => 'ajax_replace', :remote => true})
11
+ #add ajax_replace class
12
+ options[:class].nil? ? 'ajax_replace' : "#{options[:class]} ajax_replace"
13
+ #add remote => true to options
14
+ options.merge!({:remote => true})
12
15
  link_to name, url, options
13
16
  end
14
17
 
15
18
  def form_remote_tag(url, options={}, &block)
16
- options.merge!({:class => 'ajax_replace', :remote => true})
19
+ #add ajax_replace class
20
+ options[:class].nil? ? 'ajax_replace' : "#{options[:class]} ajax_replace"
21
+ #add remote => true to options
22
+ options.merge!({:remote => true})
17
23
  form_tag url, options do
18
24
  yield
19
25
  end
@@ -2,7 +2,7 @@ module ErpApp
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 13
5
+ TINY = 14
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
@@ -44,6 +44,10 @@ module ErpApp
44
44
  merge_params
45
45
  end
46
46
 
47
+ def widget_result_id
48
+ "#{self.uuid}_result"
49
+ end
50
+
47
51
  def render(opts={})
48
52
  render_view_for(opts, self.view)
49
53
  end
@@ -2,16 +2,19 @@ module ErpApp
2
2
  module Widgets
3
3
  class Loader
4
4
  class << self
5
- def load_compass_ae_widgets(engine)
6
- require_widgets_and_helpers(engine.root)
7
- load_widget_extensions(engine)
8
- end
5
+ def load_compass_ae_widgets(config, engine)
6
+ config.send(ErpBaseErpSvcs.determine_callback) do
7
+ ::ErpApp::Widgets::Loader.require_widgets_and_helpers(engine.root)
8
+ ::ErpApp::Widgets::Loader.load_widget_extensions(engine)
9
+ end
9
10
 
10
- def load_root_widgets
11
- require_widgets_and_helpers(Rails.root.to_s)
12
11
  end
13
12
 
14
- private
13
+ def load_root_widgets(config)
14
+ config.send(ErpBaseErpSvcs.determine_callback) do
15
+ ::ErpApp::Widgets::Loader.require_widgets_and_helpers(Rails.root.to_s)
16
+ end
17
+ end
15
18
 
16
19
  def require_widgets_and_helpers(path)
17
20
  widgets = []
@@ -38,11 +41,40 @@ module ErpApp
38
41
  end
39
42
  #get all view files for theme generation
40
43
  get_widget_view_files(widget_hash, widget_hash[:view_paths].first)
41
- #load any rails root extensions
44
+
45
+ #load root widget extensions that should override this widget
42
46
  load_root_widget_extensions(widget_hash)
43
47
  end
44
48
  end
45
49
 
50
+ def load_widget_extensions(engine)
51
+ widgets_path = File.join(engine.root,"lib",engine.railtie_name,"extensions/widgets")
52
+ widgets = File.directory?(widgets_path) ? Dir.entries(widgets_path) : []
53
+ widgets.delete_if{|name| name =~ /^\./}
54
+
55
+ widgets.each do |widget_name|
56
+ widget_hash = Rails.application.config.erp_app.widgets.find{|item| item[:name] == widget_name}
57
+ #load any extensions to existing widgets
58
+ Dir.glob(File.join(widgets_path,widget_name,"*.rb")).each do |file|
59
+ load file
60
+ end
61
+
62
+ #add any additional view paths to widgets
63
+ if File.directory?(File.join(widgets_path,widget_name,'views'))
64
+ view_path = File.join(widgets_path,widget_name,'views')
65
+ widget_hash[:view_paths] << view_path
66
+ #get all view files for theme generation
67
+ get_widget_view_files(widget_hash, view_path)
68
+ end
69
+
70
+ #overwrite with any extensions in rails root
71
+ load_root_widget_extensions(widget_hash)
72
+ end
73
+
74
+ end
75
+
76
+ private
77
+
46
78
  def load_widget_view_helpers(path)
47
79
  helpers = Dir.entries(path)
48
80
  helpers.delete_if{|name| name =~ /^\./}
@@ -77,32 +109,6 @@ module ErpApp
77
109
  end
78
110
  end
79
111
 
80
- def load_widget_extensions(engine)
81
- widgets_path = File.join(engine.root,"lib",engine.railtie_name,"extensions/widgets")
82
- widgets = File.directory?(widgets_path) ? Dir.entries(widgets_path) : []
83
- widgets.delete_if{|name| name =~ /^\./}
84
-
85
- widgets.each do |widget_name|
86
- widget_hash = Rails.application.config.erp_app.widgets.find{|item| item[:name] == widget_name}
87
- #load any extensions to existing widgets
88
- Dir.glob(File.join(widgets_path,widget_name,"*.rb")).each do |file|
89
- load file
90
- end
91
-
92
- #add any additional view paths to widgets
93
- if File.directory?(File.join(widgets_path,widget_name,'views'))
94
- view_path = File.join(widgets_path,widget_name,'views')
95
- widget_hash[:view_paths] << view_path
96
- #get all view files for theme generation
97
- get_widget_view_files(widget_hash, view_path)
98
- end
99
-
100
- #overwrite with any extensions in rails root
101
- load_root_widget_extensions(widget_hash)
102
- end
103
-
104
- end
105
-
106
112
  def load_root_widget_extensions(widget_hash)
107
113
  if File.directory?(File.join(Rails.root,"lib/extensions/widgets",widget_hash[:name]))
108
114
  Dir.glob(File.join(Rails.root,"lib/extensions/widgets",widget_hash[:name],"*.rb")).each do |file|
@@ -4,16 +4,16 @@ Ext.ns("ErpApp.CompassAccessNegotiator");
4
4
  * @class ErpApp.CompassAccessNegotiator.CompassUser
5
5
  **/
6
6
 
7
- ErpApp.CompassAccessNegotiator.CompassUser = function(user, applicationRoleManager){
7
+ ErpApp.CompassAccessNegotiator.CompassUser = function(user){
8
8
  this.id = user.id,
9
- this.roles = user.roles,
10
9
  this.username = user.username,
10
+ this.roles = user.roles,
11
+ this.capabilities = user.capabilities,
11
12
  this.lastloginAt = user.lastloginAt,
12
13
  this.lastActivityAt = user.lastActivityAt,
13
14
  this.failedLoginCount = user.failedLoginCount,
14
15
  this.email = user.email,
15
- this.applicationRoleManager = applicationRoleManager,
16
- this.description = user.description
16
+ this.description = user.description;
17
17
 
18
18
  /**
19
19
  * Checks to see if the passed roles exists in this.roles
@@ -44,21 +44,27 @@ ErpApp.CompassAccessNegotiator.CompassUser = function(user, applicationRoleManag
44
44
  return result;
45
45
  },
46
46
 
47
- this.hasApplicationCapability = function(application_iid, capability){
48
- return this.applicationRoleManager.hasApplicationCapability(application_iid, capability, this);
49
- },
47
+ this.hasCapability = function(capability_type_iid, klass){
48
+ for(var i = 0; i < this.capabilities.length; i++){
49
+ if (this.capabilities[i].capability_type_iid == capability_type_iid && this.capabilities[i].capability_resource_type == klass){
50
+ return true;
51
+ }
52
+ }
50
53
 
51
- this.hasWidgetCapability = function(xtype, capability){
52
- return this.applicationRoleManager.hasWidgetCapability(xtype, capability, this);
54
+ return false;
53
55
  },
54
56
 
55
- this.hasAccessToWidget = function(xtype){
56
- return this.applicationRoleManager.hasAccessToWidget(xtype, this);
57
- },
57
+ // this.hasWidgetCapability = function(xtype, capability){
58
+ // return this.applicationRoleManager.hasWidgetCapability(xtype, capability, this);
59
+ // },
58
60
 
59
- this.validWidgets = function(application_iid, filters){
60
- return this.applicationRoleManager.validWidgets(application_iid, filters, this);
61
- },
61
+ // this.hasAccessToWidget = function(xtype){
62
+ // return this.applicationRoleManager.hasAccessToWidget(xtype, this);
63
+ // },
64
+
65
+ // this.validWidgets = function(application_iid, filters){
66
+ // return this.applicationRoleManager.validWidgets(application_iid, filters, this);
67
+ // },
62
68
 
63
69
  /**
64
70
  * Use when role check fails, displays message add logging if needed.
@@ -75,9 +81,6 @@ ErpApp.CompassAccessNegotiator.CompassUser = function(user, applicationRoleManag
75
81
  fn: options['fn'] || null,
76
82
  iconCls:'icon-warning'
77
83
  });
78
- }
84
+ };
79
85
 
80
86
  };
81
-
82
-
83
-