knitkit 2.0.5 → 2.0.6

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