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.InquiriesGridPanel",{
4
4
  deleteInquiry : function(rec){
5
5
  var self = this;
6
6
  Ext.getCmp('knitkitCenterRegion').setWindowStatus('Deleting inquiry...');
7
- var conn = new Ext.data.Connection();
8
- conn.request({
7
+ Ext.Ajax.request({
9
8
  url: '/knitkit/erp_app/desktop/inquiries/delete',
10
9
  method: 'POST',
11
10
  params:{
@@ -11,13 +11,17 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit",{
11
11
  },
12
12
 
13
13
  createWindow : function(){
14
+ //***********************************************************
15
+ //Might get rid of this or make it an option you can select
16
+ var title = 'KnitKit-' + currentUser.description
17
+ //***********************************************************
14
18
  var desktop = this.app.getDesktop();
15
19
  var win = desktop.getWindow('knitkit');
16
20
  this.centerRegion = new Compass.ErpApp.Desktop.Applications.Knitkit.CenterRegion();
17
21
  if(!win){
18
22
  win = desktop.createWindow({
19
23
  id: 'knitkit',
20
- title:'KnitKit',
24
+ title:title,
21
25
  autoDestroy:true,
22
26
  width:1200,
23
27
  height:550,
@@ -20,8 +20,8 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.PublishWindow",{
20
20
  "publish_failure"
21
21
  );
22
22
 
23
- Compass.ErpApp.Desktop.Applications.Knitkit.PublishWindow.superclass.initComponent.call(this, arguments);
24
- },
23
+ this.callParent(arguments);
24
+ },
25
25
 
26
26
  constructor : function(config) {
27
27
  config = Ext.apply({
@@ -8,9 +8,9 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.PublishedGridPanel",{
8
8
 
9
9
  activate : function(rec){
10
10
  var self = this;
11
- var conn = new Ext.data.Connection();
12
- conn.request({
11
+ Ext.Ajax.request({
13
12
  url: '/knitkit/erp_app/desktop/site/activate_publication',
13
+ timeout: 90000,
14
14
  method: 'POST',
15
15
  params:{
16
16
  id:self.initialConfig.siteId,
@@ -18,11 +18,17 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.PublishedGridPanel",{
18
18
  },
19
19
  success: function(response) {
20
20
  var obj = Ext.decode(response.responseText);
21
+ var msg = "";
22
+ if (obj.msg){
23
+ msg = obj.msg;
24
+ }else{
25
+ msg = 'Error activating publication';
26
+ }
21
27
  if(obj.success){
22
28
  self.getStore().load();
23
29
  }
24
30
  else{
25
- Ext.Msg.alert('Error', 'Error activating publication');
31
+ Ext.Msg.alert('Error', msg);
26
32
  }
27
33
  },
28
34
  failure: function(response) {
@@ -33,8 +39,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.PublishedGridPanel",{
33
39
 
34
40
  setViewingVersion : function(rec){
35
41
  var self = this;
36
- var conn = new Ext.data.Connection();
37
- conn.request({
42
+ Ext.Ajax.request({
38
43
  url: '/knitkit/erp_app/desktop/site/set_viewing_version',
39
44
  method: 'POST',
40
45
  params:{
@@ -111,19 +116,19 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.PublishedGridPanel",{
111
116
  {
112
117
  header: "Version",
113
118
  sortable:true,
114
- width: 60,
119
+ width: 45,
115
120
  dataIndex: 'version'
116
121
  },
117
122
  {
118
123
  header: "Published",
119
- width: 130,
124
+ width: 117,
120
125
  sortable:true,
121
126
  renderer: Ext.util.Format.dateRenderer('m/d/Y H:i:s'),
122
127
  dataIndex: 'created_at'
123
128
  },
124
129
  {
125
130
  header: "Published By",
126
- width: 130,
131
+ width: 72,
127
132
  sortable:true,
128
133
  dataIndex: 'published_by_username'
129
134
  },
@@ -133,7 +138,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.PublishedGridPanel",{
133
138
  xtype:'actioncolumn',
134
139
  header:'Viewing',
135
140
  align:'center',
136
- width:50,
141
+ width:46,
137
142
  items:[{
138
143
  getClass: function(v, meta, rec) { // Or return a class from a function
139
144
  if (rec.get('viewing')) {
@@ -161,7 +166,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.PublishedGridPanel",{
161
166
  xtype:'actioncolumn',
162
167
  header:'Active',
163
168
  align:'center',
164
- width:50,
169
+ width:44,
165
170
  items:[{
166
171
  getClass: function(v, meta, rec) { // Or return a class from a function
167
172
  if (rec.get('active')) {
@@ -173,7 +178,11 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.PublishedGridPanel",{
173
178
  }
174
179
  },
175
180
  handler: function(grid, rowIndex, colIndex) {
176
- if(currentUser.hasRole(['admin','publisher'])){
181
+ if (currentUser.hasApplicationCapability('knitkit', {
182
+ capability_type_iid:'activate',
183
+ resource:'Website'
184
+ }))
185
+ {
177
186
  var rec = grid.getStore().getAt(rowIndex);
178
187
  if(rec.get('active')){
179
188
  return false;
@@ -1,15 +1,15 @@
1
1
  Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel",{
2
2
  extend:"Ext.grid.Panel",
3
3
  alias:'widget.knitkit_sectionarticlesgridpanel',
4
- deleteArticle : function(id){
4
+ detachArticle : function(article_id){
5
5
  var self = this;
6
- this.initialConfig['centerRegion'].setWindowStatus('Deleting...');
7
- var conn = new Ext.data.Connection();
8
- conn.request({
9
- url: '/knitkit/erp_app/desktop/articles/delete',
6
+ this.initialConfig['centerRegion'].setWindowStatus('Detaching...');
7
+ Ext.Ajax.request({
8
+ url: '/knitkit/erp_app/desktop/section/detach_article',
10
9
  method: 'POST',
11
10
  params:{
12
- id:id
11
+ id:self.initialConfig['sectionId'],
12
+ article_id:article_id
13
13
  },
14
14
  success: function(response) {
15
15
  var obj = Ext.decode(response.responseText);
@@ -18,13 +18,13 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
18
18
  self.getStore().load();
19
19
  }
20
20
  else{
21
- Ext.Msg.alert('Error', 'Error deleting Article');
21
+ Ext.Msg.alert('Error', 'Error detaching Article');
22
22
  self.initialConfig['centerRegion'].clearWindowStatus();
23
23
  }
24
24
  },
25
25
  failure: function(response) {
26
26
  self.initialConfig['centerRegion'].clearWindowStatus();
27
- Ext.Msg.alert('Error', 'Error deleting Article');
27
+ Ext.Msg.alert('Error', 'Error detaching Article');
28
28
  }
29
29
  });
30
30
  },
@@ -69,7 +69,6 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
69
69
  inputValue: 'yes',
70
70
  checked:record.get('display_title')
71
71
  },
72
-
73
72
  {
74
73
  boxLabel:'No',
75
74
  name:'display_title',
@@ -84,7 +83,19 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
84
83
  name:'internal_identifier',
85
84
  value: record.get('internal_identifier')
86
85
  },
87
- addFormItems
86
+ addFormItems,
87
+ {
88
+ xtype: 'displayfield',
89
+ fieldLabel: 'Created At',
90
+ name: 'created_at',
91
+ value: record.data.created_at
92
+ },
93
+ {
94
+ xtype: 'displayfield',
95
+ fieldLabel: 'Updated At',
96
+ name: 'updated_at',
97
+ value: record.data.updated_at
98
+ }
88
99
  ]
89
100
  },
90
101
  listeners:{
@@ -163,6 +174,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
163
174
 
164
175
  // create the Data Store
165
176
  var store = Ext.create('Ext.data.Store', {
177
+ pageSize: 10,
166
178
  proxy: {
167
179
  type: 'ajax',
168
180
  url:'/knitkit/erp_app/desktop/articles/get/' + sectionId,
@@ -199,6 +211,12 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
199
211
  },
200
212
  {
201
213
  name:'display_title'
214
+ },
215
+ {
216
+ name:'created_at'
217
+ },
218
+ {
219
+ name:'updated_at'
202
220
  }
203
221
  ]
204
222
  });
@@ -208,76 +226,88 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
208
226
  sortable:true,
209
227
  dataIndex:'title',
210
228
  width:110
211
- },{
212
- header:'Unique Name',
213
- sortable:true,
214
- dataIndex:'internal_identifier',
215
- width:110,
216
- editable:false
217
229
  }];
218
230
 
219
231
  if(!Compass.ErpApp.Utility.isBlank(config['columns'])){
220
232
  overiddenColumns = overiddenColumns.concat(config['columns']);
221
233
  }
222
234
 
223
- overiddenColumns = overiddenColumns.concat([
224
- {
225
- menuDisabled:true,
226
- resizable:false,
227
- xtype:'actioncolumn',
228
- header:'HTML',
229
- align:'center',
230
- width:40,
231
- items:[{
232
- icon:'/images/icons/edit/edit_16x16.png',
233
- tooltip:'Edit',
234
- handler :function(grid, rowIndex, colIndex){
235
- var rec = grid.getStore().getAt(rowIndex);
236
- self.initialConfig['centerRegion'].editContent(rec.get('title'), rec.get('id'), rec.get('body_html'), grid.ownerCt.initialConfig.siteId, grid.ownerCt.initialConfig.contentType, grid.getStore());
237
- }
238
- }]
239
- },
240
- {
241
- menuDisabled:true,
242
- resizable:false,
243
- xtype:'actioncolumn',
244
- header:'Edit',
245
- align:'center',
246
- width:40,
247
- items:[{
248
- icon:'/images/icons/edit/edit_16x16.png',
249
- tooltip:'Edit',
250
- handler :function(grid, rowIndex, colIndex){
251
- var rec = grid.getStore().getAt(rowIndex);
252
- self.editArticle(rec);
253
- }
254
- }]
255
- },
256
- {
257
- menuDisabled:true,
258
- resizable:false,
259
- xtype:'actioncolumn',
260
- header:'Delete',
261
- align:'center',
262
- width:40,
263
- items:[{
264
- icon:'/images/icons/delete/delete_16x16.png',
265
- tooltip:'Delete',
266
- handler :function(grid, rowIndex, colIndex){
267
- var rec = grid.getStore().getAt(rowIndex);
268
- var id = rec.get('id');
269
- var messageBox = Ext.MessageBox.confirm(
270
- 'Confirm', 'Are you sure?',
271
- function(btn){
272
- if (btn == 'yes'){
273
- self.deleteArticle(id);
235
+ overiddenColumns = overiddenColumns.concat([
236
+ {
237
+ menuDisabled:true,
238
+ resizable:false,
239
+ xtype:'actioncolumn',
240
+ header:'HTML',
241
+ align:'center',
242
+ width:40,
243
+ items:[{
244
+ icon:'/images/icons/edit/edit_16x16.png',
245
+ tooltip:'Edit',
246
+ handler :function(grid, rowIndex, colIndex){
247
+ var rec = grid.getStore().getAt(rowIndex);
248
+ self.initialConfig['centerRegion'].editContent(rec.get('title'), rec.get('id'), rec.get('body_html'), grid.ownerCt.initialConfig.siteId, grid.ownerCt.initialConfig.contentType, grid.getStore());
274
249
  }
275
- }
276
- );
277
- }
278
- }]
279
- }
280
- ]);
250
+ }]
251
+ }]);
252
+
253
+ if (currentUser.hasApplicationCapability('knitkit', {
254
+ capability_type_iid:'edit',
255
+ resource:'Article'
256
+ }))
257
+
258
+ {
259
+ overiddenColumns = overiddenColumns.concat([
260
+ {
261
+ menuDisabled:true,
262
+ resizable:false,
263
+ xtype:'actioncolumn',
264
+ header:'Edit',
265
+ align:'center',
266
+ width:40,
267
+ items:[{
268
+ icon:'/images/icons/edit/edit_16x16.png',
269
+ tooltip:'Edit Attributes',
270
+ handler :function(grid, rowIndex, colIndex){
271
+ var rec = grid.getStore().getAt(rowIndex);
272
+ self.editArticle(rec);
273
+ }
274
+ }]
275
+ }]);
276
+ }
277
+
278
+ if (currentUser.hasApplicationCapability('knitkit', {
279
+ capability_type_iid:'delete',
280
+ resource:'Article'
281
+ }))
282
+
283
+ {
284
+ overiddenColumns = overiddenColumns.concat([
285
+ {
286
+ menuDisabled:true,
287
+ resizable:false,
288
+ xtype:'actioncolumn',
289
+ header:'Detach',
290
+ align:'center',
291
+ width:40,
292
+ items:[{
293
+ icon:'/images/icons/delete/delete_16x16.png',
294
+ tooltip:'Delete Article from Section',
295
+ handler :function(grid, rowIndex, colIndex){
296
+ var rec = grid.getStore().getAt(rowIndex);
297
+ var id = rec.get('id');
298
+ var messageBox = Ext.MessageBox.confirm(
299
+ 'Confirm', 'Are you sure? NOTE: Article may be orphaned',
300
+ function(btn){
301
+ if (btn == 'yes'){
302
+ self.detachArticle(id);
303
+ }
304
+ }
305
+ );
306
+ }
307
+ }]
308
+ }
309
+ ]);
310
+ }
281
311
 
282
312
  var addFormItems = [
283
313
  {
@@ -316,166 +346,187 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.SectionArticlesGridPanel
316
346
  if(!Compass.ErpApp.Utility.isBlank(config['addFormItems'])){
317
347
  addFormItems = addFormItems.concat(config['addFormItems']);
318
348
  }
319
-
320
- config['columns'] = overiddenColumns;
321
- config = Ext.apply({
322
- store:store,
323
- tbar: [{
324
- text: 'Add New Article',
325
- iconCls: 'icon-add',
326
- handler : function(){
327
- var addArticleWindow = new Ext.Window({
328
- layout:'fit',
329
- width:375,
330
- title:'New Article',
331
- plain: true,
332
- buttonAlign:'center',
333
- items: new Ext.FormPanel({
334
- labelWidth: 110,
335
- frame:false,
336
- bodyStyle:'padding:5px 5px 0',
337
- width: 425,
338
- url:'/knitkit/erp_app/desktop/articles/new/' + self.initialConfig['sectionId'],
339
- defaults: {
340
- width: 225
341
- },
342
- items: addFormItems
343
- }),
344
- buttons: [{
345
- text:'Submit',
346
- listeners:{
347
- 'click':function(button){
348
- var window = button.findParentByType('window');
349
- var formPanel = window.query('form')[0];
350
- self.initialConfig['centerRegion'].setWindowStatus('Creating article...');
351
- formPanel.getForm().submit({
352
- reset:true,
353
- success:function(form, action){
354
- self.initialConfig['centerRegion'].clearWindowStatus();
355
- var obj = Ext.decode(action.response.responseText);
356
- if(obj.success){
357
- self.getStore().load();
358
- }
359
- else{
360
- Ext.Msg.alert("Error", obj.msg);
361
- }
362
- addArticleWindow.close();
363
-
364
- },
365
- failure:function(form, action){
366
- self.initialConfig['centerRegion'].clearWindowStatus();
367
- Ext.Msg.alert("Error", "Error creating article");
368
- }
369
- });
349
+
350
+ var tbarItems = [];
351
+
352
+ if (currentUser.hasApplicationCapability('knitkit', {
353
+ capability_type_iid:'create',
354
+ resource:'Article'
355
+ }))
356
+
357
+ {
358
+ tbarItems.push(
359
+ {
360
+ text: 'New Article',
361
+ iconCls: 'icon-add',
362
+ handler : function(){
363
+ var addArticleWindow = new Ext.Window({
364
+ layout:'fit',
365
+ width:375,
366
+ title:'New Article',
367
+ plain: true,
368
+ buttonAlign:'center',
369
+ items: new Ext.FormPanel({
370
+ labelWidth: 110,
371
+ frame:false,
372
+ bodyStyle:'padding:5px 5px 0',
373
+ width: 425,
374
+ url:'/knitkit/erp_app/desktop/articles/new/' + self.initialConfig['sectionId'],
375
+ defaults: {
376
+ width: 257
377
+ },
378
+ items: addFormItems
379
+ }),
380
+ buttons: [{
381
+ text:'Submit',
382
+ listeners:{
383
+ 'click':function(button){
384
+ var window = button.findParentByType('window');
385
+ var formPanel = window.query('form')[0];
386
+ self.initialConfig['centerRegion'].setWindowStatus('Creating article...');
387
+ formPanel.getForm().submit({
388
+ reset:true,
389
+ success:function(form, action){
390
+ self.initialConfig['centerRegion'].clearWindowStatus();
391
+ var obj = Ext.decode(action.response.responseText);
392
+ if(obj.success){
393
+ self.getStore().load();
394
+ }
395
+ else{
396
+ Ext.Msg.alert("Error", obj.msg);
397
+ }
398
+ addArticleWindow.close();
399
+
400
+ },
401
+ failure:function(form, action){
402
+ self.initialConfig['centerRegion'].clearWindowStatus();
403
+ Ext.Msg.alert("Error", "Error creating article");
404
+ }
405
+ });
406
+ }
407
+ }
408
+ },{
409
+ text: 'Close',
410
+ handler: function(){
411
+ addArticleWindow.close();
412
+ }
413
+ }]
414
+ });
415
+ addArticleWindow.show();
370
416
  }
371
- }
372
- },{
373
- text: 'Close',
374
- handler: function(){
375
- addArticleWindow.close();
376
- }
377
- }]
378
- });
379
- addArticleWindow.show();
417
+ });
380
418
  }
381
- },
382
- {
383
- text: 'Add Existing Article',
384
- iconCls: 'icon-copy',
385
- handler : function(){
386
- var addExistingArticleWindow = new Ext.Window({
387
- layout:'fit',
388
- width:375,
389
- title:'Add Existing Article',
390
- height:100,
391
- plain: true,
392
- buttonAlign:'center',
393
- items: new Ext.FormPanel({
394
- labelWidth: 75,
395
- frame:false,
396
- bodyStyle:'padding:5px 5px 0',
397
- width: 425,
398
- url:'/knitkit/erp_app/desktop/articles/add_existing/' + self.initialConfig['sectionId'],
399
- items:[
400
- {
401
- xtype:'combo',
402
- hiddenName:'article_id',
403
- name:'article_id',
404
- labelWidth: 50,
405
- width:200,
406
- loadingText:'Retrieving Articles...',
407
- store:Ext.create('Ext.data.Store',{
408
- proxy:{
409
- type:'ajax',
410
- reader:{
411
- type:'json',
412
- root:'articles'
413
- },
414
- extraParams:{
415
- section_id:self.initialConfig['sectionId']
416
- },
417
- url:'/knitkit/erp_app/desktop/section/available_articles'
418
- },
419
- fields:[
420
- {
421
- name:'id'
422
- },
423
- {
424
- name:'internal_identifier'
425
419
 
426
- }
427
- ]
428
- }),
429
- forceSelection:true,
430
- editable:true,
431
- fieldLabel:'Article',
432
- autoSelect:true,
433
- typeAhead: true,
434
- mode: 'remote',
435
- displayField:'internal_identifier',
436
- valueField:'id',
437
- triggerAction: 'all',
438
- allowBlank:false
439
- }
440
- ]
441
- }),
442
- buttons: [{
443
- text:'Submit',
444
- listeners:{
445
- 'click':function(button){
446
- var window = button.findParentByType('window');
447
- var formPanel = window.query('form')[0];
448
- self.initialConfig['centerRegion'].setWindowStatus('Adding article...');
449
- formPanel.getForm().submit({
450
- reset:true,
451
- success:function(form, action){
452
- self.initialConfig['centerRegion'].clearWindowStatus();
453
- var obj = Ext.decode(action.response.responseText);
454
- if(obj.success){
455
- self.getStore().load();
456
- }else{
457
- Ext.Msg.alert("Error", "Error Adding article");
458
- }
459
- },
460
- failure:function(form, action){
461
- self.initialConfig['centerRegion'].clearWindowStatus();
462
- Ext.Msg.alert("Error", "Error Adding article");
463
- }
464
- });
420
+ if (currentUser.hasApplicationCapability('knitkit', {
421
+ capability_type_iid:'add_existing',
422
+ resource:'Article'
423
+ }))
424
+
425
+ {
426
+ tbarItems.push(
427
+ {
428
+ text: 'Attach Article',
429
+ iconCls: 'icon-copy',
430
+ handler : function(){
431
+ var addExistingArticleWindow = new Ext.Window({
432
+ layout:'fit',
433
+ width:375,
434
+ title:'Add Existing Article',
435
+ height:100,
436
+ plain: true,
437
+ buttonAlign:'center',
438
+ items: new Ext.FormPanel({
439
+ labelWidth: 75,
440
+ frame:false,
441
+ bodyStyle:'padding:5px 5px 0',
442
+ width: 425,
443
+ url:'/knitkit/erp_app/desktop/articles/add_existing/' + self.initialConfig['sectionId'],
444
+ items:[
445
+ {
446
+ xtype:'combo',
447
+ hiddenName:'article_id',
448
+ name:'article_id',
449
+ labelWidth: 50,
450
+ width:200,
451
+ loadingText:'Retrieving Articles...',
452
+ store:Ext.create('Ext.data.Store',{
453
+ proxy:{
454
+ type:'ajax',
455
+ reader:{
456
+ type:'json',
457
+ root:'articles'
458
+ },
459
+ extraParams:{
460
+ section_id:self.initialConfig['sectionId']
461
+ },
462
+ url:'/knitkit/erp_app/desktop/section/available_articles'
463
+ },
464
+ fields:[
465
+ {
466
+ name:'id'
467
+ },
468
+ {
469
+ name:'internal_identifier'
470
+
471
+ }
472
+ ]
473
+ }),
474
+ forceSelection:true,
475
+ editable:true,
476
+ fieldLabel:'Article',
477
+ autoSelect:true,
478
+ typeAhead: true,
479
+ mode: 'remote',
480
+ displayField:'internal_identifier',
481
+ valueField:'id',
482
+ triggerAction: 'all',
483
+ allowBlank:false
484
+ }
485
+ ]
486
+ }),
487
+ buttons: [{
488
+ text:'Submit',
489
+ listeners:{
490
+ 'click':function(button){
491
+ var window = button.findParentByType('window');
492
+ var formPanel = window.query('form')[0];
493
+ self.initialConfig['centerRegion'].setWindowStatus('Adding article...');
494
+ formPanel.getForm().submit({
495
+ reset:true,
496
+ success:function(form, action){
497
+ self.initialConfig['centerRegion'].clearWindowStatus();
498
+ var obj = Ext.decode(action.response.responseText);
499
+ if(obj.success){
500
+ self.getStore().load();
501
+ }else{
502
+ Ext.Msg.alert("Error", "Error Adding article");
503
+ }
504
+ },
505
+ failure:function(form, action){
506
+ self.initialConfig['centerRegion'].clearWindowStatus();
507
+ Ext.Msg.alert("Error", "Error Adding article");
508
+ }
509
+ });
510
+ }
511
+ }
512
+ },{
513
+ text: 'Close',
514
+ handler: function(){
515
+ addExistingArticleWindow.close();
516
+ }
517
+ }]
518
+ });
519
+ addExistingArticleWindow.show();
465
520
  }
466
- }
467
- },{
468
- text: 'Close',
469
- handler: function(){
470
- addExistingArticleWindow.close();
471
- }
472
- }]
473
- });
474
- addExistingArticleWindow.show();
521
+ }
522
+ );
475
523
  }
476
- }],
524
+
525
+ config['columns'] = overiddenColumns;
526
+ config = Ext.apply({
527
+ store:store,
528
+ tbar: tbarItems,
477
529
  bbar: new Ext.PagingToolbar({
478
- pageSize: 10,
479
530
  store: store,
480
531
  displayInfo: true,
481
532
  displayMsg: '{0} - {1} of {2}',
@@ -599,7 +650,7 @@ Ext.define("Compass.ErpApp.Desktop.Applications.Knitkit.BlogArticlesGridPanel",{
599
650
  width:50,
600
651
  items:[{
601
652
  icon:'/images/icons/edit/edit_16x16.png',
602
- tooltip:'Edit',
653
+ tooltip:'Edit Excerpt',
603
654
  handler :function(grid, rowIndex, colIndex){
604
655
  var rec = grid.getStore().getAt(rowIndex);
605
656
  self.initialConfig['centerRegion'].editExcerpt(rec.get('title') + ' - Excerpt', rec.get('id'), rec.get('excerpt_html'), self.initialConfig.siteId, grid.getStore());