knitkit 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/README.md +22 -0
  2. data/app/controllers/knitkit/base_controller.rb +15 -2
  3. data/app/controllers/knitkit/blogs_controller.rb +4 -4
  4. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +16 -2
  5. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +198 -57
  6. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +25 -11
  7. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +123 -44
  8. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +83 -9
  9. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +38 -0
  10. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +15 -6
  11. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +185 -98
  12. data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +38 -16
  13. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +126 -68
  14. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +154 -107
  15. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +113 -54
  16. data/app/controllers/knitkit/online_document_sections_controller.rb +45 -0
  17. data/app/controllers/knitkit/unauthorized_controller.rb +5 -0
  18. data/app/controllers/knitkit/website_sections_controller.rb +8 -9
  19. data/app/mailers/document_mailer.rb +10 -0
  20. data/app/models/article.rb +1 -1
  21. data/app/models/content.rb +35 -3
  22. data/app/models/document.rb +8 -0
  23. data/app/models/document_type.rb +3 -0
  24. data/app/models/documented_content.rb +29 -0
  25. data/app/models/documented_item.rb +31 -0
  26. data/app/models/extensions/configuration.rb +5 -0
  27. data/app/models/extensions/party.rb +13 -0
  28. data/app/models/online_document_section.rb +40 -0
  29. data/app/models/theme.rb +22 -26
  30. data/app/models/valid_document.rb +4 -0
  31. data/app/models/website.rb +158 -119
  32. data/app/models/website_inquiry.rb +7 -2
  33. data/app/models/website_inquiry_mailer.rb +4 -3
  34. data/app/models/website_party_role.rb +5 -0
  35. data/app/models/website_section.rb +76 -38
  36. data/app/views/document_mailer/email_document.html.erb +12 -0
  37. data/app/views/knitkit/blogs/_add_comment.html.erb +2 -2
  38. data/app/views/knitkit/online_document_sections/index.html.erb +149 -0
  39. data/app/views/knitkit/website_sections/index.html.erb +0 -1
  40. data/app/views/layouts/knitkit/base.html.erb +4 -2
  41. data/app/views/layouts/knitkit/online_document_sections.html.erb +59 -0
  42. data/app/views/menus/knitkit/_default_menu.html.erb +1 -1
  43. data/app/views/menus/knitkit/_default_section_menu.html.erb +1 -1
  44. data/app/views/menus/knitkit/_default_sub_menu.html.erb +2 -2
  45. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +1 -1
  46. data/app/widgets/contact_us/base.rb +5 -5
  47. data/app/widgets/contact_us/javascript/contact_us.js +2 -1
  48. data/app/widgets/google_map/base.rb +0 -4
  49. data/app/widgets/google_map/javascript/google_map.js +4 -3
  50. data/app/widgets/login/base.rb +0 -5
  51. data/app/widgets/login/javascript/login.js +155 -153
  52. data/app/widgets/login/views/index.html.erb +3 -3
  53. data/app/widgets/login/views/reset_password.html.erb +2 -2
  54. data/app/widgets/manage_profile/base.rb +46 -67
  55. data/app/widgets/manage_profile/javascript/manage_profile.js +2 -1
  56. data/app/widgets/manage_profile/views/_user_information_form.html.erb +5 -1
  57. data/app/widgets/reset_password/base.rb +4 -6
  58. data/app/widgets/reset_password/javascript/reset_password.js +2 -1
  59. data/app/widgets/reset_password/views/index.html.erb +4 -3
  60. data/app/widgets/search/base.rb +1 -5
  61. data/app/widgets/search/javascript/search.js +2 -1
  62. data/app/widgets/search/views/show.html.erb +2 -2
  63. data/app/widgets/signup/base.rb +7 -6
  64. data/app/widgets/signup/javascript/signup.js +2 -1
  65. data/app/widgets/signup/views/error.html.erb +1 -1
  66. data/config/routes.rb +6 -2
  67. data/db/data_migrations/20110509223702_add_publisher_role.rb +10 -0
  68. data/db/data_migrations/20111118182910_setup_knitkit_capabilities.rb +84 -0
  69. data/db/data_migrations/20120127144444_create_website_role_types.rb +13 -0
  70. data/db/data_migrations/20120127150505_create_website_default_configuration.rb +72 -0
  71. data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +33 -0
  72. data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +16 -0
  73. data/db/data_migrations/upgrade/20120210195616_add_website_configs.rb +19 -0
  74. data/db/data_migrations/upgrade/20120213205519_populate_website_iids.rb +17 -0
  75. data/db/migrate/20110211002317_setup_knitkit.rb +22 -5
  76. data/db/migrate/20111207161928_create_documented_items_table.rb +13 -0
  77. data/db/migrate/20111208180539_add_document_id_to_documented_item.rb +9 -0
  78. data/db/migrate/20120315163736_add_document.rb +32 -0
  79. data/db/migrate/20120503183431_create_valid_documents.rb +16 -0
  80. data/db/migrate/upgrade/20120116201510_add_render_base_layout_flag.rb +13 -0
  81. data/db/migrate/upgrade/20120127143745_create_website_party_roles.rb +24 -0
  82. data/db/migrate/upgrade/20120213184509_add_iid_to_websites.rb +14 -0
  83. data/lib/knitkit.rb +2 -0
  84. data/lib/knitkit/config.rb +31 -0
  85. data/lib/knitkit/engine.rb +12 -3
  86. data/lib/knitkit/extensions.rb +1 -3
  87. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +2 -3
  88. data/lib/knitkit/extensions/active_record/acts_as_document.rb +63 -0
  89. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +5 -4
  90. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +70 -0
  91. data/lib/knitkit/extensions/railties/action_view.rb +22 -10
  92. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +3 -3
  93. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +8 -3
  94. data/lib/knitkit/routing_filter/section_router.rb +16 -6
  95. data/lib/knitkit/version.rb +7 -1
  96. data/public/images/check.png +0 -0
  97. data/public/images/credit_card.png +0 -0
  98. data/public/images/knitkit/tooltip.gif +0 -0
  99. data/public/javascripts/ajax_pagination.js +33 -0
  100. data/public/javascripts/datepicker.js +6 -1
  101. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +731 -258
  102. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +289 -238
  103. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +2 -4
  104. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +29 -3
  105. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +193 -21
  106. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +27 -26
  107. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +167 -20
  108. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +1 -2
  109. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +5 -1
  110. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +2 -2
  111. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +20 -11
  112. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +279 -228
  113. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +40 -40
  114. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +83 -76
  115. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +1961 -1397
  116. data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +47 -43
  117. data/public/javascripts/knitkit/helpers.js +26 -0
  118. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +1 -2
  119. data/public/stylesheets/knitkit/documentation.css +50 -0
  120. data/public/stylesheets/knitkit/style.css +23 -1
  121. data/spec/controllers/knitkit/erp_app/desktop/articles_controller_spec.rb +8 -0
  122. data/spec/controllers/knitkit/erp_app/desktop/website_controller_spec.rb +396 -0
  123. data/spec/controllers/knitkit/erp_app/desktop/website_nav_controller_spec.rb +260 -0
  124. data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +222 -0
  125. data/spec/dummy/Rakefile +7 -0
  126. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  127. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  128. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  129. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  130. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  131. data/spec/dummy/config.ru +4 -0
  132. data/spec/dummy/config/application.rb +43 -0
  133. data/spec/dummy/config/boot.rb +10 -0
  134. data/spec/dummy/config/database.yml +8 -0
  135. data/spec/dummy/config/environment.rb +5 -0
  136. data/spec/dummy/config/environments/spec.rb +27 -0
  137. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  138. data/spec/dummy/config/initializers/inflections.rb +10 -0
  139. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  140. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  141. data/spec/dummy/config/initializers/session_store.rb +8 -0
  142. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  143. data/spec/dummy/config/locales/en.yml +5 -0
  144. data/spec/dummy/config/routes.rb +4 -0
  145. data/spec/dummy/config/workflow.yml +1 -0
  146. data/spec/dummy/public/404.html +26 -0
  147. data/spec/dummy/public/422.html +26 -0
  148. data/spec/dummy/public/500.html +26 -0
  149. data/spec/dummy/public/favicon.ico +0 -0
  150. data/spec/dummy/script/rails +6 -0
  151. data/spec/factories/article.rb +4 -0
  152. data/spec/factories/basic.rb +3 -0
  153. data/spec/factories/blog.rb +5 -0
  154. data/spec/factories/documented_content.rb +4 -0
  155. data/spec/factories/documented_item.rb +4 -0
  156. data/spec/factories/online_document_section.rb +6 -0
  157. data/spec/factories/published_website.rb +4 -0
  158. data/spec/factories/theme.rb +6 -0
  159. data/spec/factories/website.rb +5 -0
  160. data/spec/factories/website_host.rb +4 -0
  161. data/spec/factories/website_nav.rb +5 -0
  162. data/spec/factories/website_nav_item.rb +4 -0
  163. data/spec/factories/website_section.rb +5 -0
  164. data/spec/models/article_spec.rb +35 -0
  165. data/spec/models/attribute_type_spec.rb +55 -0
  166. data/spec/models/attribute_value_spec.rb +114 -0
  167. data/spec/models/blog_spec.rb +16 -0
  168. data/spec/models/comment_spec.rb +11 -0
  169. data/spec/models/content_spec.rb +187 -0
  170. data/spec/models/documented_item_spec.rb +29 -0
  171. data/spec/models/online_document_section_spec.rb +34 -0
  172. data/spec/models/published_element_spec.rb +11 -0
  173. data/spec/models/published_website_spec.rb +11 -0
  174. data/spec/models/theme_spec.rb +12 -0
  175. data/spec/models/website_host_spec.rb +11 -0
  176. data/spec/models/website_inquiry_spec.rb +24 -0
  177. data/spec/models/website_nav_item_spec.rb +11 -0
  178. data/spec/models/website_nav_spec.rb +11 -0
  179. data/spec/models/website_section_content_spec.rb +11 -0
  180. data/spec/models/website_section_spec.rb +49 -0
  181. data/spec/models/website_spec.rb +146 -0
  182. data/spec/spec_helper.rb +61 -0
  183. metadata +391 -154
  184. data/app/controllers/knitkit/articles_controller.rb +0 -7
  185. data/lib/knitkit/extensions/compass/widgets/base.rb +0 -53
@@ -4,8 +4,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CommentsGridPanel",{
4
4
  approve : function(rec){
5
5
  var self = this;
6
6
  self.initialConfig['centerRegion'].setWindowStatus('Approving Comment...');
7
- var conn = new Ext.data.Connection();
8
- conn.request({
7
+ Ext.Ajax.request({
9
8
  url: '/knitkit/erp_app/desktop/comments/approve',
10
9
  method: 'POST',
11
10
  params:{
@@ -34,8 +33,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.CommentsGridPanel",{
34
33
  deleteComment : function(rec){
35
34
  var self = this;
36
35
  self.initialConfig['centerRegion'].setWindowStatus('Deleting Comment...');
37
- var conn = new Ext.data.Connection();
38
- conn.request({
36
+ Ext.Ajax.request({
39
37
  url: '/knitkit/erp_app/desktop/comments/delete',
40
38
  method: 'POST',
41
39
  params:{
@@ -2,10 +2,36 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.EastRegion",{
2
2
  extend:"Ext.TabPanel",
3
3
  alias:'widget.knitkit_eastregion',
4
4
  initComponent: function() {
5
- this.imageAssetsPanel = new Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel();
5
+ this.imageAssetsPanel = new Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel(this.initialConfig['module']);
6
6
  this.widgetsPanel = new Compass.ErpApp.Desktop.Applications.Knitkit.WidgetsPanel();
7
7
  this.fileAssetsPanel = new Compass.ErpApp.Desktop.Applications.Knitkit.FileAssetsPanel(this.initialConfig['module']);
8
- this.items = [this.imageAssetsPanel.layout, this.fileAssetsPanel.layout, this.widgetsPanel.layout];
8
+ this.items = [];
9
+
10
+ if (currentUser.hasApplicationCapability('knitkit', {
11
+ capability_type_iid:'view',
12
+ resource:'GlobalImageAsset'
13
+ }) || currentUser.hasApplicationCapability('knitkit', {
14
+ capability_type_iid:'view',
15
+ resource:'SiteImageAsset'
16
+ }))
17
+
18
+ {
19
+ this.items.push(this.imageAssetsPanel.layout)
20
+ }
21
+
22
+ if (currentUser.hasApplicationCapability('knitkit', {
23
+ capability_type_iid:'view',
24
+ resource:'GlobalFileAsset'
25
+ }) || currentUser.hasApplicationCapability('knitkit', {
26
+ capability_type_iid:'view',
27
+ resource:'SiteFileAsset'
28
+ }))
29
+
30
+ {
31
+ this.items.push(this.fileAssetsPanel.layout)
32
+ }
33
+
34
+ this.items.push(this.widgetsPanel.layout)
9
35
 
10
36
  this.callParent(arguments);
11
37
  this.setActiveTab(0);
@@ -14,7 +40,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.EastRegion",{
14
40
  constructor : function(config) {
15
41
  config = Ext.apply({
16
42
  id:'knitkitEastRegion',
17
- region:'east',
43
+ region:'east',
18
44
  width:300,
19
45
  split:true,
20
46
  autoDestroy:true,
@@ -1,13 +1,44 @@
1
1
  Compass.ErpApp.Desktop.Applications.Knitkit.FileAssetsPanel = function(module) {
2
- this.websiteId = null;
3
- var self = this;
4
- self.module = module;
2
+ this.websiteId = null;
3
+ var self = this;
4
+ self.module = module;
5
5
 
6
+ this.changeSecurityOnFile = function(node, secure, model, websiteId){
7
+ var msg = secure ? 'Securing file...' : 'Unsecuring file...';
8
+ var waitMsg = Ext.Msg.wait("Please Wait", msg);
9
+ Ext.Ajax.request({
10
+ url: '/knitkit/erp_app/desktop/file_assets/'+model+'/update_security',
11
+ method: 'POST',
12
+ params:{
13
+ path:node.get('id'),
14
+ secure:secure,
15
+ website_id:websiteId
16
+ },
17
+ success: function(response) {
18
+ var obj = Ext.decode(response.responseText);
19
+ if(obj.success){
20
+ waitMsg.hide();
21
+ if(secure){
22
+ node.set('iconCls', 'icon-document_lock');
23
+ }
24
+ else{
25
+ node.set('iconCls', 'icon-document');
26
+ }
27
+ node.set('isSecured',secure);
28
+ node.commit();
29
+ }
30
+ else{
31
+ Ext.Msg.alert('Error', 'Error securing file.');
32
+ }
33
+ },
34
+ failure: function(response) {
35
+ waitMsg.hide();
36
+ Ext.Msg.alert('Error', 'Error securing file.');
37
+ }
38
+ });
39
+ };
40
+
6
41
  this.sharedFileAssetsTreePanel = Ext.create("Compass.ErpApp.Shared.FileManagerTree",{
7
- //TODO_EXTJS4 this is added to fix error should be removed when extjs 4 releases fix.
8
- viewConfig:{
9
- loadMask: false
10
- },
11
42
  title:'Shared',
12
43
  allowDownload:false,
13
44
  addViewContentsToContextMenu:false,
@@ -18,6 +49,18 @@ Compass.ErpApp.Desktop.Applications.Knitkit.FileAssetsPanel = function(module) {
18
49
  url:'/knitkit/erp_app/desktop/file_assets/shared/expand_directory',
19
50
  containerScroll: true,
20
51
  additionalContextMenuItems:[{
52
+ nodeType:'leaf',
53
+ text:'View Details',
54
+ iconCls:'icon-add',
55
+ listeners:{
56
+ scope:self,
57
+ 'click':function(){
58
+ var node = this.sharedFileAssetsTreePanel.selectedNode;
59
+ Ext.Msg.alert('Details', 'URL: /download/'+node.data.text+'?path='+node.data.downloadPath);
60
+ }
61
+ }
62
+ },
63
+ {
21
64
  nodeType:'leaf',
22
65
  text:'Insert link at cursor',
23
66
  iconCls:'icon-add',
@@ -27,27 +70,84 @@ Compass.ErpApp.Desktop.Applications.Knitkit.FileAssetsPanel = function(module) {
27
70
  var node = this.sharedFileAssetsTreePanel.selectedNode;
28
71
  Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
29
72
  if(btn == 'ok'){
30
- self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="#" onclick="window.open(\'/erp_app/public/download_file/?path='+node.data.downloadPath+'\',\'mywindow\',\'width=400,height=200\');return false;">'+text+'</a>');
73
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'">'+text+'</a>');
74
+ }
75
+ });
76
+ }
77
+ }
78
+ },
79
+ {
80
+ nodeType:'leaf',
81
+ text:'Insert link at cursor (inline)',
82
+ iconCls:'icon-add',
83
+ listeners:{
84
+ scope:self,
85
+ 'click':function(){
86
+ var node = this.sharedFileAssetsTreePanel.selectedNode;
87
+ Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
88
+ if(btn == 'ok'){
89
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'&disposition=inline">'+text+'</a>');
90
+ }
91
+ });
92
+ }
93
+ }
94
+ },
95
+ {
96
+ nodeType:'leaf',
97
+ text:'Insert link at cursor (prompt)',
98
+ iconCls:'icon-add',
99
+ listeners:{
100
+ scope:self,
101
+ 'click':function(){
102
+ var node = this.sharedFileAssetsTreePanel.selectedNode;
103
+ Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
104
+ if(btn == 'ok'){
105
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'&disposition=attachment">'+text+'</a>');
31
106
  }
32
107
  });
33
108
  }
34
109
  }
110
+ },
111
+ {
112
+ nodeType:'leaf',
113
+ text:'Update Security',
114
+ iconCls:'icon-document_lock',
115
+ listeners:{
116
+ scope:self,
117
+ 'click':function(){
118
+ var node = this.sharedFileAssetsTreePanel.selectedNode;
119
+ self.changeSecurityOnFile(node, !node.get('isSecured'), 'shared');
120
+ }
121
+ }
35
122
  }],
36
123
  listeners:{
124
+ 'allowdelete':function(){
125
+ return currentUser.hasApplicationCapability('knitkit', {
126
+ capability_type_iid:'delete',
127
+ resource:'GlobalFileAsset'
128
+ });
129
+ },
130
+ 'allowupload':function(){
131
+ return currentUser.hasApplicationCapability('knitkit', {
132
+ capability_type_iid:'upload',
133
+ resource:'GlobalFileAsset'
134
+ });
135
+ },
37
136
  'itemclick':function(view, record, item, index, e){
38
137
  e.stopEvent();
39
138
  return false;
40
139
  },
41
140
  'fileDeleted':function(fileTreePanel, node){},
42
- 'fileUploaded':function(fileTreePanel, node){}
141
+ 'fileUploaded':function(fileTreePanel, node){},
142
+ 'downloadfile':function(fileTreePanel, node){
143
+ window.open("/download/"+node.data.text+"?path=" + node.data.downloadPath,'mywindow','width=400,height=200');
144
+ return false;
145
+ }
43
146
  }
44
147
  });
45
148
 
46
149
  this.websiteFileAssetsTreePanel = Ext.create("Compass.ErpApp.Shared.FileManagerTree",{
47
- //TODO_EXTJS4 this is added to fix error should be removed when extjs 4 releases fix.
48
- viewConfig:{
49
- loadMask: false
50
- },
150
+ autoLoadRoot:false,
51
151
  title:'Website',
52
152
  allowDownload:false,
53
153
  addViewContentsToContextMenu:false,
@@ -59,7 +159,35 @@ Compass.ErpApp.Desktop.Applications.Knitkit.FileAssetsPanel = function(module) {
59
159
  containerScroll: true,
60
160
  additionalContextMenuItems:[{
61
161
  nodeType:'leaf',
62
- text:'Insert link at cursor',
162
+ text:'View Details',
163
+ iconCls:'icon-add',
164
+ listeners:{
165
+ scope:self,
166
+ 'click':function(){
167
+ var node = this.websiteFileAssetsTreePanel.selectedNode;
168
+ Ext.Msg.alert('Details', 'URL: /download/'+node.data.text+'?path='+node.data.downloadPath);
169
+ }
170
+ }
171
+ },
172
+ {
173
+ nodeType:'leaf',
174
+ text:'Insert link at cursor (inline)',
175
+ iconCls:'icon-add',
176
+ listeners:{
177
+ scope:self,
178
+ 'click':function(){
179
+ var node = this.websiteFileAssetsTreePanel.selectedNode;
180
+ Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
181
+ if(btn == 'ok'){
182
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'">'+text+'</a>');
183
+ }
184
+ });
185
+ }
186
+ }
187
+ },
188
+ {
189
+ nodeType:'leaf',
190
+ text:'Insert link at cursor (prompt)',
63
191
  iconCls:'icon-add',
64
192
  listeners:{
65
193
  scope:self,
@@ -67,34 +195,79 @@ Compass.ErpApp.Desktop.Applications.Knitkit.FileAssetsPanel = function(module) {
67
195
  var node = this.websiteFileAssetsTreePanel.selectedNode;
68
196
  Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
69
197
  if(btn == 'ok'){
70
- self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="#" onclick="window.open(\'/erp_app/public/download_file/?path='+node.data.downloadPath+'\',\'mywindow\',\'width=400,height=200\');return false;">'+text+'</a>');
198
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'&disposition=attachment">'+text+'</a>');
71
199
  }
72
200
  });
73
201
  }
74
202
  }
203
+ },
204
+ {
205
+ nodeType:'leaf',
206
+ text:'Update Security',
207
+ iconCls:'icon-document_lock',
208
+ listeners:{
209
+ scope:self,
210
+ 'click':function(){
211
+ var node = this.websiteFileAssetsTreePanel.selectedNode;
212
+ self.changeSecurityOnFile(node, !node.get('isSecured'), 'website', this.websiteId);
213
+ }
214
+ }
75
215
  }],
76
216
  listeners:{
217
+ scope:self,
218
+ 'show': function(){
219
+ self.reloadWebsiteFileAssetsTreePanel(self.websiteId);
220
+ },
77
221
  'itemclick':function(view, record, item, index, e){
78
222
  e.stopEvent();
79
223
  return false;
80
224
  },
81
225
  'fileDeleted':function(fileTreePanel, node){},
82
- 'fileUploaded':function(fileTreePanel, node){}
226
+ 'fileUploaded':function(fileTreePanel, node){},
227
+ 'downloadfile':function(fileTreePanel, node){
228
+ window.open("/download/"+node.data.text+"?path=" + node.data.downloadPath,'mywindow','width=400,height=200');
229
+ return false;
230
+ }
83
231
  }
84
232
  });
85
-
233
+
234
+ var items = [];
235
+
236
+ if (currentUser.hasApplicationCapability('knitkit', {
237
+ capability_type_iid:'view',
238
+ resource:'GlobalFileAsset'
239
+ }))
240
+
241
+ {
242
+ items.push(this.sharedFileAssetsTreePanel);
243
+ }
244
+
245
+ if (currentUser.hasApplicationCapability('knitkit', {
246
+ capability_type_iid:'view',
247
+ resource:'SiteFileAsset'
248
+ }))
249
+
250
+ {
251
+ items.push(this.websiteFileAssetsTreePanel);
252
+ }
253
+
86
254
  this.layout = Ext.create('Ext.panel.Panel',{
87
255
  layout: 'fit',
88
256
  title:'Files',
89
257
  items: Ext.create('Ext.tab.Panel',{
90
- items:[this.sharedFileAssetsTreePanel, this.websiteFileAssetsTreePanel]
91
- })
258
+ items:items
259
+ })
92
260
  });
93
261
 
94
262
  this.selectWebsite = function(websiteId){
95
263
  this.websiteId = websiteId;
264
+ this.reloadWebsiteFileAssetsTreePanel(websiteId);
265
+ }
266
+
267
+ this.reloadWebsiteFileAssetsTreePanel = function(websiteId){
96
268
  this.websiteFileAssetsTreePanel.extraPostData = {
97
- website_id:websiteId
269
+ website_id:websiteId,
270
+ websiteid:websiteId // for xhrFileUpload to work
98
271
  };
99
272
  this.websiteFileAssetsTreePanel.getStore().setProxy({
100
273
  type: 'ajax',
@@ -106,4 +279,3 @@ Compass.ErpApp.Desktop.Applications.Knitkit.FileAssetsPanel = function(module) {
106
279
  this.websiteFileAssetsTreePanel.getStore().load();
107
280
  }
108
281
  }
109
-
@@ -1,30 +1,31 @@
1
1
  Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsDataView",{
2
- extend:"Ext.view.View",
3
- alias:'widget.knitkit_imageassetsdataview',
2
+ extend:"Ext.view.View",
3
+ alias:'widget.knitkit_imageassetsdataview',
4
4
 
5
- constructor : function(config) {
6
- config = Ext.apply({
7
- autoDestroy:true,
8
- style:'overflow:auto',
9
- store: Ext.create('Ext.data.Store', {
10
- proxy: {
11
- type: 'ajax',
12
- url: config['url'],
13
- reader: {
14
- type: 'json',
15
- root: 'images'
16
- }
17
- },
18
- fields:['name', 'url','shortName']
19
- }),
20
- tpl: new Ext.XTemplate(
21
- '<tpl for=".">',
22
- '<div class="thumb-wrap" id="{name}">',
23
- '<div class="thumb"><img src="{url}" alt="{name}" class="thumb-img"></div>',
24
- '<span>{shortName}</span></div>',
25
- '</tpl>')
26
- }, config);
5
+ constructor : function(config) {
6
+ config = Ext.apply({
7
+ autoDestroy:true,
8
+ style:'overflow:auto',
9
+ itemSelector: 'div.thumb-wrap',
10
+ store: Ext.create('Ext.data.Store', {
11
+ proxy: {
12
+ type: 'ajax',
13
+ url: config['url'],
14
+ reader: {
15
+ type: 'json',
16
+ root: 'images'
17
+ }
18
+ },
19
+ fields:['name', 'url','shortName']
20
+ }),
21
+ tpl: new Ext.XTemplate(
22
+ '<tpl for=".">',
23
+ '<div class="thumb-wrap" id="{name}">',
24
+ '<div class="thumb"><img src="{url}" alt="{name}" class="thumb-img"></div>',
25
+ '<span>{shortName}</span></div>',
26
+ '</tpl>')
27
+ }, config);
27
28
 
28
- this.callParent([config]);
29
- }
29
+ this.callParent([config]);
30
+ }
30
31
  });
@@ -1,6 +1,8 @@
1
- Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel = function() {
2
- var self = this;
1
+ Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel = function(module) {
3
2
  this.websiteId = null;
3
+ var self = this;
4
+ self.module = module;
5
+
4
6
  this.sharedImageAssetsDataView = Ext.create("Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsDataView",{
5
7
  url: '/knitkit/erp_app/desktop/image_assets/shared/get_images'
6
8
  });
@@ -9,10 +11,6 @@ Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel = function() {
9
11
  });
10
12
 
11
13
  this.sharedImageAssetsTreePanel = Ext.create("Compass.ErpApp.Shared.FileManagerTree",{
12
- //TODO_EXTJS4 this is added to fix error should be removed when extjs 4 releases fix.
13
- viewConfig:{
14
- loadMask: false
15
- },
16
14
  region:'north',
17
15
  rootText:'Images',
18
16
  collapsible:true,
@@ -25,7 +23,79 @@ Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel = function() {
25
23
  url:'/knitkit/erp_app/desktop/image_assets/shared/expand_directory',
26
24
  containerScroll: true,
27
25
  height:200,
26
+ additionalContextMenuItems:[{
27
+ nodeType:'leaf',
28
+ text:'View Details',
29
+ iconCls:'icon-add',
30
+ listeners:{
31
+ scope:self,
32
+ 'click':function(){
33
+ var node = this.sharedImageAssetsTreePanel.selectedNode;
34
+ Ext.Msg.alert('Details', 'URL: /download/'+node.data.text+'?path='+node.data.downloadPath);
35
+ }
36
+ }
37
+ },
38
+ {
39
+ nodeType:'leaf',
40
+ text:'Insert link at cursor',
41
+ iconCls:'icon-add',
42
+ listeners:{
43
+ scope:self,
44
+ 'click':function(){
45
+ var node = this.sharedImageAssetsTreePanel.selectedNode;
46
+ Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
47
+ if(btn == 'ok'){
48
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'">'+text+'</a>');
49
+ }
50
+ });
51
+ }
52
+ }
53
+ },
54
+ {
55
+ nodeType:'leaf',
56
+ text:'Insert link at cursor (inline)',
57
+ iconCls:'icon-add',
58
+ listeners:{
59
+ scope:self,
60
+ 'click':function(){
61
+ var node = this.sharedImageAssetsTreePanel.selectedNode;
62
+ Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
63
+ if(btn == 'ok'){
64
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'&disposition=inline">'+text+'</a>');
65
+ }
66
+ });
67
+ }
68
+ }
69
+ },
70
+ {
71
+ nodeType:'leaf',
72
+ text:'Insert link at cursor (prompt)',
73
+ iconCls:'icon-add',
74
+ listeners:{
75
+ scope:self,
76
+ 'click':function(){
77
+ var node = this.sharedImageAssetsTreePanel.selectedNode;
78
+ Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
79
+ if(btn == 'ok'){
80
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'&disposition=attachment">'+text+'</a>');
81
+ }
82
+ });
83
+ }
84
+ }
85
+ }],
28
86
  listeners:{
87
+ 'allowdelete':function(){
88
+ return currentUser.hasApplicationCapability('knitkit', {
89
+ capability_type_iid:'delete',
90
+ resource:'GlobalImageAsset'
91
+ });
92
+ },
93
+ 'allowupload':function(){
94
+ return currentUser.hasApplicationCapability('knitkit', {
95
+ capability_type_iid:'upload',
96
+ resource:'GlobalImageAsset'
97
+ });
98
+ },
29
99
  'itemclick':function(view, record, item, index, e){
30
100
  e.stopEvent();
31
101
  if(!record.data["leaf"]){
@@ -47,16 +117,17 @@ Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel = function() {
47
117
  'fileUploaded':function(fileTreePanel, node){
48
118
  var store = self.sharedImageAssetsDataView.getStore();
49
119
  store.load();
50
- }
120
+ },
121
+ 'downloadfile':function(fileTreePanel, node){
122
+ window.open("/download/"+node.data.text+"?path=" + node.data.downloadPath+'&disposition=attachment','mywindow','width=400,height=200');
123
+ return false;
124
+ }
51
125
  }
52
126
  });
53
127
 
54
128
  this.websiteImageAssetsTreePanel = Ext.create("Compass.ErpApp.Shared.FileManagerTree",{
55
- //TODO_EXTJS4 this is added to fix error should be removed when extjs 4 releases fix.
129
+ autoLoadRoot:false,
56
130
  region:'north',
57
- viewConfig:{
58
- loadMask: false
59
- },
60
131
  rootText:'Images',
61
132
  collapsible:true,
62
133
  allowDownload:false,
@@ -68,6 +139,50 @@ Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel = function() {
68
139
  url:'/knitkit/erp_app/desktop/image_assets/website/expand_directory',
69
140
  containerScroll: true,
70
141
  height:200,
142
+ additionalContextMenuItems:[{
143
+ nodeType:'leaf',
144
+ text:'View Details',
145
+ iconCls:'icon-add',
146
+ listeners:{
147
+ scope:self,
148
+ 'click':function(){
149
+ var node = this.websiteImageAssetsTreePanel.selectedNode;
150
+ Ext.Msg.alert('Details', 'URL: /download/'+node.data.text+'?path='+node.data.downloadPath);
151
+ }
152
+ }
153
+ },
154
+ {
155
+ nodeType:'leaf',
156
+ text:'Insert link at cursor (prompt)',
157
+ iconCls:'icon-add',
158
+ listeners:{
159
+ scope:self,
160
+ 'click':function(){
161
+ var node = this.websiteImageAssetsTreePanel.selectedNode;
162
+ Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
163
+ if(btn == 'ok'){
164
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'">'+text+'</a>');
165
+ }
166
+ });
167
+ }
168
+ }
169
+ },
170
+ {
171
+ nodeType:'leaf',
172
+ text:'Insert link at cursor (prompt)',
173
+ iconCls:'icon-add',
174
+ listeners:{
175
+ scope:self,
176
+ 'click':function(){
177
+ var node = this.websiteImageAssetsTreePanel.selectedNode;
178
+ Ext.MessageBox.prompt('Display Name', 'Please enter display name:', function(btn, text){
179
+ if(btn == 'ok'){
180
+ self.module.centerRegion.insertHtmlIntoActiveCkEditor('<a href="/download/'+node.data.text+'?path='+node.data.downloadPath+'&disposition=attachment">'+text+'</a>');
181
+ }
182
+ });
183
+ }
184
+ }
185
+ }],
71
186
  listeners:{
72
187
  'itemclick':function(view, record, item, index, e){
73
188
  if(self.websiteId != null){
@@ -101,6 +216,10 @@ Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel = function() {
101
216
  website_id:self.websiteId
102
217
  }
103
218
  });
219
+ },
220
+ 'downloadfile':function(fileTreePanel, node){
221
+ window.open("/download/"+node.data.text+"?path=" + node.data.downloadPath+'&disposition=attachment','mywindow','width=400,height=200');
222
+ return false;
104
223
  }
105
224
  }
106
225
  });
@@ -130,31 +249,59 @@ Compass.ErpApp.Desktop.Applications.Knitkit.ImageAssetsPanel = function() {
130
249
  var websiteImagesLayout = Ext.create('Ext.panel.Panel',{
131
250
  layout: 'border',
132
251
  title:'Website',
133
- items: [this.websiteImageAssetsTreePanel, websiteImagesPanel]
252
+ items: [this.websiteImageAssetsTreePanel, websiteImagesPanel],
253
+ listeners:{
254
+ scope:self,
255
+ 'show': function(){
256
+ self.reloadWebsiteImageAssetsTreePanel(self.websiteId);
257
+ }
258
+ }
134
259
  });
135
260
 
261
+ var items = [];
262
+ if (currentUser.hasApplicationCapability('knitkit', {
263
+ capability_type_iid:'view',
264
+ resource:'GlobalImageAsset'
265
+ }))
266
+
267
+ {
268
+ items.push(sharedImagesLayout);
269
+ }
270
+
271
+ if (currentUser.hasApplicationCapability('knitkit', {
272
+ capability_type_iid:'view',
273
+ resource:'SiteImageAsset'
274
+ }))
275
+
276
+ {
277
+ items.push(websiteImagesLayout);
278
+ }
279
+
136
280
  this.layout = Ext.create('Ext.panel.Panel',{
137
281
  layout:'fit',
138
282
  title:'Images',
139
283
  items: Ext.create('Ext.tab.Panel',{
140
- items: [sharedImagesLayout, websiteImagesLayout]
284
+ items: items
141
285
  })
142
286
  });
143
287
 
144
288
  this.selectWebsite = function(websiteId){
145
289
  this.websiteId = websiteId;
290
+ }
291
+
292
+ this.reloadWebsiteImageAssetsTreePanel = function(websiteId){
146
293
  this.websiteImageAssetsTreePanel.extraPostData = {
147
- website_id:websiteId
294
+ website_id:websiteId,
295
+ websiteid:websiteId // for xhrFileUpload to work
148
296
  };
149
- var store = this.websiteImageAssetsTreePanel.getStore();
150
- store.load({
151
- params:{
297
+ this.websiteImageAssetsTreePanel.getStore().setProxy({
298
+ type: 'ajax',
299
+ url:'/knitkit/erp_app/desktop/image_assets/website/expand_directory',
300
+ extraParams:{
152
301
  website_id:websiteId
153
302
  }
154
303
  });
304
+ this.websiteImageAssetsTreePanel.getStore().load();
155
305
  this.websiteImageAssetsDataView.getStore().removeAll();
156
306
  }
157
307
  }
158
-
159
-
160
-