knitkit 2.1.15 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/controllers/knitkit/base_controller.rb +1 -1
- data/app/controllers/knitkit/comments_controller.rb +7 -2
- data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +78 -98
- data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +65 -45
- data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +22 -12
- data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +1 -1
- data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +28 -16
- data/app/controllers/knitkit/erp_app/desktop/inquiries_controller.rb +15 -49
- data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +4 -3
- data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +69 -11
- data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +63 -60
- data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +98 -82
- data/app/controllers/knitkit/erp_app/desktop/website_host_controller.rb +77 -0
- data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +64 -44
- data/app/controllers/knitkit/erp_app/desktop/website_nav_item_controller.rb +147 -0
- data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +81 -45
- data/app/controllers/knitkit/mobile_controller.rb +15 -0
- data/app/controllers/knitkit/online_document_sections_controller.rb +2 -1
- data/app/controllers/knitkit/unauthorized_controller.rb +0 -1
- data/app/controllers/knitkit/website_sections_controller.rb +7 -4
- data/app/mailers/website_inquiry_mailer.rb +8 -7
- data/app/models/content.rb +11 -2
- data/app/models/document.rb +2 -17
- data/app/models/published_website.rb +96 -59
- data/app/models/theme.rb +100 -14
- data/app/models/website.rb +260 -28
- data/app/models/website_inquiry.rb +5 -12
- data/app/models/website_section.rb +9 -1
- data/app/views/knitkit/blogs/_add_comment.html.erb +44 -23
- data/app/views/knitkit/blogs/_comment.html.erb +4 -6
- data/app/views/knitkit/blogs/index.html.erb +63 -49
- data/app/views/knitkit/blogs/show.html.erb +17 -12
- data/app/views/knitkit/mobile/index.html.erb +162 -0
- data/app/views/knitkit/online_document_sections/index.html.erb +7 -5
- data/app/views/knitkit/unauthorized/index.html.erb +8 -4
- data/app/views/knitkit/website_sections/index.html.erb +8 -4
- data/app/views/layouts/knitkit/base.html.erb +79 -63
- data/app/views/layouts/knitkit/online_document_sections.html.erb +74 -52
- data/app/views/menus/knitkit/_default_menu.html.erb +4 -4
- data/app/views/menus/knitkit/_default_section_menu.html.erb +22 -23
- data/app/views/shared/knitkit/_bread_crumb.html.erb +10 -7
- data/app/views/shared/knitkit/_footer.html.erb +2 -2
- data/app/views/website_inquiry_mailer/inquiry.erb +23 -2
- data/app/widgets/contact_us/base.rb +25 -50
- data/app/widgets/contact_us/javascript/contact_us.js +7 -7
- data/app/widgets/contact_us/views/error.html.erb +6 -8
- data/app/widgets/contact_us/views/index.html.erb +28 -1
- data/app/widgets/contact_us/views/layouts/base.html.erb +9 -6
- data/app/widgets/contact_us/views/success.html.erb +3 -3
- data/app/widgets/google_map/views/index.html.erb +36 -36
- data/app/widgets/login/base.rb +1 -0
- data/app/widgets/login/javascript/login.js +3 -3
- data/app/widgets/login/views/index.html.erb +46 -26
- data/app/widgets/login/views/layouts/base.html.erb +15 -13
- data/app/widgets/login/views/login_header.html.erb +7 -9
- data/app/widgets/manage_profile/base.rb +116 -164
- data/app/widgets/manage_profile/views/_address.html.erb +184 -0
- data/app/widgets/manage_profile/views/_contact_information_form.html.erb +23 -192
- data/app/widgets/manage_profile/views/_email_address.html.erb +163 -0
- data/app/widgets/manage_profile/views/_password_form.html.erb +23 -20
- data/app/widgets/manage_profile/views/_phone_number.html.erb +165 -0
- data/app/widgets/manage_profile/views/_user_information_form.html.erb +49 -33
- data/app/widgets/manage_profile/views/error.html.erb +6 -0
- data/app/widgets/manage_profile/views/index.html.erb +44 -46
- data/app/widgets/manage_profile/views/layouts/base.html.erb +3 -1
- data/app/widgets/manage_profile/views/success.html.erb +5 -0
- data/app/widgets/reset_password/views/index.html.erb +33 -28
- data/app/widgets/reset_password/views/layouts/base.html.erb +10 -1
- data/app/widgets/search/base.rb +37 -25
- data/app/widgets/search/views/_inline_search_form.html.erb +12 -0
- data/app/widgets/search/views/_search_form.html.erb +41 -0
- data/app/widgets/search/views/index.html.erb +5 -3
- data/app/widgets/search/views/layouts/base.html.erb +13 -23
- data/app/widgets/search/views/show.html.erb +32 -47
- data/app/widgets/signup/base.rb +1 -1
- data/app/widgets/signup/javascript/signup.js +7 -9
- data/app/widgets/signup/views/_signup_form.html.erb +34 -29
- data/app/widgets/signup/views/error.html.erb +11 -11
- data/app/widgets/signup/views/index.html.erb +3 -2
- data/app/widgets/signup/views/layouts/base.html.erb +8 -5
- data/app/widgets/signup/views/success.html.erb +5 -4
- data/config/routes.rb +39 -28
- data/db/data_migrations/20120809020508_update_website_and_configuration.rb +3 -0
- data/db/migrate/20110211002317_setup_knitkit.rb +0 -1
- data/db/migrate/20131112013052_add_knitkit_missing_indexes.rb +33 -0
- data/db/migrate/20140622212723_update_website_inquiries.rb +22 -0
- data/db/migrate/20140911185022_add_publishing_to_website.rb +5 -0
- data/db/migrate/20141013073349_add_custom_fields_to_documents.rb +12 -0
- data/db/migrate/20141016101936_upgrade_remove_dynamic_attributes.rb +13 -0
- data/lib/knitkit.rb +0 -1
- data/lib/knitkit/engine.rb +1 -0
- data/lib/knitkit/extensions.rb +4 -0
- data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +33 -0
- data/lib/knitkit/extensions/active_record/acts_as_document.rb +0 -12
- data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +7 -10
- data/lib/knitkit/extensions/compass_ae/widgets/base.rb +2 -4
- data/lib/knitkit/extensions/compass_ae/widgets/widget_proxy_controller.rb +4 -1
- data/lib/knitkit/extensions/railties/action_view/helpers/blog_helper.rb +16 -13
- data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +10 -8
- data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +123 -108
- data/lib/knitkit/extensions/will_paginate/link_renderer.rb +67 -0
- data/lib/knitkit/routing_filter/section_router.rb +10 -8
- data/lib/knitkit/syntax_validator.rb +2 -2
- data/lib/knitkit/version.rb +7 -3
- data/public/images/inline_edit/close.png +0 -0
- data/public/images/knitkit/close_window.png +0 -0
- data/public/images/knitkit/logo.png +0 -0
- data/public/images/knitkit/splash/images/add-site.png +0 -0
- data/public/images/knitkit/splash/images/adjust-site.png +0 -0
- data/public/images/knitkit/splash/images/browse-site.png +0 -0
- data/public/images/knitkit/splash/images/find-themes.png +0 -0
- data/public/images/knitkit/splash/images/settings.png +0 -0
- data/public/images/knitkit/splash/images/tutorials.png +0 -0
- data/public/images/knitkit/splash/splash.png +0 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +656 -627
- data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +444 -333
- data/public/javascripts/erp_app/desktop/applications/knitkit/{east_region.js → east_region/east_region.js} +33 -33
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/file_assets_panel.js +332 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_data_view.js +144 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_panel.js +335 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/{widgets_panel.js → east_region/widgets_panel.js} +55 -55
- data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +150 -37
- data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +228 -96
- data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +89 -85
- data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +238 -217
- data/public/javascripts/erp_app/desktop/applications/knitkit/select_roles_window.js +59 -54
- data/public/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +170 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/main_menu.js +1168 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/websites_combo.js +71 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +301 -306
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/article.js +216 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +182 -153
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +48 -65
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +93 -94
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +523 -197
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +20 -34
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/hosts_tree_panel.js +74 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/menu_tree_panel.js +245 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/site_contents_tree_panel.js +360 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/themes_tree_panel.js +348 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +106 -1132
- data/public/javascripts/knitkit/bootstrap-datepicker.js +474 -0
- data/public/javascripts/knitkit/bootstrap.min.js +7 -0
- data/public/javascripts/knitkit/confirm-bootstrap.js +110 -0
- data/public/javascripts/knitkit/inline_editing.js +73 -50
- data/public/javascripts/knitkit/jquery.maskedinput.min.js +7 -0
- data/public/javascripts/knitkit/mobile/app/view/Main.js +108 -0
- data/public/javascripts/knitkit/mobile/ux/slidenavigation/View.js +734 -0
- data/public/javascripts/knitkit/theme.js +76 -0
- data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +95 -35
- data/public/stylesheets/knitkit/bootstrap-responsive.min.css +10 -0
- data/public/stylesheets/knitkit/bootstrap.min.css +7 -0
- data/public/stylesheets/knitkit/custom.css +122 -0
- data/public/stylesheets/knitkit/datepicker.css +182 -0
- data/public/stylesheets/knitkit/inline_editing.css +58 -58
- data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/models/article_spec.rb +3 -3
- data/spec/models/content_spec.rb +9 -9
- data/spec/models/website_spec.rb +1 -1
- metadata +100 -114
- data/app/helpers/application_helper.rb +0 -134
- data/app/views/knitkit/articles/index.html.erb +0 -3
- data/app/views/knitkit/articles/show.html.erb +0 -4
- data/app/views/menus/knitkit/_default_sub_menu.html.erb +0 -43
- data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +0 -47
- data/app/widgets/contact_us/views/_contact_form.html.erb +0 -36
- data/app/widgets/dynamic_forms/base.rb +0 -139
- data/app/widgets/dynamic_forms/javascript/dynamic_forms.js +0 -110
- data/app/widgets/dynamic_forms/views/error.html.erb +0 -5
- data/app/widgets/dynamic_forms/views/index.html.erb +0 -8
- data/app/widgets/dynamic_forms/views/success.html.erb +0 -4
- data/app/widgets/dynamic_grid/base.rb +0 -130
- data/app/widgets/dynamic_grid/helpers/controller/dynamic_grid_controller_helper.rb +0 -3
- data/app/widgets/dynamic_grid/helpers/view/dynamic_grid_view_helper.rb +0 -3
- data/app/widgets/dynamic_grid/javascript/dynamic_grid.js +0 -177
- data/app/widgets/dynamic_grid/views/index.html.erb +0 -14
- data/app/widgets/login/views/reset_password.html.erb +0 -26
- data/app/widgets/manage_profile/views/default_type_error.html.erb +0 -5
- data/app/widgets/scaffold/base.rb +0 -87
- data/app/widgets/scaffold/helpers/controller/scaffold_controller_helper.rb +0 -3
- data/app/widgets/scaffold/helpers/view/scaffold_view_helper.rb +0 -3
- data/app/widgets/scaffold/javascript/scaffold.js +0 -337
- data/app/widgets/scaffold/views/index.html.erb +0 -15
- data/app/widgets/search/views/_search.html.erb +0 -39
- data/public/images/knitkit/bullet.png +0 -0
- data/public/images/knitkit/close.png +0 -0
- data/public/images/knitkit/content.png +0 -0
- data/public/images/knitkit/footer.png +0 -0
- data/public/images/knitkit/graphic.png +0 -0
- data/public/images/knitkit/greyFadeDown.png +0 -0
- data/public/images/knitkit/link.png +0 -0
- data/public/images/knitkit/menu.png +0 -0
- data/public/images/knitkit/menu_select.png +0 -0
- data/public/images/knitkit/search.png +0 -0
- data/public/images/knitkit/tooltip.gif +0 -0
- data/public/javascripts/ajax_pagination.js +0 -33
- data/public/javascripts/datepicker.js +0 -445
- data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +0 -341
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +0 -31
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +0 -263
- data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +0 -722
- data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +0 -585
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website.js +0 -155
- data/public/javascripts/knitkit/helpers.js +0 -26
- data/public/stylesheets/datepicker.css +0 -121
- data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +0 -233
- data/public/stylesheets/knitkit/style.css +0 -426
data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/site_contents_tree_panel.js
ADDED
@@ -0,0 +1,360 @@
|
|
1
|
+
Ext.define('SiteContentsModel', {
|
2
|
+
extend: 'Ext.data.TreeModel',
|
3
|
+
fields: [
|
4
|
+
'recordType',
|
5
|
+
'recordId',
|
6
|
+
'objectType',
|
7
|
+
'text',
|
8
|
+
'iconCls',
|
9
|
+
'parentItemId',
|
10
|
+
'isBlog',
|
11
|
+
'display_title',
|
12
|
+
'leaf',
|
13
|
+
'isSection',
|
14
|
+
'isDocument',
|
15
|
+
'contentInfo',
|
16
|
+
'content_area',
|
17
|
+
'isSecured',
|
18
|
+
'url',
|
19
|
+
'path',
|
20
|
+
'inMenu',
|
21
|
+
'hasLayout',
|
22
|
+
'siteId',
|
23
|
+
'type',
|
24
|
+
'name',
|
25
|
+
'title',
|
26
|
+
'subtitle',
|
27
|
+
'websiteId',
|
28
|
+
'isSectionRoot',
|
29
|
+
'siteName',
|
30
|
+
'internal_identifier',
|
31
|
+
'configurationId',
|
32
|
+
'renderWithBaseLayout',
|
33
|
+
'roles',
|
34
|
+
'useMarkdown',
|
35
|
+
'parentItemId',
|
36
|
+
'tag_list',
|
37
|
+
// if an article is part of a blog then you can edit the excerpt
|
38
|
+
'canEditExcerpt',
|
39
|
+
{name: 'createdAt', mapping: 'created_at', type: 'date'},
|
40
|
+
{name: 'updatedAt', mapping: 'updated_at', type: 'date'}
|
41
|
+
]
|
42
|
+
});
|
43
|
+
|
44
|
+
var siteContentsStore = Ext.create('Ext.data.TreeStore', {
|
45
|
+
model: 'SiteContentsModel',
|
46
|
+
proxy: {
|
47
|
+
type: 'ajax',
|
48
|
+
url: '/knitkit/erp_app/desktop/site/build_content_tree',
|
49
|
+
timeout: 90000,
|
50
|
+
reader: {
|
51
|
+
type: 'json'
|
52
|
+
}
|
53
|
+
},
|
54
|
+
root: {
|
55
|
+
text: 'Sections/Web Pages',
|
56
|
+
iconCls: 'icon-ia',
|
57
|
+
expanded: true
|
58
|
+
},
|
59
|
+
listeners: {
|
60
|
+
beforeexpand: function (node, eOpts) {
|
61
|
+
if (!node.isRoot()) {
|
62
|
+
var tree = node.getOwnerTree();
|
63
|
+
tree.getStore().getProxy().setExtraParam('record_type', node.get('recordType'));
|
64
|
+
tree.getStore().getProxy().setExtraParam('record_id', node.get('recordId'));
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
});
|
69
|
+
|
70
|
+
var pluginItems = [];
|
71
|
+
|
72
|
+
pluginItems.push({
|
73
|
+
ptype: 'treeviewdragdrop'
|
74
|
+
});
|
75
|
+
|
76
|
+
var viewConfigItems = {
|
77
|
+
markDirty: false,
|
78
|
+
plugins: pluginItems,
|
79
|
+
listeners: {
|
80
|
+
'beforedrop': function (dom, data, overModel, dropPosition, dropHandlers, options) {
|
81
|
+
var record = data.records.first();
|
82
|
+
|
83
|
+
if (record.get('objectType') == 'Article') {
|
84
|
+
if (overModel.get('isSection')) {
|
85
|
+
return false;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
},
|
89
|
+
'drop': function (dom, data, overModel, dropPosition, options) {
|
90
|
+
var positionArray = [],
|
91
|
+
record = data.records.first(),
|
92
|
+
result = true,
|
93
|
+
counter = 0;
|
94
|
+
|
95
|
+
if (record.get('isSection') || record.get('isDocument')) {
|
96
|
+
// if the record is modified and the parentId has changed we need to change
|
97
|
+
// the section parent
|
98
|
+
if (record.modified && record.modified.parentId) {
|
99
|
+
Ext.Ajax.request({
|
100
|
+
url: '/knitkit/erp_app/desktop/position/change_section_parent',
|
101
|
+
method: 'PUT',
|
102
|
+
params: {
|
103
|
+
section_id: record.get('id').split('_')[1],
|
104
|
+
parent_id: record.get('parentId').split('_')[1]
|
105
|
+
},
|
106
|
+
success: function (response) {
|
107
|
+
var obj = Ext.decode(response.responseText);
|
108
|
+
if (!obj.success) {
|
109
|
+
Ext.Msg.alert("Error", obj.message);
|
110
|
+
result = false;
|
111
|
+
}
|
112
|
+
},
|
113
|
+
failure: function (response) {
|
114
|
+
Ext.Msg.alert('Error', 'Error saving positions.');
|
115
|
+
result = false;
|
116
|
+
}
|
117
|
+
});
|
118
|
+
}
|
119
|
+
else {
|
120
|
+
overModel.parentNode.eachChild(function (node) {
|
121
|
+
if (node.get('isSection') || record.get('isDocument')) {
|
122
|
+
positionArray.push({
|
123
|
+
id: node.data.id.split('_')[1],
|
124
|
+
position: counter
|
125
|
+
});
|
126
|
+
counter++;
|
127
|
+
}
|
128
|
+
});
|
129
|
+
|
130
|
+
Ext.Ajax.request({
|
131
|
+
url: '/knitkit/erp_app/desktop/position/update_section_position',
|
132
|
+
method: 'PUT',
|
133
|
+
jsonData: {
|
134
|
+
position_array: positionArray
|
135
|
+
},
|
136
|
+
success: function (response) {
|
137
|
+
var obj = Ext.decode(response.responseText);
|
138
|
+
if (!obj.success) {
|
139
|
+
Ext.Msg.alert("Error", obj.message);
|
140
|
+
result = false;
|
141
|
+
}
|
142
|
+
},
|
143
|
+
failure: function (response) {
|
144
|
+
Ext.Msg.alert('Error', 'Error saving positions.');
|
145
|
+
result = false;
|
146
|
+
}
|
147
|
+
});
|
148
|
+
}
|
149
|
+
}
|
150
|
+
// this is an article
|
151
|
+
else {
|
152
|
+
if (record.modified && record.modified.parentId) {
|
153
|
+
result = false;
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
overModel.parentNode.eachChild(function (node) {
|
157
|
+
positionArray.push({
|
158
|
+
id: node.get('id'),
|
159
|
+
position: counter
|
160
|
+
});
|
161
|
+
counter++;
|
162
|
+
});
|
163
|
+
|
164
|
+
Ext.Ajax.request({
|
165
|
+
url: '/knitkit/erp_app/desktop/position/update_article_position',
|
166
|
+
method: 'PUT',
|
167
|
+
jsonData: {
|
168
|
+
position_array: positionArray
|
169
|
+
},
|
170
|
+
params: {
|
171
|
+
section_id: record.parentNode.get('id').split('_')[1]
|
172
|
+
},
|
173
|
+
success: function (response) {
|
174
|
+
var obj = Ext.decode(response.responseText);
|
175
|
+
if (!obj.success) {
|
176
|
+
Ext.Msg.alert("Error", obj.message);
|
177
|
+
result = false;
|
178
|
+
}
|
179
|
+
},
|
180
|
+
failure: function (response) {
|
181
|
+
Ext.Msg.alert('Error', 'Error saving positions.');
|
182
|
+
result = false;
|
183
|
+
}
|
184
|
+
});
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
return result;
|
189
|
+
}
|
190
|
+
}
|
191
|
+
};
|
192
|
+
|
193
|
+
Ext.define("Compass.ErpApp.Desktop.Applications.SiteContentsTreePanel", {
|
194
|
+
|
195
|
+
extend: "Ext.tree.Panel",
|
196
|
+
id: 'knitkitSiteContentsTreePanel',
|
197
|
+
itemId: 'knitkitSiteContentsTreePanel',
|
198
|
+
alias: 'widget.knitkit_sitecontentstreepanel',
|
199
|
+
header: false,
|
200
|
+
|
201
|
+
viewConfig: viewConfigItems,
|
202
|
+
store: siteContentsStore,
|
203
|
+
enableDD: true,
|
204
|
+
|
205
|
+
editSectionLayout: function (sectionName, sectionId, websiteId) {
|
206
|
+
var self = this;
|
207
|
+
|
208
|
+
Ext.Ajax.request({
|
209
|
+
url: '/knitkit/erp_app/desktop/section/get_layout',
|
210
|
+
method: 'POST',
|
211
|
+
params: {
|
212
|
+
id: sectionId
|
213
|
+
},
|
214
|
+
success: function (response) {
|
215
|
+
self.initialConfig['centerRegion'].editSectionLayout(
|
216
|
+
sectionName,
|
217
|
+
websiteId,
|
218
|
+
sectionId,
|
219
|
+
response.responseText,
|
220
|
+
[
|
221
|
+
{
|
222
|
+
text: 'Insert Content Area',
|
223
|
+
handler: function (btn) {
|
224
|
+
var codeMirror = btn.findParentByType('codemirror');
|
225
|
+
Ext.MessageBox.prompt('New File', 'Please enter content area name:', function (btn, text) {
|
226
|
+
if (btn == 'ok') {
|
227
|
+
codeMirror.insertContent('<%=render_content_area(:' + text + ')%>');
|
228
|
+
}
|
229
|
+
|
230
|
+
});
|
231
|
+
}
|
232
|
+
}
|
233
|
+
]);
|
234
|
+
},
|
235
|
+
failure: function (response) {
|
236
|
+
Ext.Msg.alert('Error', 'Error loading section layout.');
|
237
|
+
}
|
238
|
+
});
|
239
|
+
},
|
240
|
+
|
241
|
+
clearWebsite: function () {
|
242
|
+
var store = this.getStore();
|
243
|
+
store.getProxy().extraParams = {};
|
244
|
+
store.load();
|
245
|
+
},
|
246
|
+
|
247
|
+
selectWebsite: function (website) {
|
248
|
+
var store = this.getStore();
|
249
|
+
store.getProxy().extraParams = {
|
250
|
+
website_id: website.id
|
251
|
+
};
|
252
|
+
store.load();
|
253
|
+
},
|
254
|
+
|
255
|
+
listeners: {
|
256
|
+
'itemclick': function (view, record, htmlItem, index, e) {
|
257
|
+
var self = this;
|
258
|
+
e.stopEvent();
|
259
|
+
if (record.data['isSection']) {
|
260
|
+
self.initialConfig['centerRegion'].openIframeInTab(record.data.text, record.data['url']);
|
261
|
+
}
|
262
|
+
else if (record.data['objectType'] === "Article") {
|
263
|
+
var url = '/knitkit/erp_app/desktop/articles/show/' + record.data.id;
|
264
|
+
|
265
|
+
Ext.Ajax.request({
|
266
|
+
url: url,
|
267
|
+
method: 'GET',
|
268
|
+
extraParams: {
|
269
|
+
id: record.data.id
|
270
|
+
},
|
271
|
+
timeout: 90000,
|
272
|
+
success: function (response) {
|
273
|
+
var article = Ext.decode(response.responseText);
|
274
|
+
self.initialConfig['centerRegion'].editContent(record.data.text, record.data.id, article.body_html, record.data['siteId'], 'article');
|
275
|
+
}
|
276
|
+
});
|
277
|
+
}
|
278
|
+
else if (record.data['isDocument']) {
|
279
|
+
var contentInfo = record.data['contentInfo'];
|
280
|
+
if (record.data['useMarkdown']) {
|
281
|
+
self.initialConfig['centerRegion'].editDocumentationMarkdown(
|
282
|
+
contentInfo.title,
|
283
|
+
record.data['siteId'],
|
284
|
+
contentInfo.id,
|
285
|
+
contentInfo.body_html,
|
286
|
+
[]
|
287
|
+
);
|
288
|
+
}
|
289
|
+
else {
|
290
|
+
self.initialConfig['centerRegion'].editContent(
|
291
|
+
record.data['contentInfo'].title,
|
292
|
+
record.data['contentInfo'].id,
|
293
|
+
record.data['contentInfo'].body_html,
|
294
|
+
record.data['siteId'],
|
295
|
+
'article'
|
296
|
+
);
|
297
|
+
}
|
298
|
+
}
|
299
|
+
},
|
300
|
+
'itemcontextmenu': function (view, record, htmlItem, index, e) {
|
301
|
+
e.stopEvent();
|
302
|
+
var items = [];
|
303
|
+
|
304
|
+
if (!Compass.ErpApp.Utility.isBlank(record.data['url'])) {
|
305
|
+
items.push({
|
306
|
+
text: 'View In Web Navigator',
|
307
|
+
iconCls: 'icon-globe',
|
308
|
+
listeners: {
|
309
|
+
'click': function () {
|
310
|
+
var webNavigator = window.compassDesktop.getModule('web-navigator-win');
|
311
|
+
webNavigator.createWindow(record.data['url']);
|
312
|
+
}
|
313
|
+
}
|
314
|
+
});
|
315
|
+
}
|
316
|
+
|
317
|
+
if (record.isRoot() && record.hasChildNodes()) {
|
318
|
+
items = [
|
319
|
+
Compass.ErpApp.Desktop.Applications.Knitkit.newSectionMenuItem,
|
320
|
+
Compass.ErpApp.Desktop.Applications.Knitkit.editWebsiteMenuItem(false),
|
321
|
+
Compass.ErpApp.Desktop.Applications.Knitkit.configureWebsiteMenuItem(false),
|
322
|
+
Compass.ErpApp.Desktop.Applications.Knitkit.exportWebsiteMenuItem(false),
|
323
|
+
Compass.ErpApp.Desktop.Applications.Knitkit.websitePublicationsMenuItem(false),
|
324
|
+
Compass.ErpApp.Desktop.Applications.Knitkit.websitePublishMenuItem(false),
|
325
|
+
Compass.ErpApp.Desktop.Applications.Knitkit.websiteInquiresMenuItem(false)
|
326
|
+
];
|
327
|
+
}
|
328
|
+
|
329
|
+
if (record.data['isDocument']) {
|
330
|
+
items = Compass.ErpApp.Desktop.Applications.Knitkit.addDocumentOptions(self, items, record);
|
331
|
+
}
|
332
|
+
|
333
|
+
if (record.data['objectType'] === "Article") {
|
334
|
+
|
335
|
+
items = Compass.ErpApp.Desktop.Applications.Knitkit.addArticleOptions(self, items, record);
|
336
|
+
}
|
337
|
+
|
338
|
+
if (record.data['isSection']) {
|
339
|
+
items = Compass.ErpApp.Desktop.Applications.Knitkit.addSectionOptions(self, items, record);
|
340
|
+
}
|
341
|
+
else if (record.data['isWebsite']) {
|
342
|
+
items = Compass.ErpApp.Desktop.Applications.Knitkit.addWebsiteOptions(self, items, record);
|
343
|
+
}
|
344
|
+
|
345
|
+
if (items.length != 0) {
|
346
|
+
var contextMenu = Ext.create("Ext.menu.Menu", {
|
347
|
+
items: items
|
348
|
+
});
|
349
|
+
contextMenu.showAt(e.xy);
|
350
|
+
}
|
351
|
+
}
|
352
|
+
},
|
353
|
+
|
354
|
+
initComponent: function (config) {
|
355
|
+
config = Ext.apply({
|
356
|
+
}, config);
|
357
|
+
|
358
|
+
this.callParent([config]);
|
359
|
+
}
|
360
|
+
});
|
@@ -0,0 +1,348 @@
|
|
1
|
+
Ext.define("Compass.ErpApp.Desktop.Applications.ThemesTreePanel", {
|
2
|
+
extend: "Compass.ErpApp.Shared.FileManagerTree",
|
3
|
+
alias: 'widget.knitkit_themestreepanel',
|
4
|
+
itemId: 'themesTreePanel',
|
5
|
+
|
6
|
+
clearWebsite: function () {
|
7
|
+
var store = this.getStore();
|
8
|
+
store.getProxy().extraParams = {};
|
9
|
+
store.load();
|
10
|
+
},
|
11
|
+
|
12
|
+
selectWebsite: function (website) {
|
13
|
+
var store = this.getStore();
|
14
|
+
store.getProxy().extraParams = {
|
15
|
+
website_id: website.id
|
16
|
+
};
|
17
|
+
store.load();
|
18
|
+
},
|
19
|
+
|
20
|
+
themeWidget: function (node) {
|
21
|
+
var self = this;
|
22
|
+
|
23
|
+
Ext.create("Ext.window.Window", {
|
24
|
+
layout: 'fit',
|
25
|
+
width: 375,
|
26
|
+
title: 'Theme Widget',
|
27
|
+
plain: true,
|
28
|
+
buttonAlign: 'center',
|
29
|
+
items: Ext.create('widget.form', {
|
30
|
+
labelWidth: 110,
|
31
|
+
frame: false,
|
32
|
+
bodyStyle: 'padding:5px 5px 0',
|
33
|
+
fileUpload: true,
|
34
|
+
url: '/knitkit/erp_app/desktop/theme/theme_widget',
|
35
|
+
defaults: {
|
36
|
+
width: 300
|
37
|
+
},
|
38
|
+
items: [
|
39
|
+
{
|
40
|
+
xtype: 'hidden',
|
41
|
+
name: 'site_id',
|
42
|
+
value: node.get('siteId')
|
43
|
+
},
|
44
|
+
{
|
45
|
+
xtype: 'hidden',
|
46
|
+
name: 'theme_id',
|
47
|
+
value: node.get('themeId')
|
48
|
+
},
|
49
|
+
{
|
50
|
+
xtype: 'combo',
|
51
|
+
hiddenName: 'widget_id',
|
52
|
+
name: 'widget_id',
|
53
|
+
store: Ext.create("Ext.data.Store", {
|
54
|
+
proxy: {
|
55
|
+
url: '/knitkit/erp_app/desktop/theme/available_widgets',
|
56
|
+
type: 'ajax',
|
57
|
+
reader: {
|
58
|
+
type: 'json',
|
59
|
+
root: 'widgets'
|
60
|
+
},
|
61
|
+
extraParams: {
|
62
|
+
theme_id: node.get('themeId')
|
63
|
+
}
|
64
|
+
},
|
65
|
+
fields: [
|
66
|
+
{
|
67
|
+
name: 'name'
|
68
|
+
},
|
69
|
+
{
|
70
|
+
name: 'id'
|
71
|
+
}
|
72
|
+
]
|
73
|
+
}),
|
74
|
+
forceSelection: true,
|
75
|
+
editable: false,
|
76
|
+
fieldLabel: 'Widget',
|
77
|
+
emptyText: 'Select Widget...',
|
78
|
+
typeAhead: false,
|
79
|
+
mode: 'remote',
|
80
|
+
displayField: 'name',
|
81
|
+
valueField: 'id',
|
82
|
+
allowBlank: false
|
83
|
+
}
|
84
|
+
]
|
85
|
+
}),
|
86
|
+
buttons: [
|
87
|
+
{
|
88
|
+
text: 'Submit',
|
89
|
+
listeners: {
|
90
|
+
'click': function (button) {
|
91
|
+
var window = this.up('window'),
|
92
|
+
form = window.query('form')[0].getForm();
|
93
|
+
|
94
|
+
if (form.isValid()) {
|
95
|
+
form.submit({
|
96
|
+
waitMsg: 'Generating layout files for widget...',
|
97
|
+
success: function (form, action) {
|
98
|
+
var obj = Ext.decode(action.response.responseText);
|
99
|
+
if (obj.success) {
|
100
|
+
self.getStore().load({
|
101
|
+
node: node,
|
102
|
+
callback: function(){
|
103
|
+
node.expand();
|
104
|
+
}
|
105
|
+
});
|
106
|
+
}
|
107
|
+
window.close();
|
108
|
+
},
|
109
|
+
failure: function (form, action) {
|
110
|
+
Ext.Msg.alert("Error", "Error generating layouts");
|
111
|
+
}
|
112
|
+
});
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
},
|
117
|
+
{
|
118
|
+
text: 'Close',
|
119
|
+
handler: function (btn) {
|
120
|
+
btn.up('window').close();
|
121
|
+
}
|
122
|
+
}
|
123
|
+
]
|
124
|
+
}).show();
|
125
|
+
},
|
126
|
+
|
127
|
+
updateThemeActiveStatus: function (node, active) {
|
128
|
+
var self = this;
|
129
|
+
|
130
|
+
self.initialConfig['centerRegion'].setWindowStatus('Updating Status...');
|
131
|
+
|
132
|
+
Ext.Ajax.request({
|
133
|
+
url: '/knitkit/erp_app/desktop/theme/change_status',
|
134
|
+
method: 'POST',
|
135
|
+
params: {
|
136
|
+
theme_id: node.data.id,
|
137
|
+
website_id: node.data.siteId,
|
138
|
+
active: active
|
139
|
+
},
|
140
|
+
success: function (response) {
|
141
|
+
var obj = Ext.decode(response.responseText);
|
142
|
+
if (obj.success) {
|
143
|
+
self.initialConfig['centerRegion'].clearWindowStatus();
|
144
|
+
|
145
|
+
if (active) {
|
146
|
+
// first update icon for all other theme nodes as they are now deactive
|
147
|
+
var rootNode = node.getOwnerTree().getRootNode();
|
148
|
+
rootNode.eachChild(function (childNode) {
|
149
|
+
childNode.set('iconCls', 'icon-delete');
|
150
|
+
childNode.set('isActive', false);
|
151
|
+
});
|
152
|
+
|
153
|
+
// then update this node to be active
|
154
|
+
node.set('iconCls', 'icon-add');
|
155
|
+
node.set('isActive', true);
|
156
|
+
}
|
157
|
+
else {
|
158
|
+
node.set('iconCls', 'icon-delete');
|
159
|
+
node.set('isActive', false);
|
160
|
+
}
|
161
|
+
}
|
162
|
+
else {
|
163
|
+
Ext.Msg.alert('Error', 'Error updating status');
|
164
|
+
self.initialConfig['centerRegion'].clearWindowStatus();
|
165
|
+
}
|
166
|
+
},
|
167
|
+
failure: function (response) {
|
168
|
+
self.initialConfig['centerRegion'].clearWindowStatus();
|
169
|
+
Ext.Msg.alert('Error', 'Error updating status');
|
170
|
+
}
|
171
|
+
});
|
172
|
+
},
|
173
|
+
|
174
|
+
deleteTheme: function (themeId) {
|
175
|
+
var self = this;
|
176
|
+
self.initialConfig['centerRegion'].setWindowStatus('Deleting theme...');
|
177
|
+
Ext.Ajax.request({
|
178
|
+
url: '/knitkit/erp_app/desktop/theme/delete',
|
179
|
+
method: 'POST',
|
180
|
+
params: {
|
181
|
+
theme_id: themeId
|
182
|
+
},
|
183
|
+
success: function (response) {
|
184
|
+
var obj = Ext.decode(response.responseText);
|
185
|
+
if (obj.success) {
|
186
|
+
self.initialConfig['centerRegion'].clearWindowStatus();
|
187
|
+
self.getStore().load({
|
188
|
+
node: self.getRootNode()
|
189
|
+
});
|
190
|
+
}
|
191
|
+
else {
|
192
|
+
Ext.Msg.alert('Error', 'Error deleting theme');
|
193
|
+
self.initialConfig['centerRegion'].clearWindowStatus();
|
194
|
+
}
|
195
|
+
},
|
196
|
+
failure: function (response) {
|
197
|
+
self.initialConfig['centerRegion'].clearWindowStatus();
|
198
|
+
Ext.Msg.alert('Error', 'Error deleting theme');
|
199
|
+
}
|
200
|
+
});
|
201
|
+
},
|
202
|
+
|
203
|
+
exportTheme: function (themeId) {
|
204
|
+
var self = this;
|
205
|
+
self.initialConfig['centerRegion'].setWindowStatus('Exporting theme...');
|
206
|
+
window.open('/knitkit/erp_app/desktop/theme/export?id=' + themeId, '_blank');
|
207
|
+
self.initialConfig['centerRegion'].clearWindowStatus();
|
208
|
+
},
|
209
|
+
|
210
|
+
constructor: function (config) {
|
211
|
+
var self = this;
|
212
|
+
|
213
|
+
config = Ext.apply({
|
214
|
+
autoLoadRoot: true,
|
215
|
+
rootVisible: true,
|
216
|
+
multiSelect: true,
|
217
|
+
title: 'Themes',
|
218
|
+
rootText: 'Themes',
|
219
|
+
handleRootContextMenu: true,
|
220
|
+
controllerPath: '/knitkit/erp_app/desktop/theme',
|
221
|
+
autoDestroy: true,
|
222
|
+
allowDownload: true,
|
223
|
+
addViewContentsToContextMenu: true,
|
224
|
+
standardUploadUrl: '/knitkit/erp_app/desktop/theme/upload_file',
|
225
|
+
url: '/knitkit/erp_app/desktop/theme/index',
|
226
|
+
fields: [
|
227
|
+
'isTheme',
|
228
|
+
'themeId',
|
229
|
+
'isActive',
|
230
|
+
'siteId',
|
231
|
+
'text',
|
232
|
+
'id',
|
233
|
+
'url',
|
234
|
+
'leaf',
|
235
|
+
'handleContextMenu',
|
236
|
+
'contextMenuDisabled'
|
237
|
+
],
|
238
|
+
scroll: 'vertical',
|
239
|
+
//containerScroll: true,
|
240
|
+
listeners: {
|
241
|
+
'load': function (store) {
|
242
|
+
store.getRootNode().expandChildren();
|
243
|
+
},
|
244
|
+
'showImage': function (fileManager, node, themeId) {
|
245
|
+
var themeId = null;
|
246
|
+
var themeNode = node;
|
247
|
+
while (themeId == null && !Compass.ErpApp.Utility.isBlank(themeNode.parentNode)) {
|
248
|
+
if (themeNode.data.isTheme) {
|
249
|
+
themeId = themeNode.data.id;
|
250
|
+
}
|
251
|
+
else {
|
252
|
+
themeNode = themeNode.parentNode;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
self.initialConfig['centerRegion'].showImage(node, themeId);
|
256
|
+
},
|
257
|
+
'contentLoaded': function (fileManager, node, content) {
|
258
|
+
var themeId = null;
|
259
|
+
var themeNode = node;
|
260
|
+
while (themeId == null && !Compass.ErpApp.Utility.isBlank(themeNode.parentNode)) {
|
261
|
+
if (themeNode.data.isTheme) {
|
262
|
+
themeId = themeNode.data.id;
|
263
|
+
}
|
264
|
+
else {
|
265
|
+
themeNode = themeNode.parentNode;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
self.initialConfig['centerRegion'].editTemplateFile(node, content, [], themeId);
|
269
|
+
},
|
270
|
+
'handleContextMenu': function (fileManager, node, e) {
|
271
|
+
var items = [];
|
272
|
+
|
273
|
+
if (node.isRoot()) {
|
274
|
+
items.push(Compass.ErpApp.Desktop.Applications.Knitkit.newThemeMenuItem);
|
275
|
+
items.push(Compass.ErpApp.Desktop.Applications.Knitkit.uploadThemeMenuItem);
|
276
|
+
}
|
277
|
+
else if (node.data['isTheme']) {
|
278
|
+
if (node.data['isActive']) {
|
279
|
+
items.push({
|
280
|
+
text: 'Deactivate',
|
281
|
+
iconCls: 'icon-delete',
|
282
|
+
listeners: {
|
283
|
+
'click': function () {
|
284
|
+
self.updateThemeActiveStatus(node, false);
|
285
|
+
}
|
286
|
+
}
|
287
|
+
});
|
288
|
+
}
|
289
|
+
else {
|
290
|
+
items.push({
|
291
|
+
text: 'Activate',
|
292
|
+
iconCls: 'icon-add',
|
293
|
+
listeners: {
|
294
|
+
'click': function () {
|
295
|
+
self.updateThemeActiveStatus(node, true);
|
296
|
+
}
|
297
|
+
}
|
298
|
+
});
|
299
|
+
}
|
300
|
+
items.push({
|
301
|
+
text: 'Delete Theme',
|
302
|
+
iconCls: 'icon-delete',
|
303
|
+
listeners: {
|
304
|
+
'click': function () {
|
305
|
+
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this theme?', function (btn) {
|
306
|
+
if (btn == 'no') {
|
307
|
+
return false;
|
308
|
+
}
|
309
|
+
else if (btn == 'yes') {
|
310
|
+
self.deleteTheme(node.data.id);
|
311
|
+
}
|
312
|
+
});
|
313
|
+
}
|
314
|
+
}
|
315
|
+
});
|
316
|
+
items.push({
|
317
|
+
text: 'Export',
|
318
|
+
iconCls: 'icon-document_out',
|
319
|
+
listeners: {
|
320
|
+
'click': function () {
|
321
|
+
self.exportTheme(node.data.id);
|
322
|
+
}
|
323
|
+
}
|
324
|
+
});
|
325
|
+
}
|
326
|
+
else if (node.get('text') == 'Widgets') {
|
327
|
+
items.push({
|
328
|
+
text: 'Theme Widget',
|
329
|
+
iconCls: 'icon-picture',
|
330
|
+
handler: function (btn) {
|
331
|
+
fileManager.themeWidget(node);
|
332
|
+
}
|
333
|
+
});
|
334
|
+
}
|
335
|
+
|
336
|
+
var contextMenu = Ext.create('Ext.menu.Menu', {
|
337
|
+
items: items
|
338
|
+
});
|
339
|
+
contextMenu.showAt(e.xy);
|
340
|
+
return false;
|
341
|
+
}
|
342
|
+
}
|
343
|
+
}, config);
|
344
|
+
|
345
|
+
this.callParent([config]);
|
346
|
+
}
|
347
|
+
});
|
348
|
+
|