knitkit 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/GPL-3-LICENSE +674 -0
  2. data/README.md +6 -0
  3. data/Rakefile +30 -0
  4. data/app/assets/javascripts/knitkit/application.js +9 -0
  5. data/app/assets/stylesheets/knitkit/application.css +7 -0
  6. data/app/controllers/knitkit/articles_controller.rb +7 -0
  7. data/app/controllers/knitkit/base_controller.rb +45 -0
  8. data/app/controllers/knitkit/blogs_controller.rb +27 -0
  9. data/app/controllers/knitkit/comments_controller.rb +18 -0
  10. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +135 -0
  11. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +144 -0
  12. data/app/controllers/knitkit/erp_app/desktop/comments_controller.rb +43 -0
  13. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +27 -0
  14. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +145 -0
  15. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +28 -0
  16. data/app/controllers/knitkit/erp_app/desktop/inquiries_controller.rb +68 -0
  17. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +20 -0
  18. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +272 -0
  19. data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +135 -0
  20. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +177 -0
  21. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +143 -0
  22. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +116 -0
  23. data/app/controllers/knitkit/unauthorized_controller.rb +8 -0
  24. data/app/controllers/knitkit/website_sections_controller.rb +17 -0
  25. data/app/helpers/application_helper.rb +132 -0
  26. data/app/models/article.rb +14 -0
  27. data/app/models/blog.rb +21 -0
  28. data/app/models/comment.rb +24 -0
  29. data/app/models/content.rb +158 -0
  30. data/app/models/extensions/user.rb +5 -0
  31. data/app/models/published_element.rb +9 -0
  32. data/app/models/published_website.rb +118 -0
  33. data/app/models/theme.rb +239 -0
  34. data/app/models/website.rb +457 -0
  35. data/app/models/website_host.rb +3 -0
  36. data/app/models/website_inquiry.rb +11 -0
  37. data/app/models/website_inquiry_mailer.rb +12 -0
  38. data/app/models/website_nav.rb +17 -0
  39. data/app/models/website_nav_item.rb +21 -0
  40. data/app/models/website_section.rb +152 -0
  41. data/app/models/website_section_content.rb +4 -0
  42. data/app/views/knitkit/articles/index.html.erb +3 -0
  43. data/app/views/knitkit/articles/show.html.erb +4 -0
  44. data/app/views/knitkit/blogs/_add_comment.html.erb +28 -0
  45. data/app/views/knitkit/blogs/_comment.html.erb +8 -0
  46. data/app/views/knitkit/blogs/index.html.erb +51 -0
  47. data/app/views/knitkit/blogs/index.rss.builder +23 -0
  48. data/app/views/knitkit/blogs/show.html.erb +22 -0
  49. data/app/views/knitkit/unauthorized/index.html.erb +4 -0
  50. data/app/views/knitkit/website_sections/index.html.erb +6 -0
  51. data/app/views/layouts/knitkit/base.html.erb +59 -0
  52. data/app/views/menus/knitkit/_default_menu.html.erb +23 -0
  53. data/app/views/menus/knitkit/_default_section_menu.html.erb +27 -0
  54. data/app/views/menus/knitkit/_default_sub_menu.html.erb +45 -0
  55. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +49 -0
  56. data/app/views/shared/knitkit/_bread_crumb.html.erb +7 -0
  57. data/app/views/shared/knitkit/_footer.html.erb +3 -0
  58. data/app/views/website_inquiry_mailer/inquiry.erb +3 -0
  59. data/app/widgets/contact_us/base.rb +86 -0
  60. data/app/widgets/contact_us/javascript/contact_us.js +13 -0
  61. data/app/widgets/contact_us/views/_contact_form.html.erb +36 -0
  62. data/app/widgets/contact_us/views/error.html.erb +10 -0
  63. data/app/widgets/contact_us/views/index.html.erb +1 -0
  64. data/app/widgets/contact_us/views/layouts/base.html.erb +7 -0
  65. data/app/widgets/contact_us/views/success.html.erb +4 -0
  66. data/app/widgets/google_map/base.rb +48 -0
  67. data/app/widgets/google_map/javascript/google_map.js +174 -0
  68. data/app/widgets/google_map/views/index.html.erb +41 -0
  69. data/app/widgets/login/base.rb +61 -0
  70. data/app/widgets/login/javascript/login.js +162 -0
  71. data/app/widgets/login/views/index.html.erb +37 -0
  72. data/app/widgets/login/views/layouts/base.html.erb +14 -0
  73. data/app/widgets/login/views/login_header.html.erb +9 -0
  74. data/app/widgets/login/views/reset_password.html.erb +26 -0
  75. data/app/widgets/manage_profile/base.rb +327 -0
  76. data/app/widgets/manage_profile/javascript/manage_profile.js +11 -0
  77. data/app/widgets/manage_profile/views/_contact_information_form.html.erb +180 -0
  78. data/app/widgets/manage_profile/views/_password_form.html.erb +20 -0
  79. data/app/widgets/manage_profile/views/_user_information_form.html.erb +30 -0
  80. data/app/widgets/manage_profile/views/contact_type_in_use.html.erb +4 -0
  81. data/app/widgets/manage_profile/views/default_type_error.html.erb +5 -0
  82. data/app/widgets/manage_profile/views/error.html.erb +3 -0
  83. data/app/widgets/manage_profile/views/index.html.erb +46 -0
  84. data/app/widgets/manage_profile/views/layouts/base.html.erb +1 -0
  85. data/app/widgets/manage_profile/views/password_blank.html.erb +4 -0
  86. data/app/widgets/manage_profile/views/password_invalid.html.erb +4 -0
  87. data/app/widgets/manage_profile/views/password_success.html.erb +3 -0
  88. data/app/widgets/manage_profile/views/success.html.erb +3 -0
  89. data/app/widgets/reset_password/base.rb +42 -0
  90. data/app/widgets/reset_password/javascript/reset_password.js +13 -0
  91. data/app/widgets/reset_password/views/index.html.erb +31 -0
  92. data/app/widgets/reset_password/views/layouts/base.html.erb +1 -0
  93. data/app/widgets/search/base.rb +80 -0
  94. data/app/widgets/search/javascript/search.js +31 -0
  95. data/app/widgets/search/views/_search.html.erb +39 -0
  96. data/app/widgets/search/views/index.html.erb +3 -0
  97. data/app/widgets/search/views/layouts/base.html.erb +24 -0
  98. data/app/widgets/search/views/show.html.erb +48 -0
  99. data/app/widgets/signup/base.rb +72 -0
  100. data/app/widgets/signup/javascript/signup.js +13 -0
  101. data/app/widgets/signup/views/_signup_form.html.erb +36 -0
  102. data/app/widgets/signup/views/error.html.erb +11 -0
  103. data/app/widgets/signup/views/index.html.erb +1 -0
  104. data/app/widgets/signup/views/layouts/base.html.erb +7 -0
  105. data/app/widgets/signup/views/success.html.erb +4 -0
  106. data/config/environment.rb +0 -0
  107. data/config/routes.rb +41 -0
  108. data/db/data_migrations/20110509223702_add_publisher_role.rb +11 -0
  109. data/db/data_migrations/20110816153456_add_knitkit_application.rb +31 -0
  110. data/db/data_migrations/upgrade/20111011203718_create_paths_for_sections.rb +13 -0
  111. data/db/data_migrations/upgrade/20111216192114_add_secured_models_to_menu_items.rb +18 -0
  112. data/db/data_migrations/upgrade/20111216202819_set_contents_iid_to_permalink_where_null.rb +12 -0
  113. data/db/migrate/20110211002317_setup_knitkit.rb +259 -0
  114. data/db/migrate/upgrade/20111014190442_update_contents.rb +25 -0
  115. data/db/migrate/upgrade/20111014201502_add_published_by_to_published_elements.rb +22 -0
  116. data/db/migrate/upgrade/20111017133851_add_iid_to_section.rb +21 -0
  117. data/db/migrate/upgrade/20111027145006_add_in_menu_to_section.rb +19 -0
  118. data/lib/knitkit.rb +12 -0
  119. data/lib/knitkit/engine.rb +26 -0
  120. data/lib/knitkit/extensions.rb +18 -0
  121. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +88 -0
  122. data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +28 -0
  123. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +38 -0
  124. data/lib/knitkit/extensions/active_record/theme_support/has_many_themes.rb +34 -0
  125. data/lib/knitkit/extensions/compass/widgets/base.rb +53 -0
  126. data/lib/knitkit/extensions/core/array.rb +5 -0
  127. data/lib/knitkit/extensions/railties/action_view.rb +187 -0
  128. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +198 -0
  129. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +44 -0
  130. data/lib/knitkit/routing_filter/section_router.rb +55 -0
  131. data/lib/knitkit/syntax_validator.rb +32 -0
  132. data/lib/knitkit/version.rb +3 -0
  133. data/lib/tasks/knitkit_tasks.rake +4 -0
  134. data/public/images/knitkit/bullet.png +0 -0
  135. data/public/images/knitkit/content.png +0 -0
  136. data/public/images/knitkit/footer.png +0 -0
  137. data/public/images/knitkit/graphic.png +0 -0
  138. data/public/images/knitkit/greyFadeDown.png +0 -0
  139. data/public/images/knitkit/link.png +0 -0
  140. data/public/images/knitkit/logo.png +0 -0
  141. data/public/images/knitkit/menu.png +0 -0
  142. data/public/images/knitkit/menu_select.png +0 -0
  143. data/public/images/knitkit/search.png +0 -0
  144. data/public/javascripts/datepicker.js +440 -0
  145. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +473 -0
  146. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +576 -0
  147. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +217 -0
  148. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +26 -0
  149. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +109 -0
  150. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +30 -0
  151. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +160 -0
  152. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +46 -0
  153. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +46 -0
  154. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +92 -0
  155. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +220 -0
  156. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +613 -0
  157. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +573 -0
  158. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +664 -0
  159. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +2161 -0
  160. data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +52 -0
  161. data/public/stylesheets/datepicker.css +121 -0
  162. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +114 -0
  163. data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +219 -0
  164. data/public/stylesheets/knitkit/style.css +394 -0
  165. metadata +289 -0
@@ -0,0 +1,2161 @@
1
+ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.WestRegion",{
2
+ extend:"Ext.tab.Panel",
3
+ id:'knitkitWestRegion',
4
+ alias:'widget.knitkit_westregion',
5
+ setWindowStatus : function(status){
6
+ this.findParentByType('statuswindow').setStatus(status);
7
+ },
8
+
9
+ clearWindowStatus : function(){
10
+ this.findParentByType('statuswindow').clearStatus();
11
+ },
12
+
13
+ deleteSection : function(node){
14
+ var self = this;
15
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this section?', function(btn){
16
+ if(btn == 'no'){
17
+ return false;
18
+ }
19
+ else
20
+ if(btn == 'yes')
21
+ {
22
+ self.setWindowStatus('Deleting Section...');
23
+ var conn = new Ext.data.Connection();
24
+ conn.request({
25
+ url: '/knitkit/erp_app/desktop/section/delete',
26
+ method: 'POST',
27
+ params:{
28
+ id:node.data.id.split('_')[1]
29
+ },
30
+ success: function(response) {
31
+ self.clearWindowStatus();
32
+ var obj = Ext.decode(response.responseText);
33
+ if(obj.success){
34
+ node.remove(true);
35
+ }
36
+ else{
37
+ Ext.Msg.alert('Error', 'Error deleting section');
38
+ }
39
+ },
40
+ failure: function(response) {
41
+ self.clearWindowStatus();
42
+ Ext.Msg.alert('Error', 'Error deleting section');
43
+ }
44
+ });
45
+ }
46
+ });
47
+ },
48
+
49
+ exportSite : function(id){
50
+ var self = this;
51
+ self.setWindowStatus('Exporting Website...');
52
+ window.open('/knitkit/erp_app/desktop/site/export?id='+id,'mywindow','width=400,height=200');
53
+ self.clearWindowStatus();
54
+ },
55
+
56
+ deleteSite : function(node){
57
+ var self = this;
58
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this Website?', function(btn){
59
+ if(btn == 'no'){
60
+ return false;
61
+ }
62
+ else
63
+ if(btn == 'yes')
64
+ {
65
+ self.setWindowStatus('Deleting Website...');
66
+ var conn = new Ext.data.Connection();
67
+ conn.request({
68
+ url: '/knitkit/erp_app/desktop/site/delete',
69
+ method: 'POST',
70
+ params:{
71
+ id:node.data.id.split('_')[1]
72
+ },
73
+ success: function(response) {
74
+ self.clearWindowStatus();
75
+ var obj = Ext.decode(response.responseText);
76
+ if(obj.success){
77
+ node.remove(true);
78
+ }
79
+ else{
80
+ Ext.Msg.alert('Error', 'Error deleting Website');
81
+ }
82
+ },
83
+ failure: function(response) {
84
+ self.clearWindowStatus();
85
+ Ext.Msg.alert('Error', 'Error deleting Website');
86
+ }
87
+ });
88
+ }
89
+ });
90
+ },
91
+
92
+ publish : function(node){
93
+ var self = this;
94
+ var publishWindow = new Compass.ErpApp.Desktop.Applications.Knitkit.PublishWindow({
95
+ baseParams:{
96
+ id:node.id.split('_')[1]
97
+ },
98
+ url:'/knitkit/erp_app/desktop/site/publish',
99
+ listeners:{
100
+ 'publish_success':function(window, response){
101
+ if(response.success){
102
+ self.getPublications(node);
103
+ }
104
+ else{
105
+ Ext.Msg.alert('Error', 'Error publishing Website');
106
+ }
107
+ },
108
+ 'publish_failure':function(window, response){
109
+ Ext.Msg.alert('Error', 'Error publishing Website');
110
+ }
111
+ }
112
+ });
113
+
114
+ publishWindow.show();
115
+ },
116
+
117
+ editSectionLayout : function(sectionName, sectionId, websiteId){
118
+ var self = this;
119
+ self.selectWebsite(websiteId);
120
+ self.setWindowStatus('Loading section template...');
121
+ var conn = new Ext.data.Connection();
122
+ conn.request({
123
+ url: '/knitkit/erp_app/desktop/section/get_layout',
124
+ method: 'POST',
125
+ params:{
126
+ id:sectionId
127
+ },
128
+ success: function(response) {
129
+ self.initialConfig['centerRegion'].editSectionLayout(
130
+ sectionName,
131
+ websiteId,
132
+ sectionId,
133
+ response.responseText,
134
+ [{
135
+ text: 'Insert Content Area',
136
+ handler: function(btn){
137
+ var codeMirror = btn.findParentByType('codemirror');
138
+ Ext.MessageBox.prompt('New File', 'Please enter content area name:', function(btn, text){
139
+ if(btn == 'ok'){
140
+ codeMirror.insertContent('<%=render_content_area(:'+text+')%>');
141
+ }
142
+
143
+ });
144
+ }
145
+ }]);
146
+ self.clearWindowStatus();
147
+ },
148
+ failure: function(response) {
149
+ self.clearWindowStatus();
150
+ Ext.Msg.alert('Error', 'Error loading section layout.');
151
+ }
152
+ });
153
+ },
154
+
155
+ changeSecurityOnSection : function(node, secure){
156
+ var self = this;
157
+ self.setWindowStatus('Updating section...');
158
+ var conn = new Ext.data.Connection();
159
+ conn.request({
160
+ url: '/knitkit/erp_app/desktop/section/update_security',
161
+ method: 'POST',
162
+ params:{
163
+ id:node.data.id.split('_')[1],
164
+ site_id:node.data.siteId,
165
+ secure:secure
166
+ },
167
+ success: function(response) {
168
+ var obj = Ext.decode(response.responseText);
169
+ if(obj.success){
170
+ self.clearWindowStatus();
171
+ if(secure){
172
+ node.set('iconCls', 'icon-document_lock');
173
+ }
174
+ else{
175
+ node.set('iconCls', 'icon-document');
176
+ }
177
+ node.set('isSecured',secure);
178
+ node.commit();
179
+ }
180
+ else{
181
+ Ext.Msg.alert('Error', 'Error securing section');
182
+ }
183
+ },
184
+ failure: function(response) {
185
+ self.clearWindowStatus();
186
+ Ext.Msg.alert('Error', 'Error securing section.');
187
+ }
188
+ });
189
+ },
190
+
191
+ changeSecurityOnMenuItem : function(node, secure){
192
+ var self = this;
193
+ self.setWindowStatus('Updating menu item security...');
194
+ var conn = new Ext.data.Connection();
195
+ conn.request({
196
+ url: '/knitkit/erp_app/desktop/website_nav/update_security',
197
+ method: 'POST',
198
+ params:{
199
+ id:node.data.websiteNavItemId,
200
+ site_id:node.data.websiteId,
201
+ secure:secure
202
+ },
203
+ success: function(response) {
204
+ var obj = Ext.decode(response.responseText);
205
+ if(obj.success){
206
+ self.clearWindowStatus();
207
+ if(secure){
208
+ node.set('iconCls', 'icon-document_lock');
209
+ }
210
+ else{
211
+ node.set('iconCls', 'icon-document');
212
+ }
213
+ node.set('isSecured',secure);
214
+ node.commit();
215
+ }
216
+ else{
217
+ Ext.Msg.alert('Error', 'Error securing menu item');
218
+ }
219
+ },
220
+ failure: function(response) {
221
+ self.clearWindowStatus();
222
+ Ext.Msg.alert('Error', 'Error securing menu item');
223
+ }
224
+ });
225
+ },
226
+
227
+ selectWebsite : function(websiteId){
228
+ var node = this.sitesTree.getStore().getNodeById("website_"+websiteId);
229
+ if(node.data.iconCls != 'icon-globe'){
230
+ node.set('iconCls', 'icon-globe');
231
+ node.commit();
232
+ }
233
+ node.parentNode.eachChild(function(child){
234
+ if(node.data.id != child.data.id){
235
+ if(child.data.iconCls != 'icon-globe_disconnected'){
236
+ child.set('iconCls', 'icon-globe_disconnected');
237
+ child.commit();
238
+ }
239
+ }
240
+ });
241
+ Ext.getCmp('knitkitEastRegion').fileAssetsPanel.selectWebsite(websiteId);
242
+ Ext.getCmp('knitkitEastRegion').imageAssetsPanel.selectWebsite(websiteId);
243
+ },
244
+
245
+ initComponent: function() {
246
+ var self = this;
247
+
248
+ var store = Ext.create('Ext.data.TreeStore', {
249
+ proxy:{
250
+ type: 'ajax',
251
+ url: '/knitkit/erp_app/desktop/websites'
252
+ },
253
+ root: {
254
+ text: 'Websites',
255
+ expanded: true
256
+ },
257
+ fields:[
258
+ {
259
+ name:'canAddMenuItems'
260
+ },
261
+ {
262
+ name:'isWebsiteNavItem'
263
+ },
264
+ {
265
+ name:'text'
266
+ },
267
+ {
268
+ name:'iconCls'
269
+ },
270
+ {
271
+ name:'leaf'
272
+ },
273
+ {
274
+ name:'isSection'
275
+ },
276
+ {
277
+ name:'isHost'
278
+ },
279
+ {
280
+ name:'isSecured'
281
+ },
282
+ {
283
+ name:'url'
284
+ },
285
+ {
286
+ name:'inMenu'
287
+ },
288
+ {
289
+ name:'isBlog'
290
+ },
291
+ {
292
+ name:'hasLayout'
293
+ },
294
+ {
295
+ name:'siteId'
296
+ },
297
+ {
298
+ name:'type'
299
+ },
300
+ {
301
+ name:'isWebsite'
302
+ },
303
+ {
304
+ name:'name'
305
+ },
306
+ {
307
+ name:'title'
308
+ },
309
+ {
310
+ name:'subtitle'
311
+ },
312
+ {
313
+ name:'email'
314
+ },
315
+ {
316
+ name:'autoActivatePublication'
317
+ },
318
+ {
319
+ name:'emailInquiries'
320
+ },
321
+ {
322
+ name:'isHostRoot'
323
+ },
324
+ {
325
+ name:'websiteHostId'
326
+ },
327
+ {
328
+ name:'host'
329
+ },
330
+ {
331
+ name:'websiteId'
332
+ },
333
+ {
334
+ name:'isSectionRoot'
335
+ },
336
+ {
337
+ name:'isWebsiteNav'
338
+ },
339
+ {
340
+ name:'isMenuRoot'
341
+ },
342
+ {
343
+ name:'linkToType'
344
+ },
345
+ {
346
+ name:'linkedToId'
347
+ },
348
+ {
349
+ name:'websiteNavItemId'
350
+ },
351
+ {
352
+ name:'type'
353
+ },
354
+ {
355
+ name:'siteName'
356
+ },
357
+ {
358
+ name:'websiteNavId'
359
+ },
360
+ {
361
+ name:'internal_identifier'
362
+ }
363
+ ]
364
+ });
365
+
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']){
377
+ return true;
378
+ }
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++;
399
+ });
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++;
409
+ });
410
+ }
411
+
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) {
420
+
421
+ },
422
+ failure: function(response) {
423
+ Ext.Msg.alert('Error', 'Error saving positions.');
424
+ }
425
+ });
426
+ }
427
+ }
428
+ },
429
+ store:store,
430
+ region: 'center',
431
+ rootVisible:false,
432
+ enableDD :true,
433
+ listeners:{
434
+ 'itemclick':function(view, record, htmlItem, index, e){
435
+ e.stopEvent();
436
+ if(record.data['isWebsite']){
437
+ self.selectWebsite(record.data.id.split('_')[1]);
438
+ }
439
+ else
440
+ if(record.data['isSection']){
441
+ self.getArticles(record);
442
+ }
443
+ else
444
+ if(record.data['isHost']){
445
+ var webNavigator = window.compassDesktop.getModule('web-navigator-win');
446
+ webNavigator.createWindow(record.data['url']);
447
+ }
448
+ },
449
+ 'itemcontextmenu':function(view, record, htmlItem, index, e){
450
+ e.stopEvent();
451
+ var items = [];
452
+
453
+ if(!Compass.ErpApp.Utility.isBlank(record.data['url'])){
454
+ items.push({
455
+ text:'View In Web Navigator',
456
+ iconCls:'icon-globe',
457
+ listeners:{
458
+ 'click':function(){
459
+ var webNavigator = window.compassDesktop.getModule('web-navigator-win');
460
+ webNavigator.createWindow(record.data['url']);
461
+ }
462
+ }
463
+ });
464
+ }
465
+
466
+ 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
+
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
+ });
638
+
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{
651
+ 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",{
668
+ layout:'fit',
669
+ width:375,
670
+ title:'New Section',
671
+ plain: true,
672
+ buttonAlign:'center',
673
+ items: new Ext.FormPanel({
674
+ labelWidth: 110,
675
+ frame:false,
676
+ bodyStyle:'padding:5px 5px 0',
677
+ url:'/knitkit/erp_app/desktop/section/new',
678
+ defaults: {
679
+ width: 225
680
+ },
681
+ items: [
682
+ {
683
+ xtype:'textfield',
684
+ fieldLabel:'Title',
685
+ allowBlank:false,
686
+ name:'title'
687
+ },
688
+ {
689
+ xtype:'textfield',
690
+ fieldLabel:'Unique Name',
691
+ allowBlank:true,
692
+ name:'internal_identifier'
693
+ },
694
+ {
695
+ xtype: 'combo',
696
+ forceSelection:true,
697
+ store: [
698
+ ['Page','Page'],
699
+ ['Blog','Blog'],
700
+ ],
701
+ value:'Page',
702
+ fieldLabel: 'Type',
703
+ name: 'type',
704
+ allowBlank: false,
705
+ triggerAction: 'all'
706
+ },
707
+ {
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
+ }]
725
+ },
726
+ {
727
+ xtype:'hidden',
728
+ name:'website_section_id',
729
+ value:record.data.id.split('_')[1]
730
+ },
731
+ {
732
+ xtype:'hidden',
733
+ name:'website_id',
734
+ value:record.data.siteId
735
+ }
736
+ ]
737
+ }),
738
+ buttons: [{
739
+ text:'Submit',
740
+ listeners:{
741
+ 'click':function(button){
742
+ var window = button.findParentByType('window');
743
+ var formPanel = window.query('.form')[0];
744
+ self.setWindowStatus('Creating section...');
745
+ formPanel.getForm().submit({
746
+ reset:true,
747
+ success:function(form, action){
748
+ self.clearWindowStatus();
749
+ var obj = Ext.decode(action.response.responseText);
750
+ if(obj.success){
751
+ record.appendChild(obj.node);
752
+ }
753
+ else{
754
+ Ext.Msg.alert("Error", obj.message);
755
+ }
756
+ },
757
+ failure:function(form, action){
758
+ self.clearWindowStatus();
759
+ var obj = Ext.decode(action.response.responseText);
760
+ if(obj.message){
761
+ Ext.Msg.alert("Error", obj.message);
762
+ }
763
+ else{
764
+ Ext.Msg.alert("Error", "Error creating section.");
765
+ }
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
+
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
+ }
864
+ });
865
+ }
866
+ }
867
+ },{
868
+ text: 'Close',
869
+ handler: function(){
870
+ updateSectionWindow.close();
871
+ }
872
+ }]
873
+ });
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
+ }
888
+ }
889
+ });
890
+ }
891
+ else
892
+ if(Compass.ErpApp.Utility.isBlank(record.data['isBlog'])){
893
+ items.push({
894
+ text:'Add Layout',
895
+ iconCls:'icon-add',
896
+ listeners:{
897
+ '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
913
+ {
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
+ }
925
+
926
+ items.push({
927
+ text:'Delete ' + record.data["type"],
928
+ iconCls:'icon-delete',
929
+ listeners:{
930
+ 'click':function(){
931
+ self.deleteSection(record);
932
+ }
933
+ }
934
+ });
935
+ }
936
+ else
937
+ if(record.data['isWebsite']){
938
+ if(currentUser.hasRole(['admin','publisher'])){
939
+ items.push({
940
+ text:'Publish',
941
+ iconCls:'icon-document_up',
942
+ listeners:{
943
+ 'click':function(){
944
+ self.publish(record);
945
+ }
946
+ }
947
+ });
948
+ }
949
+ else{
950
+ compassUser.showInvalidAccess();
951
+ }
952
+
953
+ items.push({
954
+ text:'Publications',
955
+ iconCls:'icon-documents',
956
+ listeners:{
957
+ 'click':function(){
958
+ self.getPublications(record);
959
+ }
960
+ }
961
+ });
962
+
963
+ items.push({
964
+ text:'View Inquiries',
965
+ iconCls:'icon-document',
966
+ listeners:{
967
+ 'click':function(){
968
+ self.initialConfig['centerRegion'].viewWebsiteInquiries(record.data.id.split('_')[1], record.data.title);
969
+ }
970
+ }
971
+ });
972
+
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']
1015
+
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:[
1031
+ {
1032
+ boxLabel:'Yes',
1033
+ name:'auto_activate_publication',
1034
+ inputValue: 'yes',
1035
+ checked:record.data['autoActivatePublication']
1036
+ },
1037
+ {
1038
+ boxLabel:'No',
1039
+ 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:[
1051
+ {
1052
+ boxLabel:'Yes',
1053
+ 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");
1062
+ }
1063
+ }
1064
+ }
1065
+ },
1066
+
1067
+ {
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
+ });
1105
+ }
1106
+ }
1107
+ },{
1108
+ text: 'Close',
1109
+ handler: function(){
1110
+ editWebsiteWindow.close();
1111
+ }
1112
+ }]
1113
+ });
1114
+ editWebsiteWindow.show();
1115
+ }
1116
+ }
1117
+ });
1118
+
1119
+ items.push({
1120
+ text:'Delete',
1121
+ iconCls:'icon-delete',
1122
+ listeners:{
1123
+ 'click':function(){
1124
+ self.deleteSite(record);
1125
+ }
1126
+ }
1127
+ });
1128
+
1129
+ items.push({
1130
+ text:'Export',
1131
+ iconCls:'icon-document_out',
1132
+ listeners:{
1133
+ 'click':function(){
1134
+ self.exportSite(record.data.id.split('_')[1]);
1135
+ }
1136
+ }
1137
+ });
1138
+ }
1139
+ 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",{
1147
+ layout:'fit',
1148
+ width:310,
1149
+ title:'Add Host',
1150
+ height:100,
1151
+ plain: true,
1152
+ buttonAlign:'center',
1153
+ items: Ext.create("Ext.form.Panel",{
1154
+ labelWidth: 50,
1155
+ frame:false,
1156
+ bodyStyle:'padding:5px 5px 0',
1157
+ width: 425,
1158
+ url:'/knitkit/erp_app/desktop/site/add_host',
1159
+ defaults: {
1160
+ width: 225
1161
+ },
1162
+ items:[
1163
+ {
1164
+ xtype:'textfield',
1165
+ fieldLabel:'Host',
1166
+ name:'host',
1167
+ allowBlank:false
1168
+ },
1169
+ {
1170
+ xtype:'hidden',
1171
+ name:'id',
1172
+ value:record.data.websiteId
1173
+ }
1174
+ ]
1175
+ }),
1176
+ buttons: [{
1177
+ text:'Submit',
1178
+ listeners:{
1179
+ 'click':function(button){
1180
+ var window = button.findParentByType('window');
1181
+ var formPanel = window.query('form')[0];
1182
+ self.setWindowStatus('Adding Host...');
1183
+ formPanel.getForm().submit({
1184
+ reset:true,
1185
+ success:function(form, action){
1186
+ self.clearWindowStatus();
1187
+ var obj = Ext.decode(action.response.responseText);
1188
+ if(obj.success){
1189
+ addHostWindow.close();
1190
+ record.appendChild(obj.node);
1191
+ }
1192
+ else{
1193
+ Ext.Msg.alert("Error", obj.msg);
1194
+ }
1195
+ },
1196
+ failure:function(form, action){
1197
+ self.clearWindowStatus();
1198
+ Ext.Msg.alert("Error", "Error adding Host");
1199
+ }
1200
+ });
1201
+ }
1202
+ }
1203
+ },{
1204
+ text: 'Close',
1205
+ handler: function(){
1206
+ addHostWindow.close();
1207
+ }
1208
+ }]
1209
+ });
1210
+ addHostWindow.show();
1211
+ }
1212
+ }
1213
+ });
1214
+ }
1215
+ 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",{
1223
+ layout:'fit',
1224
+ width:310,
1225
+ title:'Update Host',
1226
+ height:100,
1227
+ plain: true,
1228
+ buttonAlign:'center',
1229
+ items: Ext.create("Ext.form.Panel",{
1230
+ labelWidth: 50,
1231
+ frame:false,
1232
+ bodyStyle:'padding:5px 5px 0',
1233
+ width: 425,
1234
+ url:'/knitkit/erp_app/desktop/site/update_host',
1235
+ defaults: {
1236
+ width: 225
1237
+ },
1238
+ items:[
1239
+ {
1240
+ xtype:'textfield',
1241
+ fieldLabel:'Host',
1242
+ id:'knitkitUpdateWebsiteHostHost',
1243
+ name:'host',
1244
+ value:record.data.host,
1245
+ allowBlank:false
1246
+ },
1247
+ {
1248
+ xtype:'hidden',
1249
+ name:'id',
1250
+ value:record.data.websiteHostId
1251
+ }
1252
+ ]
1253
+ }),
1254
+ buttons: [{
1255
+ text:'Submit',
1256
+ listeners:{
1257
+ 'click':function(button){
1258
+ var window = button.findParentByType('window');
1259
+ var formPanel = window.query('form')[0];
1260
+ self.setWindowStatus('Updating Host...');
1261
+ formPanel.getForm().submit({
1262
+ reset:false,
1263
+ success:function(form, action){
1264
+ self.clearWindowStatus();
1265
+ var obj = Ext.decode(action.response.responseText);
1266
+ if(obj.success){
1267
+ var newHost = Ext.getCmp('knitkitUpdateWebsiteHostHost').getValue();
1268
+ record.set('host',newHost);
1269
+ record.set('text',newHost);
1270
+ record.commit();
1271
+ updateHostWindow.close();
1272
+ }
1273
+ else{
1274
+ Ext.Msg.alert("Error", obj.msg);
1275
+ }
1276
+ },
1277
+ failure:function(form, action){
1278
+ self.clearWindowStatus();
1279
+ Ext.Msg.alert("Error", "Error updating Host");
1280
+ }
1281
+ });
1282
+ }
1283
+ }
1284
+ },{
1285
+ text: 'Close',
1286
+ handler: function(){
1287
+ updateHostWindow.close();
1288
+ }
1289
+ }]
1290
+ });
1291
+ updateHostWindow.show();
1292
+ }
1293
+ }
1294
+ });
1295
+
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){
1302
+ if(btn == 'no'){
1303
+ return false;
1304
+ }
1305
+ else
1306
+ if(btn == 'yes')
1307
+ {
1308
+ self.setWindowStatus('Deleting Host...');
1309
+ var conn = new Ext.data.Connection();
1310
+ conn.request({
1311
+ url: '/knitkit/erp_app/desktop/site/delete_host',
1312
+ method: 'POST',
1313
+ params:{
1314
+ id:record.data.websiteHostId
1315
+ },
1316
+ success: function(response) {
1317
+ self.clearWindowStatus();
1318
+ var obj = Ext.decode(response.responseText);
1319
+ if(obj.success){
1320
+ record.remove(true);
1321
+ }
1322
+ else{
1323
+ Ext.Msg.alert('Error', 'Error deleting Host');
1324
+ }
1325
+ },
1326
+ failure: function(response) {
1327
+ self.clearWindowStatus();
1328
+ Ext.Msg.alert('Error', 'Error deleting Host');
1329
+ }
1330
+ });
1331
+ }
1332
+ });
1333
+ }
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
+ });
1641
+ }
1642
+ else
1643
+ 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'
1737
+
1738
+ }
1739
+ ],
1740
+ listeners:{
1741
+ 'load':function(store, records, options){
1742
+ Ext.getCmp('knitkit_website_nav_item_section').setValue(record.data.linkedToId);
1743
+ }
1744
+ }
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);
1791
+ }
1792
+ },
1793
+ failure:function(form, action){
1794
+ self.clearWindowStatus();
1795
+ if(action.response == null){
1796
+ Ext.Msg.alert("Error", 'Could not create menu item');
1797
+ }
1798
+ else{
1799
+ var obj = Ext.decode(action.response.responseText);
1800
+ Ext.Msg.alert("Error", obj.msg);
1801
+ }
1802
+
1803
+ }
1804
+ });
1805
+ }
1806
+ }
1807
+ },{
1808
+ text: 'Close',
1809
+ handler: function(){
1810
+ addMenuItemWindow.close();
1811
+ }
1812
+ }]
1813
+ });
1814
+ addMenuItemWindow.show();
1815
+ }
1816
+ });
1817
+
1818
+ if(record.data.isSecured){
1819
+ items.push({
1820
+ text:'Unsecure',
1821
+ iconCls:'icon-document',
1822
+ listeners:{
1823
+ 'click':function(){
1824
+ self.changeSecurityOnMenuItem(record, false);
1825
+ }
1826
+ }
1827
+ });
1828
+ }
1829
+ else{
1830
+ items.push({
1831
+ text:'Secure',
1832
+ iconCls:'icon-document_lock',
1833
+ listeners:{
1834
+ 'click':function(){
1835
+ self.changeSecurityOnMenuItem(record, true);
1836
+ }
1837
+ }
1838
+ });
1839
+ }
1840
+
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{
1867
+ Ext.Msg.alert('Error', 'Error deleting menu item');
1868
+ }
1869
+ },
1870
+ failure: function(response) {
1871
+ self.clearWindowStatus();
1872
+ Ext.Msg.alert('Error', 'Error deleting menu item');
1873
+ }
1874
+ });
1875
+ }
1876
+ });
1877
+ }
1878
+ });
1879
+ }
1880
+ var contextMenu = Ext.create("Ext.menu.Menu",{
1881
+ items:items
1882
+ });
1883
+ contextMenu.showAt(e.xy);
1884
+ }
1885
+ }
1886
+ });
1887
+
1888
+ this.contentsCardPanel = new Ext.Panel({
1889
+ layout:'card',
1890
+ region:'south',
1891
+ autoDestroy:true,
1892
+ split:true,
1893
+ height:300,
1894
+ collapsible:true
1895
+ });
1896
+
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
+ },
1948
+ {
1949
+ xtype:'textfield',
1950
+ fieldLabel:'Email',
1951
+ allowBlank:false,
1952
+ name:'email'
1953
+ },
1954
+ {
1955
+ xtype:'radiogroup',
1956
+ fieldLabel:'Auto Activate Publication?',
1957
+ 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
+ },
1972
+ {
1973
+ xtype:'radiogroup',
1974
+ fieldLabel:'Email Inquiries',
1975
+ 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
+ }
1990
+ }
1991
+ }
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
+ }
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
+ },
2056
+ items: [
2057
+ {
2058
+ xtype:'fileuploadfield',
2059
+ fieldLabel:'Upload Website',
2060
+ buttonText:'Upload',
2061
+ buttonOnly:false,
2062
+ allowBlank:false,
2063
+ name:'website_data'
2064
+ }
2065
+ ]
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
+ }
2095
+ }
2096
+ });
2097
+ }
2098
+ }
2099
+ },{
2100
+ text: 'Close',
2101
+ handler: function(){
2102
+ importWebsiteWindow.close();
2103
+ }
2104
+ }]
2105
+ });
2106
+ importWebsiteWindow.show();
2107
+ }
2108
+ }
2109
+ ]
2110
+ }
2111
+ });
2112
+
2113
+ this.items = [layout,
2114
+ {
2115
+ xtype:'knitkit_themestreepanel',
2116
+ centerRegion:this.initialConfig['module'].centerRegion
2117
+ },
2118
+ {
2119
+ xtype:'knitkit_articlesgridpanel',
2120
+ centerRegion:this.initialConfig['module'].centerRegion
2121
+ }];
2122
+
2123
+ this.callParent(arguments);
2124
+ this.setActiveTab(0);
2125
+ },
2126
+
2127
+ getArticles : function(node){
2128
+ this.contentsCardPanel.removeAll(true);
2129
+ var xtype = 'knitkit_'+node.data.type.toLowerCase()+'articlesgridpanel';
2130
+ this.contentsCardPanel.add({
2131
+ xtype:xtype,
2132
+ title:node.data.siteName + ' - ' + node.data.text + ' - Articles',
2133
+ sectionId:node.data.id.split('_')[1],
2134
+ centerRegion:this.initialConfig['module'].centerRegion,
2135
+ siteId:node.data.siteId
2136
+ });
2137
+ this.contentsCardPanel.getLayout().setActiveItem(this.contentsCardPanel.items.length - 1);
2138
+ },
2139
+
2140
+ getPublications : function(node){
2141
+ this.contentsCardPanel.removeAll(true);
2142
+ this.contentsCardPanel.add({
2143
+ xtype:'knitkit_publishedgridpanel',
2144
+ title:node.data.siteName + ' Publications',
2145
+ siteId:node.data.id.split('_')[1],
2146
+ centerRegion:this.initialConfig['module'].centerRegion
2147
+ });
2148
+ this.contentsCardPanel.getLayout().setActiveItem(this.contentsCardPanel.items.length - 1);
2149
+ },
2150
+
2151
+ constructor : function(config) {
2152
+ config = Ext.apply({
2153
+ region:'west',
2154
+ split:true,
2155
+ width:350,
2156
+ collapsible:true
2157
+ }, config);
2158
+
2159
+ this.callParent([config]);
2160
+ }
2161
+ });