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,265 @@
1
+ Compass.ErpApp.Desktop.Applications.Knitkit.addDocumentOptions = function (self, items, record) {
2
+ if (currentUser.hasApplicationCapability('knitkit', {
3
+ capability_type_iid:'create',
4
+ resource:'Section'
5
+ })) {
6
+ items.push({
7
+ text:'Add Document',
8
+ iconCls:'icon-add',
9
+ listeners:{
10
+ 'click':function () {
11
+ var addSectionWindow = Ext.create("Ext.window.Window", {
12
+ layout:'fit',
13
+ width:375,
14
+ title:'New Document Section',
15
+ plain:true,
16
+ buttonAlign:'center',
17
+ items:new Ext.FormPanel({
18
+ labelWidth:110,
19
+ frame:false,
20
+ bodyStyle:'padding:5px 5px 0',
21
+ url:'/knitkit/erp_app/desktop/online_document_sections/new',
22
+ defaults:{
23
+ width:225
24
+ },
25
+ items:[
26
+ {
27
+ xtype:'textfield',
28
+ fieldLabel:'Title',
29
+ allowBlank:false,
30
+ name:'title'
31
+ },
32
+ {
33
+ xtype:'textfield',
34
+ fieldLabel:'Unique Name',
35
+ allowBlank:true,
36
+ name:'internal_identifier'
37
+ },
38
+ {
39
+ xtype:'combo',
40
+ forceSelection:true,
41
+ store:[
42
+ ['OnlineDocumentSection', 'Online Document Section'],
43
+ ],
44
+ value:'OnlineDocumentSection',
45
+ fieldLabel:'Type',
46
+ name:'type',
47
+ allowBlank:false,
48
+ triggerAction:'all'
49
+ },
50
+ {
51
+ xtype:'combo',
52
+ forceSelection:true,
53
+ store:[
54
+ ['Content', 'Content']
55
+ ],
56
+ value:'Content',
57
+ fieldLabel:'Document Type',
58
+ name:'documenttype',
59
+ allowBlank:false,
60
+ triggerAction:'all'
61
+ },
62
+ {
63
+ xtype:'radiogroup',
64
+ fieldLabel:'Display in menu?',
65
+ name:'in_menu',
66
+ columns:2,
67
+ items:[
68
+ {
69
+ boxLabel:'Yes',
70
+ name:'in_menu',
71
+ inputValue:'yes',
72
+ checked:true
73
+ },
74
+
75
+ {
76
+ boxLabel:'No',
77
+ name:'in_menu',
78
+ inputValue:'no'
79
+ }
80
+ ]
81
+ },
82
+ {
83
+ xtype:'hidden',
84
+ name:'website_section_id',
85
+ value:record.data.id.split('_')[1]
86
+ },
87
+ {
88
+ xtype:'hidden',
89
+ name:'website_id',
90
+ value:record.data.siteId
91
+ }
92
+ ]
93
+ }),
94
+ buttons:[
95
+ {
96
+ text:'Submit',
97
+ listeners:{
98
+ 'click':function (button) {
99
+ var window = button.findParentByType('window');
100
+ var formPanel = window.query('.form')[0];
101
+ self.setWindowStatus('Creating document section...');
102
+ formPanel.getForm().submit({
103
+ reset:true,
104
+ success:function (form, action) {
105
+ self.clearWindowStatus();
106
+ var obj = Ext.decode(action.response.responseText);
107
+ if (obj.success) {
108
+ record.appendChild(obj.node);
109
+ self.initialConfig['centerRegion'].editContent(obj.documented_content.title, obj.documented_content.id, obj.documented_content.body_html, record.data.siteId, 'article');
110
+ }
111
+ else {
112
+ Ext.Msg.alert("Error", obj.message);
113
+ }
114
+ },
115
+ failure:function (form, action) {
116
+ self.clearWindowStatus();
117
+ var obj = Ext.decode(action.response.responseText);
118
+ if (obj.message) {
119
+ Ext.Msg.alert("Error", obj.message);
120
+ }
121
+ else {
122
+ Ext.Msg.alert("Error", "Error creating document.");
123
+ }
124
+ }
125
+ });
126
+ }
127
+ }
128
+ },
129
+ {
130
+ text:'Close',
131
+ handler:function () {
132
+ addSectionWindow.close();
133
+ }
134
+ }
135
+ ]
136
+ });
137
+ addSectionWindow.show();
138
+ }
139
+ }
140
+ });
141
+ }
142
+
143
+ if (currentUser.hasApplicationCapability('knitkit', {
144
+ capability_type_iid:'edit',
145
+ resource:'Section'
146
+ })) {
147
+ items.push({
148
+ text:'Update Document',
149
+ iconCls:'icon-edit',
150
+ listeners:{
151
+ 'click':function () {
152
+ var updateSectionWindow = Ext.create("Ext.window.Window", {
153
+ layout:'fit',
154
+ width:375,
155
+ title:'Update Document Section',
156
+ plain:true,
157
+ buttonAlign:'center',
158
+ items:new Ext.FormPanel({
159
+ labelWidth:110,
160
+ frame:false,
161
+ bodyStyle:'padding:5px 5px 0',
162
+ url:'/knitkit/erp_app/desktop/section/update',
163
+ defaults:{
164
+ width:225
165
+ },
166
+ items:[
167
+ {
168
+ xtype:'textfield',
169
+ fieldLabel:'Title',
170
+ value:record.data.text,
171
+ name:'title'
172
+ },
173
+ {
174
+ xtype:'textfield',
175
+ fieldLabel:'Unique Name',
176
+ allowBlank:true,
177
+ name:'internal_identifier',
178
+ value:record.data.internal_identifier
179
+ },
180
+ {
181
+ xtype:'radiogroup',
182
+ fieldLabel:'Display in menu?',
183
+ name:'in_menu',
184
+ columns:2,
185
+ items:[
186
+ {
187
+ boxLabel:'Yes',
188
+ name:'in_menu',
189
+ inputValue:'yes',
190
+ checked:record.data.inMenu
191
+ },
192
+
193
+ {
194
+ boxLabel:'No',
195
+ name:'in_menu',
196
+ inputValue:'no',
197
+ checked:!record.data.inMenu
198
+ }
199
+ ]
200
+ },
201
+ {
202
+ xtype:'hidden',
203
+ name:'id',
204
+ value:record.data.id.split('_')[1]
205
+ }
206
+ ]
207
+ }),
208
+ buttons:[
209
+ {
210
+ text:'Submit',
211
+ listeners:{
212
+ 'click':function (button) {
213
+ var window = button.findParentByType('window');
214
+ var formPanel = window.query('.form')[0];
215
+ self.setWindowStatus('Updating document section...');
216
+ formPanel.getForm().submit({
217
+ success:function (form, action) {
218
+ self.clearWindowStatus();
219
+ var values = formPanel.getValues();
220
+ record.set('title', values.title);
221
+ record.set('internal_identifier', values.internal_identifier);
222
+ record.set("inMenu", (values.in_menu == 'yes'));
223
+ record.commit();
224
+ updateSectionWindow.close();
225
+ },
226
+ failure:function (form, action) {
227
+ self.clearWindowStatus();
228
+ var obj = Ext.decode(action.response.responseText);
229
+ Ext.Msg.alert("Error", obj.msg);
230
+ }
231
+ });
232
+ }
233
+ }
234
+ },
235
+ {
236
+ text:'Close',
237
+ handler:function () {
238
+ updateSectionWindow.close();
239
+ }
240
+ }
241
+ ]
242
+ });
243
+ updateSectionWindow.show();
244
+ }
245
+ }
246
+ });
247
+ }
248
+
249
+ if (currentUser.hasApplicationCapability('knitkit', {
250
+ capability_type_iid:'delete',
251
+ resource:'Section'
252
+ })) {
253
+ items.push({
254
+ text:'Delete Document Section',
255
+ iconCls:'icon-delete',
256
+ listeners:{
257
+ 'click':function () {
258
+ self.deleteSection(record);
259
+ }
260
+ }
261
+ });
262
+ }
263
+
264
+ return items;
265
+ }
@@ -0,0 +1,133 @@
1
+ Compass.ErpApp.Desktop.Applications.Knitkit.addHostOptions = function (self, items, record) {
2
+ if (currentUser.hasApplicationCapability('knitkit', {
3
+ capability_type_iid:'edit',
4
+ resource:'Host'
5
+ })) {
6
+ items.push({
7
+ text:'Update',
8
+ iconCls:'icon-edit',
9
+ listeners:{
10
+ 'click':function () {
11
+ var updateHostWindow = Ext.create("Ext.window.Window", {
12
+ layout:'fit',
13
+ width:310,
14
+ title:'Update Host',
15
+ height:100,
16
+ plain:true,
17
+ buttonAlign:'center',
18
+ items:Ext.create("Ext.form.Panel", {
19
+ labelWidth:50,
20
+ frame:false,
21
+ bodyStyle:'padding:5px 5px 0',
22
+ width:425,
23
+ url:'/knitkit/erp_app/desktop/site/update_host',
24
+ defaults:{
25
+ width:225
26
+ },
27
+ items:[
28
+ {
29
+ xtype:'textfield',
30
+ fieldLabel:'Host',
31
+ id:'knitkitUpdateWebsiteHostHost',
32
+ name:'host',
33
+ value:record.data.host,
34
+ allowBlank:false
35
+ },
36
+ {
37
+ xtype:'hidden',
38
+ name:'id',
39
+ value:record.data.websiteHostId
40
+ }
41
+ ]
42
+ }),
43
+ buttons:[
44
+ {
45
+ text:'Submit',
46
+ listeners:{
47
+ 'click':function (button) {
48
+ var window = button.findParentByType('window');
49
+ var formPanel = window.query('form')[0];
50
+ self.setWindowStatus('Updating Host...');
51
+ formPanel.getForm().submit({
52
+ reset:false,
53
+ success:function (form, action) {
54
+ self.clearWindowStatus();
55
+ var obj = Ext.decode(action.response.responseText);
56
+ if (obj.success) {
57
+ var newHost = Ext.getCmp('knitkitUpdateWebsiteHostHost').getValue();
58
+ record.set('host', newHost);
59
+ record.set('text', newHost);
60
+ record.commit();
61
+ updateHostWindow.close();
62
+ }
63
+ else {
64
+ Ext.Msg.alert("Error", obj.msg);
65
+ }
66
+ },
67
+ failure:function (form, action) {
68
+ self.clearWindowStatus();
69
+ Ext.Msg.alert("Error", "Error updating Host");
70
+ }
71
+ });
72
+ }
73
+ }
74
+ },
75
+ {
76
+ text:'Close',
77
+ handler:function () {
78
+ updateHostWindow.close();
79
+ }
80
+ }
81
+ ]
82
+ });
83
+ updateHostWindow.show();
84
+ }
85
+ }
86
+ });
87
+ }
88
+
89
+ if (currentUser.hasApplicationCapability('knitkit', {
90
+ capability_type_iid:'delete',
91
+ resource:'Host'
92
+ })) {
93
+ items.push({
94
+ text:'Delete',
95
+ iconCls:'icon-delete',
96
+ listeners:{
97
+ 'click':function () {
98
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this Host?', function (btn) {
99
+ if (btn == 'no') {
100
+ return false;
101
+ }
102
+ else if (btn == 'yes') {
103
+ self.setWindowStatus('Deleting Host...');
104
+ Ext.Ajax.request({
105
+ url:'/knitkit/erp_app/desktop/site/delete_host',
106
+ method:'POST',
107
+ params:{
108
+ id:record.data.websiteHostId
109
+ },
110
+ success:function (response) {
111
+ self.clearWindowStatus();
112
+ var obj = Ext.decode(response.responseText);
113
+ if (obj.success) {
114
+ record.remove(true);
115
+ }
116
+ else {
117
+ Ext.Msg.alert('Error', 'Error deleting Host');
118
+ }
119
+ },
120
+ failure:function (response) {
121
+ self.clearWindowStatus();
122
+ Ext.Msg.alert('Error', 'Error deleting Host');
123
+ }
124
+ });
125
+ }
126
+ });
127
+ }
128
+ }
129
+ });
130
+ }
131
+
132
+ return items;
133
+ }
@@ -0,0 +1,174 @@
1
+ Compass.ErpApp.Desktop.Applications.Knitkit.addMenuOptions = function (self, items, record) {
2
+ if (record.data['canAddMenuItems']) {
3
+ if (currentUser.hasApplicationCapability('knitkit', {
4
+ capability_type_iid:'create',
5
+ resource:'MenuItem'
6
+ })) {
7
+ items.push({
8
+ text:'Add Menu Item',
9
+ iconCls:'icon-add',
10
+ handler:function (btn) {
11
+ var addMenuItemWindow = Ext.create("Ext.window.Window", {
12
+ layout:'fit',
13
+ width:375,
14
+ title:'New Menu Item',
15
+ height:175,
16
+ plain:true,
17
+ buttonAlign:'center',
18
+ items:Ext.create('Ext.form.Panel', {
19
+ labelWidth:50,
20
+ frame:false,
21
+ bodyStyle:'padding:5px 5px 0',
22
+ url:'/knitkit/erp_app/desktop/website_nav/add_menu_item',
23
+ defaults:{
24
+ width:225
25
+ },
26
+ items:[
27
+ {
28
+ xtype:'textfield',
29
+ fieldLabel:'Title',
30
+ allowBlank:false,
31
+ name:'title'
32
+ },
33
+ {
34
+ xtype:'combo',
35
+ fieldLabel:'Link to',
36
+ name:'link_to',
37
+ id:'knitkit_nav_item_link_to',
38
+ allowBlank:false,
39
+ forceSelection:true,
40
+ editable:false,
41
+ autoSelect:true,
42
+ typeAhead:false,
43
+ mode:'local',
44
+ triggerAction:'all',
45
+ store:[
46
+ ['website_section', 'Section'],
47
+ ['url', 'Url']
48
+ ],
49
+ value:'website_section',
50
+ listeners:{
51
+ 'change':function (combo, newValue, oldValue) {
52
+ switch (newValue) {
53
+ case 'website_section':
54
+ Ext.getCmp('knitkit_create_website_nav_item_section').show();
55
+ Ext.getCmp('knitkit_create_website_nav_item_url').hide();
56
+ break;
57
+ case 'url':
58
+ Ext.getCmp('knitkit_create_website_nav_item_section').hide();
59
+ Ext.getCmp('knitkit_create_website_nav_item_url').show();
60
+ break;
61
+ }
62
+ }
63
+ }
64
+ },
65
+ {
66
+ xtype:'combo',
67
+ id:'knitkit_create_website_nav_item_section',
68
+ hiddenName:'website_section_id',
69
+ name:'website_section_id',
70
+ width:300,
71
+ loadingText:'Retrieving Sections...',
72
+ store:Ext.create("Ext.data.Store", {
73
+ proxy:{
74
+ type:'ajax',
75
+ url:'/knitkit/erp_app/desktop/section/existing_sections',
76
+ reader:{
77
+ type:'json'
78
+ },
79
+ extraParams:{
80
+ website_id:record.data.websiteId
81
+ }
82
+ },
83
+ autoLoad:true,
84
+ fields:[
85
+ {
86
+ name:'id'
87
+ },
88
+ {
89
+ name:'title_permalink'
90
+
91
+ }
92
+ ]
93
+ }),
94
+ forceSelection:true,
95
+ editable:false,
96
+ fieldLabel:'Section',
97
+ autoSelect:true,
98
+ typeAhead:false,
99
+ mode:'local',
100
+ displayField:'title_permalink',
101
+ valueField:'id',
102
+
103
+ triggerAction:'all'
104
+ },
105
+ {
106
+ xtype:'textfield',
107
+ fieldLabel:'Url',
108
+ id:'knitkit_create_website_nav_item_url',
109
+ hidden:true,
110
+ name:'url'
111
+ },
112
+ {
113
+ xtype:'hidden',
114
+ name:'klass',
115
+ value:((record.data['websiteNavId']) ? 'WebsiteNav' : 'WebsiteNavItem')
116
+ },
117
+ {
118
+ xtype:'hidden',
119
+ name:'id',
120
+ value:record.data['websiteNavId'] || record.data['websiteNavItemId']
121
+ }
122
+ ]
123
+ }),
124
+ buttons:[
125
+ {
126
+ text:'Submit',
127
+ listeners:{
128
+ 'click':function (button) {
129
+ var window = button.findParentByType('window');
130
+ var formPanel = window.query('form')[0];
131
+ self.setWindowStatus('Creating menu item...');
132
+ formPanel.getForm().submit({
133
+ reset:true,
134
+ success:function (form, action) {
135
+ self.clearWindowStatus();
136
+ var obj = Ext.decode(action.response.responseText);
137
+ if (obj.success) {
138
+ record.appendChild(obj.node);
139
+ }
140
+ else {
141
+ Ext.Msg.alert("Error", obj.msg);
142
+ }
143
+ },
144
+ failure:function (form, action) {
145
+ self.clearWindowStatus();
146
+ if (action.response == null) {
147
+ Ext.Msg.alert("Error", 'Could not create menu item');
148
+ }
149
+ else {
150
+ var obj = Ext.decode(action.response.responseText);
151
+ Ext.Msg.alert("Error", obj.msg);
152
+ }
153
+
154
+ }
155
+ });
156
+ }
157
+ }
158
+ },
159
+ {
160
+ text:'Close',
161
+ handler:function () {
162
+ addMenuItemWindow.close();
163
+ }
164
+ }
165
+ ]
166
+ });
167
+ addMenuItemWindow.show();
168
+ }
169
+ });
170
+ }
171
+ }
172
+
173
+ return items;
174
+ }