knitkit 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +5 -8
  2. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +11 -8
  3. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +26 -4
  4. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +49 -35
  5. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +30 -21
  6. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +41 -32
  7. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +0 -6
  8. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +42 -6
  9. data/app/{models → mailers}/website_inquiry_mailer.rb +0 -0
  10. data/app/models/article.rb +4 -0
  11. data/app/models/content.rb +0 -4
  12. data/app/models/theme.rb +3 -3
  13. data/app/models/website.rb +44 -17
  14. data/app/views/knitkit/website_sections/index.html.erb +1 -1
  15. data/app/views/layouts/knitkit/base.html.erb +6 -0
  16. data/app/views/shared/knitkit/_footer.html.erb +2 -2
  17. data/app/widgets/signup/base.rb +0 -2
  18. data/db/data_migrations/20120809020508_update_website_and_configuration.rb +77 -0
  19. data/lib/knitkit/engine.rb +4 -0
  20. data/lib/knitkit/extensions.rb +4 -1
  21. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +36 -33
  22. data/lib/knitkit/extensions/action_mailer/theme_support/acts_as_themed_mailer.rb +60 -0
  23. data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +9 -4
  24. data/lib/knitkit/extensions/active_record/acts_as_document.rb +1 -1
  25. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +21 -1
  26. data/lib/knitkit/extensions/compass_ae/widgets/widget_proxy_controller.rb +26 -0
  27. data/lib/knitkit/extensions/railties/action_view/base.rb +11 -0
  28. data/lib/knitkit/extensions/railties/action_view/helpers/blog_helper.rb +62 -0
  29. data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +83 -0
  30. data/lib/knitkit/extensions/railties/action_view/helpers/knitkit_helper.rb +67 -0
  31. data/lib/knitkit/extensions/railties/action_view/helpers/menu_helper.rb +71 -0
  32. data/lib/knitkit/version.rb +1 -1
  33. data/public/images/knitkit/close.png +0 -0
  34. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +150 -400
  35. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +687 -593
  36. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +1 -2
  37. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +39 -15
  38. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +1 -1
  39. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +65 -126
  40. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +65 -1
  41. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +265 -183
  42. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +24 -9
  43. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +631 -595
  44. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +265 -0
  45. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +133 -0
  46. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +174 -0
  47. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +399 -0
  48. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website.js +165 -0
  49. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +266 -0
  50. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +1224 -0
  51. data/public/javascripts/knitkit/inline_editing.js +136 -0
  52. data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +1 -2
  53. data/public/stylesheets/knitkit/inline_editing.css +88 -0
  54. data/public/stylesheets/knitkit/style.css +1 -1
  55. metadata +47 -31
  56. data/lib/knitkit/extensions/railties/action_view.rb +0 -199
  57. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +0 -2725
@@ -0,0 +1,266 @@
1
+ Compass.ErpApp.Desktop.Applications.Knitkit.addWebsiteNavItemOptions = function (self, items, record) {
2
+ if (currentUser.hasApplicationCapability('knitkit', {
3
+ capability_type_iid:'edit',
4
+ resource:'MenuItem'
5
+ }))
6
+
7
+ {
8
+ items.push({
9
+ text:'Update Menu Item',
10
+ iconCls:'icon-edit',
11
+ handler:function(btn){
12
+ var addMenuItemWindow = Ext.create("Ext.window.Window",{
13
+ layout:'fit',
14
+ width:375,
15
+ title:'Update Menu Item',
16
+ height:175,
17
+ plain: true,
18
+ buttonAlign:'center',
19
+ items: new Ext.FormPanel({
20
+ labelWidth: 50,
21
+ frame:false,
22
+ bodyStyle:'padding:5px 5px 0',
23
+ url:'/knitkit/erp_app/desktop/website_nav/update_menu_item',
24
+ defaults: {
25
+ width: 225
26
+ },
27
+ items: [
28
+ {
29
+ xtype:'textfield',
30
+ fieldLabel:'Title',
31
+ value:record.data.text,
32
+ allowBlank:false,
33
+ name:'title'
34
+ },
35
+ {
36
+ xtype:'combo',
37
+ fieldLabel:'Link to',
38
+ name:'link_to',
39
+ id:'knitkit_nav_item_link_to',
40
+ allowBlank:false,
41
+ forceSelection:true,
42
+ editable:false,
43
+ autoSelect:true,
44
+ typeAhead: false,
45
+ mode: 'local',
46
+ triggerAction: 'all',
47
+ store:[
48
+ ['website_section','Section'],
49
+ //['article','Article'],
50
+ ['url','Url']
51
+
52
+ ],
53
+ value:record.data.linkToType,
54
+ listeners:{
55
+ 'change':function(combo, newValue, oldValue){
56
+ switch(newValue){
57
+ case 'website_section':
58
+ Ext.getCmp('knitkit_website_nav_item_section').show();
59
+ //Ext.getCmp('knitkit_website_nav_item_article').hide();
60
+ Ext.getCmp('knitkit_website_nav_item_url').hide();
61
+ break;
62
+ case 'article':
63
+ Ext.getCmp('knitkit_website_nav_item_section').hide();
64
+ //Ext.getCmp('knitkit_website_nav_item_article').show();
65
+ Ext.getCmp('knitkit_website_nav_item_url').hide();
66
+ break;
67
+ case 'url':
68
+ Ext.getCmp('knitkit_website_nav_item_section').hide();
69
+ //Ext.getCmp('knitkit_website_nav_item_article').hide();
70
+ Ext.getCmp('knitkit_website_nav_item_url').show();
71
+ break;
72
+ }
73
+ }
74
+ }
75
+ },
76
+ {
77
+ xtype:'combo',
78
+ width:300,
79
+ id:'knitkit_website_nav_item_section',
80
+ hiddenName:'website_section_id',
81
+ name:'website_section_id',
82
+ loadingText:'Retrieving Sections...',
83
+ store:Ext.create("Ext.data.Store",{
84
+ proxy:{
85
+ type:'ajax',
86
+ url:'/knitkit/erp_app/desktop/section/existing_sections',
87
+ reader:{
88
+ type:'json'
89
+ },
90
+ extraParams:{
91
+ website_id:record.data.websiteId
92
+ }
93
+ },
94
+ autoLoad:true,
95
+ fields:[
96
+ {
97
+ name:'id'
98
+ },
99
+ {
100
+ name:'title_permalink'
101
+
102
+ }
103
+ ],
104
+ listeners:{
105
+ 'load':function(store, records, options){
106
+ Ext.getCmp('knitkit_website_nav_item_section').setValue(record.data.linkedToId);
107
+ }
108
+ }
109
+ }),
110
+ forceSelection:true,
111
+ editable:false,
112
+ fieldLabel:'Section',
113
+ autoSelect:true,
114
+ typeAhead: false,
115
+ queryMode: 'local',
116
+ displayField:'title_permalink',
117
+ valueField:'id',
118
+ hidden:(record.data.linkToType != 'website_section' && record.data.linkToType != 'article')
119
+ },
120
+ {
121
+ xtype:'textfield',
122
+ fieldLabel:'Url',
123
+ value:record.data.url,
124
+ id:'knitkit_website_nav_item_url',
125
+ hidden:(record.data.linkToType == 'website_section' || record.data.linkToType == 'article'),
126
+ name:'url'
127
+ },
128
+ {
129
+ xtype:'hidden',
130
+ name:'website_nav_item_id',
131
+ value:record.data.websiteNavItemId
132
+ }
133
+ ]
134
+ }),
135
+ buttons: [{
136
+ text:'Submit',
137
+ listeners:{
138
+ 'click':function(button){
139
+ var window = button.findParentByType('window');
140
+ var formPanel = window.query('form')[0];
141
+ self.setWindowStatus('Updating menu item...');
142
+ formPanel.getForm().submit({
143
+ reset:false,
144
+ success:function(form, action){
145
+ self.clearWindowStatus();
146
+ var obj = Ext.decode(action.response.responseText);
147
+ if(obj.success){
148
+ record.data.linkedToId = obj.linkedToId;
149
+ record.data.linkToType = obj.linkToType;
150
+ record.data.url = obj.url;
151
+ //node.getUI().getTextEl().innerHTML = obj.title;
152
+ }
153
+ else{
154
+ Ext.Msg.alert("Error", obj.msg);
155
+ }
156
+ },
157
+ failure:function(form, action){
158
+ self.clearWindowStatus();
159
+ if(action.response == null){
160
+ Ext.Msg.alert("Error", 'Could not create menu item');
161
+ }
162
+ else{
163
+ var obj = Ext.decode(action.response.responseText);
164
+ Ext.Msg.alert("Error", obj.msg);
165
+ }
166
+
167
+ }
168
+ });
169
+ }
170
+ }
171
+ },{
172
+ text: 'Close',
173
+ handler: function(){
174
+ addMenuItemWindow.close();
175
+ }
176
+ }]
177
+ });
178
+ addMenuItemWindow.show();
179
+ }
180
+ });
181
+ }
182
+
183
+ if(record.data.isSecured){
184
+ if (currentUser.hasApplicationCapability('knitkit', {
185
+ capability_type_iid:'unsecure',
186
+ resource:'MenuItem'
187
+ }))
188
+
189
+ {
190
+ items.push({
191
+ text:'Unsecure',
192
+ iconCls:'icon-document',
193
+ listeners:{
194
+ 'click':function(){
195
+ self.changeSecurityOnMenuItem(record, false);
196
+ }
197
+ }
198
+ });
199
+ }
200
+ }
201
+ else{
202
+ if (currentUser.hasApplicationCapability('knitkit', {
203
+ capability_type_iid:'secure',
204
+ resource:'MenuItem'
205
+ }))
206
+
207
+ {
208
+ items.push({
209
+ text:'Secure',
210
+ iconCls:'icon-document_lock',
211
+ listeners:{
212
+ 'click':function(){
213
+ self.changeSecurityOnMenuItem(record, true);
214
+ }
215
+ }
216
+ });
217
+ }
218
+ }
219
+
220
+ if (currentUser.hasApplicationCapability('knitkit', {
221
+ capability_type_iid:'delete',
222
+ resource:'MenuItem'
223
+ }))
224
+
225
+ {
226
+ items.push({
227
+ text:'Delete',
228
+ iconCls:'icon-delete',
229
+ handler:function(btn){
230
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu item?', function(btn){
231
+ if(btn == 'no'){
232
+ return false;
233
+ }
234
+ else
235
+ if(btn == 'yes')
236
+ {
237
+ self.setWindowStatus('Deleting menu item...');
238
+ Ext.Ajax.request({
239
+ url: '/knitkit/erp_app/desktop/website_nav/delete_menu_item',
240
+ method: 'POST',
241
+ params:{
242
+ id:record.data.websiteNavItemId
243
+ },
244
+ success: function(response) {
245
+ self.clearWindowStatus();
246
+ var obj = Ext.decode(response.responseText);
247
+ if(obj.success){
248
+ record.remove(true);
249
+ }
250
+ else{
251
+ Ext.Msg.alert('Error', 'Error deleting menu item');
252
+ }
253
+ },
254
+ failure: function(response) {
255
+ self.clearWindowStatus();
256
+ Ext.Msg.alert('Error', 'Error deleting menu item');
257
+ }
258
+ });
259
+ }
260
+ });
261
+ }
262
+ });
263
+ }
264
+
265
+ return items;
266
+ }
@@ -0,0 +1,1224 @@
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?<br> NOTE: Articles belonging to this section will be orphaned.', function (btn) {
16
+ if (btn == 'no') {
17
+ return false;
18
+ }
19
+ else if (btn == 'yes') {
20
+ self.setWindowStatus('Deleting Section...');
21
+ Ext.Ajax.request({
22
+ url:'/knitkit/erp_app/desktop/section/delete',
23
+ method:'POST',
24
+ params:{
25
+ id:node.data.id.split('_')[1]
26
+ },
27
+ success:function (response) {
28
+ self.clearWindowStatus();
29
+ var obj = Ext.decode(response.responseText);
30
+ if (obj.success) {
31
+ node.remove(true);
32
+ }
33
+ else {
34
+ Ext.Msg.alert('Error', 'Error deleting section');
35
+ }
36
+ },
37
+ failure:function (response) {
38
+ self.clearWindowStatus();
39
+ Ext.Msg.alert('Error', 'Error deleting section');
40
+ }
41
+ });
42
+ }
43
+ });
44
+ },
45
+
46
+ exportSite:function (id) {
47
+ var self = this;
48
+ self.setWindowStatus('Exporting Website...');
49
+ window.open('/knitkit/erp_app/desktop/site/export?id=' + id, 'mywindow', 'width=400,height=200');
50
+ self.clearWindowStatus();
51
+ },
52
+
53
+ deleteSite:function (node) {
54
+ var self = this;
55
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this Website?', function (btn) {
56
+ if (btn == 'no') {
57
+ return false;
58
+ }
59
+ else if (btn == 'yes') {
60
+ self.setWindowStatus('Deleting Website...');
61
+ Ext.Ajax.request({
62
+ url:'/knitkit/erp_app/desktop/site/delete',
63
+ method:'POST',
64
+ params:{
65
+ id:node.data.id.split('_')[1]
66
+ },
67
+ success:function (response) {
68
+ self.clearWindowStatus();
69
+ var obj = Ext.decode(response.responseText);
70
+ if (obj.success) {
71
+ node.remove(true);
72
+ }
73
+ else {
74
+ Ext.Msg.alert('Error', 'Error deleting Website');
75
+ }
76
+ },
77
+ failure:function (response) {
78
+ self.clearWindowStatus();
79
+ Ext.Msg.alert('Error', 'Error deleting Website');
80
+ }
81
+ });
82
+ }
83
+ });
84
+ },
85
+
86
+ publish:function (node) {
87
+ var self = this;
88
+ var publishWindow = Ext.create('Compass.ErpApp.Desktop.Applications.Knitkit.PublishWindow',{
89
+ baseParams:{
90
+ id:node.id.split('_')[1]
91
+ },
92
+ url:'/knitkit/erp_app/desktop/site/publish',
93
+ listeners:{
94
+ 'publish_success':function (window, response) {
95
+ if (response.success) {
96
+ self.getPublications(node);
97
+ }
98
+ else {
99
+ Ext.Msg.alert('Error', 'Error publishing Website');
100
+ }
101
+ },
102
+ 'publish_failure':function (window, response) {
103
+ Ext.Msg.alert('Error', 'Error publishing Website');
104
+ }
105
+ }
106
+ });
107
+
108
+ publishWindow.show();
109
+ },
110
+
111
+ editSectionLayout:function (sectionName, sectionId, websiteId) {
112
+ var self = this;
113
+ self.selectWebsite(websiteId);
114
+ self.setWindowStatus('Loading section template...');
115
+ Ext.Ajax.request({
116
+ url:'/knitkit/erp_app/desktop/section/get_layout',
117
+ method:'POST',
118
+ params:{
119
+ id:sectionId
120
+ },
121
+ success:function (response) {
122
+ self.initialConfig['centerRegion'].editSectionLayout(
123
+ sectionName,
124
+ websiteId,
125
+ sectionId,
126
+ response.responseText,
127
+ [
128
+ {
129
+ text:'Insert Content Area',
130
+ handler:function (btn) {
131
+ var codeMirror = btn.findParentByType('codemirror');
132
+ Ext.MessageBox.prompt('New File', 'Please enter content area name:', function (btn, text) {
133
+ if (btn == 'ok') {
134
+ codeMirror.insertContent('<%=render_content_area(:' + text + ')%>');
135
+ }
136
+
137
+ });
138
+ }
139
+ }
140
+ ]);
141
+ self.clearWindowStatus();
142
+ },
143
+ failure:function (response) {
144
+ self.clearWindowStatus();
145
+ Ext.Msg.alert('Error', 'Error loading section layout.');
146
+ }
147
+ });
148
+ },
149
+
150
+ changeSecurityOnSection:function (node, secure) {
151
+ var self = this;
152
+ self.setWindowStatus('Updating section...');
153
+ Ext.Ajax.request({
154
+ url:'/knitkit/erp_app/desktop/section/update_security',
155
+ method:'POST',
156
+ params:{
157
+ id:node.data.id.split('_')[1],
158
+ site_id:node.data.siteId,
159
+ secure:secure
160
+ },
161
+ success:function (response) {
162
+ var obj = Ext.decode(response.responseText);
163
+ if (obj.success) {
164
+ self.clearWindowStatus();
165
+ if (secure) {
166
+ node.set('iconCls', 'icon-document_lock');
167
+ }
168
+ else {
169
+ node.set('iconCls', 'icon-document');
170
+ }
171
+ node.set('isSecured', secure);
172
+ node.commit();
173
+ }
174
+ else {
175
+ Ext.Msg.alert('Error', 'Error securing section');
176
+ }
177
+ },
178
+ failure:function (response) {
179
+ self.clearWindowStatus();
180
+ Ext.Msg.alert('Error', 'Error securing section.');
181
+ }
182
+ });
183
+ },
184
+
185
+ changeSecurityOnMenuItem:function (node, secure) {
186
+ var self = this;
187
+ self.setWindowStatus('Updating menu item security...');
188
+ Ext.Ajax.request({
189
+ url:'/knitkit/erp_app/desktop/website_nav/update_security',
190
+ method:'POST',
191
+ params:{
192
+ id:node.data.websiteNavItemId,
193
+ site_id:node.data.websiteId,
194
+ secure:secure
195
+ },
196
+ success:function (response) {
197
+ var obj = Ext.decode(response.responseText);
198
+ if (obj.success) {
199
+ self.clearWindowStatus();
200
+ if (secure) {
201
+ node.set('iconCls', 'icon-document_lock');
202
+ }
203
+ else {
204
+ node.set('iconCls', 'icon-document');
205
+ }
206
+ node.set('isSecured', secure);
207
+ node.commit();
208
+ }
209
+ else {
210
+ Ext.Msg.alert('Error', 'Error securing menu item');
211
+ }
212
+ },
213
+ failure:function (response) {
214
+ self.clearWindowStatus();
215
+ Ext.Msg.alert('Error', 'Error securing menu item');
216
+ }
217
+ });
218
+ },
219
+
220
+ selectWebsite:function (websiteId) {
221
+ var node = this.sitesTree.getStore().getNodeById("website_" + websiteId);
222
+ if (node.data.iconCls != 'icon-globe') {
223
+ node.set('iconCls', 'icon-globe');
224
+ node.commit();
225
+ }
226
+ node.parentNode.eachChild(function (child) {
227
+ if (node.data.id != child.data.id) {
228
+ if (child.data.iconCls != 'icon-globe_disconnected') {
229
+ child.set('iconCls', 'icon-globe_disconnected');
230
+ child.commit();
231
+ }
232
+ }
233
+ });
234
+ var eastRegion = Ext.ComponentQuery.query('#knitkitEastRegion').first();
235
+ eastRegion.fileAssetsPanel.selectWebsite(websiteId, node.data.text);
236
+ eastRegion.imageAssetsPanel.selectWebsite(websiteId, node.data.text);
237
+
238
+ Compass.ErpApp.Shared.FileManagerTree.extraPostData = {
239
+ website_id:websiteId
240
+ };
241
+ },
242
+
243
+ updateWebsiteConfiguration:function (rec) {
244
+ var configurationWindow = Ext.create("Ext.window.Window", {
245
+ layout:'fit',
246
+ width:600,
247
+ title:'Configuration',
248
+ height:400,
249
+ autoScroll:true,
250
+ plain:true,
251
+ items:[
252
+ {
253
+ xtype:'sharedconfigurationpanel',
254
+ configurationId:rec.get('configurationId')
255
+ }
256
+ ]
257
+ });
258
+
259
+ configurationWindow.show();
260
+ },
261
+
262
+ initComponent:function () {
263
+ var self = this;
264
+
265
+ var store = Ext.create('Ext.data.TreeStore', {
266
+ proxy:{
267
+ type:'ajax',
268
+ url:'/knitkit/erp_app/desktop/websites',
269
+ timeout:90000
270
+ },
271
+ root:{
272
+ text:'Websites',
273
+ expanded:true
274
+ },
275
+ fields:[
276
+ {
277
+ name:'text'
278
+ },
279
+ {
280
+ name:'iconCls'
281
+ },
282
+ {
283
+ name:'leaf'
284
+ },
285
+ {
286
+ name:'canAddMenuItems'
287
+ },
288
+ {
289
+ name:'isWebsiteNavItem'
290
+ },
291
+ {
292
+ name:'isSection'
293
+ },
294
+ {
295
+ name:'isDocument'
296
+ },
297
+ {
298
+ name:'contentInfo'
299
+ },
300
+ {
301
+ name:'isHost'
302
+ },
303
+ {
304
+ name:'isSecured'
305
+ },
306
+ {
307
+ name:'url'
308
+ },
309
+ {
310
+ name:'path'
311
+ },
312
+ {
313
+ name:'inMenu'
314
+ },
315
+ {
316
+ name:'isBlog'
317
+ },
318
+ {
319
+ name:'hasLayout'
320
+ },
321
+ {
322
+ name:'siteId'
323
+ },
324
+ {
325
+ name:'type'
326
+ },
327
+ {
328
+ name:'isWebsite'
329
+ },
330
+ {
331
+ name:'name'
332
+ },
333
+ {
334
+ name:'title'
335
+ },
336
+ {
337
+ name:'subtitle'
338
+ },
339
+ {
340
+ name:'isHostRoot'
341
+ },
342
+ {
343
+ name:'websiteHostId'
344
+ },
345
+ {
346
+ name:'host'
347
+ },
348
+ {
349
+ name:'websiteId'
350
+ },
351
+ {
352
+ name:'isSectionRoot'
353
+ },
354
+ {
355
+ name:'isWebsiteNav'
356
+ },
357
+ {
358
+ name:'isMenuRoot'
359
+ },
360
+ {
361
+ name:'linkToType'
362
+ },
363
+ {
364
+ name:'linkedToId'
365
+ },
366
+ {
367
+ name:'websiteNavItemId'
368
+ },
369
+ {
370
+ name:'siteName'
371
+ },
372
+ {
373
+ name:'websiteNavId'
374
+ },
375
+ {
376
+ name:'internal_identifier'
377
+ },
378
+ {
379
+ name:'configurationId'
380
+ },
381
+ {
382
+ name:'renderWithBaseLayout'
383
+ },
384
+ {
385
+ name:'publication_comments_enabled'
386
+ }
387
+ ],
388
+ listeners:{
389
+ 'load':function(store, node, records){
390
+ var websiteId = records[0].id.split('_')[1];
391
+ var westRegion = Ext.ComponentQuery.query('#knitkitWestRegion').first();
392
+ westRegion.selectWebsite(websiteId);
393
+ }
394
+ }
395
+ });
396
+
397
+ var pluginItems = [];
398
+
399
+ if (currentUser.hasApplicationCapability('knitkit', {
400
+ capability_type_iid:'drag_item',
401
+ resource:'WebsiteTree'
402
+ })) {
403
+ pluginItems.push({
404
+ ptype:'treeviewdragdrop'
405
+ });
406
+ }
407
+
408
+ var viewConfigItems = {
409
+ markDirty:false,
410
+ plugins:pluginItems,
411
+ listeners:{
412
+ 'beforedrop':function (node, data, overModel, dropPosition, dropFunction, options) {
413
+ if (overModel.data['isWebsiteNavItem']) {
414
+ return true;
415
+ }
416
+ else if (overModel.data['isSection']) {
417
+ if (overModel.parentNode.data['isSectionRoot']) {
418
+ return true;
419
+ }
420
+ }
421
+ else if (overModel.data['isDocument']) {
422
+ return true;
423
+ }
424
+ return false;
425
+ },
426
+ 'drop':function (node, data, overModel, dropPosition, options) {
427
+ var positionArray = [];
428
+ var counter = 0;
429
+ var dropNode = data.records[0];
430
+
431
+ if (dropNode.data['isWebsiteNavItem']) {
432
+ overModel.parentNode.eachChild(function (node) {
433
+ positionArray.push({
434
+ id:node.data.websiteNavItemId,
435
+ position:counter,
436
+ klass:'WebsiteNavItem'
437
+ });
438
+ counter++;
439
+ });
440
+ }
441
+ else {
442
+ overModel.parentNode.eachChild(function (node) {
443
+ positionArray.push({
444
+ id:node.data.id.split('_')[1],
445
+ position:counter,
446
+ klass:'WebsiteSection'
447
+ });
448
+ counter++;
449
+ });
450
+ }
451
+
452
+ Ext.Ajax.request({
453
+ url:'/knitkit/erp_app/desktop/position/update',
454
+ method:'PUT',
455
+ jsonData:{
456
+ position_array:positionArray
457
+ },
458
+ success:function (response) {
459
+ var obj = Ext.decode(response.responseText);
460
+ if (obj.success) {
461
+
462
+ }
463
+ else {
464
+ Ext.Msg.alert("Error", obj.message);
465
+ }
466
+ },
467
+ failure:function (response) {
468
+ Ext.Msg.alert('Error', 'Error saving positions.');
469
+ }
470
+ });
471
+ }
472
+ }
473
+ };
474
+
475
+ this.sitesTree = new Ext.create('Ext.tree.TreePanel',{
476
+ viewConfig:viewConfigItems,
477
+ store:store,
478
+ region:'center',
479
+ rootVisible:false,
480
+ enableDD:true,
481
+ listeners:{
482
+ 'itemclick':function (view, record, htmlItem, index, e) {
483
+ e.stopEvent();
484
+ if (record.data['isWebsite']) {
485
+ self.selectWebsite(record.data.id.split('_')[1]);
486
+ }
487
+ else if (record.data['isSection']) {
488
+ self.getArticles(record);
489
+ }
490
+ else if (record.data['isHost']) {
491
+ var webNavigator = window.compassDesktop.getModule('web-navigator-win');
492
+ webNavigator.createWindow(record.data['url']);
493
+ }
494
+ else if (record.data['isDocument']) {
495
+ self.initialConfig['centerRegion'].editContent(record.data['contentInfo'].title, record.data['contentInfo'].id, record.data['contentInfo'].body_html, record.data['siteId'], 'article');
496
+ }
497
+ },
498
+ 'itemcontextmenu':function (view, record, htmlItem, index, e) {
499
+ e.stopEvent();
500
+ var items = [];
501
+
502
+ if (!Compass.ErpApp.Utility.isBlank(record.data['url'])) {
503
+ items.push({
504
+ text:'View In Web Navigator',
505
+ iconCls:'icon-globe',
506
+ listeners:{
507
+ 'click':function () {
508
+ var webNavigator = window.compassDesktop.getModule('web-navigator-win');
509
+ webNavigator.createWindow(record.data['url']);
510
+ }
511
+ }
512
+ });
513
+ }
514
+
515
+ items = Compass.ErpApp.Desktop.Applications.Knitkit.addMenuOptions(self, items, record);
516
+
517
+ if (record.data['isDocument']) {
518
+ items = Compass.ErpApp.Desktop.Applications.Knitkit.addDocumentOptions(self, items, record);
519
+ }
520
+
521
+ if (record.data['isSection']) {
522
+ items = Compass.ErpApp.Desktop.Applications.Knitkit.addSectionOptions(self, items, record);
523
+ }
524
+ else if (record.data['isWebsite']) {
525
+ items = Compass.ErpApp.Desktop.Applications.Knitkit.addWebsiteOptions(self, items, record);
526
+ }
527
+ else if (record.data['isHostRoot']) {
528
+ if (currentUser.hasApplicationCapability('knitkit', {
529
+ capability_type_iid:'create',
530
+ resource:'Host'
531
+ })) {
532
+ items.push({
533
+ text:'Add Host',
534
+ iconCls:'icon-add',
535
+ listeners:{
536
+ 'click':function () {
537
+ var addHostWindow = Ext.create("Ext.window.Window", {
538
+ layout:'fit',
539
+ width:310,
540
+ title:'Add Host',
541
+ height:100,
542
+ plain:true,
543
+ buttonAlign:'center',
544
+ items:Ext.create("Ext.form.Panel", {
545
+ labelWidth:50,
546
+ frame:false,
547
+ bodyStyle:'padding:5px 5px 0',
548
+ width:425,
549
+ url:'/knitkit/erp_app/desktop/site/add_host',
550
+ defaults:{
551
+ width:225
552
+ },
553
+ items:[
554
+ {
555
+ xtype:'textfield',
556
+ fieldLabel:'Host',
557
+ name:'host',
558
+ allowBlank:false
559
+ },
560
+ {
561
+ xtype:'hidden',
562
+ name:'id',
563
+ value:record.data.websiteId
564
+ }
565
+ ]
566
+ }),
567
+ buttons:[
568
+ {
569
+ text:'Submit',
570
+ listeners:{
571
+ 'click':function (button) {
572
+ var window = button.findParentByType('window');
573
+ var formPanel = window.query('form')[0];
574
+ self.setWindowStatus('Adding Host...');
575
+ formPanel.getForm().submit({
576
+ reset:true,
577
+ success:function (form, action) {
578
+ self.clearWindowStatus();
579
+ var obj = Ext.decode(action.response.responseText);
580
+ if (obj.success) {
581
+ addHostWindow.close();
582
+ record.appendChild(obj.node);
583
+ }
584
+ else {
585
+ Ext.Msg.alert("Error", obj.msg);
586
+ }
587
+ },
588
+ failure:function (form, action) {
589
+ self.clearWindowStatus();
590
+ Ext.Msg.alert("Error", "Error adding Host");
591
+ }
592
+ });
593
+ }
594
+ }
595
+ },
596
+ {
597
+ text:'Close',
598
+ handler:function () {
599
+ addHostWindow.close();
600
+ }
601
+ }
602
+ ]
603
+ });
604
+ addHostWindow.show();
605
+ }
606
+ }
607
+ });
608
+ }
609
+ }
610
+ else if (record.data['isHost']) {
611
+ items = Compass.ErpApp.Desktop.Applications.Knitkit.addHostOptions(self, items, record);
612
+ }
613
+ else if (record.data['isSectionRoot']) {
614
+ if (currentUser.hasApplicationCapability('knitkit', {
615
+ capability_type_iid:'create',
616
+ resource:'Section'
617
+ })) {
618
+ items.push({
619
+ text:'Add Section',
620
+ iconCls:'icon-add',
621
+ listeners:{
622
+ 'click':function () {
623
+ var addSectionWindow = Ext.create("Ext.window.Window", {
624
+ layout:'fit',
625
+ width:375,
626
+ title:'New Section',
627
+ plain:true,
628
+ buttonAlign:'center',
629
+ items:Ext.create("Ext.form.Panel", {
630
+ labelWidth:110,
631
+ frame:false,
632
+ bodyStyle:'padding:5px 5px 0',
633
+ url:'/knitkit/erp_app/desktop/section/new',
634
+ defaults:{
635
+ width:225
636
+ },
637
+ items:[
638
+ {
639
+ xtype:'textfield',
640
+ fieldLabel:'Title',
641
+ allowBlank:false,
642
+ name:'title'
643
+ },
644
+ {
645
+ xtype:'textfield',
646
+ fieldLabel:'Unique Name',
647
+ allowBlank:true,
648
+ name:'internal_identifier'
649
+ },
650
+ {
651
+ xtype:'combo',
652
+ forceSelection:true,
653
+ store:[
654
+ ['Page', 'Page'],
655
+ ['Blog', 'Blog'],
656
+ ['OnlineDocumentSection', 'Online Document Section']
657
+ ],
658
+ value:'Page',
659
+ fieldLabel:'Type',
660
+ name:'type',
661
+ allowBlank:false,
662
+ triggerAction:'all'
663
+ },
664
+ {
665
+ xtype:'radiogroup',
666
+ fieldLabel:'Display in menu?',
667
+ name:'in_menu',
668
+ columns:2,
669
+ items:[
670
+ {
671
+ boxLabel:'Yes',
672
+ name:'in_menu',
673
+ inputValue:'yes',
674
+ checked:true
675
+ },
676
+
677
+ {
678
+ boxLabel:'No',
679
+ name:'in_menu',
680
+ inputValue:'no'
681
+ }
682
+ ]
683
+ },
684
+ {
685
+ xtype:'radiogroup',
686
+ fieldLabel:'Render with Base Layout?',
687
+ name:'render_with_base_layout',
688
+ columns:2,
689
+ items:[
690
+ {
691
+ boxLabel:'Yes',
692
+ name:'render_with_base_layout',
693
+ inputValue:'yes',
694
+ checked:true
695
+ },
696
+
697
+ {
698
+ boxLabel:'No',
699
+ name:'render_with_base_layout',
700
+ inputValue:'no'
701
+ }
702
+ ]
703
+ },
704
+ {
705
+ xtype:'hidden',
706
+ name:'website_id',
707
+ value:record.data.websiteId
708
+ }
709
+ ]
710
+ }),
711
+ buttons:[
712
+ {
713
+ text:'Submit',
714
+ listeners:{
715
+ 'click':function (button) {
716
+ var window = button.findParentByType('window');
717
+ var formPanel = window.query('form')[0];
718
+ self.setWindowStatus('Creating section...');
719
+ formPanel.getForm().submit({
720
+ reset:true,
721
+ success:function (form, action) {
722
+ self.clearWindowStatus();
723
+ var obj = Ext.decode(action.response.responseText);
724
+ if (obj.success) {
725
+ record.appendChild(obj.node);
726
+ addSectionWindow.close();
727
+ }
728
+ else {
729
+ Ext.Msg.alert("Error", obj.msg);
730
+ }
731
+ },
732
+ failure:function (form, action) {
733
+ self.clearWindowStatus();
734
+ var obj = Ext.decode(action.response.responseText);
735
+ if (obj.message) {
736
+ Ext.Msg.alert("Error", obj.message);
737
+ }
738
+ else {
739
+ Ext.Msg.alert("Error", "Error creating section.");
740
+ }
741
+ }
742
+ });
743
+ }
744
+ }
745
+ },
746
+ {
747
+ text:'Close',
748
+ handler:function () {
749
+ addSectionWindow.close();
750
+ }
751
+ }
752
+ ]
753
+ });
754
+ addSectionWindow.show();
755
+ }
756
+ }
757
+ });
758
+ }
759
+ }
760
+ else if (record.data['isMenuRoot']) {
761
+ if (currentUser.hasApplicationCapability('knitkit', {
762
+ capability_type_iid:'create',
763
+ resource:'Menu'
764
+ })) {
765
+ items.push({
766
+ text:'Add Menu',
767
+ iconCls:'icon-add',
768
+ handler:function (btn) {
769
+ var addMenuWindow = Ext.create("Ext.window.Window", {
770
+ layout:'fit',
771
+ width:375,
772
+ title:'New Menu',
773
+ height:100,
774
+ plain:true,
775
+ buttonAlign:'center',
776
+ items:Ext.create("Ext.form.Panel", {
777
+ labelWidth:50,
778
+ frame:false,
779
+ bodyStyle:'padding:5px 5px 0',
780
+ url:'/knitkit/erp_app/desktop/website_nav/new',
781
+ defaults:{
782
+ width:225
783
+ },
784
+ items:[
785
+ {
786
+ xtype:'textfield',
787
+ fieldLabel:'name',
788
+ allowBlank:false,
789
+ name:'name'
790
+ },
791
+ {
792
+ xtype:'hidden',
793
+ name:'website_id',
794
+ value:record.data.websiteId
795
+ }
796
+ ]
797
+ }),
798
+ buttons:[
799
+ {
800
+ text:'Submit',
801
+ listeners:{
802
+ 'click':function (button) {
803
+ var window = button.findParentByType('window');
804
+ var formPanel = window.query('form')[0];
805
+ self.setWindowStatus('Creating menu...');
806
+ formPanel.getForm().submit({
807
+ reset:true,
808
+ success:function (form, action) {
809
+ self.clearWindowStatus();
810
+ var obj = Ext.decode(action.response.responseText);
811
+ if (obj.success) {
812
+ record.appendChild(obj.node);
813
+ }
814
+ else {
815
+ Ext.Msg.alert("Error", obj.msg);
816
+ }
817
+ },
818
+ failure:function (form, action) {
819
+ self.clearWindowStatus();
820
+ var obj = Ext.decode(action.response.responseText);
821
+ Ext.Msg.alert("Error", obj.msg);
822
+ }
823
+ });
824
+ }
825
+ }
826
+ },
827
+ {
828
+ text:'Close',
829
+ handler:function () {
830
+ addMenuWindow.close();
831
+ }
832
+ }
833
+ ]
834
+ });
835
+ addMenuWindow.show();
836
+ }
837
+ });
838
+ }
839
+ }
840
+ else if (record.data['isWebsiteNav']) {
841
+ if (currentUser.hasApplicationCapability('knitkit', {
842
+ capability_type_iid:'edit',
843
+ resource:'Menu'
844
+ })) {
845
+ items.push({
846
+ text:'Update',
847
+ iconCls:'icon-edit',
848
+ handler:function (btn) {
849
+ var updateMenuWindow = Ext.create("Ext.window.Window", {
850
+ layout:'fit',
851
+ width:375,
852
+ title:'Update Menu',
853
+ height:100,
854
+ plain:true,
855
+ buttonAlign:'center',
856
+ items:new Ext.FormPanel({
857
+ labelWidth:50,
858
+ frame:false,
859
+ bodyStyle:'padding:5px 5px 0',
860
+ url:'/knitkit/erp_app/desktop/website_nav/update',
861
+ defaults:{
862
+ width:225
863
+ },
864
+ items:[
865
+ {
866
+ xtype:'textfield',
867
+ fieldLabel:'Name',
868
+ value:record.data.text,
869
+ id:'knitkit_website_nav_update_name',
870
+ allowBlank:false,
871
+ name:'name'
872
+ },
873
+ {
874
+ xtype:'hidden',
875
+ name:'website_nav_id',
876
+ value:record.data.websiteNavId
877
+ }
878
+ ]
879
+ }),
880
+ buttons:[
881
+ {
882
+ text:'Submit',
883
+ listeners:{
884
+ 'click':function (button) {
885
+ var window = button.findParentByType('window');
886
+ var formPanel = window.query('form')[0];
887
+ self.setWindowStatus('Creating menu...');
888
+ formPanel.getForm().submit({
889
+ reset:false,
890
+ success:function (form, action) {
891
+ self.clearWindowStatus();
892
+ var obj = Ext.decode(action.response.responseText);
893
+ if (obj.success) {
894
+ var newText = Ext.getCmp('knitkit_website_nav_update_name').getValue();
895
+ record.set('text', newText);
896
+ record.commit();
897
+ }
898
+ else {
899
+ Ext.Msg.alert("Error", obj.msg);
900
+ }
901
+ },
902
+ failure:function (form, action) {
903
+ self.clearWindowStatus();
904
+ var obj = Ext.decode(action.response.responseText);
905
+ Ext.Msg.alert("Error", obj.msg);
906
+ }
907
+ });
908
+ }
909
+ }
910
+ },
911
+ {
912
+ text:'Close',
913
+ handler:function () {
914
+ updateMenuWindow.close();
915
+ }
916
+ }
917
+ ]
918
+ });
919
+ updateMenuWindow.show();
920
+ }
921
+ });
922
+ }
923
+
924
+ if (currentUser.hasApplicationCapability('knitkit', {
925
+ capability_type_iid:'delete',
926
+ resource:'Menu'
927
+ })) {
928
+ items.push({
929
+ text:'Delete',
930
+ iconCls:'icon-delete',
931
+ handler:function (btn) {
932
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu?', function (btn) {
933
+ if (btn == 'no') {
934
+ return false;
935
+ }
936
+ else if (btn == 'yes') {
937
+ self.setWindowStatus('Deleting menu...');
938
+ Ext.Ajax.request({
939
+ url:'/knitkit/erp_app/desktop/website_nav/delete',
940
+ method:'POST',
941
+ params:{
942
+ id:record.data.websiteNavId
943
+ },
944
+ success:function (response) {
945
+ self.clearWindowStatus();
946
+ var obj = Ext.decode(response.responseText);
947
+ if (obj.success) {
948
+ record.remove(true);
949
+ }
950
+ else {
951
+ Ext.Msg.alert('Error', 'Error deleting menu');
952
+ }
953
+ },
954
+ failure:function (response) {
955
+ self.clearWindowStatus();
956
+ Ext.Msg.alert('Error', 'Error deleting menu');
957
+ }
958
+ });
959
+ }
960
+ });
961
+ }
962
+ });
963
+ }
964
+ }
965
+ else if (record.data['isWebsiteNavItem']) {
966
+ items = Compass.ErpApp.Desktop.Applications.Knitkit.addWebsiteNavItemOptions(self, items, record);
967
+ }
968
+ if (items.length != 0) {
969
+ var contextMenu = Ext.create("Ext.menu.Menu", {
970
+ items:items
971
+ });
972
+ contextMenu.showAt(e.xy);
973
+ }
974
+ }
975
+ }
976
+ });
977
+
978
+ this.contentsCardPanel = Ext.create('Ext.Panel',{
979
+ layout:'card',
980
+ region:'south',
981
+ split:true,
982
+ height:300,
983
+ collapsible:true
984
+ });
985
+
986
+ var tbarItems = [];
987
+
988
+ if (currentUser.hasApplicationCapability('knitkit', {
989
+ capability_type_iid:'create',
990
+ resource:'Website'
991
+ })) {
992
+ tbarItems.push({
993
+ text:'New Website',
994
+ iconCls:'icon-add',
995
+ handler:function (btn) {
996
+ var addWebsiteWindow = Ext.create("Ext.window.Window", {
997
+ title:'New Website',
998
+ plain:true,
999
+ buttonAlign:'center',
1000
+ items:new Ext.FormPanel({
1001
+ labelWidth:110,
1002
+ frame:false,
1003
+ bodyStyle:'padding:5px 5px 0',
1004
+ url:'/knitkit/erp_app/desktop/site/new',
1005
+ defaults:{
1006
+ width:225
1007
+ },
1008
+ items:[
1009
+ {
1010
+ xtype:'textfield',
1011
+ fieldLabel:'Name',
1012
+ allowBlank:false,
1013
+ name:'name'
1014
+ },
1015
+ {
1016
+ xtype:'textfield',
1017
+ fieldLabel:'Host',
1018
+ allowBlank:false,
1019
+ name:'host'
1020
+ },
1021
+ {
1022
+ xtype:'textfield',
1023
+ fieldLabel:'Title',
1024
+ allowBlank:false,
1025
+ name:'title'
1026
+ },
1027
+ {
1028
+ xtype:'textfield',
1029
+ fieldLabel:'Sub Title',
1030
+ allowBlank:true,
1031
+ name:'subtitle'
1032
+ }
1033
+ ]
1034
+ }),
1035
+ buttons:[
1036
+ {
1037
+ text:'Submit',
1038
+ listeners:{
1039
+ 'click':function (button) {
1040
+ var window = button.findParentByType('window');
1041
+ var formPanel = window.query('.form')[0];
1042
+ self.setWindowStatus('Creating website...');
1043
+ formPanel.getForm().submit({
1044
+ success:function (form, action) {
1045
+ self.clearWindowStatus();
1046
+ var obj = Ext.decode(action.response.responseText);
1047
+ if (obj.success) {
1048
+ self.sitesTree.getStore().load();
1049
+ addWebsiteWindow.close();
1050
+ }
1051
+ },
1052
+ failure:function (form, action) {
1053
+ self.clearWindowStatus();
1054
+ Ext.Msg.alert("Error", "Error creating website");
1055
+ }
1056
+ });
1057
+ }
1058
+ }
1059
+ },
1060
+ {
1061
+ text:'Close',
1062
+ handler:function () {
1063
+ addWebsiteWindow.close();
1064
+ }
1065
+ }
1066
+ ]
1067
+ });
1068
+ addWebsiteWindow.show();
1069
+ }
1070
+ }
1071
+ );
1072
+ }
1073
+
1074
+ if (currentUser.hasApplicationCapability('knitkit', {
1075
+ capability_type_iid:'import',
1076
+ resource:'Website'
1077
+ })) {
1078
+ tbarItems.push({
1079
+ text:'Import Website',
1080
+ iconCls:'icon-globe',
1081
+ handler:function (btn) {
1082
+ var importWebsiteWindow = Ext.create("Ext.window.Window", {
1083
+ layout:'fit',
1084
+ width:375,
1085
+ title:'Import Website',
1086
+ height:100,
1087
+ plain:true,
1088
+ buttonAlign:'center',
1089
+ items:new Ext.FormPanel({
1090
+ labelWidth:110,
1091
+ frame:false,
1092
+ fileUpload:true,
1093
+ bodyStyle:'padding:5px 5px 0',
1094
+ url:'/knitkit/erp_app/desktop/site/import',
1095
+ defaults:{
1096
+ width:225
1097
+ },
1098
+ items:[
1099
+ {
1100
+ xtype:'fileuploadfield',
1101
+ fieldLabel:'Upload Website',
1102
+ buttonText:'Upload',
1103
+ buttonOnly:false,
1104
+ allowBlank:false,
1105
+ name:'website_data'
1106
+ }
1107
+ ]
1108
+ }),
1109
+ buttons:[
1110
+ {
1111
+ text:'Submit',
1112
+ listeners:{
1113
+ 'click':function (button) {
1114
+ var window = button.findParentByType('window');
1115
+ var formPanel = window.query('form')[0];
1116
+ self.setWindowStatus('Importing website...');
1117
+ formPanel.getForm().submit({
1118
+ success:function (form, action) {
1119
+ self.clearWindowStatus();
1120
+ var obj = Ext.decode(action.response.responseText);
1121
+ if (obj.success) {
1122
+ self.sitesTree.getStore().load();
1123
+ importWebsiteWindow.close();
1124
+ }
1125
+ else {
1126
+ Ext.Msg.alert("Error", obj.message);
1127
+ }
1128
+ },
1129
+ failure:function (form, action) {
1130
+ self.clearWindowStatus();
1131
+ var obj = Ext.decode(action.response.responseText);
1132
+ if (obj != null) {
1133
+ Ext.Msg.alert("Error", obj.message);
1134
+ }
1135
+ else {
1136
+ Ext.Msg.alert("Error", "Error importing website");
1137
+ }
1138
+ }
1139
+ });
1140
+ }
1141
+ }
1142
+ },
1143
+ {
1144
+ text:'Close',
1145
+ handler:function () {
1146
+ importWebsiteWindow.close();
1147
+ }
1148
+ }
1149
+ ]
1150
+ });
1151
+ importWebsiteWindow.show();
1152
+ }
1153
+ });
1154
+ }
1155
+
1156
+ var layout = new Ext.Panel({
1157
+ layout:'border',
1158
+ title:'Websites',
1159
+ items:[this.sitesTree, this.contentsCardPanel],
1160
+ tbar:{
1161
+ items:tbarItems
1162
+ }
1163
+ });
1164
+
1165
+ if (currentUser.hasApplicationCapability('knitkit', {
1166
+ capability_type_iid:'view',
1167
+ resource:'Theme'
1168
+ })) {
1169
+ this.items = [layout,
1170
+ {
1171
+ xtype:'knitkit_themestreepanel',
1172
+ centerRegion:this.initialConfig['module'].centerRegion
1173
+ },
1174
+ {
1175
+ xtype:'knitkit_articlesgridpanel',
1176
+ centerRegion:this.initialConfig['module'].centerRegion
1177
+ }];
1178
+ } else {
1179
+ this.items = [layout,
1180
+ {
1181
+ xtype:'knitkit_articlesgridpanel',
1182
+ centerRegion:this.initialConfig['module'].centerRegion
1183
+ }];
1184
+ }
1185
+
1186
+ this.callParent(arguments);
1187
+ this.setActiveTab(0);
1188
+ },
1189
+
1190
+ getArticles:function (node) {
1191
+ this.contentsCardPanel.removeAll(true);
1192
+ var xtype = 'knitkit_' + node.data.type.toLowerCase() + 'articlesgridpanel';
1193
+ this.contentsCardPanel.add({
1194
+ xtype:xtype,
1195
+ title:node.data.siteName + ' - ' + node.data.text + ' - Articles',
1196
+ sectionId:node.data.id.split('_')[1],
1197
+ centerRegion:this.initialConfig['module'].centerRegion,
1198
+ siteId:node.data.siteId
1199
+ });
1200
+ this.contentsCardPanel.getLayout().setActiveItem(this.contentsCardPanel.items.length - 1);
1201
+ },
1202
+
1203
+ getPublications:function (node) {
1204
+ this.contentsCardPanel.removeAll(true);
1205
+ this.contentsCardPanel.add({
1206
+ xtype:'knitkit_publishedgridpanel',
1207
+ title:node.data.siteName + ' Publications',
1208
+ siteId:node.data.id.split('_')[1],
1209
+ centerRegion:this.initialConfig['module'].centerRegion
1210
+ });
1211
+ this.contentsCardPanel.getLayout().setActiveItem(this.contentsCardPanel.items.length - 1);
1212
+ },
1213
+
1214
+ constructor:function (config) {
1215
+ config = Ext.apply({
1216
+ region:'west',
1217
+ split:true,
1218
+ width:350,
1219
+ collapsible:true
1220
+ }, config);
1221
+
1222
+ this.callParent([config]);
1223
+ }
1224
+ });