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
@@ -9,16 +9,16 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion",{
9
9
  ['SpellChecker','-','SelectAll'],
10
10
  ['TextColor','BGColor'],
11
11
  ['Bold','Italic','Underline','Strike'],
12
- ['Subscript','Superscript','-','RemoveFormat'],
13
- ['NumberedList','BulletedList'],
14
- ['Outdent','Indent','Blockquote','CreateDiv'],
12
+ ['Subscript','Superscript','-','jwplayer'],
13
+ ['Table','NumberedList','BulletedList'],
14
+ ['Outdent','Indent','Blockquote'],
15
15
  ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
16
16
  ['BidiLtr','BidiRtl'],
17
17
  ['Link','Unlink','Anchor'],
18
- ['jwplayer','Flash','Table'],
19
18
  ['HorizontalRule','SpecialChar','PageBreak'],
19
+ ['ShowBlocks','RemoveFormat'],
20
20
  ['Styles','Format','Font','FontSize' ],
21
- ['Maximize','ShowBlocks','-','About']
21
+ ['Maximize','-','About']
22
22
  ],
23
23
 
24
24
  setWindowStatus : function(status){
@@ -45,8 +45,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion",{
45
45
  saveSectionLayout : function(sectionId, content){
46
46
  var self = this;
47
47
  this.setWindowStatus('Saving...');
48
- var conn = new Ext.data.Connection();
49
- conn.request({
48
+ Ext.Ajax.request({
50
49
  url: '/knitkit/erp_app/desktop/section/save_layout',
51
50
  method: 'POST',
52
51
  params:{
@@ -73,52 +72,58 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion",{
73
72
 
74
73
  editSectionLayout : function(sectionName, websiteId, websiteSectionId, content, tbarItems){
75
74
  var self = this;
76
- var centerRegionLayout = Ext.create("Ext.panel.Panel",{
77
- layout:'border',
78
- title:sectionName,
79
- closable:true,
80
- items:[
81
- {
82
- title:sectionName + ' - Layout',
83
- tbarItems:tbarItems,
84
- xtype:'codemirror',
85
- parser:'erb',
86
- region:'center',
87
- sourceCode:content,
75
+ var itemId = 'section-'+websiteSectionId;
76
+ var item = this.workArea.query('#'+itemId).first();
77
+
78
+ if(Compass.ErpApp.Utility.isBlank(item)){
79
+ item = Ext.create("Ext.panel.Panel",{
80
+ layout:'border',
81
+ title:sectionName,
88
82
  closable:true,
89
- listeners:{
90
- 'save':function(codeMirror, content){
91
- self.saveSectionLayout(websiteSectionId, content);
83
+ itemId:itemId,
84
+ items:[
85
+ {
86
+ title:sectionName + ' - Layout',
87
+ tbarItems:tbarItems,
88
+ xtype:'codemirror',
89
+ parser:'erb',
90
+ region:'center',
91
+ sourceCode:content,
92
+ closable:true,
93
+ listeners:{
94
+ 'save':function(codeMirror, content){
95
+ self.saveSectionLayout(websiteSectionId, content);
96
+ }
92
97
  }
98
+ },
99
+ {
100
+ xtype:'knitkit_versionswebsitesectiongridpanel',
101
+ websiteSectionId:websiteSectionId,
102
+ region:'south',
103
+ height:150,
104
+ collapsible:true,
105
+ centerRegion:self,
106
+ siteId:websiteId
93
107
  }
94
- },
95
- {
96
- xtype:'knitkit_versionswebsitesectiongridpanel',
97
- websiteSectionId:websiteSectionId,
98
- region:'south',
99
- height:300,
100
- collapsible:true,
101
- centerRegion:self,
102
- siteId:websiteId
103
- }
104
- ],
105
- listeners:{
106
- 'show':function(panel){
107
- Ext.getCmp('knitkitWestRegion').selectWebsite(websiteId);
108
+ ],
109
+ listeners:{
110
+ 'show':function(panel){
111
+ Ext.getCmp('knitkitWestRegion').selectWebsite(websiteId);
112
+ }
108
113
  }
109
- }
110
- });
114
+ });
111
115
 
112
- this.workArea.add(centerRegionLayout);
113
- this.workArea.setActiveTab(this.workArea.items.length - 1);
116
+ this.workArea.add(item);
117
+ }
118
+
119
+ this.workArea.setActiveTab(item);
114
120
  return false;
115
121
  },
116
122
 
117
123
  saveTemplateFile : function(path, content){
118
124
  var self = this;
119
125
  this.setWindowStatus('Saving...');
120
- var conn = new Ext.data.Connection();
121
- conn.request({
126
+ Ext.Ajax.request({
122
127
  url: '/knitkit/erp_app/desktop/theme/update_file',
123
128
  method: 'POST',
124
129
  params:{
@@ -139,38 +144,44 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion",{
139
144
  });
140
145
  },
141
146
 
142
- editTemplateFile : function(node, content, tbarItems){
147
+ editTemplateFile : function(node, content, tbarItems, themeId){
143
148
  var self = this;
144
- var file_name = node.data.id.split('/').pop().split('.')[0];
149
+ var fileName = node.data.id.split('/').pop().split('.')[0];
145
150
  var fileType = node.data.id.split('.').pop();
146
- this.workArea.add(
147
- {
148
- closable:true,
149
- title:file_name,
150
- xtype:'panel',
151
- layout:'fit',
152
- items:[{
153
- tbarItems:tbarItems,
154
- xtype:'codemirror',
155
- parser:fileType,
156
- sourceCode:content,
151
+ var itemId = fileName+themeId;
152
+ var item = this.workArea.query('#'+itemId).first();
153
+
154
+ if(Compass.ErpApp.Utility.isBlank(item)){
155
+ item = Ext.create('Ext.panel.Panel',{
157
156
  closable:true,
158
- listeners:{
159
- 'save':function(codeMirror, content){
160
- self.saveTemplateFile(node.data.id, content);
157
+ title:fileName,
158
+ itemId:itemId,
159
+ layout:'fit',
160
+ items:[{
161
+ tbarItems:tbarItems,
162
+ xtype:'codemirror',
163
+ parser:fileType,
164
+ sourceCode:content,
165
+ closable:true,
166
+ listeners:{
167
+ 'save':function(codeMirror, content){
168
+ self.saveTemplateFile(node.data.id, content);
169
+ }
161
170
  }
162
- }
163
- }]
164
- });
165
- this.workArea.setActiveTab(this.workArea.items.length - 1);
171
+ }]
172
+ });
173
+
174
+ this.workArea.add(item);
175
+ }
176
+
177
+ this.workArea.setActiveTab(item);
166
178
  return false;
167
179
  },
168
180
 
169
181
  saveExcerpt : function(id, content){
170
182
  var self = this;
171
183
  this.setWindowStatus('Saving...');
172
- var conn = new Ext.data.Connection();
173
- conn.request({
184
+ Ext.Ajax.request({
174
185
  url: '/knitkit/erp_app/desktop/content/save_excerpt',
175
186
  method: 'POST',
176
187
  params:{
@@ -202,75 +213,81 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion",{
202
213
 
203
214
  editExcerpt : function(title, id, content, siteId, contentGridStore){
204
215
  var self = this;
205
- var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor",{
206
- autoHeight:true,
207
- value:content,
208
- ckEditorConfig:{
209
- extraPlugins:'compasssave,codemirror,jwplayer',
210
- toolbar:self.ckEditorToolbar
211
- },
212
- listeners:{
213
- 'save':function(ckEditor, content){
214
- self.saveExcerpt(id, content);
215
- contentGridStore.load();
216
+ var itemId = 'editExcerpt-'+id;
217
+ var item = this.workArea.query('#'+itemId).first();
218
+
219
+ if(Compass.ErpApp.Utility.isBlank(item)){
220
+ var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor",{
221
+ autoHeight:true,
222
+ value:content,
223
+ ckEditorConfig:{
224
+ extraPlugins:'compasssave,jwplayer', // removed codemirror plugin as it is unstable
225
+ toolbar:self.ckEditorToolbar
226
+ },
227
+ listeners:{
228
+ 'save':function(ckEditor, content){
229
+ self.saveExcerpt(id, content);
230
+ contentGridStore.load();
231
+ }
216
232
  }
217
- }
218
- });
219
-
220
- var items = [ {
221
- xtype:'panel',
222
- layout:'fit',
223
- split:true,
224
- region:'center',
225
- items:ckEditor,
226
- autoDestroy:true
227
- }];
228
-
229
- if(!Compass.ErpApp.Utility.isBlank(siteId)){
230
- items.push( {
231
- xtype:'knitkit_versionsbloggridpanel',
232
- contentId:id,
233
- region:'south',
234
- height:300,
235
- collapsible:true,
236
- centerRegion:self,
237
- siteId:siteId
238
233
  });
239
- }
240
- else{
241
- items.push({
242
- xtype:'knitkit_nonpublishedversionswebsitesectiongridpanel',
243
- contentId:id,
244
- region:'south',
245
- height:300,
246
- collapsible:true,
247
- centerRegion:self
248
- });
249
- }
250
234
 
251
- var centerRegionLayout = Ext.create("Ext.panel.Panel",{
252
- layout:'border',
253
- title:title,
254
- closable:true,
255
- items:items,
256
- listeners:{
257
- 'show':function(panel){
258
- if(!Compass.ErpApp.Utility.isBlank(siteId)){
259
- Ext.getCmp('knitkitWestRegion').selectWebsite(siteId);
235
+ var items = [ {
236
+ xtype:'panel',
237
+ layout:'fit',
238
+ split:true,
239
+ region:'center',
240
+ items:ckEditor,
241
+ autoDestroy:true
242
+ }];
243
+
244
+ if(!Compass.ErpApp.Utility.isBlank(siteId)){
245
+ items.push( {
246
+ xtype:'knitkit_versionsbloggridpanel',
247
+ contentId:id,
248
+ region:'south',
249
+ height:150,
250
+ collapsible:true,
251
+ centerRegion:self,
252
+ siteId:siteId
253
+ });
254
+ }
255
+ else{
256
+ items.push({
257
+ xtype:'knitkit_nonpublishedversionswebsitesectiongridpanel',
258
+ contentId:id,
259
+ region:'south',
260
+ height:150,
261
+ collapsible:true,
262
+ centerRegion:self
263
+ });
264
+ }
265
+
266
+ item = Ext.create("Ext.panel.Panel",{
267
+ layout:'border',
268
+ title:title,
269
+ closable:true,
270
+ items:items,
271
+ itemId:itemId,
272
+ listeners:{
273
+ 'show':function(panel){
274
+ if(!Compass.ErpApp.Utility.isBlank(siteId)){
275
+ Ext.getCmp('knitkitWestRegion').selectWebsite(siteId);
276
+ }
260
277
  }
261
278
  }
262
- }
263
- })
279
+ });
264
280
 
265
- this.workArea.add(centerRegionLayout);
266
- this.workArea.setActiveTab(this.workArea.items.length - 1);
281
+ this.workArea.add(item);
282
+ }
283
+
284
+ this.workArea.setActiveTab(item);
267
285
  },
268
286
 
269
287
  saveContent : function(id, content, contentType){
270
288
  var self = this;
271
289
  this.setWindowStatus('Saving...');
272
- var conn = new Ext.data.Connection();
273
- conn.request({
290
+ Ext.Ajax.request({
274
291
  url: '/knitkit/erp_app/desktop/content/update',
275
292
  method: 'POST',
276
293
  params:{
@@ -311,8 +328,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion",{
311
328
  }
312
329
  });
313
330
 
314
- this.workArea.add({
315
- xtype:'panel',
331
+ var item = Ext.create('Ext.panel.Panel',{
316
332
  closable:true,
317
333
  layout:'fit',
318
334
  title:title,
@@ -320,77 +336,98 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion",{
320
336
  items:ckEditor,
321
337
  autoDestroy:true
322
338
  });
323
- this.workArea.setActiveTab(this.workArea.items.length - 1);
339
+
340
+ this.workArea.add(item);
341
+ this.workArea.setActiveTab(item);
324
342
  },
325
343
 
326
344
  editContent : function(title, id, content, siteId, contentType, contentGridStore){
327
345
  var self = this;
328
- var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor",{
329
- autoHeight:true,
330
- //value:content,
331
- ckEditorConfig:{
332
- extraPlugins:'compasssave,codemirror,jwplayer',
333
- toolbar:self.ckEditorToolbar
334
- },
335
- listeners:{
336
- 'save':function(ckEditor, content){
337
- self.saveContent(id, content, contentType);
338
- contentGridStore.load();
346
+ var itemId = 'editContent-'+id;
347
+ var item = this.workArea.query('#'+itemId).first();
348
+
349
+ if(Compass.ErpApp.Utility.isBlank(item)){
350
+ var ckEditor = Ext.create("Compass.ErpApp.Shared.CKeditor",{
351
+ autoHeight:true,
352
+ //value:content,
353
+ ckEditorConfig:{
354
+ extraPlugins:'compasssave,jwplayer', // removed codemirror plugin as it is unstable
355
+ toolbar:self.ckEditorToolbar
356
+ },
357
+ listeners:{
358
+ 'save':function(ckEditor, content){
359
+ if (currentUser.hasApplicationCapability('knitkit', {
360
+ capability_type_iid:'edit_html',
361
+ resource:'Article'
362
+ }))
363
+ {
364
+ self.saveContent(id, content, contentType);
365
+ if (contentGridStore){
366
+ contentGridStore.load();
367
+ }
368
+
369
+ }else{
370
+ currentUser.showInvalidAccess();
371
+ }
372
+ }
339
373
  }
340
- }
341
- });
374
+ });
342
375
 
343
- ckEditor.setValue(content);
376
+ ckEditor.setValue(content);
344
377
 
345
- var items = [
346
- {
347
- xtype:'panel',
348
- layout:'fit',
349
- split:true,
350
- region:'center',
351
- items:ckEditor,
352
- autoDestroy:true
353
- }
354
- ];
355
-
356
- if(!Compass.ErpApp.Utility.isBlank(siteId)){
357
- items.push({
358
- xtype:'knitkit_versions'+contentType+'gridpanel',
359
- contentId:id,
360
- region:'south',
361
- height:300,
362
- collapsible:true,
363
- centerRegion:self,
364
- siteId:siteId
365
- });
366
- }
367
- else{
368
- items.push({
369
- xtype:'knitkit_nonpublishedversionswebsitesectiongridpanel',
370
- contentId:id,
371
- region:'south',
372
- height:300,
373
- collapsible:true,
374
- centerRegion:self
375
- });
376
- }
378
+ var items = [
379
+ {
380
+ xtype:'panel',
381
+ layout:'fit',
382
+ split:true,
383
+ region:'center',
384
+ items:ckEditor,
385
+ autoDestroy:true
386
+ }
387
+ ];
388
+
389
+ if(!Compass.ErpApp.Utility.isBlank(siteId)){
390
+ items.push({
391
+ xtype:'knitkit_versions'+contentType+'gridpanel',
392
+ contentId:id,
393
+ region:'south',
394
+ height:150,
395
+ collapsible:true,
396
+ centerRegion:self,
397
+ siteId:siteId
398
+ });
399
+ }
400
+ else{
401
+ items.push({
402
+ xtype:'knitkit_nonpublishedversionswebsitesectiongridpanel',
403
+ contentId:id,
404
+ region:'south',
405
+ height:150,
406
+ collapsible:true,
407
+ centerRegion:self
408
+ });
409
+ }
377
410
 
378
- var centerRegionLayout = Ext.create("Ext.panel.Panel",{
379
- layout:'border',
380
- title:title,
381
- closable:true,
382
- items:items,
383
- listeners:{
384
- 'show':function(panel){
385
- if(!Compass.ErpApp.Utility.isBlank(siteId)){
386
- Ext.getCmp('knitkitWestRegion').selectWebsite(siteId);
411
+ item = Ext.create('Ext.panel.Panel',{
412
+ xtype:'panel',
413
+ layout:'border',
414
+ title:title,
415
+ itemId:itemId,
416
+ closable:true,
417
+ items:items,
418
+ listeners:{
419
+ 'show':function(panel){
420
+ if(!Compass.ErpApp.Utility.isBlank(siteId)){
421
+ Ext.getCmp('knitkitWestRegion').selectWebsite(siteId);
422
+ }
387
423
  }
388
424
  }
389
- }
390
- });
425
+ });
391
426
 
392
- this.workArea.add(centerRegionLayout);
393
- this.workArea.setActiveTab(this.workArea.items.length - 1);
427
+ this.workArea.add(item);
428
+ }
429
+
430
+ this.workArea.setActiveTab(item);
394
431
  },
395
432
 
396
433
  showComment : function(comment){
@@ -406,67 +443,81 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion",{
406
443
 
407
444
  viewContentComments : function(contentId, title){
408
445
  var self = this;
409
- var centerRegionLayout = Ext.create("Ext.panel.Panel",{
410
- layout:'border',
411
- title:title,
412
- closable:true,
413
- items:[
414
- {
415
- xtype:'panel',
416
- layout:'card',
417
- split:true,
418
- region:'center',
419
- items:[],
420
- autoDestroy:true
421
- },
422
- {
423
- xtype:'knitkit_commentsgridpanel',
424
- contentId:contentId,
425
- region:'south',
426
- height:300,
427
- collapsible:true,
428
- centerRegion:self
429
- }
430
- ]
431
- });
432
-
433
- this.workArea.add(centerRegionLayout);
434
- this.workArea.setActiveTab(this.workArea.items.length - 1);
446
+ var itemId = 'contentComments-'+contentId;
447
+ var item = this.workArea.query('#'+itemId).first();
448
+
449
+ if(Compass.ErpApp.Utility.isBlank(item)){
450
+ item = Ext.create("Ext.panel.Panel",{
451
+ layout:'border',
452
+ itemId:itemId,
453
+ title:title,
454
+ closable:true,
455
+ items:[
456
+ {
457
+ xtype:'panel',
458
+ layout:'card',
459
+ split:true,
460
+ region:'center',
461
+ items:[],
462
+ autoDestroy:true
463
+ },
464
+ {
465
+ xtype:'knitkit_commentsgridpanel',
466
+ contentId:contentId,
467
+ region:'south',
468
+ height:300,
469
+ collapsible:true,
470
+ centerRegion:self
471
+ }
472
+ ]
473
+ });
474
+ this.workArea.add(item);
475
+ }
476
+
477
+ this.workArea.setActiveTab(item);
435
478
  },
436
479
 
437
480
  viewWebsiteInquiries : function(websiteId, title){
438
481
  var self = this;
439
- var centerRegionLayout = Ext.create("Ext.panel.Panel",{
440
- layout:'border',
441
- title:title + " Inquiries",
442
- closable:true,
443
- items:[
444
- {
482
+ var itemId = 'websiteInqueries-'+websiteId;
483
+ var item = this.workArea.query('#'+itemId).first();
484
+
485
+ if(Compass.ErpApp.Utility.isBlank(item)){
486
+ item = {
445
487
  xtype:'panel',
446
- layout:'card',
447
- split:true,
448
- region:'center',
449
- items:[],
450
- autoDestroy:true
451
- },
452
- {
453
- xtype:'knitkit_inquiriesgridpanel',
454
- websiteId:websiteId,
455
- region:'south',
456
- height:300,
457
- collapsible:true,
458
- centerRegion:self
459
- }
460
- ],
461
- listeners:{
462
- 'show':function(panel){
463
- Ext.getCmp('knitkitWestRegion').selectWebsite(websiteId);
488
+ layout:'border',
489
+ title:title + " Inquiries",
490
+ itemId:itemId,
491
+ closable:true,
492
+ items:[
493
+ {
494
+ xtype:'panel',
495
+ layout:'card',
496
+ split:true,
497
+ region:'center',
498
+ items:[],
499
+ autoDestroy:true
500
+ },
501
+ {
502
+ xtype:'knitkit_inquiriesgridpanel',
503
+ websiteId:websiteId,
504
+ region:'south',
505
+ height:300,
506
+ collapsible:true,
507
+ centerRegion:self
464
508
  }
465
- }
466
- });
509
+ ],
510
+ listeners:{
511
+ 'show':function(panel){
512
+ Ext.getCmp('knitkitWestRegion').selectWebsite(websiteId);
513
+ }
514
+ }
515
+ };
467
516
 
468
- this.workArea.add(centerRegionLayout);
469
- this.workArea.setActiveTab(this.workArea.items.length - 1);
517
+ this.workArea.add(item);
518
+ }
519
+
520
+ this.workArea.setActiveTab(item);
470
521
  },
471
522
 
472
523
  insertHtmlIntoActiveCkEditor : function(html){