knitkit 2.1.3 → 2.1.4

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 (31) hide show
  1. data/app/controllers/knitkit/base_controller.rb +1 -0
  2. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +2 -0
  3. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +2 -2
  4. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +17 -7
  5. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +8 -1
  6. data/app/controllers/knitkit/online_document_sections_controller.rb +25 -17
  7. data/app/models/documented_content.rb +3 -3
  8. data/app/models/online_document_section.rb +1 -0
  9. data/app/models/published_website.rb +18 -11
  10. data/app/models/website.rb +49 -28
  11. data/app/models/website_nav_item.rb +12 -0
  12. data/app/models/website_section.rb +1 -3
  13. data/app/views/knitkit/online_document_sections/index.html.erb +77 -46
  14. data/app/views/layouts/knitkit/online_document_sections.html.erb +13 -14
  15. data/app/widgets/login/base.rb +1 -1
  16. data/config/routes.rb +1 -1
  17. data/db/migrate/20110211002317_setup_knitkit.rb +1 -0
  18. data/db/migrate/20130405184234_add_use_markdown_to_section.rb +19 -0
  19. data/lib/knitkit/extensions/railties/action_view/helpers/knitkit_helper.rb +1 -1
  20. data/lib/knitkit/extensions/railties/action_view/helpers/menu_helper.rb +0 -1
  21. data/lib/knitkit/version.rb +1 -1
  22. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +1 -0
  23. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +109 -26
  24. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +60 -61
  25. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +26 -0
  26. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +3 -2
  27. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +9 -24
  28. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +232 -248
  29. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +33 -43
  30. metadata +19 -3
  31. data/public/stylesheets/knitkit/documentation.css +0 -50
@@ -33,57 +33,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
33
33
  var self = this;
34
34
  var itemId = 'editArticle-'+record.get('id');
35
35
  var editArticleWindow = Ext.ComponentQuery.query('#'+itemId).first();
36
- // var addFormItems = self.addFormItems;
37
- if (self.alias.first() == 'widget.knitkit_pagearticlesgridpanel'){
38
- var addFormItems = [
39
- {
40
- xtype:'textfield',
41
- fieldLabel:'Content Area',
42
- name:'content_area',
43
- value:record.data.content_area
44
- },
45
- {
46
- xtype:'numberfield',
47
- fieldLabel:'Position',
48
- name:'position',
49
- value:record.data.position
50
- }
51
- ];
52
- }
53
- else {
54
- if (self.alias.first() == 'widget.knitkit_blogarticlesgridpanel'){
55
- var addFormItems = [
56
- {
57
- xtype:'textfield',
58
- fieldLabel:'Tags',
59
- allowBlank:true,
60
- name:'tags',
61
- value:record.data.tag_list
62
- }
63
- ];
64
- }
65
- }
66
-
67
- if(Compass.ErpApp.Utility.isBlank(editArticleWindow)){
68
- var editArticleWindow = Ext.create("Ext.window.Window",{
69
- layout:'fit',
70
- width:375,
71
- title:'Edit Article',
72
- itemId:itemId,
73
- plain: true,
74
- buttonAlign:'center',
75
- items: {
76
- xtype: 'form',
77
- labelWidth: 110,
78
- frame:false,
79
- bodyStyle:'padding:5px 5px 0',
80
- width: 425,
81
- url:'/knitkit/erp_app/desktop/articles/update/' + self.sectionId,
82
- defaults: {
83
- width: 225
84
- },
85
- items: [
86
- {
36
+ var editFormItems = [{
87
37
  xtype:'hidden',
88
38
  allowBlank:false,
89
39
  name:'id',
@@ -115,14 +65,44 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
115
65
  checked:!record.data.display_title
116
66
  }]
117
67
  },
118
- {
119
- xtype:'textfield',
120
- fieldLabel:'Internal ID',
121
- allowBlank:true,
122
- name:'internal_identifier',
123
- value: record.data.internal_identifier
124
- },
125
- addFormItems,
68
+ {
69
+ xtype:'textfield',
70
+ fieldLabel:'Internal ID',
71
+ allowBlank:true,
72
+ name:'internal_identifier',
73
+ value: record.data.internal_identifier
74
+ }
75
+ ];
76
+ if (self.alias.first() == 'widget.knitkit_pagearticlesgridpanel'){
77
+ editFormItems = editFormItems.concat([
78
+ {
79
+ xtype:'textfield',
80
+ fieldLabel:'Content Area',
81
+ name:'content_area',
82
+ value:record.data.content_area
83
+ },
84
+ {
85
+ xtype:'numberfield',
86
+ fieldLabel:'Position',
87
+ name:'position',
88
+ value:record.data.position
89
+ }
90
+ ]);
91
+ }
92
+ else {
93
+ if (self.alias.first() == 'widget.knitkit_blogarticlesgridpanel'){
94
+ editFormItems = editFormItems.concat( [
95
+ {
96
+ xtype:'textfield',
97
+ fieldLabel:'Tags',
98
+ allowBlank:true,
99
+ name:'tags',
100
+ value:record.data.tag_list
101
+ }
102
+ ]);
103
+ }
104
+ }
105
+ editFormItems = editFormItems.concat([
126
106
  {
127
107
  xtype: 'displayfield',
128
108
  fieldLabel: 'Created At',
@@ -135,7 +115,26 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
135
115
  name: 'updated_at',
136
116
  value: record.data.updated_at
137
117
  }
138
- ]
118
+ ]);
119
+ if(Ext.isEmpty(editArticleWindow)){
120
+ editArticleWindow = Ext.create("Ext.window.Window",{
121
+ layout:'fit',
122
+ width:375,
123
+ title:'Edit Article',
124
+ itemId:itemId,
125
+ plain: true,
126
+ buttonAlign:'center',
127
+ items: {
128
+ xtype: 'form',
129
+ labelWidth: 110,
130
+ frame:false,
131
+ bodyStyle:'padding:5px 5px 0',
132
+ width: 425,
133
+ url:'/knitkit/erp_app/desktop/articles/update/' + self.sectionId,
134
+ defaults: {
135
+ width: 225
136
+ },
137
+ items: editFormItems
139
138
  },
140
139
  buttons: [{
141
140
  text:'Submit',
@@ -265,7 +264,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
265
264
  width:40,
266
265
  items:[{
267
266
  icon:'/images/icons/edit/edit_16x16.png',
268
- iconCls:'actioncolumn_hover',
267
+ iconCls:'actioncolumn_hover',
269
268
  tooltip:'Edit Attributes',
270
269
  handler :function(grid, rowIndex, colIndex){
271
270
  var rec = grid.getStore().getAt(rowIndex);
@@ -104,6 +104,7 @@ Compass.ErpApp.Desktop.Applications.Knitkit.addDocumentOptions = function (self,
104
104
  if (obj.success) {
105
105
  record.appendChild(obj.node);
106
106
  self.initialConfig['centerRegion'].editContent(obj.documented_content.title, obj.documented_content.id, obj.documented_content.body_html, record.data.siteId, 'article');
107
+ window.close();
107
108
  }
108
109
  else {
109
110
  Ext.Msg.alert("Error", obj.message);
@@ -138,6 +139,8 @@ Compass.ErpApp.Desktop.Applications.Knitkit.addDocumentOptions = function (self,
138
139
  }
139
140
 
140
141
  if (currentUser.hasCapability('edit','WebsiteSection')) {
142
+ var contentInfo = record.data['contentInfo'];
143
+
141
144
  items.push({
142
145
  text:'Update Document',
143
146
  iconCls:'icon-edit',
@@ -192,6 +195,27 @@ Compass.ErpApp.Desktop.Applications.Knitkit.addDocumentOptions = function (self,
192
195
  }
193
196
  ]
194
197
  },
198
+ {
199
+ xtype:'radiogroup',
200
+ fieldLabel:'Use markdown?',
201
+ name:'use_markdown',
202
+ columns:2,
203
+ items:[
204
+ {
205
+ boxLabel:'Yes',
206
+ name:'use_markdown',
207
+ inputValue:'yes',
208
+ checked:record.data.useMarkdown
209
+ },
210
+
211
+ {
212
+ boxLabel:'No',
213
+ name:'use_markdown',
214
+ inputValue:'no',
215
+ checked:!record.data.useMarkdown
216
+ }
217
+ ]
218
+ },
195
219
  {
196
220
  xtype:'hidden',
197
221
  name:'id',
@@ -211,9 +235,11 @@ Compass.ErpApp.Desktop.Applications.Knitkit.addDocumentOptions = function (self,
211
235
  success:function (form, action) {
212
236
  self.clearWindowStatus();
213
237
  var values = formPanel.getValues();
238
+
214
239
  record.set('title', values.title);
215
240
  record.set('internal_identifier', values.internal_identifier);
216
241
  record.set("inMenu", (values.in_menu == 'yes'));
242
+ record.set("useMarkdown", (values.use_markdown == 'yes'));
217
243
  record.commit();
218
244
  updateSectionWindow.close();
219
245
  },
@@ -123,8 +123,8 @@ Compass.ErpApp.Desktop.Applications.Knitkit.addMenuOptions = function (self, ite
123
123
  text:'Submit',
124
124
  listeners:{
125
125
  'click':function (button) {
126
- var window = button.findParentByType('window');
127
- var formPanel = window.query('form')[0];
126
+ var window = button.findParentByType('window'),
127
+ formPanel = window.query('form')[0];
128
128
  self.setWindowStatus('Creating menu item...');
129
129
  formPanel.getForm().submit({
130
130
  reset:true,
@@ -137,6 +137,7 @@ Compass.ErpApp.Desktop.Applications.Knitkit.addMenuOptions = function (self, ite
137
137
  else {
138
138
  Ext.Msg.alert("Error", obj.msg);
139
139
  }
140
+ window.close();
140
141
  },
141
142
  failure:function (form, action) {
142
143
  self.clearWindowStatus();
@@ -9,31 +9,16 @@ Compass.ErpApp.Desktop.Applications.Knitkit.addSectionOptions = function (self,
9
9
  }
10
10
  });
11
11
 
12
- if (record.data.isSecured) {
13
- if (currentUser.hasCapability('unsecure','WebsiteSection')) {
14
- items.push({
15
- text:'Security',
16
- iconCls:'icon-document_lock',
17
- listeners:{
18
- 'click':function () {
19
- self.changeSecurityOnSection(record, true);
20
- }
21
- }
22
- });
23
- }
24
- }
25
- else {
26
- if (currentUser.hasCapability('secure','WebsiteSection')) {
27
- items.push({
28
- text:'Security',
29
- iconCls:'icon-document_lock',
30
- listeners:{
31
- 'click':function () {
32
- self.changeSecurityOnSection(record, true);
33
- }
12
+ if (currentUser.hasCapability('unsecure','WebsiteSection') || currentUser.hasCapability('secure','WebsiteSection')) {
13
+ items.push({
14
+ text:'Security',
15
+ iconCls:'icon-document_lock',
16
+ listeners:{
17
+ 'click':function () {
18
+ self.changeSecurity(record, '/knitkit/erp_app/desktop/section/update_security', record.data.id.split('_')[1]);
34
19
  }
35
- });
36
- }
20
+ }
21
+ });
37
22
  }
38
23
 
39
24
  if (currentUser.hasCapability('create','WebsiteSection')) {
@@ -1,250 +1,234 @@
1
1
  Compass.ErpApp.Desktop.Applications.Knitkit.addWebsiteNavItemOptions = function (self, items, record) {
2
- if (currentUser.hasCapability('edit','WebsiteNavItem'))
3
- {
4
- items.push({
5
- text:'Update Menu Item',
6
- iconCls:'icon-edit',
7
- handler:function(btn){
8
- var addMenuItemWindow = Ext.create("Ext.window.Window",{
9
- layout:'fit',
10
- width:375,
11
- title:'Update Menu Item',
12
- height:175,
13
- plain: true,
14
- buttonAlign:'center',
15
- items: Ext.create('Ext.form.Panel',{
16
- labelWidth: 50,
17
- frame:false,
18
- bodyStyle:'padding:5px 5px 0',
19
- url:'/knitkit/erp_app/desktop/website_nav/update_menu_item',
20
- defaults: {
21
- width: 225
22
- },
23
- items: [
24
- {
25
- xtype:'textfield',
26
- fieldLabel:'Title',
27
- value:record.data.text,
28
- allowBlank:false,
29
- name:'title'
30
- },
31
- {
32
- xtype:'combo',
33
- fieldLabel:'Link to',
34
- name:'link_to',
35
- id:'knitkit_nav_item_link_to',
36
- allowBlank:false,
37
- forceSelection:true,
38
- editable:false,
39
- autoSelect:true,
40
- typeAhead: false,
41
- mode: 'local',
42
- triggerAction: 'all',
43
- store:[
44
- ['website_section','Section'],
45
- //['article','Article'],
46
- ['url','Url']
47
-
48
- ],
49
- value:record.data.linkToType,
50
- listeners:{
51
- 'change':function(combo, newValue, oldValue){
52
- switch(newValue){
53
- case 'website_section':
54
- Ext.getCmp('knitkit_website_nav_item_section').show();
55
- //Ext.getCmp('knitkit_website_nav_item_article').hide();
56
- Ext.getCmp('knitkit_website_nav_item_url').hide();
57
- break;
58
- case 'article':
59
- Ext.getCmp('knitkit_website_nav_item_section').hide();
60
- //Ext.getCmp('knitkit_website_nav_item_article').show();
61
- Ext.getCmp('knitkit_website_nav_item_url').hide();
62
- break;
63
- case 'url':
64
- Ext.getCmp('knitkit_website_nav_item_section').hide();
65
- //Ext.getCmp('knitkit_website_nav_item_article').hide();
66
- Ext.getCmp('knitkit_website_nav_item_url').show();
67
- break;
68
- }
69
- }
70
- }
71
- },
72
- {
73
- xtype:'combo',
74
- width:300,
75
- id:'knitkit_website_nav_item_section',
76
- hiddenName:'website_section_id',
77
- name:'website_section_id',
78
- loadingText:'Retrieving Sections...',
79
- store:Ext.create("Ext.data.Store",{
80
- proxy:{
81
- type:'ajax',
82
- url:'/knitkit/erp_app/desktop/section/existing_sections',
83
- reader:{
84
- type:'json'
85
- },
86
- extraParams:{
87
- website_id:record.data.websiteId
88
- }
89
- },
90
- autoLoad:true,
91
- fields:[
92
- {
93
- name:'id'
94
- },
95
- {
96
- name:'title_permalink'
97
-
98
- }
99
- ],
100
- listeners:{
101
- 'load':function(store, records, options){
102
- Ext.getCmp('knitkit_website_nav_item_section').setValue(record.data.linkedToId);
103
- }
104
- }
105
- }),
106
- forceSelection:true,
107
- editable:false,
108
- fieldLabel:'Section',
109
- autoSelect:true,
110
- typeAhead: false,
111
- queryMode: 'local',
112
- displayField:'title_permalink',
113
- valueField:'id',
114
- hidden:(record.data.linkToType != 'website_section' && record.data.linkToType != 'article')
115
- },
116
- {
117
- xtype:'textfield',
118
- fieldLabel:'Url',
119
- value:record.data.url,
120
- id:'knitkit_website_nav_item_url',
121
- hidden:(record.data.linkToType == 'website_section' || record.data.linkToType == 'article'),
122
- name:'url'
123
- },
124
- {
125
- xtype:'hidden',
126
- name:'website_nav_item_id',
127
- value:record.data.websiteNavItemId
128
- }
129
- ]
130
- }),
131
- buttons: [{
132
- text:'Submit',
133
- listeners:{
134
- 'click':function(button){
135
- var window = button.findParentByType('window');
136
- var formPanel = window.query('form')[0];
137
- self.setWindowStatus('Updating menu item...');
138
- formPanel.getForm().submit({
139
- reset:false,
140
- success:function(form, action){
141
- self.clearWindowStatus();
142
- var obj = Ext.decode(action.response.responseText);
143
- if(obj.success){
144
- record.data.linkedToId = obj.linkedToId;
145
- record.data.linkToType = obj.linkToType;
146
- record.data.url = obj.url;
147
- //node.getUI().getTextEl().innerHTML = obj.title;
148
- }
149
- else{
150
- Ext.Msg.alert("Error", obj.msg);
151
- }
152
- },
153
- failure:function(form, action){
154
- self.clearWindowStatus();
155
- if(action.response === null){
156
- Ext.Msg.alert("Error", 'Could not create menu item');
157
- }
158
- else{
159
- var obj = Ext.decode(action.response.responseText);
160
- Ext.Msg.alert("Error", obj.msg);
161
- }
162
-
163
- }
164
- });
165
- }
166
- }
167
- },{
168
- text: 'Close',
169
- handler: function(){
170
- addMenuItemWindow.close();
171
- }
172
- }]
173
- });
174
- addMenuItemWindow.show();
175
- }
176
- });
177
- }
178
-
179
- if(record.data.isSecured){
180
- if (currentUser.hasCapability('unsecure','WebsiteNavItem'))
181
- {
182
- items.push({
183
- text:'Unsecure',
184
- iconCls:'icon-document',
185
- listeners:{
186
- 'click':function(){
187
- self.changeSecurityOnMenuItem(record, false);
188
- }
189
- }
190
- });
191
- }
192
- }
193
- else{
194
- if (currentUser.hasCapability('secure','WebsiteNavItem'))
195
- {
196
- items.push({
197
- text:'Secure',
198
- iconCls:'icon-document_lock',
199
- listeners:{
200
- 'click':function(){
201
- self.changeSecurityOnMenuItem(record, true);
202
- }
203
- }
204
- });
205
- }
206
- }
207
-
208
- if (currentUser.hasCapability('delete','WebsiteNavItem'))
209
- {
210
- items.push({
211
- text:'Delete',
212
- iconCls:'icon-delete',
213
- handler:function(btn){
214
- Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu item?', function(btn){
215
- if(btn == 'no'){
216
- return false;
217
- }
218
- else
219
- if(btn == 'yes')
220
- {
221
- self.setWindowStatus('Deleting menu item...');
222
- Ext.Ajax.request({
223
- url: '/knitkit/erp_app/desktop/website_nav/delete_menu_item',
224
- method: 'POST',
225
- params:{
226
- id:record.data.websiteNavItemId
227
- },
228
- success: function(response) {
229
- self.clearWindowStatus();
230
- var obj = Ext.decode(response.responseText);
231
- if(obj.success){
232
- record.remove(true);
233
- }
234
- else{
235
- Ext.Msg.alert('Error', 'Error deleting menu item');
236
- }
237
- },
238
- failure: function(response) {
239
- self.clearWindowStatus();
240
- Ext.Msg.alert('Error', 'Error deleting menu item');
241
- }
242
- });
243
- }
244
- });
245
- }
246
- });
247
- }
248
-
249
- return items;
2
+ if (currentUser.hasCapability('edit','WebsiteNavItem'))
3
+ {
4
+ items.push({
5
+ text:'Update Menu Item',
6
+ iconCls:'icon-edit',
7
+ handler:function(btn){
8
+ var addMenuItemWindow = Ext.create("Ext.window.Window",{
9
+ layout:'fit',
10
+ width:375,
11
+ title:'Update Menu Item',
12
+ height:175,
13
+ plain: true,
14
+ buttonAlign:'center',
15
+ items: Ext.create('Ext.form.Panel',{
16
+ labelWidth: 50,
17
+ frame:false,
18
+ bodyStyle:'padding:5px 5px 0',
19
+ url:'/knitkit/erp_app/desktop/website_nav/update_menu_item',
20
+ defaults: {
21
+ width: 225
22
+ },
23
+ items: [
24
+ {
25
+ xtype:'textfield',
26
+ fieldLabel:'Title',
27
+ value:record.data.text,
28
+ allowBlank:false,
29
+ name:'title'
30
+ },
31
+ {
32
+ xtype:'combo',
33
+ fieldLabel:'Link to',
34
+ name:'link_to',
35
+ id:'knitkit_nav_item_link_to',
36
+ allowBlank:false,
37
+ forceSelection:true,
38
+ editable:false,
39
+ autoSelect:true,
40
+ typeAhead: false,
41
+ mode: 'local',
42
+ triggerAction: 'all',
43
+ store:[
44
+ ['website_section','Section'],
45
+ //['article','Article'],
46
+ ['url','Url']
47
+
48
+ ],
49
+ value:record.data.linkToType,
50
+ listeners:{
51
+ 'change':function(combo, newValue, oldValue){
52
+ switch(newValue){
53
+ case 'website_section':
54
+ Ext.getCmp('knitkit_website_nav_item_section').show();
55
+ //Ext.getCmp('knitkit_website_nav_item_article').hide();
56
+ Ext.getCmp('knitkit_website_nav_item_url').hide();
57
+ break;
58
+ case 'article':
59
+ Ext.getCmp('knitkit_website_nav_item_section').hide();
60
+ //Ext.getCmp('knitkit_website_nav_item_article').show();
61
+ Ext.getCmp('knitkit_website_nav_item_url').hide();
62
+ break;
63
+ case 'url':
64
+ Ext.getCmp('knitkit_website_nav_item_section').hide();
65
+ //Ext.getCmp('knitkit_website_nav_item_article').hide();
66
+ Ext.getCmp('knitkit_website_nav_item_url').show();
67
+ break;
68
+ }
69
+ }
70
+ }
71
+ },
72
+ {
73
+ xtype:'combo',
74
+ width:300,
75
+ id:'knitkit_website_nav_item_section',
76
+ hiddenName:'website_section_id',
77
+ name:'website_section_id',
78
+ loadingText:'Retrieving Sections...',
79
+ store:Ext.create("Ext.data.Store",{
80
+ proxy:{
81
+ type:'ajax',
82
+ url:'/knitkit/erp_app/desktop/section/existing_sections',
83
+ reader:{
84
+ type:'json'
85
+ },
86
+ extraParams:{
87
+ website_id:record.data.websiteId
88
+ }
89
+ },
90
+ autoLoad:true,
91
+ fields:[
92
+ {
93
+ name:'id'
94
+ },
95
+ {
96
+ name:'title_permalink'
97
+
98
+ }
99
+ ],
100
+ listeners:{
101
+ 'load':function(store, records, options){
102
+ Ext.getCmp('knitkit_website_nav_item_section').setValue(record.data.linkedToId);
103
+ }
104
+ }
105
+ }),
106
+ forceSelection:true,
107
+ editable:false,
108
+ fieldLabel:'Section',
109
+ autoSelect:true,
110
+ typeAhead: false,
111
+ queryMode: 'local',
112
+ displayField:'title_permalink',
113
+ valueField:'id',
114
+ hidden:(record.data.linkToType != 'website_section' && record.data.linkToType != 'article')
115
+ },
116
+ {
117
+ xtype:'textfield',
118
+ fieldLabel:'Url',
119
+ value:record.data.url,
120
+ id:'knitkit_website_nav_item_url',
121
+ hidden:(record.data.linkToType == 'website_section' || record.data.linkToType == 'article'),
122
+ name:'url'
123
+ },
124
+ {
125
+ xtype:'hidden',
126
+ name:'website_nav_item_id',
127
+ value:record.data.websiteNavItemId
128
+ }
129
+ ]
130
+ }),
131
+ buttons: [{
132
+ text:'Submit',
133
+ listeners:{
134
+ 'click':function(button){
135
+ var window = button.findParentByType('window'),
136
+ formPanel = window.query('form')[0];
137
+ self.setWindowStatus('Updating menu item...');
138
+ formPanel.getForm().submit({
139
+ reset:false,
140
+ success:function(form, action){
141
+ self.clearWindowStatus();
142
+ var obj = Ext.decode(action.response.responseText);
143
+ if(obj.success){
144
+ record.data.linkedToId = obj.linkedToId;
145
+ record.data.linkToType = obj.linkToType;
146
+ record.data.url = obj.url;
147
+ window.close();
148
+ }
149
+ else{
150
+ Ext.Msg.alert("Error", obj.msg);
151
+ }
152
+ },
153
+ failure:function(form, action){
154
+ self.clearWindowStatus();
155
+ if(action.response === null){
156
+ Ext.Msg.alert("Error", 'Could not create menu item');
157
+ }
158
+ else{
159
+ var obj = Ext.decode(action.response.responseText);
160
+ Ext.Msg.alert("Error", obj.msg);
161
+ }
162
+
163
+ }
164
+ });
165
+ }
166
+ }
167
+ },{
168
+ text: 'Close',
169
+ handler: function(){
170
+ addMenuItemWindow.close();
171
+ }
172
+ }]
173
+ });
174
+ addMenuItemWindow.show();
175
+ }
176
+ });
177
+ }
178
+
179
+ if (currentUser.hasCapability('unsecure','WebsiteNavItem') || currentUser.hasCapability('secure','WebsiteNavItem'))
180
+ {
181
+ items.push({
182
+ text:'Security',
183
+ iconCls:'icon-document_lock',
184
+ listeners:{
185
+ 'click':function(){
186
+ self.changeSecurity(record, '/knitkit/erp_app/desktop/website_nav/update_security', record.data.websiteNavItemId);
187
+ }
188
+ }
189
+ });
190
+ }
191
+
192
+ if (currentUser.hasCapability('delete','WebsiteNavItem'))
193
+ {
194
+ items.push({
195
+ text:'Delete',
196
+ iconCls:'icon-delete',
197
+ handler:function(btn){
198
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this menu item?', function(btn){
199
+ if(btn == 'no'){
200
+ return false;
201
+ }
202
+ else
203
+ if(btn == 'yes')
204
+ {
205
+ self.setWindowStatus('Deleting menu item...');
206
+ Ext.Ajax.request({
207
+ url: '/knitkit/erp_app/desktop/website_nav/delete_menu_item',
208
+ method: 'POST',
209
+ params:{
210
+ id:record.data.websiteNavItemId
211
+ },
212
+ success: function(response) {
213
+ self.clearWindowStatus();
214
+ var obj = Ext.decode(response.responseText);
215
+ if(obj.success){
216
+ record.remove(true);
217
+ }
218
+ else{
219
+ Ext.Msg.alert('Error', 'Error deleting menu item');
220
+ }
221
+ },
222
+ failure: function(response) {
223
+ self.clearWindowStatus();
224
+ Ext.Msg.alert('Error', 'Error deleting menu item');
225
+ }
226
+ });
227
+ }
228
+ });
229
+ }
230
+ });
231
+ }
232
+
233
+ return items;
250
234
  };