knitkit 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/README.md +22 -0
  2. data/app/controllers/knitkit/base_controller.rb +15 -2
  3. data/app/controllers/knitkit/blogs_controller.rb +4 -4
  4. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +16 -2
  5. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +198 -57
  6. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +25 -11
  7. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +123 -44
  8. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +83 -9
  9. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +38 -0
  10. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +15 -6
  11. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +185 -98
  12. data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +38 -16
  13. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +126 -68
  14. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +154 -107
  15. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +113 -54
  16. data/app/controllers/knitkit/online_document_sections_controller.rb +45 -0
  17. data/app/controllers/knitkit/unauthorized_controller.rb +5 -0
  18. data/app/controllers/knitkit/website_sections_controller.rb +8 -9
  19. data/app/mailers/document_mailer.rb +10 -0
  20. data/app/models/article.rb +1 -1
  21. data/app/models/content.rb +35 -3
  22. data/app/models/document.rb +8 -0
  23. data/app/models/document_type.rb +3 -0
  24. data/app/models/documented_content.rb +29 -0
  25. data/app/models/documented_item.rb +31 -0
  26. data/app/models/extensions/configuration.rb +5 -0
  27. data/app/models/extensions/party.rb +13 -0
  28. data/app/models/online_document_section.rb +40 -0
  29. data/app/models/theme.rb +22 -26
  30. data/app/models/valid_document.rb +4 -0
  31. data/app/models/website.rb +158 -119
  32. data/app/models/website_inquiry.rb +7 -2
  33. data/app/models/website_inquiry_mailer.rb +4 -3
  34. data/app/models/website_party_role.rb +5 -0
  35. data/app/models/website_section.rb +76 -38
  36. data/app/views/document_mailer/email_document.html.erb +12 -0
  37. data/app/views/knitkit/blogs/_add_comment.html.erb +2 -2
  38. data/app/views/knitkit/online_document_sections/index.html.erb +149 -0
  39. data/app/views/knitkit/website_sections/index.html.erb +0 -1
  40. data/app/views/layouts/knitkit/base.html.erb +4 -2
  41. data/app/views/layouts/knitkit/online_document_sections.html.erb +59 -0
  42. data/app/views/menus/knitkit/_default_menu.html.erb +1 -1
  43. data/app/views/menus/knitkit/_default_section_menu.html.erb +1 -1
  44. data/app/views/menus/knitkit/_default_sub_menu.html.erb +2 -2
  45. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +1 -1
  46. data/app/widgets/contact_us/base.rb +5 -5
  47. data/app/widgets/contact_us/javascript/contact_us.js +2 -1
  48. data/app/widgets/google_map/base.rb +0 -4
  49. data/app/widgets/google_map/javascript/google_map.js +4 -3
  50. data/app/widgets/login/base.rb +0 -5
  51. data/app/widgets/login/javascript/login.js +155 -153
  52. data/app/widgets/login/views/index.html.erb +3 -3
  53. data/app/widgets/login/views/reset_password.html.erb +2 -2
  54. data/app/widgets/manage_profile/base.rb +46 -67
  55. data/app/widgets/manage_profile/javascript/manage_profile.js +2 -1
  56. data/app/widgets/manage_profile/views/_user_information_form.html.erb +5 -1
  57. data/app/widgets/reset_password/base.rb +4 -6
  58. data/app/widgets/reset_password/javascript/reset_password.js +2 -1
  59. data/app/widgets/reset_password/views/index.html.erb +4 -3
  60. data/app/widgets/search/base.rb +1 -5
  61. data/app/widgets/search/javascript/search.js +2 -1
  62. data/app/widgets/search/views/show.html.erb +2 -2
  63. data/app/widgets/signup/base.rb +7 -6
  64. data/app/widgets/signup/javascript/signup.js +2 -1
  65. data/app/widgets/signup/views/error.html.erb +1 -1
  66. data/config/routes.rb +6 -2
  67. data/db/data_migrations/20110509223702_add_publisher_role.rb +10 -0
  68. data/db/data_migrations/20111118182910_setup_knitkit_capabilities.rb +84 -0
  69. data/db/data_migrations/20120127144444_create_website_role_types.rb +13 -0
  70. data/db/data_migrations/20120127150505_create_website_default_configuration.rb +72 -0
  71. data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +33 -0
  72. data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +16 -0
  73. data/db/data_migrations/upgrade/20120210195616_add_website_configs.rb +19 -0
  74. data/db/data_migrations/upgrade/20120213205519_populate_website_iids.rb +17 -0
  75. data/db/migrate/20110211002317_setup_knitkit.rb +22 -5
  76. data/db/migrate/20111207161928_create_documented_items_table.rb +13 -0
  77. data/db/migrate/20111208180539_add_document_id_to_documented_item.rb +9 -0
  78. data/db/migrate/20120315163736_add_document.rb +32 -0
  79. data/db/migrate/20120503183431_create_valid_documents.rb +16 -0
  80. data/db/migrate/upgrade/20120116201510_add_render_base_layout_flag.rb +13 -0
  81. data/db/migrate/upgrade/20120127143745_create_website_party_roles.rb +24 -0
  82. data/db/migrate/upgrade/20120213184509_add_iid_to_websites.rb +14 -0
  83. data/lib/knitkit.rb +2 -0
  84. data/lib/knitkit/config.rb +31 -0
  85. data/lib/knitkit/engine.rb +12 -3
  86. data/lib/knitkit/extensions.rb +1 -3
  87. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +2 -3
  88. data/lib/knitkit/extensions/active_record/acts_as_document.rb +63 -0
  89. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +5 -4
  90. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +70 -0
  91. data/lib/knitkit/extensions/railties/action_view.rb +22 -10
  92. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +3 -3
  93. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +8 -3
  94. data/lib/knitkit/routing_filter/section_router.rb +16 -6
  95. data/lib/knitkit/version.rb +7 -1
  96. data/public/images/check.png +0 -0
  97. data/public/images/credit_card.png +0 -0
  98. data/public/images/knitkit/tooltip.gif +0 -0
  99. data/public/javascripts/ajax_pagination.js +33 -0
  100. data/public/javascripts/datepicker.js +6 -1
  101. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +731 -258
  102. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +289 -238
  103. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +2 -4
  104. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +29 -3
  105. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +193 -21
  106. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +27 -26
  107. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +167 -20
  108. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +1 -2
  109. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +5 -1
  110. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +2 -2
  111. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +20 -11
  112. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +279 -228
  113. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +40 -40
  114. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +83 -76
  115. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +1961 -1397
  116. data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +47 -43
  117. data/public/javascripts/knitkit/helpers.js +26 -0
  118. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +1 -2
  119. data/public/stylesheets/knitkit/documentation.css +50 -0
  120. data/public/stylesheets/knitkit/style.css +23 -1
  121. data/spec/controllers/knitkit/erp_app/desktop/articles_controller_spec.rb +8 -0
  122. data/spec/controllers/knitkit/erp_app/desktop/website_controller_spec.rb +396 -0
  123. data/spec/controllers/knitkit/erp_app/desktop/website_nav_controller_spec.rb +260 -0
  124. data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +222 -0
  125. data/spec/dummy/Rakefile +7 -0
  126. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  127. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  128. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  129. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  130. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  131. data/spec/dummy/config.ru +4 -0
  132. data/spec/dummy/config/application.rb +43 -0
  133. data/spec/dummy/config/boot.rb +10 -0
  134. data/spec/dummy/config/database.yml +8 -0
  135. data/spec/dummy/config/environment.rb +5 -0
  136. data/spec/dummy/config/environments/spec.rb +27 -0
  137. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  138. data/spec/dummy/config/initializers/inflections.rb +10 -0
  139. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  140. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  141. data/spec/dummy/config/initializers/session_store.rb +8 -0
  142. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  143. data/spec/dummy/config/locales/en.yml +5 -0
  144. data/spec/dummy/config/routes.rb +4 -0
  145. data/spec/dummy/config/workflow.yml +1 -0
  146. data/spec/dummy/public/404.html +26 -0
  147. data/spec/dummy/public/422.html +26 -0
  148. data/spec/dummy/public/500.html +26 -0
  149. data/spec/dummy/public/favicon.ico +0 -0
  150. data/spec/dummy/script/rails +6 -0
  151. data/spec/factories/article.rb +4 -0
  152. data/spec/factories/basic.rb +3 -0
  153. data/spec/factories/blog.rb +5 -0
  154. data/spec/factories/documented_content.rb +4 -0
  155. data/spec/factories/documented_item.rb +4 -0
  156. data/spec/factories/online_document_section.rb +6 -0
  157. data/spec/factories/published_website.rb +4 -0
  158. data/spec/factories/theme.rb +6 -0
  159. data/spec/factories/website.rb +5 -0
  160. data/spec/factories/website_host.rb +4 -0
  161. data/spec/factories/website_nav.rb +5 -0
  162. data/spec/factories/website_nav_item.rb +4 -0
  163. data/spec/factories/website_section.rb +5 -0
  164. data/spec/models/article_spec.rb +35 -0
  165. data/spec/models/attribute_type_spec.rb +55 -0
  166. data/spec/models/attribute_value_spec.rb +114 -0
  167. data/spec/models/blog_spec.rb +16 -0
  168. data/spec/models/comment_spec.rb +11 -0
  169. data/spec/models/content_spec.rb +187 -0
  170. data/spec/models/documented_item_spec.rb +29 -0
  171. data/spec/models/online_document_section_spec.rb +34 -0
  172. data/spec/models/published_element_spec.rb +11 -0
  173. data/spec/models/published_website_spec.rb +11 -0
  174. data/spec/models/theme_spec.rb +12 -0
  175. data/spec/models/website_host_spec.rb +11 -0
  176. data/spec/models/website_inquiry_spec.rb +24 -0
  177. data/spec/models/website_nav_item_spec.rb +11 -0
  178. data/spec/models/website_nav_spec.rb +11 -0
  179. data/spec/models/website_section_content_spec.rb +11 -0
  180. data/spec/models/website_section_spec.rb +49 -0
  181. data/spec/models/website_spec.rb +146 -0
  182. data/spec/spec_helper.rb +61 -0
  183. metadata +391 -154
  184. data/app/controllers/knitkit/articles_controller.rb +0 -7
  185. data/lib/knitkit/extensions/compass/widgets/base.rb +0 -53
@@ -8,8 +8,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ThemesTreePanel",{
8
8
  updateThemeActiveStatus : function(themeId, siteId, active){
9
9
  var self = this;
10
10
  self.initialConfig['centerRegion'].setWindowStatus('Updating Status...');
11
- var conn = new Ext.data.Connection();
12
- conn.request({
11
+ Ext.Ajax.request({
13
12
  url: '/knitkit/erp_app/desktop/theme/change_status',
14
13
  method: 'POST',
15
14
  params:{
@@ -39,42 +38,31 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ThemesTreePanel",{
39
38
 
40
39
  deleteTheme : function(themeId){
41
40
  var self = this;
42
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this theme?', function(btn){
43
- if(btn == 'no'){
44
- return false;
45
- }
46
- else
47
- if(btn == 'yes')
48
- {
49
- self.initialConfig['centerRegion'].setWindowStatus('Deleting theme...');
50
- var conn = new Ext.data.Connection();
51
- conn.request({
52
- url: '/knitkit/erp_app/desktop/theme/delete',
53
- method: 'POST',
54
- params:{
55
- theme_id:themeId
56
- },
57
- success: function(response) {
58
- var obj = Ext.decode(response.responseText);
59
- if(obj.success){
60
- self.initialConfig['centerRegion'].clearWindowStatus();
61
- self.getStore().load({
62
- node:self.getRootNode()
63
- });
64
- }
65
- else{
66
- Ext.Msg.alert('Error', 'Error deleting theme');
67
- self.initialConfig['centerRegion'].clearWindowStatus();
68
- }
69
- },
70
- failure: function(response) {
71
- self.initialConfig['centerRegion'].clearWindowStatus();
72
- Ext.Msg.alert('Error', 'Error deleting theme');
73
- }
74
- });
41
+ self.initialConfig['centerRegion'].setWindowStatus('Deleting theme...');
42
+ Ext.Ajax.request({
43
+ url: '/knitkit/erp_app/desktop/theme/delete',
44
+ method: 'POST',
45
+ params:{
46
+ theme_id:themeId
47
+ },
48
+ success: function(response) {
49
+ var obj = Ext.decode(response.responseText);
50
+ if(obj.success){
51
+ self.initialConfig['centerRegion'].clearWindowStatus();
52
+ self.getStore().load({
53
+ node:self.getRootNode()
54
+ });
55
+ }
56
+ else{
57
+ Ext.Msg.alert('Error', 'Error deleting theme');
58
+ self.initialConfig['centerRegion'].clearWindowStatus();
59
+ }
60
+ },
61
+ failure: function(response) {
62
+ self.initialConfig['centerRegion'].clearWindowStatus();
63
+ Ext.Msg.alert('Error', 'Error deleting theme');
75
64
  }
76
- });
77
-
65
+ });
78
66
  },
79
67
 
80
68
  exportTheme : function(themeId){
@@ -88,7 +76,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ThemesTreePanel",{
88
76
  var self = this;
89
77
  self.sitesJsonStore.load();
90
78
  var themesJsonStore = Ext.create("Ext.data.Store",{
91
- autoLoad:true,
79
+ autoLoad:false,
92
80
  proxy:{
93
81
  url:'/knitkit/erp_app/desktop/theme/available_themes',
94
82
  type:'ajax',
@@ -261,12 +249,14 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ThemesTreePanel",{
261
249
  var self = this;
262
250
 
263
251
  config = Ext.apply({
252
+ autoLoadRoot:true,
253
+ rootVisible:true,
264
254
  title:'Themes',
255
+ rootText:'Websites',
265
256
  controllerPath:'/knitkit/erp_app/desktop/theme',
266
257
  autoDestroy:true,
267
258
  allowDownload:true,
268
259
  addViewContentsToContextMenu:true,
269
- rootVisible:false,
270
260
  standardUploadUrl:'/knitkit/erp_app/desktop/theme/upload_file',
271
261
  xhrUploadUrl:'/knitkit/erp_app/desktop/theme/upload_file',
272
262
  url:'/knitkit/erp_app/desktop/theme/index',
@@ -306,7 +296,17 @@ Ext.define("Compass.ErpApp.Desktop.Applications.ThemesTreePanel",{
306
296
  containerScroll: true,
307
297
  listeners:{
308
298
  'contentLoaded':function(fileManager, node, content){
309
- self.initialConfig['centerRegion'].editTemplateFile(node, content, []);
299
+ var themeId = null;
300
+ var themeNode = node;
301
+ while(themeId == null && !Compass.ErpApp.Utility.isBlank(themeNode.parentNode)){
302
+ if(themeNode.data.isTheme){
303
+ themeId = themeNode.data.id
304
+ }
305
+ else{
306
+ themeNode = themeNode.parentNode;
307
+ }
308
+ }
309
+ self.initialConfig['centerRegion'].editTemplateFile(node, content, [], themeId);
310
310
  },
311
311
  'handleContextMenu':function(fileManager, node, e){
312
312
  if(node.data['isTheme']){
@@ -80,18 +80,13 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.VersionsGridPanel",{
80
80
  }
81
81
  },
82
82
  handler: function(grid, rowIndex, colIndex) {
83
- if(currentUser.hasRole(['publisher','admin'])){
84
- var rec = grid.getStore().getAt(rowIndex);
85
- if(rec.get('published')){
86
- return false;
87
- }
88
- else{
89
- grid.ownerCt.publish(rec)
90
- }
91
- }
92
- else{
93
- compassUser.showInvalidAccess();
94
- }
83
+ var rec = grid.getStore().getAt(rowIndex);
84
+ if(rec.get('published')){
85
+ return false;
86
+ }
87
+ else{
88
+ grid.ownerCt.publish(rec)
89
+ }
95
90
 
96
91
  }
97
92
  }]
@@ -136,65 +131,81 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.VersionsArticleGridPanel
136
131
  this.initialConfig['centerRegion'].viewContent(rec.get('title') + " - Revision " + rec.get('version'), rec.get('body_html'));
137
132
  },
138
133
 
139
- revert: function(rec){
140
- var self = this;
141
- self.initialConfig['centerRegion'].setWindowStatus('Reverting...');
142
- var conn = new Ext.data.Connection();
143
- conn.request({
144
- url: '/knitkit/erp_app/desktop/versions/revert_content',
145
- method: 'POST',
146
- params:{
147
- id:rec.get('id'),
148
- version:rec.get('version')
149
- },
150
- success: function(response) {
151
- self.initialConfig['centerRegion'].clearWindowStatus();
152
- var obj = Ext.decode(response.responseText);
153
- if(obj.success){
154
- self.initialConfig['centerRegion'].replaceHtmlInActiveCkEditor(rec.get('body_html'));
155
- self.getStore().load();
156
- }
157
- else{
158
- Ext.Msg.alert('Error', 'Error reverting');
134
+ revert: function(rec){
135
+ if (currentUser.hasApplicationCapability('knitkit', {
136
+ capability_type_iid:'revert_version',
137
+ resource:'Article'
138
+ }))
139
+ {
140
+ var self = this;
141
+ self.initialConfig['centerRegion'].setWindowStatus('Reverting...');
142
+ var conn = new Ext.data.Connection();
143
+ conn.request({
144
+ url: '/knitkit/erp_app/desktop/versions/revert_content',
145
+ method: 'POST',
146
+ params:{
147
+ id:rec.get('id'),
148
+ version:rec.get('version')
149
+ },
150
+ success: function(response) {
151
+ self.initialConfig['centerRegion'].clearWindowStatus();
152
+ var obj = Ext.decode(response.responseText);
153
+ if(obj.success){
154
+ self.initialConfig['centerRegion'].replaceHtmlInActiveCkEditor(rec.get('body_html'));
155
+ self.getStore().load();
156
+ }
157
+ else{
158
+ Ext.Msg.alert('Error', 'Error reverting');
159
+ }
160
+ },
161
+ failure: function(response) {
162
+ self.initialConfig['centerRegion'].clearWindowStatus();
163
+ Ext.Msg.alert('Error', 'Error reverting');
164
+ }
165
+ });
166
+ } else {
167
+ currentUser.showInvalidAccess();
159
168
  }
160
- },
161
- failure: function(response) {
162
- self.initialConfig['centerRegion'].clearWindowStatus();
163
- Ext.Msg.alert('Error', 'Error reverting');
164
- }
165
- });
166
- },
169
+ },
167
170
 
168
- publish: function(rec){
169
- var self = this;
170
-
171
- var publishWindow = new Compass.ErpApp.Desktop.Applications.Knitkit.PublishWindow({
172
- baseParams:{
173
- id:rec.get('id'),
174
- site_id:self.initialConfig.siteId,
175
- version:rec.get('version')
176
- },
177
- url:'/knitkit/erp_app/desktop/versions/publish_content',
178
- listeners:{
179
- 'publish_success':function(window, response){
180
- if(response.success){
181
- self.initialConfig['centerRegion'].clearWindowStatus();
182
- self.getStore().load();
183
- }
184
- else{
185
- Ext.Msg.alert('Error', 'Error publishing');
186
- self.initialConfig['centerRegion'].clearWindowStatus();
187
- }
188
- },
189
- 'publish_failure':function(window, response){
190
- self.initialConfig['centerRegion'].clearWindowStatus();
191
- Ext.Msg.alert('Error', 'Error publishing');
171
+ publish: function(rec){
172
+ if (currentUser.hasApplicationCapability('knitkit', {
173
+ capability_type_iid:'publish',
174
+ resource:'Article'
175
+ }))
176
+ {
177
+ var self = this;
178
+
179
+ var publishWindow = new Compass.ErpApp.Desktop.Applications.Knitkit.PublishWindow({
180
+ baseParams:{
181
+ id:rec.get('id'),
182
+ site_id:self.initialConfig.siteId,
183
+ version:rec.get('version')
184
+ },
185
+ url:'/knitkit/erp_app/desktop/versions/publish_content',
186
+ listeners:{
187
+ 'publish_success':function(window, response){
188
+ if(response.success){
189
+ self.initialConfig['centerRegion'].clearWindowStatus();
190
+ self.getStore().load();
191
+ }
192
+ else{
193
+ Ext.Msg.alert('Error', 'Error publishing');
194
+ self.initialConfig['centerRegion'].clearWindowStatus();
195
+ }
196
+ },
197
+ 'publish_failure':function(window, response){
198
+ self.initialConfig['centerRegion'].clearWindowStatus();
199
+ Ext.Msg.alert('Error', 'Error publishing');
200
+ }
201
+ }
202
+ });
203
+
204
+ publishWindow.show();
205
+ } else {
206
+ currentUser.showInvalidAccess();
192
207
  }
193
- }
194
- });
195
-
196
- publishWindow.show();
197
- },
208
+ },
198
209
 
199
210
  constructor : function(config) {
200
211
  config = Ext.apply({
@@ -261,8 +272,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.VersionsBlogGridPanel",{
261
272
  revert: function(rec){
262
273
  var self = this;
263
274
  self.initialConfig['centerRegion'].setWindowStatus('Reverting...');
264
- var conn = new Ext.data.Connection();
265
- conn.request({
275
+ Ext.Ajax.request({
266
276
  url: '/knitkit/erp_app/desktop/versions/revert_content',
267
277
  method: 'POST',
268
278
  params:{
@@ -396,8 +406,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.VersionsWebsiteSectionGr
396
406
  viewVersionedContent : function(rec){
397
407
  this.initialConfig['centerRegion'].setWindowStatus('Loading template...');
398
408
  var self = this;
399
- var conn = new Ext.data.Connection();
400
- conn.request({
409
+ Ext.Ajax.request({
401
410
  url: '/knitkit/erp_app/desktop/versions/get_website_section_version',
402
411
  method: 'POST',
403
412
  params:{
@@ -419,8 +428,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.VersionsWebsiteSectionGr
419
428
  revert: function(rec){
420
429
  var self = this;
421
430
  self.initialConfig['centerRegion'].setWindowStatus('Reverting...');
422
- var conn = new Ext.data.Connection();
423
- conn.request({
431
+ Ext.Ajax.request({
424
432
  url: '/knitkit/erp_app/desktop/versions/revert_website_section',
425
433
  method: 'POST',
426
434
  params:{
@@ -534,8 +542,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.NonPublishedVersionsGrid
534
542
  revert: function(rec){
535
543
  var self = this;
536
544
  self.initialConfig['centerRegion'].setWindowStatus('Reverting...');
537
- var conn = new Ext.data.Connection();
538
- conn.request({
545
+ Ext.Ajax.request({
539
546
  url: '/knitkit/erp_app/desktop/versions/revert_content',
540
547
  method: 'POST',
541
548
  params:{
@@ -12,7 +12,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
12
12
 
13
13
  deleteSection : function(node){
14
14
  var self = this;
15
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this section?', function(btn){
15
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this section?<br> NOTE: Articles belonging to this section will be orphaned.', function(btn){
16
16
  if(btn == 'no'){
17
17
  return false;
18
18
  }
@@ -20,8 +20,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
20
20
  if(btn == 'yes')
21
21
  {
22
22
  self.setWindowStatus('Deleting Section...');
23
- var conn = new Ext.data.Connection();
24
- conn.request({
23
+ Ext.Ajax.request({
25
24
  url: '/knitkit/erp_app/desktop/section/delete',
26
25
  method: 'POST',
27
26
  params:{
@@ -63,8 +62,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
63
62
  if(btn == 'yes')
64
63
  {
65
64
  self.setWindowStatus('Deleting Website...');
66
- var conn = new Ext.data.Connection();
67
- conn.request({
65
+ Ext.Ajax.request({
68
66
  url: '/knitkit/erp_app/desktop/site/delete',
69
67
  method: 'POST',
70
68
  params:{
@@ -118,8 +116,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
118
116
  var self = this;
119
117
  self.selectWebsite(websiteId);
120
118
  self.setWindowStatus('Loading section template...');
121
- var conn = new Ext.data.Connection();
122
- conn.request({
119
+ Ext.Ajax.request({
123
120
  url: '/knitkit/erp_app/desktop/section/get_layout',
124
121
  method: 'POST',
125
122
  params:{
@@ -155,8 +152,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
155
152
  changeSecurityOnSection : function(node, secure){
156
153
  var self = this;
157
154
  self.setWindowStatus('Updating section...');
158
- var conn = new Ext.data.Connection();
159
- conn.request({
155
+ Ext.Ajax.request({
160
156
  url: '/knitkit/erp_app/desktop/section/update_security',
161
157
  method: 'POST',
162
158
  params:{
@@ -191,8 +187,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
191
187
  changeSecurityOnMenuItem : function(node, secure){
192
188
  var self = this;
193
189
  self.setWindowStatus('Updating menu item security...');
194
- var conn = new Ext.data.Connection();
195
- conn.request({
190
+ Ext.Ajax.request({
196
191
  url: '/knitkit/erp_app/desktop/website_nav/update_security',
197
192
  method: 'POST',
198
193
  params:{
@@ -240,6 +235,26 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
240
235
  });
241
236
  Ext.getCmp('knitkitEastRegion').fileAssetsPanel.selectWebsite(websiteId);
242
237
  Ext.getCmp('knitkitEastRegion').imageAssetsPanel.selectWebsite(websiteId);
238
+ Compass.ErpApp.Shared.FileManagerTree.extraPostData = {
239
+ website_id:websiteId
240
+ };
241
+ },
242
+
243
+ updateWebsiteConfiguration : function(rec){
244
+ var configurationWindow = Ext.create("Ext.window.Window",{
245
+ layout:'fit',
246
+ width:600,
247
+ title:'Configuration',
248
+ height:400,
249
+ autoScroll:true,
250
+ plain: true,
251
+ items:[{
252
+ xtype:'sharedconfigurationpanel',
253
+ configurationId:rec.get('configurationId')
254
+ }]
255
+ });
256
+
257
+ configurationWindow.show();
243
258
  },
244
259
 
245
260
  initComponent: function() {
@@ -248,7 +263,8 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
248
263
  var store = Ext.create('Ext.data.TreeStore', {
249
264
  proxy:{
250
265
  type: 'ajax',
251
- url: '/knitkit/erp_app/desktop/websites'
266
+ url: '/knitkit/erp_app/desktop/websites',
267
+ timeout: 90000
252
268
  },
253
269
  root: {
254
270
  text: 'Websites',
@@ -273,6 +289,12 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
273
289
  {
274
290
  name:'isSection'
275
291
  },
292
+ {
293
+ name:'isDocument'
294
+ },
295
+ {
296
+ name:'contentInfo'
297
+ },
276
298
  {
277
299
  name:'isHost'
278
300
  },
@@ -282,6 +304,9 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
282
304
  {
283
305
  name:'url'
284
306
  },
307
+ {
308
+ name:'path'
309
+ },
285
310
  {
286
311
  name:'inMenu'
287
312
  },
@@ -359,73 +384,98 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
359
384
  },
360
385
  {
361
386
  name:'internal_identifier'
387
+ },
388
+ {
389
+ name:'configurationId'
390
+ },
391
+ {
392
+ name:'renderWithBaseLayout'
362
393
  }
363
394
  ]
364
395
  });
365
396
 
366
- this.sitesTree = new Ext.tree.TreePanel({
367
- viewConfig: {
368
- //TODO_EXTJS4 this is added to fix error should be removed when extjs 4 releases fix.
369
- loadMask: false,
370
- markDirty: false,
371
- plugins: {
372
- ptype: 'treeviewdragdrop'
373
- },
374
- listeners:{
375
- 'beforedrop':function(node, data, overModel, dropPosition,dropFunction,options){
376
- if(overModel.data['isWebsiteNavItem']){
397
+ var pluginItems = [];
398
+
399
+ if (currentUser.hasApplicationCapability('knitkit', {
400
+ capability_type_iid:'drag_item',
401
+ resource:'WebsiteTree'
402
+ }))
403
+
404
+ {
405
+ pluginItems.push({
406
+ ptype: 'treeviewdragdrop'
407
+ });
408
+ }
409
+
410
+ var viewConfigItems = {
411
+ markDirty: false,
412
+ plugins: pluginItems,
413
+ listeners:{
414
+ 'beforedrop':function(node, data, overModel, dropPosition,dropFunction,options){
415
+ if(overModel.data['isWebsiteNavItem']){
416
+ return true;
417
+ }
418
+ else if(overModel.data['isSection']){
419
+ if(overModel.parentNode.data['isSectionRoot']){
377
420
  return true;
378
421
  }
379
- else if(overModel.data['isSection']){
380
- if(overModel.parentNode.data['isSectionRoot']){
381
- return true;
382
- }
383
- }
384
- return false;
385
- },
386
- 'drop':function(node, data, overModel, dropPosition, options){
387
- var positionArray = [];
388
- var counter = 0;
389
- var dropNode = data.records[0];
390
-
391
- if(dropNode.data['isWebsiteNavItem']){
392
- overModel.parentNode.eachChild(function(node){
393
- positionArray.push({
394
- id:node.data.websiteNavItemId,
395
- position:counter,
396
- klass:'WebsiteNavItem'
397
- });
398
- counter++;
422
+ }
423
+ else if (overModel.data['isDocument']){
424
+ return true;
425
+ }
426
+ return false;
427
+ },
428
+ 'drop':function(node, data, overModel, dropPosition, options){
429
+ var positionArray = [];
430
+ var counter = 0;
431
+ var dropNode = data.records[0];
432
+
433
+ if(dropNode.data['isWebsiteNavItem']){
434
+ overModel.parentNode.eachChild(function(node){
435
+ positionArray.push({
436
+ id:node.data.websiteNavItemId,
437
+ position:counter,
438
+ klass:'WebsiteNavItem'
399
439
  });
400
- }
401
- else{
402
- overModel.parentNode.eachChild(function(node){
403
- positionArray.push({
404
- id:node.data.id.split('_')[1],
405
- position:counter,
406
- klass:'WebsiteSection'
407
- });
408
- counter++;
440
+ counter++;
441
+ });
442
+ }
443
+ else{
444
+ overModel.parentNode.eachChild(function(node){
445
+ positionArray.push({
446
+ id:node.data.id.split('_')[1],
447
+ position:counter,
448
+ klass:'WebsiteSection'
409
449
  });
410
- }
450
+ counter++;
451
+ });
452
+ }
411
453
 
412
- var conn = new Ext.data.Connection();
413
- conn.request({
414
- url:'/knitkit/erp_app/desktop/position/update',
415
- method: 'PUT',
416
- jsonData:{
417
- position_array:positionArray
418
- },
419
- success: function(response) {
454
+ Ext.Ajax.request({
455
+ url:'/knitkit/erp_app/desktop/position/update',
456
+ method: 'PUT',
457
+ jsonData:{
458
+ position_array:positionArray
459
+ },
460
+ success: function(response) {
461
+ var obj = Ext.decode(response.responseText);
462
+ if(obj.success){
420
463
 
421
- },
422
- failure: function(response) {
423
- Ext.Msg.alert('Error', 'Error saving positions.');
424
464
  }
425
- });
426
- }
465
+ else{
466
+ Ext.Msg.alert("Error", obj.message);
467
+ }
468
+ },
469
+ failure: function(response) {
470
+ Ext.Msg.alert('Error', 'Error saving positions.');
471
+ }
472
+ });
427
473
  }
428
- },
474
+ }
475
+ };
476
+
477
+ this.sitesTree = new Ext.tree.TreePanel({
478
+ viewConfig:viewConfigItems,
429
479
  store:store,
430
480
  region: 'center',
431
481
  rootVisible:false,
@@ -445,6 +495,10 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
445
495
  var webNavigator = window.compassDesktop.getModule('web-navigator-win');
446
496
  webNavigator.createWindow(record.data['url']);
447
497
  }
498
+ else
499
+ if(record.data['isDocument']){
500
+ self.initialConfig['centerRegion'].editContent(record.data['contentInfo'].title, record.data['contentInfo'].id, record.data['contentInfo'].body_html, record.data['siteId'], 'article');
501
+ }
448
502
  },
449
503
  'itemcontextmenu':function(view, record, htmlItem, index, e){
450
504
  e.stopEvent();
@@ -464,217 +518,29 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
464
518
  }
465
519
 
466
520
  if(record.data['canAddMenuItems']){
467
- items.push({
468
- text:'Add Menu Item',
469
- iconCls:'icon-add',
470
- handler:function(btn){
471
- var addMenuItemWindow = Ext.create("Ext.window.Window",{
472
- layout:'fit',
473
- width:375,
474
- title:'New Menu Item',
475
- height:175,
476
- plain: true,
477
- buttonAlign:'center',
478
- items: new Ext.FormPanel({
479
- labelWidth: 50,
480
- frame:false,
481
- bodyStyle:'padding:5px 5px 0',
482
- url:'/knitkit/erp_app/desktop/website_nav/add_menu_item',
483
- defaults: {
484
- width: 225
485
- },
486
- items: [
487
- {
488
- xtype:'textfield',
489
- fieldLabel:'Title',
490
- allowBlank:false,
491
- name:'title'
492
- },
493
- {
494
- xtype:'combo',
495
- fieldLabel:'Link to',
496
- name:'link_to',
497
- id:'knitkit_nav_item_link_to',
498
- allowBlank:false,
499
- forceSelection:true,
500
- editable:false,
501
- autoSelect:true,
502
- typeAhead: false,
503
- mode: 'local',
504
- triggerAction: 'all',
505
- store:[
506
- ['website_section','Section'],
507
- ['url','Url']
508
- ],
509
- value:'website_section',
510
- listeners:{
511
- 'change':function(combo, newValue, oldValue){
512
- switch(newValue){
513
- case 'website_section':
514
- Ext.getCmp('knitkit_create_website_nav_item_section').show();
515
- Ext.getCmp('knitkit_create_website_nav_item_url').hide();
516
- break;
517
- case 'url':
518
- Ext.getCmp('knitkit_create_website_nav_item_section').hide();
519
- Ext.getCmp('knitkit_create_website_nav_item_url').show();
520
- break;
521
- }
522
- }
523
- }
524
- },
525
- {
526
- xtype:'combo',
527
- id:'knitkit_create_website_nav_item_section',
528
- hiddenName:'website_section_id',
529
- name:'website_section_id',
530
- width:300,
531
- loadingText:'Retrieving Sections...',
532
- store:Ext.create("Ext.data.Store",{
533
- proxy:{
534
- type:'ajax',
535
- url:'/knitkit/erp_app/desktop/section/existing_sections',
536
- reader:{
537
- type:'json'
538
- },
539
- extraParams:{
540
- website_id:record.data.websiteId
541
- }
542
- },
543
- autoLoad:true,
544
- fields:[
545
- {
546
- name:'id'
547
- },
548
- {
549
- name:'title_permalink'
550
-
551
- }
552
- ]
553
- }),
554
- forceSelection:true,
555
- editable:false,
556
- fieldLabel:'Section',
557
- autoSelect:true,
558
- typeAhead: false,
559
- mode: 'local',
560
- displayField:'title_permalink',
561
- valueField:'id',
562
- triggerAction: 'all'
563
- },
564
- {
565
- xtype:'textfield',
566
- fieldLabel:'Url',
567
- id:'knitkit_create_website_nav_item_url',
568
- hidden:true,
569
- name:'url'
570
- },
571
- {
572
- xtype:'hidden',
573
- name:'klass',
574
- value: ((record.data['websiteNavId']) ? 'WebsiteNav' : 'WebsiteNavItem')
575
- },
576
- {
577
- xtype:'hidden',
578
- name:'id',
579
- value:record.data['websiteNavId'] || record.data['websiteNavItemId']
580
- }
581
- ]
582
- }),
583
- buttons: [{
584
- text:'Submit',
585
- listeners:{
586
- 'click':function(button){
587
- var window = button.findParentByType('window');
588
- var formPanel = window.query('form')[0];
589
- self.setWindowStatus('Creating menu item...');
590
- formPanel.getForm().submit({
591
- reset:true,
592
- success:function(form, action){
593
- self.clearWindowStatus();
594
- var obj = Ext.decode(action.response.responseText);
595
- if(obj.success){
596
- record.appendChild(obj.node);
597
- }
598
- else{
599
- Ext.Msg.alert("Error", obj.msg);
600
- }
601
- },
602
- failure:function(form, action){
603
- self.clearWindowStatus();
604
- if(action.response == null){
605
- Ext.Msg.alert("Error", 'Could not create menu item');
606
- }
607
- else{
608
- var obj = Ext.decode(action.response.responseText);
609
- Ext.Msg.alert("Error", obj.msg);
610
- }
611
-
612
- }
613
- });
614
- }
615
- }
616
- },{
617
- text: 'Close',
618
- handler: function(){
619
- addMenuItemWindow.close();
620
- }
621
- }]
622
- });
623
- addMenuItemWindow.show();
624
- }
625
- });
626
- }
627
521
 
628
- if(record.data['isSection']){
629
- items.push({
630
- text:'View Articles',
631
- iconCls:'icon-document',
632
- listeners:{
633
- 'click':function(){
634
- self.getArticles(record);
635
- }
636
- }
637
- });
522
+ if (currentUser.hasApplicationCapability('knitkit', {
523
+ capability_type_iid:'create',
524
+ resource:'MenuItem'
525
+ }))
638
526
 
639
- if(record.data.isSecured){
640
- items.push({
641
- text:'Unsecure',
642
- iconCls:'icon-document',
643
- listeners:{
644
- 'click':function(){
645
- self.changeSecurityOnSection(record, false);
646
- }
647
- }
648
- });
649
- }
650
- else{
527
+ {
651
528
  items.push({
652
- text:'Secure',
653
- iconCls:'icon-document_lock',
654
- listeners:{
655
- 'click':function(){
656
- self.changeSecurityOnSection(record, true);
657
- }
658
- }
659
- });
660
- }
661
-
662
- items.push({
663
- text:'Add Section',
664
- iconCls:'icon-add',
665
- listeners:{
666
- 'click':function(){
667
- var addSectionWindow = Ext.create("Ext.window.Window",{
529
+ text:'Add Menu Item',
530
+ iconCls:'icon-add',
531
+ handler:function(btn){
532
+ var addMenuItemWindow = Ext.create("Ext.window.Window",{
668
533
  layout:'fit',
669
534
  width:375,
670
- title:'New Section',
535
+ title:'New Menu Item',
536
+ height:175,
671
537
  plain: true,
672
538
  buttonAlign:'center',
673
539
  items: new Ext.FormPanel({
674
- labelWidth: 110,
540
+ labelWidth: 50,
675
541
  frame:false,
676
542
  bodyStyle:'padding:5px 5px 0',
677
- url:'/knitkit/erp_app/desktop/section/new',
543
+ url:'/knitkit/erp_app/desktop/website_nav/add_menu_item',
678
544
  defaults: {
679
545
  width: 225
680
546
  },
@@ -686,52 +552,93 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
686
552
  name:'title'
687
553
  },
688
554
  {
689
- xtype:'textfield',
690
- fieldLabel:'Unique Name',
691
- allowBlank:true,
692
- name:'internal_identifier'
555
+ xtype:'combo',
556
+ fieldLabel:'Link to',
557
+ name:'link_to',
558
+ id:'knitkit_nav_item_link_to',
559
+ allowBlank:false,
560
+ forceSelection:true,
561
+ editable:false,
562
+ autoSelect:true,
563
+ typeAhead: false,
564
+ mode: 'local',
565
+ triggerAction: 'all',
566
+ store:[
567
+ ['website_section','Section'],
568
+ ['url','Url']
569
+ ],
570
+ value:'website_section',
571
+ listeners:{
572
+ 'change':function(combo, newValue, oldValue){
573
+ switch(newValue){
574
+ case 'website_section':
575
+ Ext.getCmp('knitkit_create_website_nav_item_section').show();
576
+ Ext.getCmp('knitkit_create_website_nav_item_url').hide();
577
+ break;
578
+ case 'url':
579
+ Ext.getCmp('knitkit_create_website_nav_item_section').hide();
580
+ Ext.getCmp('knitkit_create_website_nav_item_url').show();
581
+ break;
582
+ }
583
+ }
584
+ }
693
585
  },
694
586
  {
695
- xtype: 'combo',
587
+ xtype:'combo',
588
+ id:'knitkit_create_website_nav_item_section',
589
+ hiddenName:'website_section_id',
590
+ name:'website_section_id',
591
+ width:300,
592
+ loadingText:'Retrieving Sections...',
593
+ store:Ext.create("Ext.data.Store",{
594
+ proxy:{
595
+ type:'ajax',
596
+ url:'/knitkit/erp_app/desktop/section/existing_sections',
597
+ reader:{
598
+ type:'json'
599
+ },
600
+ extraParams:{
601
+ website_id:record.data.websiteId
602
+ }
603
+ },
604
+ autoLoad:true,
605
+ fields:[
606
+ {
607
+ name:'id'
608
+ },
609
+ {
610
+ name:'title_permalink'
611
+
612
+ }
613
+ ]
614
+ }),
696
615
  forceSelection:true,
697
- store: [
698
- ['Page','Page'],
699
- ['Blog','Blog'],
700
- ],
701
- value:'Page',
702
- fieldLabel: 'Type',
703
- name: 'type',
704
- allowBlank: false,
616
+ editable:false,
617
+ fieldLabel:'Section',
618
+ autoSelect:true,
619
+ typeAhead: false,
620
+ mode: 'local',
621
+ displayField:'title_permalink',
622
+ valueField:'id',
623
+
705
624
  triggerAction: 'all'
706
625
  },
707
626
  {
708
- xtype:'radiogroup',
709
- fieldLabel:'Display in menu?',
710
- name:'in_menu',
711
- columns:2,
712
- items:[
713
- {
714
- boxLabel:'Yes',
715
- name:'in_menu',
716
- inputValue: 'yes',
717
- checked:true
718
- },
719
-
720
- {
721
- boxLabel:'No',
722
- name:'in_menu',
723
- inputValue: 'no'
724
- }]
627
+ xtype:'textfield',
628
+ fieldLabel:'Url',
629
+ id:'knitkit_create_website_nav_item_url',
630
+ hidden:true,
631
+ name:'url'
725
632
  },
726
633
  {
727
634
  xtype:'hidden',
728
- name:'website_section_id',
729
- value:record.data.id.split('_')[1]
635
+ name:'klass',
636
+ value: ((record.data['websiteNavId']) ? 'WebsiteNav' : 'WebsiteNavItem')
730
637
  },
731
638
  {
732
639
  xtype:'hidden',
733
- name:'website_id',
734
- value:record.data.siteId
640
+ name:'id',
641
+ value:record.data['websiteNavId'] || record.data['websiteNavItemId']
735
642
  }
736
643
  ]
737
644
  }),
@@ -740,8 +647,8 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
740
647
  listeners:{
741
648
  'click':function(button){
742
649
  var window = button.findParentByType('window');
743
- var formPanel = window.query('.form')[0];
744
- self.setWindowStatus('Creating section...');
650
+ var formPanel = window.query('form')[0];
651
+ self.setWindowStatus('Creating menu item...');
745
652
  formPanel.getForm().submit({
746
653
  reset:true,
747
654
  success:function(form, action){
@@ -751,115 +658,19 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
751
658
  record.appendChild(obj.node);
752
659
  }
753
660
  else{
754
- Ext.Msg.alert("Error", obj.message);
661
+ Ext.Msg.alert("Error", obj.msg);
755
662
  }
756
663
  },
757
664
  failure:function(form, action){
758
665
  self.clearWindowStatus();
759
- var obj = Ext.decode(action.response.responseText);
760
- if(obj.message){
761
- Ext.Msg.alert("Error", obj.message);
666
+ if(action.response == null){
667
+ Ext.Msg.alert("Error", 'Could not create menu item');
762
668
  }
763
669
  else{
764
- Ext.Msg.alert("Error", "Error creating section.");
670
+ var obj = Ext.decode(action.response.responseText);
671
+ Ext.Msg.alert("Error", obj.msg);
765
672
  }
766
- }
767
- });
768
- }
769
- }
770
- },{
771
- text: 'Close',
772
- handler: function(){
773
- addSectionWindow.close();
774
- }
775
- }]
776
- });
777
- addSectionWindow.show();
778
- }
779
- }
780
- });
781
-
782
- items.push({
783
- text:'Update Section',
784
- iconCls:'icon-edit',
785
- listeners:{
786
- 'click':function(){
787
- var updateSectionWindow = Ext.create("Ext.window.Window",{
788
- layout:'fit',
789
- width:375,
790
- title:'Update Section',
791
- plain: true,
792
- buttonAlign:'center',
793
- items: new Ext.FormPanel({
794
- labelWidth: 110,
795
- frame:false,
796
- bodyStyle:'padding:5px 5px 0',
797
- url:'/knitkit/erp_app/desktop/section/update',
798
- defaults: {
799
- width: 225
800
- },
801
- items: [
802
- {
803
- xtype:'textfield',
804
- fieldLabel:'Title',
805
- value:record.data.text,
806
- name:'title'
807
- },
808
- {
809
- xtype:'textfield',
810
- fieldLabel:'Unique Name',
811
- allowBlank:true,
812
- name:'internal_identifier',
813
- value:record.data.internal_identifier
814
- },
815
- {
816
- xtype:'radiogroup',
817
- fieldLabel:'Display in menu?',
818
- name:'in_menu',
819
- columns:2,
820
- items:[
821
- {
822
- boxLabel:'Yes',
823
- name:'in_menu',
824
- inputValue: 'yes',
825
- checked:record.data.inMenu
826
- },
827
673
 
828
- {
829
- boxLabel:'No',
830
- name:'in_menu',
831
- inputValue: 'no',
832
- checked:!record.data.inMenu
833
- }]
834
- },
835
- {
836
- xtype:'hidden',
837
- name:'id',
838
- value:record.data.id.split('_')[1]
839
- }
840
- ]
841
- }),
842
- buttons: [{
843
- text:'Submit',
844
- listeners:{
845
- 'click':function(button){
846
- var window = button.findParentByType('window');
847
- var formPanel = window.query('.form')[0];
848
- self.setWindowStatus('Updating section...');
849
- formPanel.getForm().submit({
850
- success:function(form, action){
851
- self.clearWindowStatus();
852
- var values = formPanel.getValues();
853
- record.set('title',values.title);
854
- record.set('internal_identifier',values.internal_identifier);
855
- record.set("inMenu",(values.in_menu == 'yes'));
856
- record.commit();
857
- updateSectionWindow.close();
858
- },
859
- failure:function(form, action){
860
- self.clearWindowStatus();
861
- var obj = Ext.decode(action.response.responseText);
862
- Ext.Msg.alert("Error", obj.msg);
863
674
  }
864
675
  });
865
676
  }
@@ -867,75 +678,697 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
867
678
  },{
868
679
  text: 'Close',
869
680
  handler: function(){
870
- updateSectionWindow.close();
681
+ addMenuItemWindow.close();
871
682
  }
872
683
  }]
873
684
  });
874
- updateSectionWindow.show();
875
- }
876
- }
877
- });
878
-
879
- //no layouts for blogs.
880
- if(Compass.ErpApp.Utility.isBlank(record.data['isBlog']) && record.data['hasLayout']){
881
- items.push({
882
- text:'Edit Layout',
883
- iconCls:'icon-edit',
884
- listeners:{
885
- 'click':function(){
886
- self.editSectionLayout(record.data.text, record.data.id.split('_')[1], record.data.siteId);
887
- }
685
+ addMenuItemWindow.show();
888
686
  }
889
687
  });
890
688
  }
891
- else
892
- if(Compass.ErpApp.Utility.isBlank(record.data['isBlog'])){
689
+ }
690
+
691
+ if(record.data['isDocument']){
692
+
693
+ if (currentUser.hasApplicationCapability('knitkit', {
694
+ capability_type_iid:'create',
695
+ resource:'Section'
696
+ }))
697
+ {
893
698
  items.push({
894
- text:'Add Layout',
699
+ text:'Add Document',
895
700
  iconCls:'icon-add',
896
701
  listeners:{
897
702
  'click':function(){
898
- var sectionId = record.data.id.split('_')[1];
899
- var conn = new Ext.data.Connection();
900
- conn.request({
901
- url: '/knitkit/erp_app/desktop/section/add_layout',
902
- method: 'POST',
903
- params:{
904
- id:sectionId
905
- },
906
- success: function(response) {
907
- var obj = Ext.decode(response.responseText);
908
- if(obj.success){
909
- record.data.hasLayout = true;
910
- self.editSectionLayout(record.data.text, sectionId, record.data.siteId);
911
- }
912
- else
703
+ var addSectionWindow = Ext.create("Ext.window.Window",{
704
+ layout:'fit',
705
+ width:375,
706
+ title:'New Document Section',
707
+ plain: true,
708
+ buttonAlign:'center',
709
+ items: new Ext.FormPanel({
710
+ labelWidth: 110,
711
+ frame:false,
712
+ bodyStyle:'padding:5px 5px 0',
713
+ url:'/knitkit/erp_app/desktop/online_document_sections/new',
714
+ defaults: {
715
+ width: 225
716
+ },
717
+ items: [
913
718
  {
914
- Ext.Msg.alert('Status', obj.message);
915
- }
916
- },
917
- failure: function(response) {
918
- Ext.Msg.alert('Status', 'Error adding layout.');
919
- }
920
- });
921
- }
922
- }
923
- });
924
- }
719
+ xtype:'textfield',
720
+ fieldLabel:'Title',
721
+ allowBlank:false,
722
+ name:'title'
723
+ },
724
+ {
725
+ xtype:'textfield',
726
+ fieldLabel:'Unique Name',
727
+ allowBlank:true,
728
+ name:'internal_identifier'
729
+ },
730
+ {
731
+ xtype: 'combo',
732
+ forceSelection:true,
733
+ store: [
734
+ ['OnlineDocumentSection','Online Document Section'],
735
+ ],
736
+ value:'OnlineDocumentSection',
737
+ fieldLabel: 'Type',
738
+ name: 'type',
739
+ allowBlank: false,
740
+ triggerAction: 'all'
741
+ },
742
+ {
743
+ xtype: 'combo',
744
+ forceSelection: true,
745
+ store:[
746
+ ['Content', 'Content']
747
+ ],
748
+ value: 'Content',
749
+ fieldLabel: 'Document Type',
750
+ name: 'documenttype',
751
+ allowBlank: false,
752
+ triggerAction: 'all'
753
+ },
754
+ {
755
+ xtype:'radiogroup',
756
+ fieldLabel:'Display in menu?',
757
+ name:'in_menu',
758
+ columns:2,
759
+ items:[
760
+ {
761
+ boxLabel:'Yes',
762
+ name:'in_menu',
763
+ inputValue: 'yes',
764
+ checked:true
765
+ },
925
766
 
767
+ {
768
+ boxLabel:'No',
769
+ name:'in_menu',
770
+ inputValue: 'no'
771
+ }]
772
+ },
773
+ {
774
+ xtype:'hidden',
775
+ name:'website_section_id',
776
+ value:record.data.id.split('_')[1]
777
+ },
778
+ {
779
+ xtype:'hidden',
780
+ name:'website_id',
781
+ value:record.data.siteId
782
+ }
783
+ ]
784
+ }),
785
+ buttons: [{
786
+ text:'Submit',
787
+ listeners:{
788
+ 'click':function(button){
789
+ var window = button.findParentByType('window');
790
+ var formPanel = window.query('.form')[0];
791
+ self.setWindowStatus('Creating document section...');
792
+ formPanel.getForm().submit({
793
+ reset:true,
794
+ success:function(form, action){
795
+ self.clearWindowStatus();
796
+ var obj = Ext.decode(action.response.responseText);
797
+ if(obj.success){
798
+ record.appendChild(obj.node);
799
+ self.initialConfig['centerRegion'].editContent(obj.documented_content.title, obj.documented_content.id, obj.documented_content.body_html, record.data.siteId, 'article');
800
+ }
801
+ else{
802
+ Ext.Msg.alert("Error", obj.message);
803
+ }
804
+ },
805
+ failure:function(form, action){
806
+ self.clearWindowStatus();
807
+ var obj = Ext.decode(action.response.responseText);
808
+ if(obj.message){
809
+ Ext.Msg.alert("Error", obj.message);
810
+ }
811
+ else{
812
+ Ext.Msg.alert("Error", "Error creating document.");
813
+ }
814
+ }
815
+ });
816
+ }
817
+ }
818
+ },{
819
+ text: 'Close',
820
+ handler: function(){
821
+ addSectionWindow.close();
822
+ }
823
+ }]
824
+ });
825
+ addSectionWindow.show();
826
+ }
827
+ }
828
+ });
829
+ }
830
+
831
+ if (currentUser.hasApplicationCapability('knitkit', {
832
+ capability_type_iid:'edit',
833
+ resource:'Section'
834
+ }))
835
+ {
836
+ items.push({
837
+ text:'Update Document',
838
+ iconCls:'icon-edit',
839
+ listeners:{
840
+ 'click':function(){
841
+ var updateSectionWindow = Ext.create("Ext.window.Window",{
842
+ layout:'fit',
843
+ width:375,
844
+ title:'Update Document Section',
845
+ plain: true,
846
+ buttonAlign:'center',
847
+ items: new Ext.FormPanel({
848
+ labelWidth: 110,
849
+ frame:false,
850
+ bodyStyle:'padding:5px 5px 0',
851
+ url:'/knitkit/erp_app/desktop/section/update',
852
+ defaults: {
853
+ width: 225
854
+ },
855
+ items: [
856
+ {
857
+ xtype:'textfield',
858
+ fieldLabel:'Title',
859
+ value:record.data.text,
860
+ name:'title'
861
+ },
862
+ {
863
+ xtype:'textfield',
864
+ fieldLabel:'Unique Name',
865
+ allowBlank:true,
866
+ name:'internal_identifier',
867
+ value:record.data.internal_identifier
868
+ },
869
+ {
870
+ xtype:'radiogroup',
871
+ fieldLabel:'Display in menu?',
872
+ name:'in_menu',
873
+ columns:2,
874
+ items:[
875
+ {
876
+ boxLabel:'Yes',
877
+ name:'in_menu',
878
+ inputValue: 'yes',
879
+ checked:record.data.inMenu
880
+ },
881
+
882
+ {
883
+ boxLabel:'No',
884
+ name:'in_menu',
885
+ inputValue: 'no',
886
+ checked:!record.data.inMenu
887
+ }]
888
+ },
889
+ {
890
+ xtype:'hidden',
891
+ name:'id',
892
+ value:record.data.id.split('_')[1]
893
+ }
894
+ ]
895
+ }),
896
+ buttons: [{
897
+ text:'Submit',
898
+ listeners:{
899
+ 'click':function(button){
900
+ var window = button.findParentByType('window');
901
+ var formPanel = window.query('.form')[0];
902
+ self.setWindowStatus('Updating document section...');
903
+ formPanel.getForm().submit({
904
+ success:function(form, action){
905
+ self.clearWindowStatus();
906
+ var values = formPanel.getValues();
907
+ record.set('title',values.title);
908
+ record.set('internal_identifier',values.internal_identifier);
909
+ record.set("inMenu",(values.in_menu == 'yes'));
910
+ record.commit();
911
+ updateSectionWindow.close();
912
+ },
913
+ failure:function(form, action){
914
+ self.clearWindowStatus();
915
+ var obj = Ext.decode(action.response.responseText);
916
+ Ext.Msg.alert("Error", obj.msg);
917
+ }
918
+ });
919
+ }
920
+ }
921
+ },{
922
+ text: 'Close',
923
+ handler: function(){
924
+ updateSectionWindow.close();
925
+ }
926
+ }]
927
+ });
928
+ updateSectionWindow.show();
929
+ }
930
+ }
931
+ });
932
+ }
933
+
934
+ if (currentUser.hasApplicationCapability('knitkit', {
935
+ capability_type_iid:'delete',
936
+ resource:'Section'
937
+ }))
938
+ {
939
+ items.push({
940
+ text:'Delete Document Section',
941
+ iconCls:'icon-delete',
942
+ listeners:{
943
+ 'click':function(){
944
+ self.deleteSection(record);
945
+ }
946
+ }
947
+ });
948
+ }
949
+ }
950
+
951
+ if(record.data['isSection']){
926
952
  items.push({
927
- text:'Delete ' + record.data["type"],
928
- iconCls:'icon-delete',
953
+ text:'View Articles',
954
+ iconCls:'icon-document',
929
955
  listeners:{
930
956
  'click':function(){
931
- self.deleteSection(record);
957
+ self.getArticles(record);
932
958
  }
933
959
  }
934
960
  });
961
+
962
+ if(record.data.isSecured){
963
+ if (currentUser.hasApplicationCapability('knitkit', {
964
+ capability_type_iid:'unsecure',
965
+ resource:'Section'
966
+ }))
967
+
968
+ {
969
+ items.push({
970
+ text:'Unsecure',
971
+ iconCls:'icon-document',
972
+ listeners:{
973
+ 'click':function(){
974
+ self.changeSecurityOnSection(record, false);
975
+ }
976
+ }
977
+ });
978
+ }
979
+ }
980
+ else{
981
+ if (currentUser.hasApplicationCapability('knitkit', {
982
+ capability_type_iid:'secure',
983
+ resource:'Section'
984
+ }))
985
+
986
+ {
987
+ items.push({
988
+ text:'Secure',
989
+ iconCls:'icon-document_lock',
990
+ listeners:{
991
+ 'click':function(){
992
+ self.changeSecurityOnSection(record, true);
993
+ }
994
+ }
995
+ });
996
+ }
997
+ }
998
+
999
+ if (currentUser.hasApplicationCapability('knitkit', {
1000
+ capability_type_iid:'create',
1001
+ resource:'Section'
1002
+ }))
1003
+
1004
+ {
1005
+ items.push({
1006
+ text:'Add Section',
1007
+ iconCls:'icon-add',
1008
+ listeners:{
1009
+ 'click':function(){
1010
+ var addSectionWindow = Ext.create("Ext.window.Window",{
1011
+ layout:'fit',
1012
+ width:375,
1013
+ title:'New Section',
1014
+ plain: true,
1015
+ buttonAlign:'center',
1016
+ items: new Ext.FormPanel({
1017
+ labelWidth: 110,
1018
+ frame:false,
1019
+ bodyStyle:'padding:5px 5px 0',
1020
+ url:'/knitkit/erp_app/desktop/section/new',
1021
+ defaults: {
1022
+ width: 225
1023
+ },
1024
+ items: [
1025
+ {
1026
+ xtype:'textfield',
1027
+ fieldLabel:'Title',
1028
+ allowBlank:false,
1029
+ name:'title'
1030
+ },
1031
+ {
1032
+ xtype:'textfield',
1033
+ fieldLabel:'Unique Name',
1034
+ allowBlank:true,
1035
+ name:'internal_identifier'
1036
+ },
1037
+ {
1038
+ xtype: 'combo',
1039
+ forceSelection:true,
1040
+ store: [
1041
+ ['Page','Page'],
1042
+ ['Blog','Blog'],
1043
+ ],
1044
+ value:'Page',
1045
+ fieldLabel: 'Type',
1046
+ name: 'type',
1047
+ allowBlank: false,
1048
+ triggerAction: 'all'
1049
+ },
1050
+ {
1051
+ xtype:'radiogroup',
1052
+ fieldLabel:'Display in menu?',
1053
+ name:'in_menu',
1054
+ columns:2,
1055
+ items:[
1056
+ {
1057
+ boxLabel:'Yes',
1058
+ name:'in_menu',
1059
+ inputValue: 'yes',
1060
+ checked:true
1061
+ },
1062
+
1063
+ {
1064
+ boxLabel:'No',
1065
+ name:'in_menu',
1066
+ inputValue: 'no'
1067
+ }]
1068
+ },
1069
+ {
1070
+ xtype:'radiogroup',
1071
+ fieldLabel:'Render with Base Layout?',
1072
+ name:'render_with_base_layout',
1073
+ columns:2,
1074
+ items:[
1075
+ {
1076
+ boxLabel:'Yes',
1077
+ name:'render_with_base_layout',
1078
+ inputValue: 'yes',
1079
+ checked:true
1080
+ },
1081
+
1082
+ {
1083
+ boxLabel:'No',
1084
+ name:'render_with_base_layout',
1085
+ inputValue: 'no'
1086
+ }]
1087
+ },
1088
+ {
1089
+ xtype:'hidden',
1090
+ name:'website_section_id',
1091
+ value:record.data.id.split('_')[1]
1092
+ },
1093
+ {
1094
+ xtype:'hidden',
1095
+ name:'website_id',
1096
+ value:record.data.siteId
1097
+ }
1098
+ ]
1099
+ }),
1100
+ buttons: [{
1101
+ text:'Submit',
1102
+ listeners:{
1103
+ 'click':function(button){
1104
+ var window = button.findParentByType('window');
1105
+ var formPanel = window.query('.form')[0];
1106
+ self.setWindowStatus('Creating section...');
1107
+ formPanel.getForm().submit({
1108
+ reset:true,
1109
+ success:function(form, action){
1110
+ self.clearWindowStatus();
1111
+ var obj = Ext.decode(action.response.responseText);
1112
+ if(obj.success){
1113
+ record.appendChild(obj.node);
1114
+ }
1115
+ else{
1116
+ Ext.Msg.alert("Error", obj.message);
1117
+ }
1118
+ },
1119
+ failure:function(form, action){
1120
+ self.clearWindowStatus();
1121
+ var obj = Ext.decode(action.response.responseText);
1122
+ if(obj.message){
1123
+ Ext.Msg.alert("Error", obj.message);
1124
+ }
1125
+ else{
1126
+ Ext.Msg.alert("Error", "Error creating section.");
1127
+ }
1128
+ }
1129
+ });
1130
+ }
1131
+ }
1132
+ },{
1133
+ text: 'Close',
1134
+ handler: function(){
1135
+ addSectionWindow.close();
1136
+ }
1137
+ }]
1138
+ });
1139
+ addSectionWindow.show();
1140
+ }
1141
+ }
1142
+ });
1143
+ }
1144
+
1145
+ if (currentUser.hasApplicationCapability('knitkit', {
1146
+ capability_type_iid:'edit',
1147
+ resource:'Section'
1148
+ }))
1149
+
1150
+ {
1151
+ items.push({
1152
+ text:'Update Section',
1153
+ iconCls:'icon-edit',
1154
+ listeners:{
1155
+ 'click':function(){
1156
+ var updateSectionWindow = Ext.create("Ext.window.Window",{
1157
+ layout:'fit',
1158
+ width:375,
1159
+ title:'Update Section',
1160
+ plain: true,
1161
+ buttonAlign:'center',
1162
+ items: new Ext.FormPanel({
1163
+ labelWidth: 110,
1164
+ frame:false,
1165
+ bodyStyle:'padding:5px 5px 0',
1166
+ url:'/knitkit/erp_app/desktop/section/update',
1167
+ defaults: {
1168
+ width: 225
1169
+ },
1170
+ items: [
1171
+ {
1172
+ xtype:'textfield',
1173
+ fieldLabel:'Title',
1174
+ value:record.data.text,
1175
+ name:'title'
1176
+ },
1177
+ {
1178
+ xtype:'textfield',
1179
+ fieldLabel:'Unique Name',
1180
+ allowBlank:true,
1181
+ name:'internal_identifier',
1182
+ value:record.data.internal_identifier
1183
+ },
1184
+ {
1185
+ xtype:'radiogroup',
1186
+ fieldLabel:'Display in menu?',
1187
+ name:'in_menu',
1188
+ columns:2,
1189
+ items:[
1190
+ {
1191
+ boxLabel:'Yes',
1192
+ name:'in_menu',
1193
+ inputValue: 'yes',
1194
+ checked:record.data.inMenu
1195
+ },
1196
+
1197
+ {
1198
+ boxLabel:'No',
1199
+ name:'in_menu',
1200
+ inputValue: 'no',
1201
+ checked:!record.data.inMenu
1202
+ }]
1203
+ },
1204
+ {
1205
+ xtype:'radiogroup',
1206
+ fieldLabel:'Render with Base Layout?',
1207
+ name:'render_with_base_layout',
1208
+ columns:2,
1209
+ items:[
1210
+ {
1211
+ boxLabel:'Yes',
1212
+ name:'render_with_base_layout',
1213
+ inputValue: 'yes',
1214
+ checked:record.data.renderWithBaseLayout
1215
+ },
1216
+
1217
+ {
1218
+ boxLabel:'No',
1219
+ name:'render_with_base_layout',
1220
+ inputValue: 'no',
1221
+ checked:!record.data.renderWithBaseLayout
1222
+ }]
1223
+ },
1224
+ {
1225
+ xtype: 'displayfield',
1226
+ fieldLabel: 'Path',
1227
+ name: 'path',
1228
+ value: record.data.path
1229
+ },
1230
+ {
1231
+ xtype:'hidden',
1232
+ name:'id',
1233
+ value:record.data.id.split('_')[1]
1234
+ }
1235
+ ]
1236
+ }),
1237
+ buttons: [{
1238
+ text:'Submit',
1239
+ listeners:{
1240
+ 'click':function(button){
1241
+ var window = button.findParentByType('window');
1242
+ var formPanel = window.query('.form')[0];
1243
+ self.setWindowStatus('Updating section...');
1244
+ formPanel.getForm().submit({
1245
+ success:function(form, action){
1246
+ self.clearWindowStatus();
1247
+ var values = formPanel.getValues();
1248
+ record.set('title',values.title);
1249
+ record.set('text',values.title);
1250
+ record.set('internal_identifier',values.internal_identifier);
1251
+ record.set("inMenu",(values.in_menu == 'yes'));
1252
+ record.set("renderWithBaseLayout",(values.render_with_base_layout == 'yes'));
1253
+ record.commit();
1254
+ updateSectionWindow.close();
1255
+ },
1256
+ failure:function(form, action){
1257
+ self.clearWindowStatus();
1258
+ var obj = Ext.decode(action.response.responseText);
1259
+ Ext.Msg.alert("Error", obj.msg);
1260
+ }
1261
+ });
1262
+ }
1263
+ }
1264
+ },{
1265
+ text: 'Close',
1266
+ handler: function(){
1267
+ updateSectionWindow.close();
1268
+ }
1269
+ }]
1270
+ });
1271
+ updateSectionWindow.show();
1272
+ }
1273
+ }
1274
+ });
1275
+ }
1276
+
1277
+ //no layouts for blogs.
1278
+ if(Compass.ErpApp.Utility.isBlank(record.data['isBlog']) && record.data['hasLayout']){
1279
+ if (currentUser.hasApplicationCapability('knitkit', {
1280
+ capability_type_iid:'edit',
1281
+ resource:'Layout'
1282
+ }))
1283
+
1284
+ {
1285
+ items.push({
1286
+ text:'Edit Layout',
1287
+ iconCls:'icon-edit',
1288
+ listeners:{
1289
+ 'click':function(){
1290
+ self.editSectionLayout(record.data.text, record.data.id.split('_')[1], record.data.siteId);
1291
+ }
1292
+ }
1293
+ });
1294
+ }
1295
+ }
1296
+ else
1297
+ if(Compass.ErpApp.Utility.isBlank(record.data['isBlog'])){
1298
+ if (currentUser.hasApplicationCapability('knitkit', {
1299
+ capability_type_iid:'create',
1300
+ resource:'Layout'
1301
+ }))
1302
+
1303
+ {
1304
+ items.push({
1305
+ text:'Add Layout',
1306
+ iconCls:'icon-add',
1307
+ listeners:{
1308
+ 'click':function(){
1309
+ var sectionId = record.data.id.split('_')[1];
1310
+ Ext.Ajax.request({
1311
+ url: '/knitkit/erp_app/desktop/section/add_layout',
1312
+ method: 'POST',
1313
+ params:{
1314
+ id:sectionId
1315
+ },
1316
+ success: function(response) {
1317
+ var obj = Ext.decode(response.responseText);
1318
+ if(obj.success){
1319
+ record.data.hasLayout = true;
1320
+ self.editSectionLayout(record.data.text, sectionId, record.data.siteId);
1321
+ }
1322
+ else
1323
+ {
1324
+ Ext.Msg.alert('Status', obj.message);
1325
+ }
1326
+ },
1327
+ failure: function(response) {
1328
+ Ext.Msg.alert('Status', 'Error adding layout.');
1329
+ }
1330
+ });
1331
+ }
1332
+ }
1333
+ });
1334
+ }
1335
+ }
1336
+
1337
+ if (currentUser.hasApplicationCapability('knitkit', {
1338
+ capability_type_iid:'delete',
1339
+ resource:'Section'
1340
+ }))
1341
+
1342
+ {
1343
+ items.push({
1344
+ text:'Delete ' + record.data["type"],
1345
+ iconCls:'icon-delete',
1346
+ listeners:{
1347
+ 'click':function(){
1348
+ self.deleteSection(record);
1349
+ }
1350
+ }
1351
+ });
1352
+ }
935
1353
  }
936
1354
  else
937
1355
  if(record.data['isWebsite']){
938
- if(currentUser.hasRole(['admin','publisher'])){
1356
+ items.push({
1357
+ text:'Configure',
1358
+ iconCls:'icon-gear',
1359
+ listeners:{
1360
+ 'click':function(){
1361
+ self.updateWebsiteConfiguration(record);
1362
+ }
1363
+ }
1364
+ });
1365
+
1366
+ if (currentUser.hasApplicationCapability('knitkit', {
1367
+ capability_type_iid:'publish',
1368
+ resource:'Website'
1369
+ }))
1370
+
1371
+ {
939
1372
  items.push({
940
1373
  text:'Publish',
941
1374
  iconCls:'icon-document_up',
@@ -946,9 +1379,6 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
946
1379
  }
947
1380
  });
948
1381
  }
949
- else{
950
- compassUser.showInvalidAccess();
951
- }
952
1382
 
953
1383
  items.push({
954
1384
  text:'Publications',
@@ -970,183 +1400,560 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
970
1400
  }
971
1401
  });
972
1402
 
973
- items.push({
974
- text:'Update Website',
975
- iconCls:'icon-edit',
976
- listeners:{
977
- 'click':function(){
978
- var editWebsiteWindow = Ext.create("Ext.window.Window",{
979
- layout:'fit',
980
- width:375,
981
- title:'Update Website',
982
- height:250,
983
- plain: true,
984
- buttonAlign:'center',
985
- items: Ext.create("Ext.form.Panel",{
986
- labelWidth: 110,
987
- frame:false,
988
- bodyStyle:'padding:5px 5px 0',
989
- url:'/knitkit/erp_app/desktop/site/update',
990
- defaults: {
991
- width: 225
992
- },
993
- items: [
994
- {
995
- xtype:'textfield',
996
- fieldLabel:'Name',
997
- allowBlank:false,
998
- name:'name',
999
- value:record.data['name']
1000
- },
1001
- {
1002
- xtype:'textfield',
1003
- fieldLabel:'Title',
1004
- id:'knitkitUpdateSiteTitle',
1005
- allowBlank:false,
1006
- name:'title',
1007
- value:record.data['title']
1008
- },
1009
- {
1010
- xtype:'textfield',
1011
- fieldLabel:'Sub Title',
1012
- allowBlank:true,
1013
- name:'subtitle',
1014
- value:record.data['subtitle']
1403
+ if (currentUser.hasApplicationCapability('knitkit', {
1404
+ capability_type_iid:'edit',
1405
+ resource:'Website'
1406
+ }))
1015
1407
 
1016
- },
1017
- {
1018
- xtype:'textfield',
1019
- fieldLabel:'Email',
1020
- allowBlank:false,
1021
- name:'email',
1022
- value:record.data['email']
1023
- },
1024
- {
1025
- xtype:'radiogroup',
1026
- fieldLabel:'Auto Activate Publication?',
1027
- name:'auto_activate_publication',
1028
- id:'knitkitAutoActivatePublication',
1029
- columns:2,
1030
- items:[
1408
+ {
1409
+ items.push({
1410
+ text:'Update Website',
1411
+ iconCls:'icon-edit',
1412
+ listeners:{
1413
+ 'click':function(){
1414
+ var editWebsiteWindow = Ext.create("Ext.window.Window",{
1415
+ title:'Update Website',
1416
+ plain: true,
1417
+ buttonAlign:'center',
1418
+ items: Ext.create("Ext.form.Panel",{
1419
+ labelWidth: 110,
1420
+ frame:false,
1421
+ bodyStyle:'padding:5px 5px 0',
1422
+ url:'/knitkit/erp_app/desktop/site/update',
1423
+ defaults: {
1424
+ width: 225
1425
+ },
1426
+ items: [
1031
1427
  {
1032
- boxLabel:'Yes',
1033
- name:'auto_activate_publication',
1034
- inputValue: 'yes',
1035
- checked:record.data['autoActivatePublication']
1428
+ xtype:'textfield',
1429
+ fieldLabel:'Name',
1430
+ allowBlank:false,
1431
+ name:'name',
1432
+ value:record.data['name']
1036
1433
  },
1037
1434
  {
1038
- boxLabel:'No',
1435
+ xtype:'textfield',
1436
+ fieldLabel:'Title',
1437
+ id:'knitkitUpdateSiteTitle',
1438
+ allowBlank:false,
1439
+ name:'title',
1440
+ value:record.data['title']
1441
+ },
1442
+ {
1443
+ xtype:'textfield',
1444
+ fieldLabel:'Sub Title',
1445
+ allowBlank:true,
1446
+ name:'subtitle',
1447
+ value:record.data['subtitle']
1448
+
1449
+ },
1450
+ {
1451
+ xtype:'textfield',
1452
+ fieldLabel:'Email',
1453
+ allowBlank:false,
1454
+ name:'email',
1455
+ value:record.data['email']
1456
+ },
1457
+ {
1458
+ xtype:'radiogroup',
1459
+ fieldLabel:'Auto Activate Publication?',
1039
1460
  name:'auto_activate_publication',
1040
- inputValue: 'no',
1041
- checked:!record.data['autoActivatePublication']
1042
- }]
1043
- },
1044
- {
1045
- xtype:'radiogroup',
1046
- fieldLabel:'Email Inquiries?',
1047
- name:'email_inquiries',
1048
- id:'knitkitEmailInquiries',
1049
- columns:2,
1050
- items:[
1461
+ id:'knitkitAutoActivatePublication',
1462
+ columns:2,
1463
+ items:[
1464
+ {
1465
+ boxLabel:'Yes',
1466
+ name:'auto_activate_publication',
1467
+ inputValue: 'yes',
1468
+ checked:record.data['autoActivatePublication']
1469
+ },
1470
+ {
1471
+ boxLabel:'No',
1472
+ name:'auto_activate_publication',
1473
+ inputValue: 'no',
1474
+ checked:!record.data['autoActivatePublication']
1475
+ }]
1476
+ },
1051
1477
  {
1052
- boxLabel:'Yes',
1478
+ xtype:'radiogroup',
1479
+ fieldLabel:'Email Inquiries?',
1053
1480
  name:'email_inquiries',
1054
- inputValue: 'yes',
1055
- checked:record.data['emailInquiries'],
1056
- listeners:{
1057
- scope:this,
1058
- 'check':function(checkbox, checked){
1059
- if(checked)
1060
- {
1061
- Ext.Msg.alert("Warning","ActionMailer must be setup to send emails");
1481
+ id:'knitkitEmailInquiries',
1482
+ columns:2,
1483
+ items:[
1484
+ {
1485
+ boxLabel:'Yes',
1486
+ name:'email_inquiries',
1487
+ inputValue: 'yes',
1488
+ checked:record.data['emailInquiries'],
1489
+ listeners:{
1490
+ scope:this,
1491
+ 'check':function(checkbox, checked){
1492
+ if(checked)
1493
+ {
1494
+ Ext.Msg.alert("Warning","ActionMailer must be setup to send emails");
1495
+ }
1062
1496
  }
1063
1497
  }
1498
+ },
1499
+
1500
+ {
1501
+ boxLabel:'No',
1502
+ name:'email_inquiries',
1503
+ inputValue: 'no',
1504
+ checked:!record.data['emailInquiries']
1505
+ }]
1506
+ },
1507
+ {
1508
+ xtype:'hidden',
1509
+ name:'id',
1510
+ value:record.data.id.split('_')[1]
1511
+ }
1512
+ ]
1513
+ }),
1514
+ buttons: [{
1515
+ text:'Submit',
1516
+ listeners:{
1517
+ 'click':function(button){
1518
+ var window = button.findParentByType('window');
1519
+ var formPanel = window.query('form')[0];
1520
+ self.setWindowStatus('Updating website...');
1521
+ formPanel.getForm().submit({
1522
+ success:function(form, action){
1523
+ self.clearWindowStatus();
1524
+ record.data['name'] = form.findField('name').getValue();
1525
+ record.data['title'] = form.findField('title').getValue();
1526
+ record.data['subtitle'] = form.findField('subtitle').getValue();
1527
+ record.data['email'] = form.findField('email').getValue();
1528
+ //node.setText(node.attributes['title']);
1529
+ record.data.emailInquiries = form.findField('knitkitEmailInquiries').getValue().inputValue == 'yes';
1530
+ record.data.autoActivatePublication = form.findField('knitkitAutoActivatePublication').getValue().inputValue == 'yes';
1531
+ editWebsiteWindow.close();
1532
+ },
1533
+ failure:function(form, action){
1534
+ self.clearWindowStatus();
1535
+ Ext.Msg.alert("Error", "Error updating website");
1536
+ }
1537
+ });
1064
1538
  }
1539
+ }
1540
+ },{
1541
+ text: 'Close',
1542
+ handler: function(){
1543
+ editWebsiteWindow.close();
1544
+ }
1545
+ }]
1546
+ });
1547
+ editWebsiteWindow.show();
1548
+ }
1549
+ }
1550
+ });
1551
+ }
1552
+
1553
+ if (currentUser.hasApplicationCapability('knitkit', {
1554
+ capability_type_iid:'delete',
1555
+ resource:'Website'
1556
+ }))
1557
+
1558
+ {
1559
+ items.push({
1560
+ text:'Delete',
1561
+ iconCls:'icon-delete',
1562
+ listeners:{
1563
+ 'click':function(){
1564
+ self.deleteSite(record);
1565
+ }
1566
+ }
1567
+ });
1568
+ }
1569
+
1570
+ items.push({
1571
+ text:'Export',
1572
+ iconCls:'icon-document_out',
1573
+ listeners:{
1574
+ 'click':function(){
1575
+ self.exportSite(record.data.id.split('_')[1]);
1576
+ }
1577
+ }
1578
+ });
1579
+ }
1580
+ else
1581
+ if(record.data['isHostRoot']){
1582
+ if (currentUser.hasApplicationCapability('knitkit', {
1583
+ capability_type_iid:'create',
1584
+ resource:'Host'
1585
+ }))
1586
+
1587
+ {
1588
+ items.push({
1589
+ text:'Add Host',
1590
+ iconCls:'icon-add',
1591
+ listeners:{
1592
+ 'click':function(){
1593
+ var addHostWindow = Ext.create("Ext.window.Window",{
1594
+ layout:'fit',
1595
+ width:310,
1596
+ title:'Add Host',
1597
+ height:100,
1598
+ plain: true,
1599
+ buttonAlign:'center',
1600
+ items: Ext.create("Ext.form.Panel",{
1601
+ labelWidth: 50,
1602
+ frame:false,
1603
+ bodyStyle:'padding:5px 5px 0',
1604
+ width: 425,
1605
+ url:'/knitkit/erp_app/desktop/site/add_host',
1606
+ defaults: {
1607
+ width: 225
1065
1608
  },
1609
+ items:[
1610
+ {
1611
+ xtype:'textfield',
1612
+ fieldLabel:'Host',
1613
+ name:'host',
1614
+ allowBlank:false
1615
+ },
1616
+ {
1617
+ xtype:'hidden',
1618
+ name:'id',
1619
+ value:record.data.websiteId
1620
+ }
1621
+ ]
1622
+ }),
1623
+ buttons: [{
1624
+ text:'Submit',
1625
+ listeners:{
1626
+ 'click':function(button){
1627
+ var window = button.findParentByType('window');
1628
+ var formPanel = window.query('form')[0];
1629
+ self.setWindowStatus('Adding Host...');
1630
+ formPanel.getForm().submit({
1631
+ reset:true,
1632
+ success:function(form, action){
1633
+ self.clearWindowStatus();
1634
+ var obj = Ext.decode(action.response.responseText);
1635
+ if(obj.success){
1636
+ addHostWindow.close();
1637
+ record.appendChild(obj.node);
1638
+ }
1639
+ else{
1640
+ Ext.Msg.alert("Error", obj.msg);
1641
+ }
1642
+ },
1643
+ failure:function(form, action){
1644
+ self.clearWindowStatus();
1645
+ Ext.Msg.alert("Error", "Error adding Host");
1646
+ }
1647
+ });
1648
+ }
1649
+ }
1650
+ },{
1651
+ text: 'Close',
1652
+ handler: function(){
1653
+ addHostWindow.close();
1654
+ }
1655
+ }]
1656
+ });
1657
+ addHostWindow.show();
1658
+ }
1659
+ }
1660
+ });
1661
+ }
1662
+ }
1663
+ else
1664
+ if(record.data['isHost']){
1665
+ if (currentUser.hasApplicationCapability('knitkit', {
1666
+ capability_type_iid:'edit',
1667
+ resource:'Host'
1668
+ }))
1066
1669
 
1670
+ {
1671
+ items.push({
1672
+ text:'Update',
1673
+ iconCls:'icon-edit',
1674
+ listeners:{
1675
+ 'click':function(){
1676
+ var updateHostWindow = Ext.create("Ext.window.Window",{
1677
+ layout:'fit',
1678
+ width:310,
1679
+ title:'Update Host',
1680
+ height:100,
1681
+ plain: true,
1682
+ buttonAlign:'center',
1683
+ items: Ext.create("Ext.form.Panel",{
1684
+ labelWidth: 50,
1685
+ frame:false,
1686
+ bodyStyle:'padding:5px 5px 0',
1687
+ width: 425,
1688
+ url:'/knitkit/erp_app/desktop/site/update_host',
1689
+ defaults: {
1690
+ width: 225
1691
+ },
1692
+ items:[
1067
1693
  {
1068
- boxLabel:'No',
1069
- name:'email_inquiries',
1070
- inputValue: 'no',
1071
- checked:!record.data['emailInquiries']
1072
- }]
1073
- },
1074
- {
1075
- xtype:'hidden',
1076
- name:'id',
1077
- value:record.data.id.split('_')[1]
1078
- }
1079
- ]
1080
- }),
1081
- buttons: [{
1082
- text:'Submit',
1083
- listeners:{
1084
- 'click':function(button){
1085
- var window = button.findParentByType('window');
1086
- var formPanel = window.query('form')[0];
1087
- self.setWindowStatus('Updating website...');
1088
- formPanel.getForm().submit({
1089
- success:function(form, action){
1090
- self.clearWindowStatus();
1091
- record.data['name'] = form.findField('name').getValue();
1092
- record.data['title'] = form.findField('title').getValue();
1093
- record.data['subtitle'] = form.findField('subtitle').getValue();
1094
- record.data['email'] = form.findField('email').getValue();
1095
- //node.setText(node.attributes['title']);
1096
- record.data.emailInquiries = form.findField('knitkitEmailInquiries').getValue().inputValue == 'yes';
1097
- record.data.autoActivatePublication = form.findField('knitkitAutoActivatePublication').getValue().inputValue == 'yes';
1098
- editWebsiteWindow.close();
1099
- },
1100
- failure:function(form, action){
1101
- self.clearWindowStatus();
1102
- Ext.Msg.alert("Error", "Error updating website");
1103
- }
1104
- });
1694
+ xtype:'textfield',
1695
+ fieldLabel:'Host',
1696
+ id:'knitkitUpdateWebsiteHostHost',
1697
+ name:'host',
1698
+ value:record.data.host,
1699
+ allowBlank:false
1700
+ },
1701
+ {
1702
+ xtype:'hidden',
1703
+ name:'id',
1704
+ value:record.data.websiteHostId
1105
1705
  }
1706
+ ]
1707
+ }),
1708
+ buttons: [{
1709
+ text:'Submit',
1710
+ listeners:{
1711
+ 'click':function(button){
1712
+ var window = button.findParentByType('window');
1713
+ var formPanel = window.query('form')[0];
1714
+ self.setWindowStatus('Updating Host...');
1715
+ formPanel.getForm().submit({
1716
+ reset:false,
1717
+ success:function(form, action){
1718
+ self.clearWindowStatus();
1719
+ var obj = Ext.decode(action.response.responseText);
1720
+ if(obj.success){
1721
+ var newHost = Ext.getCmp('knitkitUpdateWebsiteHostHost').getValue();
1722
+ record.set('host',newHost);
1723
+ record.set('text',newHost);
1724
+ record.commit();
1725
+ updateHostWindow.close();
1726
+ }
1727
+ else{
1728
+ Ext.Msg.alert("Error", obj.msg);
1729
+ }
1730
+ },
1731
+ failure:function(form, action){
1732
+ self.clearWindowStatus();
1733
+ Ext.Msg.alert("Error", "Error updating Host");
1734
+ }
1735
+ });
1736
+ }
1737
+ }
1738
+ },{
1739
+ text: 'Close',
1740
+ handler: function(){
1741
+ updateHostWindow.close();
1742
+ }
1743
+ }]
1744
+ });
1745
+ updateHostWindow.show();
1746
+ }
1747
+ }
1748
+ });
1749
+ }
1750
+
1751
+ if (currentUser.hasApplicationCapability('knitkit', {
1752
+ capability_type_iid:'delete',
1753
+ resource:'Host'
1754
+ }))
1755
+
1756
+ {
1757
+ items.push({
1758
+ text:'Delete',
1759
+ iconCls:'icon-delete',
1760
+ listeners:{
1761
+ 'click':function(){
1762
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this Host?', function(btn){
1763
+ if(btn == 'no'){
1764
+ return false;
1106
1765
  }
1107
- },{
1108
- text: 'Close',
1109
- handler: function(){
1110
- editWebsiteWindow.close();
1766
+ else
1767
+ if(btn == 'yes')
1768
+ {
1769
+ self.setWindowStatus('Deleting Host...');
1770
+ Ext.Ajax.request({
1771
+ url: '/knitkit/erp_app/desktop/site/delete_host',
1772
+ method: 'POST',
1773
+ params:{
1774
+ id:record.data.websiteHostId
1775
+ },
1776
+ success: function(response) {
1777
+ self.clearWindowStatus();
1778
+ var obj = Ext.decode(response.responseText);
1779
+ if(obj.success){
1780
+ record.remove(true);
1781
+ }
1782
+ else{
1783
+ Ext.Msg.alert('Error', 'Error deleting Host');
1784
+ }
1785
+ },
1786
+ failure: function(response) {
1787
+ self.clearWindowStatus();
1788
+ Ext.Msg.alert('Error', 'Error deleting Host');
1789
+ }
1790
+ });
1111
1791
  }
1112
- }]
1113
- });
1114
- editWebsiteWindow.show();
1792
+ });
1793
+ }
1115
1794
  }
1116
- }
1117
- });
1795
+ });
1796
+ }
1797
+ }
1798
+ else if(record.data['isSectionRoot']){
1799
+ if (currentUser.hasApplicationCapability('knitkit', {
1800
+ capability_type_iid:'create',
1801
+ resource:'Section'
1802
+ }))
1803
+
1804
+ {
1805
+ items.push({
1806
+ text:'Add Section',
1807
+ iconCls:'icon-add',
1808
+ listeners:{
1809
+ 'click':function(){
1810
+ var addSectionWindow = Ext.create("Ext.window.Window",{
1811
+ layout:'fit',
1812
+ width:375,
1813
+ title:'New Section',
1814
+ plain: true,
1815
+ buttonAlign:'center',
1816
+ items: Ext.create("Ext.form.Panel",{
1817
+ labelWidth: 110,
1818
+ frame:false,
1819
+ bodyStyle:'padding:5px 5px 0',
1820
+ url:'/knitkit/erp_app/desktop/section/new',
1821
+ defaults: {
1822
+ width: 225
1823
+ },
1824
+ items: [
1825
+ {
1826
+ xtype:'textfield',
1827
+ fieldLabel:'Title',
1828
+ allowBlank:false,
1829
+ name:'title'
1830
+ },
1831
+ {
1832
+ xtype:'textfield',
1833
+ fieldLabel:'Unique Name',
1834
+ allowBlank:true,
1835
+ name:'internal_identifier'
1836
+ },
1837
+ {
1838
+ xtype: 'combo',
1839
+ forceSelection:true,
1840
+ store: [
1841
+ ['Page','Page'],
1842
+ ['Blog','Blog'],
1843
+ ['OnlineDocumentSection', 'Online Document Section']
1844
+ ],
1845
+ value:'Page',
1846
+ fieldLabel: 'Type',
1847
+ name: 'type',
1848
+ allowBlank: false,
1849
+ triggerAction: 'all'
1850
+ },
1851
+ {
1852
+ xtype:'radiogroup',
1853
+ fieldLabel:'Display in menu?',
1854
+ name:'in_menu',
1855
+ columns:2,
1856
+ items:[
1857
+ {
1858
+ boxLabel:'Yes',
1859
+ name:'in_menu',
1860
+ inputValue: 'yes',
1861
+ checked:true
1862
+ },
1118
1863
 
1119
- items.push({
1120
- text:'Delete',
1121
- iconCls:'icon-delete',
1122
- listeners:{
1123
- 'click':function(){
1124
- self.deleteSite(record);
1125
- }
1126
- }
1127
- });
1864
+ {
1865
+ boxLabel:'No',
1866
+ name:'in_menu',
1867
+ inputValue: 'no'
1868
+ }]
1869
+ },
1870
+ {
1871
+ xtype:'radiogroup',
1872
+ fieldLabel:'Render with Base Layout?',
1873
+ name:'render_with_base_layout',
1874
+ columns:2,
1875
+ items:[
1876
+ {
1877
+ boxLabel:'Yes',
1878
+ name:'render_with_base_layout',
1879
+ inputValue: 'yes',
1880
+ checked:true
1881
+ },
1128
1882
 
1129
- items.push({
1130
- text:'Export',
1131
- iconCls:'icon-document_out',
1132
- listeners:{
1133
- 'click':function(){
1134
- self.exportSite(record.data.id.split('_')[1]);
1883
+ {
1884
+ boxLabel:'No',
1885
+ name:'render_with_base_layout',
1886
+ inputValue: 'no'
1887
+ }]
1888
+ },
1889
+ {
1890
+ xtype:'hidden',
1891
+ name:'website_id',
1892
+ value:record.data.websiteId
1893
+ }
1894
+ ]
1895
+ }),
1896
+ buttons: [{
1897
+ text:'Submit',
1898
+ listeners:{
1899
+ 'click':function(button){
1900
+ var window = button.findParentByType('window');
1901
+ var formPanel = window.query('form')[0];
1902
+ self.setWindowStatus('Creating section...');
1903
+ formPanel.getForm().submit({
1904
+ reset:true,
1905
+ success:function(form, action){
1906
+ self.clearWindowStatus();
1907
+ var obj = Ext.decode(action.response.responseText);
1908
+ if(obj.success){
1909
+ record.appendChild(obj.node);
1910
+ }
1911
+ else{
1912
+ Ext.Msg.alert("Error", obj.msg);
1913
+ }
1914
+ },
1915
+ failure:function(form, action){
1916
+ self.clearWindowStatus();
1917
+ var obj = Ext.decode(action.response.responseText);
1918
+ if(obj.message){
1919
+ Ext.Msg.alert("Error", obj.message);
1920
+ }
1921
+ else{
1922
+ Ext.Msg.alert("Error", "Error creating section.");
1923
+ }
1924
+ }
1925
+ });
1926
+ }
1927
+ }
1928
+ },{
1929
+ text: 'Close',
1930
+ handler: function(){
1931
+ addSectionWindow.close();
1932
+ }
1933
+ }]
1934
+ });
1935
+ addSectionWindow.show();
1936
+ }
1135
1937
  }
1136
- }
1137
- });
1938
+ });
1939
+ }
1138
1940
  }
1139
1941
  else
1140
- if(record.data['isHostRoot']){
1141
- items.push({
1142
- text:'Add Host',
1143
- iconCls:'icon-add',
1144
- listeners:{
1145
- 'click':function(){
1146
- var addHostWindow = Ext.create("Ext.window.Window",{
1942
+ if(record.data['isMenuRoot']){
1943
+ if (currentUser.hasApplicationCapability('knitkit', {
1944
+ capability_type_iid:'create',
1945
+ resource:'Menu'
1946
+ }))
1947
+
1948
+ {
1949
+ items.push({
1950
+ text:'Add Menu',
1951
+ iconCls:'icon-add',
1952
+ handler:function(btn){
1953
+ var addMenuWindow = Ext.create("Ext.window.Window",{
1147
1954
  layout:'fit',
1148
- width:310,
1149
- title:'Add Host',
1955
+ width:375,
1956
+ title:'New Menu',
1150
1957
  height:100,
1151
1958
  plain: true,
1152
1959
  buttonAlign:'center',
@@ -1154,21 +1961,20 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
1154
1961
  labelWidth: 50,
1155
1962
  frame:false,
1156
1963
  bodyStyle:'padding:5px 5px 0',
1157
- width: 425,
1158
- url:'/knitkit/erp_app/desktop/site/add_host',
1964
+ url:'/knitkit/erp_app/desktop/website_nav/new',
1159
1965
  defaults: {
1160
1966
  width: 225
1161
1967
  },
1162
- items:[
1968
+ items: [
1163
1969
  {
1164
1970
  xtype:'textfield',
1165
- fieldLabel:'Host',
1166
- name:'host',
1167
- allowBlank:false
1971
+ fieldLabel:'name',
1972
+ allowBlank:false,
1973
+ name:'name'
1168
1974
  },
1169
1975
  {
1170
1976
  xtype:'hidden',
1171
- name:'id',
1977
+ name:'website_id',
1172
1978
  value:record.data.websiteId
1173
1979
  }
1174
1980
  ]
@@ -1179,14 +1985,13 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
1179
1985
  'click':function(button){
1180
1986
  var window = button.findParentByType('window');
1181
1987
  var formPanel = window.query('form')[0];
1182
- self.setWindowStatus('Adding Host...');
1988
+ self.setWindowStatus('Creating menu...');
1183
1989
  formPanel.getForm().submit({
1184
1990
  reset:true,
1185
1991
  success:function(form, action){
1186
1992
  self.clearWindowStatus();
1187
- var obj = Ext.decode(action.response.responseText);
1993
+ var obj = Ext.decode(action.response.responseText);
1188
1994
  if(obj.success){
1189
- addHostWindow.close();
1190
1995
  record.appendChild(obj.node);
1191
1996
  }
1192
1997
  else{
@@ -1195,7 +2000,8 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
1195
2000
  },
1196
2001
  failure:function(form, action){
1197
2002
  self.clearWindowStatus();
1198
- Ext.Msg.alert("Error", "Error adding Host");
2003
+ var obj = Ext.decode(action.response.responseText);
2004
+ Ext.Msg.alert("Error", obj.msg);
1199
2005
  }
1200
2006
  });
1201
2007
  }
@@ -1203,51 +2009,55 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
1203
2009
  },{
1204
2010
  text: 'Close',
1205
2011
  handler: function(){
1206
- addHostWindow.close();
2012
+ addMenuWindow.close();
1207
2013
  }
1208
2014
  }]
1209
2015
  });
1210
- addHostWindow.show();
2016
+ addMenuWindow.show();
1211
2017
  }
1212
- }
1213
- });
2018
+ });
2019
+ }
1214
2020
  }
1215
2021
  else
1216
- if(record.data['isHost']){
1217
- items.push({
1218
- text:'Update',
1219
- iconCls:'icon-edit',
1220
- listeners:{
1221
- 'click':function(){
1222
- var updateHostWindow = Ext.create("Ext.window.Window",{
2022
+ if(record.data['isWebsiteNav']){
2023
+ if (currentUser.hasApplicationCapability('knitkit', {
2024
+ capability_type_iid:'edit',
2025
+ resource:'Menu'
2026
+ }))
2027
+
2028
+ {
2029
+ items.push({
2030
+ text:'Update',
2031
+ iconCls:'icon-edit',
2032
+ handler:function(btn){
2033
+ var updateMenuWindow = Ext.create("Ext.window.Window",{
1223
2034
  layout:'fit',
1224
- width:310,
1225
- title:'Update Host',
2035
+ width:375,
2036
+ title:'Update Menu',
1226
2037
  height:100,
1227
2038
  plain: true,
1228
2039
  buttonAlign:'center',
1229
- items: Ext.create("Ext.form.Panel",{
2040
+ items: new Ext.FormPanel({
1230
2041
  labelWidth: 50,
1231
2042
  frame:false,
1232
2043
  bodyStyle:'padding:5px 5px 0',
1233
- width: 425,
1234
- url:'/knitkit/erp_app/desktop/site/update_host',
2044
+ url:'/knitkit/erp_app/desktop/website_nav/update',
1235
2045
  defaults: {
1236
2046
  width: 225
1237
2047
  },
1238
- items:[
2048
+ items: [
1239
2049
  {
1240
2050
  xtype:'textfield',
1241
- fieldLabel:'Host',
1242
- id:'knitkitUpdateWebsiteHostHost',
1243
- name:'host',
1244
- value:record.data.host,
1245
- allowBlank:false
2051
+ fieldLabel:'Name',
2052
+ value:record.data.text,
2053
+ id:'knitkit_website_nav_update_name',
2054
+ allowBlank:false,
2055
+ name:'name'
1246
2056
  },
1247
2057
  {
1248
2058
  xtype:'hidden',
1249
- name:'id',
1250
- value:record.data.websiteHostId
2059
+ name:'website_nav_id',
2060
+ value:record.data.websiteNavId
1251
2061
  }
1252
2062
  ]
1253
2063
  }),
@@ -1257,18 +2067,16 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
1257
2067
  'click':function(button){
1258
2068
  var window = button.findParentByType('window');
1259
2069
  var formPanel = window.query('form')[0];
1260
- self.setWindowStatus('Updating Host...');
2070
+ self.setWindowStatus('Creating menu...');
1261
2071
  formPanel.getForm().submit({
1262
2072
  reset:false,
1263
2073
  success:function(form, action){
1264
2074
  self.clearWindowStatus();
1265
- var obj = Ext.decode(action.response.responseText);
2075
+ var obj = Ext.decode(action.response.responseText);
1266
2076
  if(obj.success){
1267
- var newHost = Ext.getCmp('knitkitUpdateWebsiteHostHost').getValue();
1268
- record.set('host',newHost);
1269
- record.set('text',newHost);
2077
+ var newText = Ext.getCmp('knitkit_website_nav_update_name').getValue();
2078
+ record.set('text',newText);
1270
2079
  record.commit();
1271
- updateHostWindow.close();
1272
2080
  }
1273
2081
  else{
1274
2082
  Ext.Msg.alert("Error", obj.msg);
@@ -1276,7 +2084,8 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
1276
2084
  },
1277
2085
  failure:function(form, action){
1278
2086
  self.clearWindowStatus();
1279
- Ext.Msg.alert("Error", "Error updating Host");
2087
+ var obj = Ext.decode(action.response.responseText);
2088
+ Ext.Msg.alert("Error", obj.msg);
1280
2089
  }
1281
2090
  });
1282
2091
  }
@@ -1284,34 +2093,38 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
1284
2093
  },{
1285
2094
  text: 'Close',
1286
2095
  handler: function(){
1287
- updateHostWindow.close();
2096
+ updateMenuWindow.close();
1288
2097
  }
1289
2098
  }]
1290
2099
  });
1291
- updateHostWindow.show();
2100
+ updateMenuWindow.show();
1292
2101
  }
1293
- }
1294
- });
2102
+ });
2103
+ }
1295
2104
 
1296
- items.push({
1297
- text:'Delete',
1298
- iconCls:'icon-delete',
1299
- listeners:{
1300
- 'click':function(){
1301
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this Host?', function(btn){
2105
+ if (currentUser.hasApplicationCapability('knitkit', {
2106
+ capability_type_iid:'delete',
2107
+ resource:'Menu'
2108
+ }))
2109
+
2110
+ {
2111
+ items.push({
2112
+ text:'Delete',
2113
+ iconCls:'icon-delete',
2114
+ handler:function(btn){
2115
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu?', function(btn){
1302
2116
  if(btn == 'no'){
1303
2117
  return false;
1304
2118
  }
1305
2119
  else
1306
2120
  if(btn == 'yes')
1307
2121
  {
1308
- self.setWindowStatus('Deleting Host...');
1309
- var conn = new Ext.data.Connection();
1310
- conn.request({
1311
- url: '/knitkit/erp_app/desktop/site/delete_host',
2122
+ self.setWindowStatus('Deleting menu...');
2123
+ Ext.Ajax.request({
2124
+ url: '/knitkit/erp_app/desktop/website_nav/delete',
1312
2125
  method: 'POST',
1313
2126
  params:{
1314
- id:record.data.websiteHostId
2127
+ id:record.data.websiteNavId
1315
2128
  },
1316
2129
  success: function(response) {
1317
2130
  self.clearWindowStatus();
@@ -1320,567 +2133,292 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
1320
2133
  record.remove(true);
1321
2134
  }
1322
2135
  else{
1323
- Ext.Msg.alert('Error', 'Error deleting Host');
2136
+ Ext.Msg.alert('Error', 'Error deleting menu');
1324
2137
  }
1325
2138
  },
1326
2139
  failure: function(response) {
1327
2140
  self.clearWindowStatus();
1328
- Ext.Msg.alert('Error', 'Error deleting Host');
2141
+ Ext.Msg.alert('Error', 'Error deleting menu');
1329
2142
  }
1330
2143
  });
1331
2144
  }
1332
2145
  });
1333
2146
  }
1334
- }
1335
- });
1336
- }
1337
- else if(record.data['isSectionRoot']){
1338
- items.push({
1339
- text:'Add Section',
1340
- iconCls:'icon-add',
1341
- listeners:{
1342
- 'click':function(){
1343
- var addSectionWindow = Ext.create("Ext.window.Window",{
1344
- layout:'fit',
1345
- width:375,
1346
- title:'New Section',
1347
- plain: true,
1348
- buttonAlign:'center',
1349
- items: Ext.create("Ext.form.Panel",{
1350
- labelWidth: 110,
1351
- frame:false,
1352
- bodyStyle:'padding:5px 5px 0',
1353
- url:'/knitkit/erp_app/desktop/section/new',
1354
- defaults: {
1355
- width: 225
1356
- },
1357
- items: [
1358
- {
1359
- xtype:'textfield',
1360
- fieldLabel:'Title',
1361
- allowBlank:false,
1362
- name:'title'
1363
- },
1364
- {
1365
- xtype:'textfield',
1366
- fieldLabel:'Unique Name',
1367
- allowBlank:true,
1368
- name:'internal_identifier'
1369
- },
1370
- {
1371
- xtype: 'combo',
1372
- forceSelection:true,
1373
- store: [
1374
- ['Page','Page'],
1375
- ['Blog','Blog'],
1376
- ],
1377
- value:'Page',
1378
- fieldLabel: 'Type',
1379
- name: 'type',
1380
- allowBlank: false,
1381
- triggerAction: 'all'
1382
- },
1383
- {
1384
- xtype:'radiogroup',
1385
- fieldLabel:'Display in menu?',
1386
- name:'in_menu',
1387
- columns:2,
1388
- items:[
1389
- {
1390
- boxLabel:'Yes',
1391
- name:'in_menu',
1392
- inputValue: 'yes',
1393
- checked:true
1394
- },
1395
-
1396
- {
1397
- boxLabel:'No',
1398
- name:'in_menu',
1399
- inputValue: 'no'
1400
- }]
1401
- },
1402
- {
1403
- xtype:'hidden',
1404
- name:'website_id',
1405
- value:record.data.websiteId
1406
- }
1407
- ]
1408
- }),
1409
- buttons: [{
1410
- text:'Submit',
1411
- listeners:{
1412
- 'click':function(button){
1413
- var window = button.findParentByType('window');
1414
- var formPanel = window.query('form')[0];
1415
- self.setWindowStatus('Creating section...');
1416
- formPanel.getForm().submit({
1417
- reset:true,
1418
- success:function(form, action){
1419
- self.clearWindowStatus();
1420
- var obj = Ext.decode(action.response.responseText);
1421
- if(obj.success){
1422
- record.appendChild(obj.node);
1423
- }
1424
- else{
1425
- Ext.Msg.alert("Error", obj.message);
1426
- }
1427
- },
1428
- failure:function(form, action){
1429
- self.clearWindowStatus();
1430
- var obj = Ext.decode(action.response.responseText);
1431
- if(obj.message){
1432
- Ext.Msg.alert("Error", obj.message);
1433
- }
1434
- else{
1435
- Ext.Msg.alert("Error", "Error creating section.");
1436
- }
1437
- }
1438
- });
1439
- }
1440
- }
1441
- },{
1442
- text: 'Close',
1443
- handler: function(){
1444
- addSectionWindow.close();
1445
- }
1446
- }]
1447
- });
1448
- addSectionWindow.show();
1449
- }
1450
- }
1451
- });
1452
- }
1453
- else
1454
- if(record.data['isMenuRoot']){
1455
- items.push({
1456
- text:'Add Menu',
1457
- iconCls:'icon-add',
1458
- handler:function(btn){
1459
- var addMenuWindow = Ext.create("Ext.window.Window",{
1460
- layout:'fit',
1461
- width:375,
1462
- title:'New Menu',
1463
- height:100,
1464
- plain: true,
1465
- buttonAlign:'center',
1466
- items: Ext.create("Ext.form.Panel",{
1467
- labelWidth: 50,
1468
- frame:false,
1469
- bodyStyle:'padding:5px 5px 0',
1470
- url:'/knitkit/erp_app/desktop/website_nav/new',
1471
- defaults: {
1472
- width: 225
1473
- },
1474
- items: [
1475
- {
1476
- xtype:'textfield',
1477
- fieldLabel:'name',
1478
- allowBlank:false,
1479
- name:'name'
1480
- },
1481
- {
1482
- xtype:'hidden',
1483
- name:'website_id',
1484
- value:record.data.websiteId
1485
- }
1486
- ]
1487
- }),
1488
- buttons: [{
1489
- text:'Submit',
1490
- listeners:{
1491
- 'click':function(button){
1492
- var window = button.findParentByType('window');
1493
- var formPanel = window.query('form')[0];
1494
- self.setWindowStatus('Creating menu...');
1495
- formPanel.getForm().submit({
1496
- reset:true,
1497
- success:function(form, action){
1498
- self.clearWindowStatus();
1499
- var obj = Ext.decode(action.response.responseText);
1500
- if(obj.success){
1501
- record.appendChild(obj.node);
1502
- }
1503
- else{
1504
- Ext.Msg.alert("Error", obj.msg);
1505
- }
1506
- },
1507
- failure:function(form, action){
1508
- self.clearWindowStatus();
1509
- var obj = Ext.decode(action.response.responseText);
1510
- Ext.Msg.alert("Error", obj.msg);
1511
- }
1512
- });
1513
- }
1514
- }
1515
- },{
1516
- text: 'Close',
1517
- handler: function(){
1518
- addMenuWindow.close();
1519
- }
1520
- }]
1521
- });
1522
- addMenuWindow.show();
1523
- }
1524
- });
1525
- }
1526
- else
1527
- if(record.data['isWebsiteNav']){
1528
- items.push({
1529
- text:'Update',
1530
- iconCls:'icon-edit',
1531
- handler:function(btn){
1532
- var updateMenuWindow = Ext.create("Ext.window.Window",{
1533
- layout:'fit',
1534
- width:375,
1535
- title:'Update Menu',
1536
- height:100,
1537
- plain: true,
1538
- buttonAlign:'center',
1539
- items: new Ext.FormPanel({
1540
- labelWidth: 50,
1541
- frame:false,
1542
- bodyStyle:'padding:5px 5px 0',
1543
- url:'/knitkit/erp_app/desktop/website_nav/update',
1544
- defaults: {
1545
- width: 225
1546
- },
1547
- items: [
1548
- {
1549
- xtype:'textfield',
1550
- fieldLabel:'Name',
1551
- value:record.data.text,
1552
- id:'knitkit_website_nav_update_name',
1553
- allowBlank:false,
1554
- name:'name'
1555
- },
1556
- {
1557
- xtype:'hidden',
1558
- name:'website_nav_id',
1559
- value:record.data.websiteNavId
1560
- }
1561
- ]
1562
- }),
1563
- buttons: [{
1564
- text:'Submit',
1565
- listeners:{
1566
- 'click':function(button){
1567
- var window = button.findParentByType('window');
1568
- var formPanel = window.query('form')[0];
1569
- self.setWindowStatus('Creating menu...');
1570
- formPanel.getForm().submit({
1571
- reset:false,
1572
- success:function(form, action){
1573
- self.clearWindowStatus();
1574
- var obj = Ext.decode(action.response.responseText);
1575
- if(obj.success){
1576
- var newText = Ext.getCmp('knitkit_website_nav_update_name').getValue();
1577
- record.set('text',newText);
1578
- record.commit();
1579
- }
1580
- else{
1581
- Ext.Msg.alert("Error", obj.msg);
1582
- }
1583
- },
1584
- failure:function(form, action){
1585
- self.clearWindowStatus();
1586
- var obj = Ext.decode(action.response.responseText);
1587
- Ext.Msg.alert("Error", obj.msg);
1588
- }
1589
- });
1590
- }
1591
- }
1592
- },{
1593
- text: 'Close',
1594
- handler: function(){
1595
- updateMenuWindow.close();
1596
- }
1597
- }]
1598
- });
1599
- updateMenuWindow.show();
1600
- }
1601
- });
1602
-
1603
- items.push({
1604
- text:'Delete',
1605
- iconCls:'icon-delete',
1606
- handler:function(btn){
1607
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu?', function(btn){
1608
- if(btn == 'no'){
1609
- return false;
1610
- }
1611
- else
1612
- if(btn == 'yes')
1613
- {
1614
- self.setWindowStatus('Deleting menu...');
1615
- var conn = new Ext.data.Connection();
1616
- conn.request({
1617
- url: '/knitkit/erp_app/desktop/website_nav/delete',
1618
- method: 'POST',
1619
- params:{
1620
- id:record.data.websiteNavId
1621
- },
1622
- success: function(response) {
1623
- self.clearWindowStatus();
1624
- var obj = Ext.decode(response.responseText);
1625
- if(obj.success){
1626
- record.remove(true);
1627
- }
1628
- else{
1629
- Ext.Msg.alert('Error', 'Error deleting menu');
1630
- }
1631
- },
1632
- failure: function(response) {
1633
- self.clearWindowStatus();
1634
- Ext.Msg.alert('Error', 'Error deleting menu');
1635
- }
1636
- });
1637
- }
1638
- });
1639
- }
1640
- });
2147
+ });
2148
+ }
1641
2149
  }
1642
2150
  else
1643
2151
  if(record.data['isWebsiteNavItem'])
1644
- {
1645
- items.push({
1646
- text:'Update Menu Item',
1647
- iconCls:'icon-edit',
1648
- handler:function(btn){
1649
- var addMenuItemWindow = Ext.create("Ext.window.Window",{
1650
- layout:'fit',
1651
- width:375,
1652
- title:'Update Menu Item',
1653
- height:175,
1654
- plain: true,
1655
- buttonAlign:'center',
1656
- items: new Ext.FormPanel({
1657
- labelWidth: 50,
1658
- frame:false,
1659
- bodyStyle:'padding:5px 5px 0',
1660
- url:'/knitkit/erp_app/desktop/website_nav/update_menu_item',
1661
- defaults: {
1662
- width: 225
1663
- },
1664
- items: [
1665
- {
1666
- xtype:'textfield',
1667
- fieldLabel:'Title',
1668
- value:record.data.text,
1669
- allowBlank:false,
1670
- name:'title'
1671
- },
1672
- {
1673
- xtype:'combo',
1674
- fieldLabel:'Link to',
1675
- name:'link_to',
1676
- id:'knitkit_nav_item_link_to',
1677
- allowBlank:false,
1678
- forceSelection:true,
1679
- editable:false,
1680
- autoSelect:true,
1681
- typeAhead: false,
1682
- mode: 'local',
1683
- triggerAction: 'all',
1684
- store:[
1685
- ['website_section','Section'],
1686
- //['article','Article'],
1687
- ['url','Url']
1688
- ],
1689
- value:record.data.linkToType,
1690
- listeners:{
1691
- 'change':function(combo, newValue, oldValue){
1692
- switch(newValue){
1693
- case 'website_section':
1694
- Ext.getCmp('knitkit_website_nav_item_section').show();
1695
- //Ext.getCmp('knitkit_website_nav_item_article').hide();
1696
- Ext.getCmp('knitkit_website_nav_item_url').hide();
1697
- break;
1698
- case 'article':
1699
- Ext.getCmp('knitkit_website_nav_item_section').hide();
1700
- //Ext.getCmp('knitkit_website_nav_item_article').show();
1701
- Ext.getCmp('knitkit_website_nav_item_url').hide();
1702
- break;
1703
- case 'url':
1704
- Ext.getCmp('knitkit_website_nav_item_section').hide();
1705
- //Ext.getCmp('knitkit_website_nav_item_article').hide();
1706
- Ext.getCmp('knitkit_website_nav_item_url').show();
1707
- break;
1708
- }
1709
- }
1710
- }
1711
- },
1712
- {
1713
- xtype:'combo',
1714
- width:300,
1715
- id:'knitkit_website_nav_item_section',
1716
- hiddenName:'website_section_id',
1717
- name:'website_section_id',
1718
- loadingText:'Retrieving Sections...',
1719
- store:Ext.create("Ext.data.Store",{
1720
- proxy:{
1721
- type:'ajax',
1722
- url:'/knitkit/erp_app/desktop/section/existing_sections',
1723
- reader:{
1724
- type:'json'
1725
- },
1726
- extraParams:{
1727
- website_id:record.data.websiteId
1728
- }
1729
- },
1730
- autoLoad:true,
1731
- fields:[
1732
- {
1733
- name:'id'
1734
- },
1735
- {
1736
- name:'title_permalink'
2152
+ {
2153
+ if (currentUser.hasApplicationCapability('knitkit', {
2154
+ capability_type_iid:'edit',
2155
+ resource:'MenuItem'
2156
+ }))
2157
+
2158
+ {
2159
+ items.push({
2160
+ text:'Update Menu Item',
2161
+ iconCls:'icon-edit',
2162
+ handler:function(btn){
2163
+ var addMenuItemWindow = Ext.create("Ext.window.Window",{
2164
+ layout:'fit',
2165
+ width:375,
2166
+ title:'Update Menu Item',
2167
+ height:175,
2168
+ plain: true,
2169
+ buttonAlign:'center',
2170
+ items: new Ext.FormPanel({
2171
+ labelWidth: 50,
2172
+ frame:false,
2173
+ bodyStyle:'padding:5px 5px 0',
2174
+ url:'/knitkit/erp_app/desktop/website_nav/update_menu_item',
2175
+ defaults: {
2176
+ width: 225
2177
+ },
2178
+ items: [
2179
+ {
2180
+ xtype:'textfield',
2181
+ fieldLabel:'Title',
2182
+ value:record.data.text,
2183
+ allowBlank:false,
2184
+ name:'title'
2185
+ },
2186
+ {
2187
+ xtype:'combo',
2188
+ fieldLabel:'Link to',
2189
+ name:'link_to',
2190
+ id:'knitkit_nav_item_link_to',
2191
+ allowBlank:false,
2192
+ forceSelection:true,
2193
+ editable:false,
2194
+ autoSelect:true,
2195
+ typeAhead: false,
2196
+ mode: 'local',
2197
+ triggerAction: 'all',
2198
+ store:[
2199
+ ['website_section','Section'],
2200
+ //['article','Article'],
2201
+ ['url','Url']
1737
2202
 
1738
- }
1739
2203
  ],
2204
+ value:record.data.linkToType,
1740
2205
  listeners:{
1741
- 'load':function(store, records, options){
1742
- Ext.getCmp('knitkit_website_nav_item_section').setValue(record.data.linkedToId);
2206
+ 'change':function(combo, newValue, oldValue){
2207
+ switch(newValue){
2208
+ case 'website_section':
2209
+ Ext.getCmp('knitkit_website_nav_item_section').show();
2210
+ //Ext.getCmp('knitkit_website_nav_item_article').hide();
2211
+ Ext.getCmp('knitkit_website_nav_item_url').hide();
2212
+ break;
2213
+ case 'article':
2214
+ Ext.getCmp('knitkit_website_nav_item_section').hide();
2215
+ //Ext.getCmp('knitkit_website_nav_item_article').show();
2216
+ Ext.getCmp('knitkit_website_nav_item_url').hide();
2217
+ break;
2218
+ case 'url':
2219
+ Ext.getCmp('knitkit_website_nav_item_section').hide();
2220
+ //Ext.getCmp('knitkit_website_nav_item_article').hide();
2221
+ Ext.getCmp('knitkit_website_nav_item_url').show();
2222
+ break;
2223
+ }
1743
2224
  }
1744
2225
  }
1745
- }),
1746
- forceSelection:true,
1747
- editable:false,
1748
- fieldLabel:'Section',
1749
- autoSelect:true,
1750
- typeAhead: false,
1751
- queryMode: 'local',
1752
- displayField:'title_permalink',
1753
- valueField:'id',
1754
- hidden:(record.data.linkToType != 'website_section' && record.data.linkToType != 'article')
1755
- },
1756
- {
1757
- xtype:'textfield',
1758
- fieldLabel:'Url',
1759
- value:record.data.url,
1760
- id:'knitkit_website_nav_item_url',
1761
- hidden:(record.data.linkToType == 'website_section' || record.data.linkToType == 'article'),
1762
- name:'url'
1763
- },
1764
- {
1765
- xtype:'hidden',
1766
- name:'website_nav_item_id',
1767
- value:record.data.websiteNavItemId
1768
- }
1769
- ]
1770
- }),
1771
- buttons: [{
1772
- text:'Submit',
1773
- listeners:{
1774
- 'click':function(button){
1775
- var window = button.findParentByType('window');
1776
- var formPanel = window.query('form')[0];
1777
- self.setWindowStatus('Updating menu item...');
1778
- formPanel.getForm().submit({
1779
- reset:false,
1780
- success:function(form, action){
1781
- self.clearWindowStatus();
1782
- var obj = Ext.decode(action.response.responseText);
1783
- if(obj.success){
1784
- record.data.linkedToId = obj.linkedToId;
1785
- record.data.linkToType = obj.linkToType;
1786
- record.data.url = obj.url;
1787
- //node.getUI().getTextEl().innerHTML = obj.title;
1788
- }
1789
- else{
1790
- Ext.Msg.alert("Error", obj.msg);
2226
+ },
2227
+ {
2228
+ xtype:'combo',
2229
+ width:300,
2230
+ id:'knitkit_website_nav_item_section',
2231
+ hiddenName:'website_section_id',
2232
+ name:'website_section_id',
2233
+ loadingText:'Retrieving Sections...',
2234
+ store:Ext.create("Ext.data.Store",{
2235
+ proxy:{
2236
+ type:'ajax',
2237
+ url:'/knitkit/erp_app/desktop/section/existing_sections',
2238
+ reader:{
2239
+ type:'json'
2240
+ },
2241
+ extraParams:{
2242
+ website_id:record.data.websiteId
1791
2243
  }
1792
2244
  },
1793
- failure:function(form, action){
1794
- self.clearWindowStatus();
1795
- if(action.response == null){
1796
- Ext.Msg.alert("Error", 'Could not create menu item');
2245
+ autoLoad:true,
2246
+ fields:[
2247
+ {
2248
+ name:'id'
2249
+ },
2250
+ {
2251
+ name:'title_permalink'
2252
+
2253
+ }
2254
+ ],
2255
+ listeners:{
2256
+ 'load':function(store, records, options){
2257
+ Ext.getCmp('knitkit_website_nav_item_section').setValue(record.data.linkedToId);
1797
2258
  }
1798
- else{
2259
+ }
2260
+ }),
2261
+ forceSelection:true,
2262
+ editable:false,
2263
+ fieldLabel:'Section',
2264
+ autoSelect:true,
2265
+ typeAhead: false,
2266
+ queryMode: 'local',
2267
+ displayField:'title_permalink',
2268
+ valueField:'id',
2269
+ hidden:(record.data.linkToType != 'website_section' && record.data.linkToType != 'article')
2270
+ },
2271
+ {
2272
+ xtype:'textfield',
2273
+ fieldLabel:'Url',
2274
+ value:record.data.url,
2275
+ id:'knitkit_website_nav_item_url',
2276
+ hidden:(record.data.linkToType == 'website_section' || record.data.linkToType == 'article'),
2277
+ name:'url'
2278
+ },
2279
+ {
2280
+ xtype:'hidden',
2281
+ name:'website_nav_item_id',
2282
+ value:record.data.websiteNavItemId
2283
+ }
2284
+ ]
2285
+ }),
2286
+ buttons: [{
2287
+ text:'Submit',
2288
+ listeners:{
2289
+ 'click':function(button){
2290
+ var window = button.findParentByType('window');
2291
+ var formPanel = window.query('form')[0];
2292
+ self.setWindowStatus('Updating menu item...');
2293
+ formPanel.getForm().submit({
2294
+ reset:false,
2295
+ success:function(form, action){
2296
+ self.clearWindowStatus();
1799
2297
  var obj = Ext.decode(action.response.responseText);
1800
- Ext.Msg.alert("Error", obj.msg);
2298
+ if(obj.success){
2299
+ record.data.linkedToId = obj.linkedToId;
2300
+ record.data.linkToType = obj.linkToType;
2301
+ record.data.url = obj.url;
2302
+ //node.getUI().getTextEl().innerHTML = obj.title;
2303
+ }
2304
+ else{
2305
+ Ext.Msg.alert("Error", obj.msg);
2306
+ }
2307
+ },
2308
+ failure:function(form, action){
2309
+ self.clearWindowStatus();
2310
+ if(action.response == null){
2311
+ Ext.Msg.alert("Error", 'Could not create menu item');
2312
+ }
2313
+ else{
2314
+ var obj = Ext.decode(action.response.responseText);
2315
+ Ext.Msg.alert("Error", obj.msg);
2316
+ }
2317
+
1801
2318
  }
1802
-
1803
- }
1804
- });
2319
+ });
2320
+ }
1805
2321
  }
1806
- }
1807
- },{
1808
- text: 'Close',
1809
- handler: function(){
1810
- addMenuItemWindow.close();
1811
- }
1812
- }]
1813
- });
1814
- addMenuItemWindow.show();
1815
- }
1816
- });
2322
+ },{
2323
+ text: 'Close',
2324
+ handler: function(){
2325
+ addMenuItemWindow.close();
2326
+ }
2327
+ }]
2328
+ });
2329
+ addMenuItemWindow.show();
2330
+ }
2331
+ });
2332
+ }
1817
2333
 
1818
2334
  if(record.data.isSecured){
1819
- items.push({
1820
- text:'Unsecure',
1821
- iconCls:'icon-document',
1822
- listeners:{
1823
- 'click':function(){
1824
- self.changeSecurityOnMenuItem(record, false);
2335
+ if (currentUser.hasApplicationCapability('knitkit', {
2336
+ capability_type_iid:'unsecure',
2337
+ resource:'MenuItem'
2338
+ }))
2339
+
2340
+ {
2341
+ items.push({
2342
+ text:'Unsecure',
2343
+ iconCls:'icon-document',
2344
+ listeners:{
2345
+ 'click':function(){
2346
+ self.changeSecurityOnMenuItem(record, false);
2347
+ }
1825
2348
  }
1826
- }
1827
- });
2349
+ });
2350
+ }
1828
2351
  }
1829
2352
  else{
1830
- items.push({
1831
- text:'Secure',
1832
- iconCls:'icon-document_lock',
1833
- listeners:{
1834
- 'click':function(){
1835
- self.changeSecurityOnMenuItem(record, true);
2353
+ if (currentUser.hasApplicationCapability('knitkit', {
2354
+ capability_type_iid:'secure',
2355
+ resource:'MenuItem'
2356
+ }))
2357
+
2358
+ {
2359
+ items.push({
2360
+ text:'Secure',
2361
+ iconCls:'icon-document_lock',
2362
+ listeners:{
2363
+ 'click':function(){
2364
+ self.changeSecurityOnMenuItem(record, true);
2365
+ }
1836
2366
  }
1837
- }
1838
- });
2367
+ });
2368
+ }
1839
2369
  }
1840
2370
 
1841
- items.push({
1842
- text:'Delete',
1843
- iconCls:'icon-delete',
1844
- handler:function(btn){
1845
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu item?', function(btn){
1846
- if(btn == 'no'){
1847
- return false;
1848
- }
1849
- else
1850
- if(btn == 'yes')
1851
- {
1852
- self.setWindowStatus('Deleting menu item...');
1853
- var conn = new Ext.data.Connection();
1854
- conn.request({
1855
- url: '/knitkit/erp_app/desktop/website_nav/delete_menu_item',
1856
- method: 'POST',
1857
- params:{
1858
- id:record.data.websiteNavItemId
1859
- },
1860
- success: function(response) {
1861
- self.clearWindowStatus();
1862
- var obj = Ext.decode(response.responseText);
1863
- if(obj.success){
1864
- record.remove(true);
1865
- }
1866
- else{
2371
+ if (currentUser.hasApplicationCapability('knitkit', {
2372
+ capability_type_iid:'delete',
2373
+ resource:'MenuItem'
2374
+ }))
2375
+
2376
+ {
2377
+ items.push({
2378
+ text:'Delete',
2379
+ iconCls:'icon-delete',
2380
+ handler:function(btn){
2381
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu item?', function(btn){
2382
+ if(btn == 'no'){
2383
+ return false;
2384
+ }
2385
+ else
2386
+ if(btn == 'yes')
2387
+ {
2388
+ self.setWindowStatus('Deleting menu item...');
2389
+ Ext.Ajax.request({
2390
+ url: '/knitkit/erp_app/desktop/website_nav/delete_menu_item',
2391
+ method: 'POST',
2392
+ params:{
2393
+ id:record.data.websiteNavItemId
2394
+ },
2395
+ success: function(response) {
2396
+ self.clearWindowStatus();
2397
+ var obj = Ext.decode(response.responseText);
2398
+ if(obj.success){
2399
+ record.remove(true);
2400
+ }
2401
+ else{
2402
+ Ext.Msg.alert('Error', 'Error deleting menu item');
2403
+ }
2404
+ },
2405
+ failure: function(response) {
2406
+ self.clearWindowStatus();
1867
2407
  Ext.Msg.alert('Error', 'Error deleting menu item');
1868
2408
  }
1869
- },
1870
- failure: function(response) {
1871
- self.clearWindowStatus();
1872
- Ext.Msg.alert('Error', 'Error deleting menu item');
1873
- }
1874
- });
1875
- }
1876
- });
1877
- }
2409
+ });
2410
+ }
2411
+ });
2412
+ }
2413
+ });
2414
+ }
2415
+ }
2416
+ if (items.length !=0){
2417
+ var contextMenu = Ext.create("Ext.menu.Menu",{
2418
+ items:items
1878
2419
  });
2420
+ contextMenu.showAt(e.xy);
1879
2421
  }
1880
- var contextMenu = Ext.create("Ext.menu.Menu",{
1881
- items:items
1882
- });
1883
- contextMenu.showAt(e.xy);
1884
2422
  }
1885
2423
  }
1886
2424
  });
@@ -1894,231 +2432,257 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
1894
2432
  collapsible:true
1895
2433
  });
1896
2434
 
1897
- var layout = new Ext.Panel({
1898
- layout: 'border',
1899
- autoDestroy:true,
1900
- title:'Websites',
1901
- items: [this.sitesTree,this.contentsCardPanel],
1902
- tbar:{
1903
- items:[
1904
- {
1905
- text:'New Website',
1906
- iconCls:'icon-add',
1907
- handler:function(btn){
1908
- var addWebsiteWindow = Ext.create("Ext.window.Window",{
1909
- layout:'fit',
1910
- width:375,
1911
- title:'New Website',
1912
- height:300,
1913
- plain: true,
1914
- buttonAlign:'center',
1915
- items: new Ext.FormPanel({
1916
- labelWidth: 110,
1917
- frame:false,
1918
- bodyStyle:'padding:5px 5px 0',
1919
- url:'/knitkit/erp_app/desktop/site/new',
1920
- defaults: {
1921
- width: 225
1922
- },
1923
- items: [
1924
- {
1925
- xtype:'textfield',
1926
- fieldLabel:'Name',
1927
- allowBlank:false,
1928
- name:'name'
1929
- },
1930
- {
1931
- xtype:'textfield',
1932
- fieldLabel:'Host',
1933
- allowBlank:false,
1934
- name:'host'
1935
- },
1936
- {
1937
- xtype:'textfield',
1938
- fieldLabel:'Title',
1939
- allowBlank:false,
1940
- name:'title'
1941
- },
1942
- {
1943
- xtype:'textfield',
1944
- fieldLabel:'Sub Title',
1945
- allowBlank:true,
1946
- name:'subtitle'
1947
- },
2435
+ var tbarItems = [];
2436
+
2437
+ if (currentUser.hasApplicationCapability('knitkit', {
2438
+ capability_type_iid:'create',
2439
+ resource:'Website'
2440
+ }))
2441
+ {
2442
+ tbarItems.push({
2443
+ text:'New Website',
2444
+ iconCls:'icon-add',
2445
+ handler:function(btn){
2446
+ var addWebsiteWindow = Ext.create("Ext.window.Window",{
2447
+ title:'New Website',
2448
+ plain: true,
2449
+ buttonAlign:'center',
2450
+ items: new Ext.FormPanel({
2451
+ labelWidth: 110,
2452
+ frame:false,
2453
+ bodyStyle:'padding:5px 5px 0',
2454
+ url:'/knitkit/erp_app/desktop/site/new',
2455
+ defaults: {
2456
+ width: 225
2457
+ },
2458
+ items: [
2459
+ {
2460
+ xtype:'textfield',
2461
+ fieldLabel:'Name',
2462
+ allowBlank:false,
2463
+ name:'name'
2464
+ },
2465
+ {
2466
+ xtype:'textfield',
2467
+ fieldLabel:'Host',
2468
+ allowBlank:false,
2469
+ name:'host'
2470
+ },
2471
+ {
2472
+ xtype:'textfield',
2473
+ fieldLabel:'Title',
2474
+ allowBlank:false,
2475
+ name:'title'
2476
+ },
2477
+ {
2478
+ xtype:'textfield',
2479
+ fieldLabel:'Sub Title',
2480
+ allowBlank:true,
2481
+ name:'subtitle'
2482
+ },
2483
+ {
2484
+ xtype:'textfield',
2485
+ fieldLabel:'Email',
2486
+ allowBlank:false,
2487
+ name:'email'
2488
+ },
2489
+ {
2490
+ xtype:'radiogroup',
2491
+ fieldLabel:'Auto Activate Publication?',
2492
+ name:'auto_activate_publication',
2493
+ columns:2,
2494
+ items:[
1948
2495
  {
1949
- xtype:'textfield',
1950
- fieldLabel:'Email',
1951
- allowBlank:false,
1952
- name:'email'
2496
+ boxLabel:'Yes',
2497
+ name:'auto_activate_publication',
2498
+ inputValue: 'yes'
1953
2499
  },
1954
2500
  {
1955
- xtype:'radiogroup',
1956
- fieldLabel:'Auto Activate Publication?',
2501
+ boxLabel:'No',
1957
2502
  name:'auto_activate_publication',
1958
- columns:2,
1959
- items:[
1960
- {
1961
- boxLabel:'Yes',
1962
- name:'auto_activate_publication',
1963
- inputValue: 'yes'
1964
- },
1965
- {
1966
- boxLabel:'No',
1967
- name:'auto_activate_publication',
1968
- inputValue: 'no',
1969
- checked:true
1970
- }]
1971
- },
2503
+ inputValue: 'no',
2504
+ checked:true
2505
+ }]
2506
+ },
2507
+ {
2508
+ xtype:'radiogroup',
2509
+ fieldLabel:'Email Inquiries',
2510
+ name:'email_inquiries',
2511
+ columns:2,
2512
+ items:[
1972
2513
  {
1973
- xtype:'radiogroup',
1974
- fieldLabel:'Email Inquiries',
2514
+ boxLabel:'Yes',
1975
2515
  name:'email_inquiries',
1976
- columns:2,
1977
- items:[
1978
- {
1979
- boxLabel:'Yes',
1980
- name:'email_inquiries',
1981
- inputValue: 'yes',
1982
- checked:false,
1983
- listeners:{
1984
- scope:this,
1985
- 'check':function(checkbox, checked){
1986
- if(checked)
1987
- {
1988
- Ext.Msg.alert("Warning","ActionMailer must be setup to send emails");
1989
- }
2516
+ inputValue: 'yes',
2517
+ checked:false,
2518
+ listeners:{
2519
+ scope:this,
2520
+ 'check':function(checkbox, checked){
2521
+ if(checked)
2522
+ {
2523
+ Ext.Msg.alert("Warning","ActionMailer must be setup to send emails");
1990
2524
  }
1991
2525
  }
1992
- },
1993
- {
1994
- boxLabel:'No',
1995
- name:'email_inquiries',
1996
- inputValue: 'no',
1997
- checked:true
1998
- }
1999
- ]
2000
- }
2001
- ]
2002
- }),
2003
- buttons: [{
2004
- text:'Submit',
2005
- listeners:{
2006
- 'click':function(button){
2007
- var window = button.findParentByType('window');
2008
- var formPanel = window.query('.form')[0];
2009
- self.setWindowStatus('Creating website...');
2010
- formPanel.getForm().submit({
2011
- success:function(form, action){
2012
- self.clearWindowStatus();
2013
- var obj = Ext.decode(action.response.responseText);
2014
- if(obj.success){
2015
- self.sitesTree.getStore().load();
2016
- addWebsiteWindow.close();
2017
- }
2018
- },
2019
- failure:function(form, action){
2020
- self.clearWindowStatus();
2021
- Ext.Msg.alert("Error", "Error creating website");
2022
- }
2023
- });
2024
2526
  }
2025
- }
2026
- },{
2027
- text: 'Close',
2028
- handler: function(){
2029
- addWebsiteWindow.close();
2030
- }
2031
- }]
2032
- });
2033
- addWebsiteWindow.show();
2034
- }
2035
- },
2036
- {
2037
- text:'Import Website',
2038
- iconCls:'icon-globe',
2039
- handler:function(btn){
2040
- var importWebsiteWindow = Ext.create("Ext.window.Window",{
2041
- layout:'fit',
2042
- width:375,
2043
- title:'Import Website',
2044
- height:100,
2045
- plain: true,
2046
- buttonAlign:'center',
2047
- items: new Ext.FormPanel({
2048
- labelWidth: 110,
2049
- frame:false,
2050
- fileUpload: true,
2051
- bodyStyle:'padding:5px 5px 0',
2052
- url:'/knitkit/erp_app/desktop/site/import',
2053
- defaults: {
2054
- width: 225
2055
2527
  },
2056
- items: [
2057
2528
  {
2058
- xtype:'fileuploadfield',
2059
- fieldLabel:'Upload Website',
2060
- buttonText:'Upload',
2061
- buttonOnly:false,
2062
- allowBlank:false,
2063
- name:'website_data'
2529
+ boxLabel:'No',
2530
+ name:'email_inquiries',
2531
+ inputValue: 'no',
2532
+ checked:true
2064
2533
  }
2065
2534
  ]
2066
- }),
2067
- buttons: [{
2068
- text:'Submit',
2069
- listeners:{
2070
- 'click':function(button){
2071
- var window = button.findParentByType('window');
2072
- var formPanel = window.query('form')[0];
2073
- self.setWindowStatus('Importing website...');
2074
- formPanel.getForm().submit({
2075
- success:function(form, action){
2076
- self.clearWindowStatus();
2077
- var obj = Ext.decode(action.response.responseText);
2078
- if(obj.success){
2079
- self.sitesTree.getStore().load();
2080
- importWebsiteWindow.close();
2081
- }
2082
- else{
2083
- Ext.Msg.alert("Error", obj.message);
2084
- }
2085
- },
2086
- failure:function(form, action){
2087
- self.clearWindowStatus();
2088
- var obj = Ext.decode(action.response.responseText);
2089
- if(obj != null){
2090
- Ext.Msg.alert("Error", obj.message);
2091
- }
2092
- else{
2093
- Ext.Msg.alert("Error", "Error importing website");
2094
- }
2535
+ }
2536
+ ]
2537
+ }),
2538
+ buttons: [{
2539
+ text:'Submit',
2540
+ listeners:{
2541
+ 'click':function(button){
2542
+ var window = button.findParentByType('window');
2543
+ var formPanel = window.query('.form')[0];
2544
+ self.setWindowStatus('Creating website...');
2545
+ formPanel.getForm().submit({
2546
+ success:function(form, action){
2547
+ self.clearWindowStatus();
2548
+ var obj = Ext.decode(action.response.responseText);
2549
+ if(obj.success){
2550
+ self.sitesTree.getStore().load();
2551
+ addWebsiteWindow.close();
2095
2552
  }
2096
- });
2097
- }
2553
+ },
2554
+ failure:function(form, action){
2555
+ self.clearWindowStatus();
2556
+ Ext.Msg.alert("Error", "Error creating website");
2557
+ }
2558
+ });
2098
2559
  }
2099
- },{
2100
- text: 'Close',
2101
- handler: function(){
2102
- importWebsiteWindow.close();
2560
+ }
2561
+ },{
2562
+ text: 'Close',
2563
+ handler: function(){
2564
+ addWebsiteWindow.close();
2565
+ }
2566
+ }]
2567
+ });
2568
+ addWebsiteWindow.show();
2569
+ }
2570
+ }
2571
+ );
2572
+ }
2573
+
2574
+ if (currentUser.hasApplicationCapability('knitkit', {
2575
+ capability_type_iid:'import',
2576
+ resource:'Website'
2577
+ }))
2578
+ {
2579
+ tbarItems.push({
2580
+ text:'Import Website',
2581
+ iconCls:'icon-globe',
2582
+ handler:function(btn){
2583
+ var importWebsiteWindow = Ext.create("Ext.window.Window",{
2584
+ layout:'fit',
2585
+ width:375,
2586
+ title:'Import Website',
2587
+ height:100,
2588
+ plain: true,
2589
+ buttonAlign:'center',
2590
+ items: new Ext.FormPanel({
2591
+ labelWidth: 110,
2592
+ frame:false,
2593
+ fileUpload: true,
2594
+ bodyStyle:'padding:5px 5px 0',
2595
+ url:'/knitkit/erp_app/desktop/site/import',
2596
+ defaults: {
2597
+ width: 225
2598
+ },
2599
+ items: [
2600
+ {
2601
+ xtype:'fileuploadfield',
2602
+ fieldLabel:'Upload Website',
2603
+ buttonText:'Upload',
2604
+ buttonOnly:false,
2605
+ allowBlank:false,
2606
+ name:'website_data'
2607
+ }
2608
+ ]
2609
+ }),
2610
+ buttons: [{
2611
+ text:'Submit',
2612
+ listeners:{
2613
+ 'click':function(button){
2614
+ var window = button.findParentByType('window');
2615
+ var formPanel = window.query('form')[0];
2616
+ self.setWindowStatus('Importing website...');
2617
+ formPanel.getForm().submit({
2618
+ success:function(form, action){
2619
+ self.clearWindowStatus();
2620
+ var obj = Ext.decode(action.response.responseText);
2621
+ if(obj.success){
2622
+ self.sitesTree.getStore().load();
2623
+ importWebsiteWindow.close();
2624
+ }
2625
+ else{
2626
+ Ext.Msg.alert("Error", obj.message);
2627
+ }
2628
+ },
2629
+ failure:function(form, action){
2630
+ self.clearWindowStatus();
2631
+ var obj = Ext.decode(action.response.responseText);
2632
+ if(obj != null){
2633
+ Ext.Msg.alert("Error", obj.message);
2634
+ }
2635
+ else{
2636
+ Ext.Msg.alert("Error", "Error importing website");
2637
+ }
2638
+ }
2639
+ });
2103
2640
  }
2104
- }]
2105
- });
2106
- importWebsiteWindow.show();
2107
- }
2641
+ }
2642
+ },{
2643
+ text: 'Close',
2644
+ handler: function(){
2645
+ importWebsiteWindow.close();
2646
+ }
2647
+ }]
2648
+ });
2649
+ importWebsiteWindow.show();
2108
2650
  }
2109
- ]
2651
+ });
2652
+ }
2653
+
2654
+ var layout = new Ext.Panel({
2655
+ layout: 'border',
2656
+ autoDestroy:true,
2657
+ title:'Websites',
2658
+ items: [this.sitesTree,this.contentsCardPanel],
2659
+ tbar:{
2660
+ items:tbarItems
2110
2661
  }
2111
2662
  });
2112
2663
 
2113
- this.items = [layout,
2114
- {
2115
- xtype:'knitkit_themestreepanel',
2116
- centerRegion:this.initialConfig['module'].centerRegion
2117
- },
2664
+ if (currentUser.hasApplicationCapability('knitkit', {
2665
+ capability_type_iid:'view',
2666
+ resource:'Theme'
2667
+ }))
2668
+
2118
2669
  {
2119
- xtype:'knitkit_articlesgridpanel',
2120
- centerRegion:this.initialConfig['module'].centerRegion
2121
- }];
2670
+ this.items = [layout,
2671
+ {
2672
+ xtype:'knitkit_themestreepanel',
2673
+ centerRegion:this.initialConfig['module'].centerRegion
2674
+ },
2675
+ {
2676
+ xtype:'knitkit_articlesgridpanel',
2677
+ centerRegion:this.initialConfig['module'].centerRegion
2678
+ }];
2679
+ } else {
2680
+ this.items = [layout,
2681
+ {
2682
+ xtype:'knitkit_articlesgridpanel',
2683
+ centerRegion:this.initialConfig['module'].centerRegion
2684
+ }];
2685
+ }
2122
2686
 
2123
2687
  this.callParent(arguments);
2124
2688
  this.setActiveTab(0);