knitkit 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -0
- data/app/controllers/knitkit/base_controller.rb +15 -2
- data/app/controllers/knitkit/blogs_controller.rb +4 -4
- data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +16 -2
- data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +198 -57
- data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +25 -11
- data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +123 -44
- data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +83 -9
- data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +38 -0
- data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +15 -6
- data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +185 -98
- data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +38 -16
- data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +126 -68
- data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +154 -107
- data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +113 -54
- data/app/controllers/knitkit/online_document_sections_controller.rb +45 -0
- data/app/controllers/knitkit/unauthorized_controller.rb +5 -0
- data/app/controllers/knitkit/website_sections_controller.rb +8 -9
- data/app/mailers/document_mailer.rb +10 -0
- data/app/models/article.rb +1 -1
- data/app/models/content.rb +35 -3
- data/app/models/document.rb +8 -0
- data/app/models/document_type.rb +3 -0
- data/app/models/documented_content.rb +29 -0
- data/app/models/documented_item.rb +31 -0
- data/app/models/extensions/configuration.rb +5 -0
- data/app/models/extensions/party.rb +13 -0
- data/app/models/online_document_section.rb +40 -0
- data/app/models/theme.rb +22 -26
- data/app/models/valid_document.rb +4 -0
- data/app/models/website.rb +158 -119
- data/app/models/website_inquiry.rb +7 -2
- data/app/models/website_inquiry_mailer.rb +4 -3
- data/app/models/website_party_role.rb +5 -0
- data/app/models/website_section.rb +76 -38
- data/app/views/document_mailer/email_document.html.erb +12 -0
- data/app/views/knitkit/blogs/_add_comment.html.erb +2 -2
- data/app/views/knitkit/online_document_sections/index.html.erb +149 -0
- data/app/views/knitkit/website_sections/index.html.erb +0 -1
- data/app/views/layouts/knitkit/base.html.erb +4 -2
- data/app/views/layouts/knitkit/online_document_sections.html.erb +59 -0
- data/app/views/menus/knitkit/_default_menu.html.erb +1 -1
- data/app/views/menus/knitkit/_default_section_menu.html.erb +1 -1
- data/app/views/menus/knitkit/_default_sub_menu.html.erb +2 -2
- data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +1 -1
- data/app/widgets/contact_us/base.rb +5 -5
- data/app/widgets/contact_us/javascript/contact_us.js +2 -1
- data/app/widgets/google_map/base.rb +0 -4
- data/app/widgets/google_map/javascript/google_map.js +4 -3
- data/app/widgets/login/base.rb +0 -5
- data/app/widgets/login/javascript/login.js +155 -153
- data/app/widgets/login/views/index.html.erb +3 -3
- data/app/widgets/login/views/reset_password.html.erb +2 -2
- data/app/widgets/manage_profile/base.rb +46 -67
- data/app/widgets/manage_profile/javascript/manage_profile.js +2 -1
- data/app/widgets/manage_profile/views/_user_information_form.html.erb +5 -1
- data/app/widgets/reset_password/base.rb +4 -6
- data/app/widgets/reset_password/javascript/reset_password.js +2 -1
- data/app/widgets/reset_password/views/index.html.erb +4 -3
- data/app/widgets/search/base.rb +1 -5
- data/app/widgets/search/javascript/search.js +2 -1
- data/app/widgets/search/views/show.html.erb +2 -2
- data/app/widgets/signup/base.rb +7 -6
- data/app/widgets/signup/javascript/signup.js +2 -1
- data/app/widgets/signup/views/error.html.erb +1 -1
- data/config/routes.rb +6 -2
- data/db/data_migrations/20110509223702_add_publisher_role.rb +10 -0
- data/db/data_migrations/20111118182910_setup_knitkit_capabilities.rb +84 -0
- data/db/data_migrations/20120127144444_create_website_role_types.rb +13 -0
- data/db/data_migrations/20120127150505_create_website_default_configuration.rb +72 -0
- data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +33 -0
- data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +16 -0
- data/db/data_migrations/upgrade/20120210195616_add_website_configs.rb +19 -0
- data/db/data_migrations/upgrade/20120213205519_populate_website_iids.rb +17 -0
- data/db/migrate/20110211002317_setup_knitkit.rb +22 -5
- data/db/migrate/20111207161928_create_documented_items_table.rb +13 -0
- data/db/migrate/20111208180539_add_document_id_to_documented_item.rb +9 -0
- data/db/migrate/20120315163736_add_document.rb +32 -0
- data/db/migrate/20120503183431_create_valid_documents.rb +16 -0
- data/db/migrate/upgrade/20120116201510_add_render_base_layout_flag.rb +13 -0
- data/db/migrate/upgrade/20120127143745_create_website_party_roles.rb +24 -0
- data/db/migrate/upgrade/20120213184509_add_iid_to_websites.rb +14 -0
- data/lib/knitkit.rb +2 -0
- data/lib/knitkit/config.rb +31 -0
- data/lib/knitkit/engine.rb +12 -3
- data/lib/knitkit/extensions.rb +1 -3
- data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +2 -3
- data/lib/knitkit/extensions/active_record/acts_as_document.rb +63 -0
- data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +5 -4
- data/lib/knitkit/extensions/compass_ae/widgets/base.rb +70 -0
- data/lib/knitkit/extensions/railties/action_view.rb +22 -10
- data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +3 -3
- data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +8 -3
- data/lib/knitkit/routing_filter/section_router.rb +16 -6
- data/lib/knitkit/version.rb +7 -1
- data/public/images/check.png +0 -0
- data/public/images/credit_card.png +0 -0
- data/public/images/knitkit/tooltip.gif +0 -0
- data/public/javascripts/ajax_pagination.js +33 -0
- data/public/javascripts/datepicker.js +6 -1
- data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +731 -258
- data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +289 -238
- data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +2 -4
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +29 -3
- data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +193 -21
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +27 -26
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +167 -20
- data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +1 -2
- data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +5 -1
- data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +2 -2
- data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +20 -11
- data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +279 -228
- data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +40 -40
- data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +83 -76
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +1961 -1397
- data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +47 -43
- data/public/javascripts/knitkit/helpers.js +26 -0
- data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +1 -2
- data/public/stylesheets/knitkit/documentation.css +50 -0
- data/public/stylesheets/knitkit/style.css +23 -1
- data/spec/controllers/knitkit/erp_app/desktop/articles_controller_spec.rb +8 -0
- data/spec/controllers/knitkit/erp_app/desktop/website_controller_spec.rb +396 -0
- data/spec/controllers/knitkit/erp_app/desktop/website_nav_controller_spec.rb +260 -0
- data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +222 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +43 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +8 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/spec.rb +27 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/workflow.yml +1 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/article.rb +4 -0
- data/spec/factories/basic.rb +3 -0
- data/spec/factories/blog.rb +5 -0
- data/spec/factories/documented_content.rb +4 -0
- data/spec/factories/documented_item.rb +4 -0
- data/spec/factories/online_document_section.rb +6 -0
- data/spec/factories/published_website.rb +4 -0
- data/spec/factories/theme.rb +6 -0
- data/spec/factories/website.rb +5 -0
- data/spec/factories/website_host.rb +4 -0
- data/spec/factories/website_nav.rb +5 -0
- data/spec/factories/website_nav_item.rb +4 -0
- data/spec/factories/website_section.rb +5 -0
- data/spec/models/article_spec.rb +35 -0
- data/spec/models/attribute_type_spec.rb +55 -0
- data/spec/models/attribute_value_spec.rb +114 -0
- data/spec/models/blog_spec.rb +16 -0
- data/spec/models/comment_spec.rb +11 -0
- data/spec/models/content_spec.rb +187 -0
- data/spec/models/documented_item_spec.rb +29 -0
- data/spec/models/online_document_section_spec.rb +34 -0
- data/spec/models/published_element_spec.rb +11 -0
- data/spec/models/published_website_spec.rb +11 -0
- data/spec/models/theme_spec.rb +12 -0
- data/spec/models/website_host_spec.rb +11 -0
- data/spec/models/website_inquiry_spec.rb +24 -0
- data/spec/models/website_nav_item_spec.rb +11 -0
- data/spec/models/website_nav_spec.rb +11 -0
- data/spec/models/website_section_content_spec.rb +11 -0
- data/spec/models/website_section_spec.rb +49 -0
- data/spec/models/website_spec.rb +146 -0
- data/spec/spec_helper.rb +61 -0
- metadata +391 -154
- data/app/controllers/knitkit/articles_controller.rb +0 -7
- data/lib/knitkit/extensions/compass/widgets/base.rb +0 -53
@@ -42,9 +42,16 @@ module Knitkit
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def activate_publication
|
45
|
-
|
45
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
46
|
+
begin
|
47
|
+
current_user.with_capability(model, 'activate', 'Website') do
|
48
|
+
@website.set_publication_version(params[:version].to_f, current_user)
|
46
49
|
|
47
|
-
|
50
|
+
render :json => {:success => true}
|
51
|
+
end
|
52
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
53
|
+
render :json => {:success => false, :message => ex.message}
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
50
57
|
def set_viewing_version
|
@@ -60,62 +67,91 @@ module Knitkit
|
|
60
67
|
end
|
61
68
|
|
62
69
|
def publish
|
63
|
-
|
70
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
71
|
+
begin
|
72
|
+
current_user.with_capability(model, 'publish', 'Website') do
|
73
|
+
@website.publish(params[:comment], current_user)
|
64
74
|
|
65
|
-
|
75
|
+
render :json => {:success => true}
|
76
|
+
end
|
77
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
78
|
+
render :json => {:success => false, :message => ex.message}
|
79
|
+
end
|
66
80
|
end
|
67
81
|
|
68
82
|
def new
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
83
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
84
|
+
begin
|
85
|
+
current_user.with_capability(model, 'create', 'Website') do
|
86
|
+
result = {}
|
87
|
+
website = Website.new
|
88
|
+
website.subtitle = params[:subtitle]
|
89
|
+
website.title = params[:title]
|
90
|
+
website.name = params[:name]
|
91
|
+
website.email = params[:email]
|
92
|
+
website.auto_activate_publication = params[:auto_activate_publication] == 'yes'
|
93
|
+
website.email_inquiries = params[:email_inquiries] == 'yes'
|
94
|
+
|
95
|
+
# create homepage
|
96
|
+
website_section = WebsiteSection.new
|
97
|
+
website_section.title = "Home"
|
98
|
+
website_section.in_menu = true
|
99
|
+
website.website_sections << website_section
|
100
|
+
if website.save
|
101
|
+
website.setup_default_pages
|
102
|
+
|
103
|
+
#set default publication published by user
|
104
|
+
first_publication = website.published_websites.first
|
105
|
+
first_publication.published_by = current_user
|
106
|
+
first_publication.save
|
107
|
+
|
108
|
+
website.hosts << WebsiteHost.create(:host => params[:host])
|
109
|
+
website.configurations.first.update_configuration_item(ConfigurationItemType.find_by_internal_identifier('primary_host'), params[:host])
|
110
|
+
website.save
|
111
|
+
|
112
|
+
website.publish("Publish Default Sections", current_user)
|
113
|
+
PublishedWebsite.activate(website, 1, current_user)
|
96
114
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
115
|
+
result[:success] = true
|
116
|
+
else
|
117
|
+
result[:success] = false
|
118
|
+
end
|
101
119
|
|
102
|
-
|
120
|
+
render :json => result
|
121
|
+
end
|
122
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
123
|
+
render :json => {:success => false, :message => ex.message}
|
124
|
+
end
|
103
125
|
end
|
104
126
|
|
105
127
|
def update
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
128
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
129
|
+
begin
|
130
|
+
current_user.with_capability(model, 'edit', 'Website') do
|
131
|
+
@website.email = params[:email]
|
132
|
+
@website.name = params[:name]
|
133
|
+
@website.title = params[:title]
|
134
|
+
@website.subtitle = params[:subtitle]
|
135
|
+
@website.auto_activate_publication = params[:auto_activate_publication] == 'yes'
|
136
|
+
@website.email_inquiries = params[:email_inquiries] == 'yes'
|
137
|
+
|
138
|
+
render :json => @website.save ? {:success => true} : {:success => false}
|
139
|
+
end
|
140
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
141
|
+
render :json => {:success => false, :message => ex.message}
|
142
|
+
end
|
114
143
|
end
|
115
144
|
|
116
145
|
|
117
146
|
def delete
|
118
|
-
|
147
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
148
|
+
begin
|
149
|
+
current_user.with_capability(model, 'delete', 'Website') do
|
150
|
+
render :json => @website.destroy ? {:success => true} : {:success => false}
|
151
|
+
end
|
152
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
153
|
+
render :json => {:success => false, :message => ex.message}
|
154
|
+
end
|
119
155
|
end
|
120
156
|
|
121
157
|
def export
|
@@ -125,6 +161,7 @@ module Knitkit
|
|
125
161
|
FileUtils.rm_r File.dirname(zip_path) rescue nil
|
126
162
|
end
|
127
163
|
|
164
|
+
# TODO add role restriction to this
|
128
165
|
def import
|
129
166
|
result, message = Website.import(params[:website_data], current_user)
|
130
167
|
|
@@ -134,35 +171,56 @@ module Knitkit
|
|
134
171
|
end
|
135
172
|
|
136
173
|
def add_host
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
:
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
174
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
175
|
+
begin
|
176
|
+
current_user.with_capability(model, 'create', 'Host') do
|
177
|
+
website = Website.find(params[:id])
|
178
|
+
website_host = WebsiteHost.create(:host => params[:host])
|
179
|
+
website.hosts << website_host
|
180
|
+
website.save
|
181
|
+
|
182
|
+
render :json => {
|
183
|
+
:success => true,
|
184
|
+
:node => {
|
185
|
+
:text => website_host.attributes['host'],
|
186
|
+
:websiteHostId => website_host.id,
|
187
|
+
:host => website_host.attributes['host'],
|
188
|
+
:iconCls => 'icon-globe',
|
189
|
+
:url => "http://#{website_host.attributes['host']}",
|
190
|
+
:isHost => true,
|
191
|
+
:leaf => true,
|
192
|
+
:children => []}
|
193
|
+
}
|
194
|
+
end
|
195
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
196
|
+
render :json => {:success => false, :message => ex.message}
|
197
|
+
end
|
154
198
|
end
|
155
199
|
|
156
200
|
def update_host
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
201
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
202
|
+
begin
|
203
|
+
current_user.with_capability(model, 'edit', 'Host') do
|
204
|
+
website_host = WebsiteHost.find(params[:id])
|
205
|
+
website_host.host = params[:host]
|
206
|
+
website_host.save
|
207
|
+
|
208
|
+
render :json => {:success => true}
|
209
|
+
end
|
210
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
211
|
+
render :json => {:success => false, :message => ex.message}
|
212
|
+
end
|
162
213
|
end
|
163
214
|
|
164
215
|
def delete_host
|
165
|
-
|
216
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
217
|
+
begin
|
218
|
+
current_user.with_capability(model, 'delete', 'Host') do
|
219
|
+
render :json => WebsiteHost.destroy(params[:id]) ? {:success => true} : {:success => false}
|
220
|
+
end
|
221
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
222
|
+
render :json => {:success => false, :message => ex.message}
|
223
|
+
end
|
166
224
|
end
|
167
225
|
|
168
226
|
protected
|
@@ -3,138 +3,185 @@ module Knitkit
|
|
3
3
|
module Desktop
|
4
4
|
class WebsiteNavController < Knitkit::ErpApp::Desktop::AppController
|
5
5
|
def new
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
6
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
7
|
+
begin
|
8
|
+
current_user.with_capability(model, 'create', 'Menu') do
|
9
|
+
result = {}
|
10
|
+
website = Website.find(params[:website_id])
|
11
|
+
website_nav = WebsiteNav.new(:name => params[:name])
|
12
|
+
website.website_navs << website_nav
|
13
|
+
|
14
|
+
if website_nav.save
|
15
|
+
result[:success] = true
|
16
|
+
result[:node] = {:text => params[:name],
|
17
|
+
:websiteNavId => website_nav.id,
|
18
|
+
:websiteId => website.id,
|
19
|
+
:iconCls => 'icon-index',
|
20
|
+
:canAddMenuItems => true,
|
21
|
+
:isWebsiteNav => true,
|
22
|
+
:leaf => false,
|
23
|
+
:children => []}
|
24
|
+
else
|
25
|
+
result[:success] = false
|
26
|
+
end
|
27
|
+
|
28
|
+
render :json => result
|
29
|
+
end
|
30
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
31
|
+
render :json => {:success => false, :message => ex.message}
|
23
32
|
end
|
24
|
-
|
25
|
-
render :json => result
|
26
33
|
end
|
27
34
|
|
28
35
|
def update
|
29
|
-
|
30
|
-
|
36
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
37
|
+
begin
|
38
|
+
current_user.with_capability(model, 'edit', 'Menu') do
|
39
|
+
website_nav = WebsiteNav.find(params[:website_nav_id])
|
40
|
+
website_nav.name = params[:name]
|
31
41
|
|
32
|
-
|
42
|
+
render :json => (website_nav.save ? {:success => true} : {:success => false})
|
43
|
+
end
|
44
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
45
|
+
render :json => {:success => false, :message => ex.message}
|
46
|
+
end
|
33
47
|
end
|
34
48
|
|
35
49
|
def delete
|
36
|
-
|
50
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
51
|
+
begin
|
52
|
+
current_user.with_capability(model, 'delete', 'Menu') do
|
53
|
+
render :json => (WebsiteNav.destroy(params[:id]) ? {:success => true} : {:success => false})
|
54
|
+
end
|
55
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
56
|
+
render :json => {:success => false, :message => ex.message}
|
57
|
+
end
|
37
58
|
end
|
38
59
|
|
39
60
|
def add_menu_item
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
62
|
+
begin
|
63
|
+
current_user.with_capability(model, 'create', 'MenuItem') do
|
64
|
+
result = {}
|
65
|
+
klass = params[:klass].constantize
|
66
|
+
parent = klass.find(params[:id])
|
67
|
+
website_nav = parent.is_a?(WebsiteNav) ? parent : parent.website_nav
|
68
|
+
website_nav_item = WebsiteNavItem.new(:title => params[:title])
|
69
|
+
|
70
|
+
url = params[:url]
|
71
|
+
if(params[:link_to] != 'url')
|
72
|
+
#user wants to see Section so this is needed
|
73
|
+
params[:link_to] = 'WebsiteSection' if params[:link_to] == 'website_section'
|
74
|
+
|
75
|
+
#get link to item can be Article or Section
|
76
|
+
linked_to_id = params["#{params[:link_to].underscore}_id".to_sym]
|
77
|
+
link_to_item = params[:link_to].constantize.find(linked_to_id)
|
78
|
+
#setup link
|
79
|
+
website_nav_item.url = '/' + link_to_item.permalink
|
80
|
+
website_nav_item.linked_to_item = link_to_item
|
81
|
+
url = "http://#{website_nav.website.hosts.first.host}/" + link_to_item.permalink
|
82
|
+
else
|
83
|
+
website_nav_item.url = url
|
84
|
+
end
|
85
|
+
|
86
|
+
if website_nav_item.save
|
87
|
+
if parent.is_a?(WebsiteNav)
|
88
|
+
parent.website_nav_items << website_nav_item
|
89
|
+
else
|
90
|
+
website_nav_item.move_to_child_of(parent)
|
91
|
+
end
|
92
|
+
|
93
|
+
result[:success] = true
|
94
|
+
result[:node] = {:text => params[:title],
|
95
|
+
:linkToType => params[:link_to].underscore,
|
96
|
+
:linkedToId => linked_to_id,
|
97
|
+
:websiteId => website_nav.website.id,
|
98
|
+
:url => url,
|
99
|
+
:isSecure => false,
|
100
|
+
:canAddMenuItems => true,
|
101
|
+
:websiteNavItemId => website_nav_item.id,
|
102
|
+
:iconCls => 'icon-document',
|
103
|
+
:isWebsiteNavItem => true,
|
104
|
+
:leaf => false,
|
105
|
+
:children => []}
|
106
|
+
else
|
107
|
+
result[:success] = false
|
108
|
+
end
|
109
|
+
|
110
|
+
render :json => result
|
67
111
|
end
|
68
|
-
|
69
|
-
|
70
|
-
result[:node] = {:text => params[:title],
|
71
|
-
:linkToType => params[:link_to].underscore,
|
72
|
-
:linkedToId => linked_to_id,
|
73
|
-
:websiteId => website_nav.website.id,
|
74
|
-
:url => url,
|
75
|
-
:isSecure => false,
|
76
|
-
:canAddMenuItems => true,
|
77
|
-
:websiteNavItemId => website_nav_item.id,
|
78
|
-
:iconCls => 'icon-document',
|
79
|
-
:isWebsiteNavItem => true,
|
80
|
-
:leaf => false,
|
81
|
-
:children => []}
|
82
|
-
else
|
83
|
-
result[:success] = false
|
112
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
113
|
+
render :json => {:success => false, :message => ex.message}
|
84
114
|
end
|
85
|
-
|
86
|
-
render :json => result
|
87
115
|
end
|
88
116
|
|
89
117
|
def update_menu_item
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
118
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
119
|
+
begin
|
120
|
+
current_user.with_capability(model, 'edit', 'MenuItem') do
|
121
|
+
result = {}
|
122
|
+
website_nav_item = WebsiteNavItem.find(params[:website_nav_item_id])
|
123
|
+
website_nav_item.title = params[:title]
|
124
|
+
|
125
|
+
url = params[:url]
|
126
|
+
linked_to_id = nil
|
127
|
+
if(params[:link_to] != 'url')
|
128
|
+
#user wants to see Section so this is needed
|
129
|
+
params[:link_to] = 'WebsiteSection' if params[:link_to] == 'website_section'
|
130
|
+
|
131
|
+
#get link to item can be Article or Section
|
132
|
+
linked_to_id = params["#{params[:link_to].underscore}_id".to_sym]
|
133
|
+
link_to_item = params[:link_to].constantize.find(linked_to_id)
|
134
|
+
#setup link
|
135
|
+
website_nav_item.url = '/' + link_to_item.permalink
|
136
|
+
website_nav_item.linked_to_item = link_to_item
|
137
|
+
url = "http://#{website_nav_item.website_nav.website.hosts.first.host}/" + link_to_item.permalink
|
138
|
+
else
|
139
|
+
website_nav_item.url = url
|
140
|
+
end
|
141
|
+
|
142
|
+
if website_nav_item.save
|
143
|
+
result[:success] = true
|
144
|
+
result[:title] = params[:title]
|
145
|
+
result[:linkedToId] = linked_to_id
|
146
|
+
result[:linkToType] = params[:link_to].underscore
|
147
|
+
result[:url] = url
|
148
|
+
else
|
149
|
+
result[:success] = false
|
150
|
+
end
|
151
|
+
|
152
|
+
render :json => result
|
153
|
+
end
|
154
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
155
|
+
render :json => {:success => false, :message => ex.message}
|
119
156
|
end
|
120
|
-
|
121
|
-
render :json => result
|
122
157
|
end
|
123
158
|
|
124
159
|
def update_security
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
160
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
161
|
+
if current_user.has_capability?(model, 'secure', 'MenuItem') or current_user.has_capability?(model, 'unsecure', 'MenuItem')
|
162
|
+
website_nav_item = WebsiteNavItem.find(params[:id])
|
163
|
+
website = Website.find(params[:site_id])
|
164
|
+
if(params[:secure] == "true")
|
165
|
+
website_nav_item.add_role(website.role)
|
166
|
+
else
|
167
|
+
website_nav_item.remove_role(website.role)
|
168
|
+
end
|
169
|
+
|
170
|
+
render :json => {:success => true}
|
129
171
|
else
|
130
|
-
|
172
|
+
render :json => {:success => false, :message => "User does not have capability."}
|
131
173
|
end
|
132
|
-
|
133
|
-
render :json => {:success => true}
|
134
174
|
end
|
135
175
|
|
136
176
|
def delete_menu_item
|
137
|
-
|
177
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
178
|
+
begin
|
179
|
+
current_user.with_capability(model, 'delete', 'MenuItem') do
|
180
|
+
render :json => (WebsiteNavItem.destroy(params[:id]) ? {:success => true} : {:success => false})
|
181
|
+
end
|
182
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
183
|
+
render :json => {:success => false, :message => ex.message}
|
184
|
+
end
|
138
185
|
end
|
139
186
|
|
140
187
|
end#WebsiteNavController
|