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
@@ -0,0 +1,399 @@
1
+ Compass.ErpApp.Desktop.Applications.Knitkit.addSectionOptions = function (self, items, record) {
2
+ items.push({
3
+ text:'View Articles',
4
+ iconCls:'icon-document',
5
+ listeners:{
6
+ 'click':function () {
7
+ self.getArticles(record);
8
+ }
9
+ }
10
+ });
11
+
12
+ if (record.data.isSecured) {
13
+ if (currentUser.hasApplicationCapability('knitkit', {
14
+ capability_type_iid:'unsecure',
15
+ resource:'Section'
16
+ })) {
17
+ items.push({
18
+ text:'Unsecure',
19
+ iconCls:'icon-document',
20
+ listeners:{
21
+ 'click':function () {
22
+ self.changeSecurityOnSection(record, false);
23
+ }
24
+ }
25
+ });
26
+ }
27
+ }
28
+ else {
29
+ if (currentUser.hasApplicationCapability('knitkit', {
30
+ capability_type_iid:'secure',
31
+ resource:'Section'
32
+ })) {
33
+ items.push({
34
+ text:'Secure',
35
+ iconCls:'icon-document_lock',
36
+ listeners:{
37
+ 'click':function () {
38
+ self.changeSecurityOnSection(record, true);
39
+ }
40
+ }
41
+ });
42
+ }
43
+ }
44
+
45
+ if (currentUser.hasApplicationCapability('knitkit', {
46
+ capability_type_iid:'create',
47
+ resource:'Section'
48
+ })) {
49
+ items.push({
50
+ text:'Add Section',
51
+ iconCls:'icon-add',
52
+ listeners:{
53
+ 'click':function () {
54
+ var addSectionWindow = Ext.create("Ext.window.Window", {
55
+ layout:'fit',
56
+ width:375,
57
+ title:'New Section',
58
+ plain:true,
59
+ buttonAlign:'center',
60
+ items:new Ext.FormPanel({
61
+ labelWidth:110,
62
+ frame:false,
63
+ bodyStyle:'padding:5px 5px 0',
64
+ url:'/knitkit/erp_app/desktop/section/new',
65
+ defaults:{
66
+ width:225
67
+ },
68
+ items:[
69
+ {
70
+ xtype:'textfield',
71
+ fieldLabel:'Title',
72
+ allowBlank:false,
73
+ name:'title'
74
+ },
75
+ {
76
+ xtype:'textfield',
77
+ fieldLabel:'Unique Name',
78
+ allowBlank:true,
79
+ name:'internal_identifier'
80
+ },
81
+ {
82
+ xtype:'combo',
83
+ forceSelection:true,
84
+ store:[
85
+ ['Page', 'Page'],
86
+ ['Blog', 'Blog']
87
+ ],
88
+ value:'Page',
89
+ fieldLabel:'Type',
90
+ name:'type',
91
+ allowBlank:false,
92
+ triggerAction:'all'
93
+ },
94
+ {
95
+ xtype:'radiogroup',
96
+ fieldLabel:'Display in menu?',
97
+ name:'in_menu',
98
+ columns:2,
99
+ items:[
100
+ {
101
+ boxLabel:'Yes',
102
+ name:'in_menu',
103
+ inputValue:'yes',
104
+ checked:true
105
+ },
106
+
107
+ {
108
+ boxLabel:'No',
109
+ name:'in_menu',
110
+ inputValue:'no'
111
+ }
112
+ ]
113
+ },
114
+ {
115
+ xtype:'radiogroup',
116
+ fieldLabel:'Render with Base Layout?',
117
+ name:'render_with_base_layout',
118
+ columns:2,
119
+ items:[
120
+ {
121
+ boxLabel:'Yes',
122
+ name:'render_with_base_layout',
123
+ inputValue:'yes',
124
+ checked:true
125
+ },
126
+
127
+ {
128
+ boxLabel:'No',
129
+ name:'render_with_base_layout',
130
+ inputValue:'no'
131
+ }
132
+ ]
133
+ },
134
+ {
135
+ xtype:'hidden',
136
+ name:'website_section_id',
137
+ value:record.data.id.split('_')[1]
138
+ },
139
+ {
140
+ xtype:'hidden',
141
+ name:'website_id',
142
+ value:record.data.siteId
143
+ }
144
+ ]
145
+ }),
146
+ buttons:[
147
+ {
148
+ text:'Submit',
149
+ listeners:{
150
+ 'click':function (button) {
151
+ var window = button.findParentByType('window');
152
+ var formPanel = window.query('.form')[0];
153
+ self.setWindowStatus('Creating section...');
154
+ formPanel.getForm().submit({
155
+ reset:true,
156
+ success:function (form, action) {
157
+ self.clearWindowStatus();
158
+ var obj = Ext.decode(action.response.responseText);
159
+ if (obj.success) {
160
+ record.appendChild(obj.node);
161
+ }
162
+ else {
163
+ Ext.Msg.alert("Error", obj.message);
164
+ }
165
+ },
166
+ failure:function (form, action) {
167
+ self.clearWindowStatus();
168
+ var obj = Ext.decode(action.response.responseText);
169
+ if (obj.message) {
170
+ Ext.Msg.alert("Error", obj.message);
171
+ }
172
+ else {
173
+ Ext.Msg.alert("Error", "Error creating section.");
174
+ }
175
+ }
176
+ });
177
+ }
178
+ }
179
+ },
180
+ {
181
+ text:'Close',
182
+ handler:function () {
183
+ addSectionWindow.close();
184
+ }
185
+ }
186
+ ]
187
+ });
188
+ addSectionWindow.show();
189
+ }
190
+ }
191
+ });
192
+ }
193
+
194
+ if (currentUser.hasApplicationCapability('knitkit', {
195
+ capability_type_iid:'edit',
196
+ resource:'Section'
197
+ })) {
198
+ items.push({
199
+ text:'Update Section',
200
+ iconCls:'icon-edit',
201
+ listeners:{
202
+ 'click':function () {
203
+ var updateSectionWindow = Ext.create("Ext.window.Window", {
204
+ layout:'fit',
205
+ width:375,
206
+ title:'Update Section',
207
+ plain:true,
208
+ buttonAlign:'center',
209
+ items:new Ext.FormPanel({
210
+ labelWidth:110,
211
+ frame:false,
212
+ bodyStyle:'padding:5px 5px 0',
213
+ url:'/knitkit/erp_app/desktop/section/update',
214
+ defaults:{
215
+ width:225
216
+ },
217
+ items:[
218
+ {
219
+ xtype:'textfield',
220
+ fieldLabel:'Title',
221
+ value:record.data.text,
222
+ name:'title'
223
+ },
224
+ {
225
+ xtype:'textfield',
226
+ fieldLabel:'Unique Name',
227
+ allowBlank:true,
228
+ name:'internal_identifier',
229
+ value:record.data.internal_identifier
230
+ },
231
+ {
232
+ xtype:'radiogroup',
233
+ fieldLabel:'Display in menu?',
234
+ name:'in_menu',
235
+ columns:2,
236
+ items:[
237
+ {
238
+ boxLabel:'Yes',
239
+ name:'in_menu',
240
+ inputValue:'yes',
241
+ checked:record.data.inMenu
242
+ },
243
+
244
+ {
245
+ boxLabel:'No',
246
+ name:'in_menu',
247
+ inputValue:'no',
248
+ checked:!record.data.inMenu
249
+ }
250
+ ]
251
+ },
252
+ {
253
+ xtype:'radiogroup',
254
+ fieldLabel:'Render with Base Layout?',
255
+ name:'render_with_base_layout',
256
+ columns:2,
257
+ items:[
258
+ {
259
+ boxLabel:'Yes',
260
+ name:'render_with_base_layout',
261
+ inputValue:'yes',
262
+ checked:record.data.renderWithBaseLayout
263
+ },
264
+
265
+ {
266
+ boxLabel:'No',
267
+ name:'render_with_base_layout',
268
+ inputValue:'no',
269
+ checked:!record.data.renderWithBaseLayout
270
+ }
271
+ ]
272
+ },
273
+ {
274
+ xtype:'displayfield',
275
+ fieldLabel:'Path',
276
+ name:'path',
277
+ value:record.data.path
278
+ },
279
+ {
280
+ xtype:'hidden',
281
+ name:'id',
282
+ value:record.data.id.split('_')[1]
283
+ }
284
+ ]
285
+ }),
286
+ buttons:[
287
+ {
288
+ text:'Submit',
289
+ listeners:{
290
+ 'click':function (button) {
291
+ var window = button.findParentByType('window');
292
+ var formPanel = window.query('.form')[0];
293
+ self.setWindowStatus('Updating section...');
294
+ formPanel.getForm().submit({
295
+ success:function (form, action) {
296
+ self.clearWindowStatus();
297
+ var values = formPanel.getValues();
298
+ record.set('title', values.title);
299
+ record.set('text', values.title);
300
+ record.set('internal_identifier', values.internal_identifier);
301
+ record.set("inMenu", (values.in_menu == 'yes'));
302
+ record.set("renderWithBaseLayout", (values.render_with_base_layout == 'yes'));
303
+ record.commit();
304
+ updateSectionWindow.close();
305
+ },
306
+ failure:function (form, action) {
307
+ self.clearWindowStatus();
308
+ var obj = Ext.decode(action.response.responseText);
309
+ Ext.Msg.alert("Error", obj.msg);
310
+ }
311
+ });
312
+ }
313
+ }
314
+ },
315
+ {
316
+ text:'Close',
317
+ handler:function () {
318
+ updateSectionWindow.close();
319
+ }
320
+ }
321
+ ]
322
+ });
323
+ updateSectionWindow.show();
324
+ }
325
+ }
326
+ });
327
+ }
328
+
329
+ //no layouts for blogs.
330
+ if (Compass.ErpApp.Utility.isBlank(record.data['isBlog']) && record.data['hasLayout']) {
331
+ if (currentUser.hasApplicationCapability('knitkit', {
332
+ capability_type_iid:'edit',
333
+ resource:'Layout'
334
+ })) {
335
+ items.push({
336
+ text:'Edit Layout',
337
+ iconCls:'icon-edit',
338
+ listeners:{
339
+ 'click':function () {
340
+ self.editSectionLayout(record.data.text, record.data.id.split('_')[1], record.data.siteId);
341
+ }
342
+ }
343
+ });
344
+ }
345
+ }
346
+ else if (Compass.ErpApp.Utility.isBlank(record.data['isBlog'])) {
347
+ if (currentUser.hasApplicationCapability('knitkit', {
348
+ capability_type_iid:'create',
349
+ resource:'Layout'
350
+ })) {
351
+ items.push({
352
+ text:'Add Layout',
353
+ iconCls:'icon-add',
354
+ listeners:{
355
+ 'click':function () {
356
+ var sectionId = record.data.id.split('_')[1];
357
+ Ext.Ajax.request({
358
+ url:'/knitkit/erp_app/desktop/section/add_layout',
359
+ method:'POST',
360
+ params:{
361
+ id:sectionId
362
+ },
363
+ success:function (response) {
364
+ var obj = Ext.decode(response.responseText);
365
+ if (obj.success) {
366
+ record.data.hasLayout = true;
367
+ self.editSectionLayout(record.data.text, sectionId, record.data.siteId);
368
+ }
369
+ else {
370
+ Ext.Msg.alert('Status', obj.message);
371
+ }
372
+ },
373
+ failure:function (response) {
374
+ Ext.Msg.alert('Status', 'Error adding layout.');
375
+ }
376
+ });
377
+ }
378
+ }
379
+ });
380
+ }
381
+ }
382
+
383
+ if (currentUser.hasApplicationCapability('knitkit', {
384
+ capability_type_iid:'delete',
385
+ resource:'Section'
386
+ })) {
387
+ items.push({
388
+ text:'Delete ' + record.data["type"],
389
+ iconCls:'icon-delete',
390
+ listeners:{
391
+ 'click':function () {
392
+ self.deleteSection(record);
393
+ }
394
+ }
395
+ });
396
+ }
397
+
398
+ return items;
399
+ }
@@ -0,0 +1,165 @@
1
+ Compass.ErpApp.Desktop.Applications.Knitkit.addWebsiteOptions = function (self, items, record) {
2
+ items.push({
3
+ text:'Configure',
4
+ iconCls:'icon-gear',
5
+ listeners:{
6
+ 'click':function () {
7
+ self.updateWebsiteConfiguration(record);
8
+ }
9
+ }
10
+ });
11
+
12
+ if (currentUser.hasApplicationCapability('knitkit', {
13
+ capability_type_iid:'publish',
14
+ resource:'Website'
15
+ })) {
16
+ items.push({
17
+ text:'Publish',
18
+ iconCls:'icon-document_up',
19
+ listeners:{
20
+ 'click':function () {
21
+ self.publish(record);
22
+ }
23
+ }
24
+ });
25
+ }
26
+
27
+ items.push({
28
+ text:'Publications',
29
+ iconCls:'icon-documents',
30
+ listeners:{
31
+ 'click':function () {
32
+ self.getPublications(record);
33
+ }
34
+ }
35
+ });
36
+
37
+ items.push({
38
+ text:'View Inquiries',
39
+ iconCls:'icon-document',
40
+ listeners:{
41
+ 'click':function () {
42
+ self.initialConfig['centerRegion'].viewWebsiteInquiries(record.data.id.split('_')[1], record.data.title);
43
+ }
44
+ }
45
+ });
46
+
47
+ if (currentUser.hasApplicationCapability('knitkit', {
48
+ capability_type_iid:'edit',
49
+ resource:'Website'
50
+ })) {
51
+ items.push({
52
+ text:'Update Website',
53
+ iconCls:'icon-edit',
54
+ listeners:{
55
+ 'click':function () {
56
+ var editWebsiteWindow = Ext.create("Ext.window.Window", {
57
+ title:'Update Website',
58
+ plain:true,
59
+ buttonAlign:'center',
60
+ items:Ext.create("Ext.form.Panel", {
61
+ labelWidth:110,
62
+ frame:false,
63
+ bodyStyle:'padding:5px 5px 0',
64
+ url:'/knitkit/erp_app/desktop/site/update',
65
+ defaults:{
66
+ width:225
67
+ },
68
+ items:[
69
+ {
70
+ xtype:'textfield',
71
+ fieldLabel:'Name',
72
+ allowBlank:false,
73
+ name:'name',
74
+ value:record.data['name']
75
+ },
76
+ {
77
+ xtype:'textfield',
78
+ fieldLabel:'Title',
79
+ id:'knitkitUpdateSiteTitle',
80
+ allowBlank:false,
81
+ name:'title',
82
+ value:record.data['title']
83
+ },
84
+ {
85
+ xtype:'textfield',
86
+ fieldLabel:'Sub Title',
87
+ allowBlank:true,
88
+ name:'subtitle',
89
+ value:record.data['subtitle']
90
+
91
+ },
92
+ {
93
+ xtype:'hidden',
94
+ name:'id',
95
+ value:record.data.id.split('_')[1]
96
+ }
97
+ ]
98
+ }),
99
+ buttons:[
100
+ {
101
+ text:'Submit',
102
+ listeners:{
103
+ 'click':function (button) {
104
+ var window = button.findParentByType('window');
105
+ var formPanel = window.query('form')[0];
106
+ self.setWindowStatus('Updating website...');
107
+ formPanel.getForm().submit({
108
+ success:function (form, action) {
109
+ self.clearWindowStatus();
110
+ record.data['name'] = form.findField('name').getValue();
111
+ record.data['title'] = form.findField('title').getValue();
112
+ record.data['subtitle'] = form.findField('subtitle').getValue();
113
+ record.data['email'] = form.findField('email').getValue();
114
+ //node.setText(node.attributes['title']);
115
+ editWebsiteWindow.close();
116
+ },
117
+ failure:function (form, action) {
118
+ self.clearWindowStatus();
119
+ Ext.Msg.alert("Error", "Error updating website");
120
+ }
121
+ });
122
+ }
123
+ }
124
+ },
125
+ {
126
+ text:'Close',
127
+ handler:function () {
128
+ editWebsiteWindow.close();
129
+ }
130
+ }
131
+ ]
132
+ });
133
+ editWebsiteWindow.show();
134
+ }
135
+ }
136
+ });
137
+ }
138
+
139
+ if (currentUser.hasApplicationCapability('knitkit', {
140
+ capability_type_iid:'delete',
141
+ resource:'Website'
142
+ })) {
143
+ items.push({
144
+ text:'Delete',
145
+ iconCls:'icon-delete',
146
+ listeners:{
147
+ 'click':function () {
148
+ self.deleteSite(record);
149
+ }
150
+ }
151
+ });
152
+ }
153
+
154
+ items.push({
155
+ text:'Export',
156
+ iconCls:'icon-document_out',
157
+ listeners:{
158
+ 'click':function () {
159
+ self.exportSite(record.data.id.split('_')[1]);
160
+ }
161
+ }
162
+ });
163
+
164
+ return items;
165
+ }