integral 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +4 -3
- data/app/assets/javascripts/integral/backend.js +86 -2
- data/app/assets/javascripts/integral/support/character_counter.js +13 -8
- data/app/assets/javascripts/integral/support/list.coffee +1 -0
- data/app/assets/javascripts/integral/support/record_selector.coffee +2 -0
- data/app/assets/javascripts/integral/support/slug_generator.coffee +1 -0
- data/app/assets/stylesheets/integral/backend.sass +34 -23
- data/app/assets/stylesheets/integral/backend/_foundation_settings.scss +2 -2
- data/app/assets/stylesheets/integral/backend/dashboard-layout.scss +27 -63
- data/app/assets/stylesheets/integral/backend/devise.sass +2 -3
- data/app/assets/stylesheets/integral/backend/materialize-tags.sass +1 -0
- data/app/assets/stylesheets/integral/backend/modules/dropdown_pane_notifications.scss +150 -0
- data/app/assets/stylesheets/integral/backend/modules/dropdown_pane_profile.scss +59 -0
- data/app/assets/stylesheets/integral/backend/shared.sass +41 -2
- data/app/assets/stylesheets/integral/frontend/layout.sass +10 -0
- data/app/assets/stylesheets/integral/support/media-query-indicator.sass +4 -4
- data/app/controllers/integral/backend/activities_controller.rb +21 -27
- data/app/controllers/integral/backend/base_controller.rb +87 -37
- data/app/controllers/integral/backend/images_controller.rb +26 -8
- data/app/controllers/integral/backend/lists_controller.rb +2 -14
- data/app/controllers/integral/backend/notification_subscriptions_controller.rb +23 -0
- data/app/controllers/integral/backend/pages_controller.rb +0 -4
- data/app/controllers/integral/backend/posts_controller.rb +0 -4
- data/app/controllers/integral/backend/settings_controller.rb +4 -0
- data/app/controllers/integral/backend/static_pages_controller.rb +6 -0
- data/app/controllers/integral/backend/users_controller.rb +43 -24
- data/app/controllers/integral/blog_controller.rb +12 -0
- data/app/controllers/integral/categories_controller.rb +17 -3
- data/app/controllers/integral/tags_controller.rb +5 -2
- data/app/decorators/integral/base_decorator.rb +16 -0
- data/app/decorators/integral/image_decorator.rb +2 -2
- data/app/decorators/integral/list_decorator.rb +1 -13
- data/app/decorators/integral/notification/notification_decorator.rb +74 -0
- data/app/decorators/integral/page_decorator.rb +1 -13
- data/app/decorators/integral/post_decorator.rb +1 -2
- data/app/decorators/integral/user_decorator.rb +1 -13
- data/app/decorators/integral/version_decorator.rb +8 -4
- data/app/helpers/integral/backend/base_helper.rb +97 -31
- data/app/jobs/integral/application_job.rb +1 -0
- data/app/jobs/integral/newsletter_signup_job.rb +0 -2
- data/app/mailers/integral/devise_mailer.rb +6 -0
- data/app/models/concerns/integral/notification/subscribable.rb +67 -0
- data/app/models/integral/application_record.rb +9 -0
- data/app/models/integral/category.rb +9 -0
- data/app/models/integral/image.rb +40 -3
- data/app/models/integral/list.rb +10 -2
- data/app/models/integral/list_item.rb +14 -14
- data/app/models/integral/list_item_connection.rb +6 -0
- data/app/models/integral/notification/notification.rb +28 -0
- data/app/models/integral/notification/subscription.rb +14 -0
- data/app/models/integral/page.rb +15 -8
- data/app/models/integral/post.rb +11 -13
- data/app/models/integral/user.rb +45 -2
- data/app/policies/integral/base_policy.rb +7 -12
- data/app/policies/integral/page_policy.rb +1 -0
- data/app/policies/integral/version_policy.rb +0 -8
- data/app/views/devise/invitations/edit.haml +1 -4
- data/app/views/devise/mailer/invitation_instructions.inky-haml +20 -0
- data/app/views/integral/backend/activities/grid/_dropdown_actions.haml +1 -0
- data/app/views/integral/backend/activities/grid/_row_content.haml +13 -0
- data/app/views/integral/backend/activities/index.haml +7 -13
- data/app/views/integral/backend/activities/shared/_grid.haml +35 -20
- data/app/views/integral/backend/activities/shared/index.haml +12 -12
- data/app/views/integral/backend/activities/shared/show.haml +7 -7
- data/app/views/integral/backend/activities/show.haml +1 -1
- data/app/views/integral/backend/categories/_modal.haml +2 -3
- data/app/views/integral/backend/images/_form.haml +13 -25
- data/app/views/integral/backend/images/edit.haml +1 -9
- data/app/views/integral/backend/images/grid/_dropdown_actions.haml +5 -0
- data/app/views/integral/backend/images/grid/_row_content.haml +5 -0
- data/app/views/integral/backend/images/index.haml +11 -17
- data/app/views/integral/backend/images/list.haml +11 -0
- data/app/views/integral/backend/images/show.haml +26 -0
- data/app/views/integral/backend/lists/_form.haml +6 -19
- data/app/views/integral/backend/lists/_item_modal.haml +3 -3
- data/app/views/integral/backend/lists/_manager.haml +11 -13
- data/app/views/integral/backend/lists/edit.haml +6 -20
- data/app/views/integral/backend/lists/grid/_dropdown_actions.haml +9 -0
- data/app/views/integral/backend/lists/grid/_row_content.haml +3 -0
- data/app/views/integral/backend/lists/index.haml +11 -17
- data/app/views/integral/backend/lists/list.haml +11 -0
- data/app/views/integral/backend/lists/show.haml +30 -0
- data/app/views/integral/backend/notifications/_notification.haml +21 -0
- data/app/views/integral/backend/pages/_form.haml +19 -43
- data/app/views/integral/backend/pages/edit.haml +4 -12
- data/app/views/integral/backend/pages/grid/_dropdown_actions.haml +11 -0
- data/app/views/integral/backend/pages/grid/_row_content.haml +5 -0
- data/app/views/integral/backend/pages/index.haml +6 -6
- data/app/views/integral/backend/pages/list.haml +12 -19
- data/app/views/integral/backend/pages/show.haml +19 -35
- data/app/views/integral/backend/posts/_form.haml +18 -56
- data/app/views/integral/backend/posts/edit.haml +4 -14
- data/app/views/integral/backend/posts/grid/_dropdown_actions.haml +10 -0
- data/app/views/integral/backend/posts/grid/_row_content.haml +6 -0
- data/app/views/integral/backend/posts/index.haml +6 -6
- data/app/views/integral/backend/posts/list.haml +11 -18
- data/app/views/integral/backend/posts/new.haml +0 -1
- data/app/views/integral/backend/posts/show.haml +18 -41
- data/app/views/integral/backend/shared/_breadcrumbs.haml +7 -4
- data/app/views/integral/backend/shared/_image_preview.haml +10 -3
- data/app/views/integral/backend/shared/_image_selector.haml +1 -1
- data/app/views/integral/backend/shared/_notification_subscription_toggle.haml +22 -0
- data/app/views/integral/backend/shared/action_bar/_index.haml +9 -0
- data/app/views/integral/backend/shared/action_bar/_show.haml +3 -0
- data/app/views/integral/backend/shared/cards/_at_a_glance.haml +3 -3
- data/app/views/integral/backend/shared/cards/_categories.haml +27 -28
- data/app/views/integral/backend/shared/cards/_object.haml +1 -1
- data/app/views/integral/backend/shared/cards/_recent_activity.haml +12 -12
- data/app/views/integral/backend/shared/cards/_recent_resources.haml +17 -0
- data/app/views/integral/backend/shared/cards/_top_post_authors.haml +14 -15
- data/app/views/integral/backend/shared/cards/_welcome.haml +24 -25
- data/app/views/integral/backend/shared/{_empty_grid.haml → grid/_empty.haml} +0 -0
- data/app/views/integral/backend/shared/grid/_form.haml +9 -0
- data/app/views/integral/backend/shared/grid/_grid.haml +21 -0
- data/app/views/integral/backend/shared/{_pagination.haml → grid/_pagination.haml} +0 -0
- data/app/views/integral/backend/shared/grid/_row_layout.haml +8 -0
- data/app/views/integral/backend/shared/record_selector/_collection.haml +1 -0
- data/app/views/integral/backend/shared/record_selector/_modal.haml +9 -10
- data/app/views/integral/backend/static_pages/dashboard.haml +6 -7
- data/app/views/integral/backend/users/_form.haml +34 -46
- data/app/views/integral/backend/users/grid/_dropdown_actions.haml +17 -0
- data/app/views/integral/backend/users/grid/_row_content.haml +8 -0
- data/app/views/integral/backend/users/index.haml +6 -6
- data/app/views/integral/backend/users/list.haml +10 -16
- data/app/views/integral/backend/users/show.haml +10 -1
- data/app/views/integral/categories/show.haml +3 -3
- data/app/views/integral/posts/_article_footer.haml +1 -1
- data/app/views/integral/posts/_card.haml +1 -1
- data/app/views/integral/posts/_most_read_section.haml +1 -1
- data/app/views/integral/posts/_post.haml +1 -1
- data/app/views/integral/posts/templates/default.haml +1 -1
- data/app/views/integral/shared/sidebar/_item.haml +1 -1
- data/app/views/layouts/integral/backend.html.haml +24 -5
- data/app/views/layouts/integral/backend/_create_dropdown.haml +1 -30
- data/app/views/layouts/integral/backend/_main_menu_items.haml +1 -101
- data/config/initializers/devise.rb +1 -1
- data/config/locales/en.yml +60 -2
- data/config/routes.rb +2 -0
- data/db/migrate/20200407022636_create_integral_notifications.rb +25 -0
- data/db/migrate/20200421223602_add_status_to_integral_users.rb +5 -0
- data/db/seeds.rb +15 -11
- data/lib/integral.rb +1 -0
- data/lib/integral/acts_as_integral.rb +115 -0
- data/lib/integral/acts_as_listable.rb +1 -1
- data/lib/integral/engine.rb +9 -0
- data/lib/integral/grids/activities_grid.rb +0 -1
- data/lib/integral/grids/lists_grid.rb +1 -0
- data/lib/integral/grids/posts_grid.rb +5 -1
- data/lib/integral/grids/users_grid.rb +5 -0
- data/lib/integral/list_renderer.rb +5 -1
- data/lib/integral/router.rb +20 -4
- data/lib/integral/version.rb +1 -1
- data/spec/factories.rb +15 -1
- metadata +45 -39
- data/app/decorators/integral/category_version_decorator.rb +0 -7
- data/app/decorators/integral/image_version_decorator.rb +0 -7
- data/app/decorators/integral/list_version_decorator.rb +0 -7
- data/app/decorators/integral/page_version_decorator.rb +0 -7
- data/app/decorators/integral/post_version_decorator.rb +0 -7
- data/app/decorators/integral/user_version_decorator.rb +0 -7
- data/app/views/devise/mailer/invitation_instructions.html.erb +0 -13
- data/app/views/integral/backend/activities/_grid.haml +0 -22
- data/app/views/integral/backend/images/_grid.haml +0 -16
- data/app/views/integral/backend/lists/_grid.haml +0 -14
- data/app/views/integral/backend/pages/_grid.haml +0 -46
- data/app/views/integral/backend/posts/_grid.haml +0 -51
- data/app/views/integral/backend/shared/_grid.haml +0 -18
- data/app/views/integral/backend/shared/cards/_recent_pages.haml +0 -19
- data/app/views/integral/backend/shared/cards/_recent_posts.haml +0 -18
- data/app/views/integral/backend/shared/cards/_recent_users.haml +0 -19
- data/app/views/integral/backend/users/_grid.haml +0 -36
|
@@ -29,45 +29,24 @@ module Integral
|
|
|
29
29
|
# GET /:id
|
|
30
30
|
# Show resource
|
|
31
31
|
def show
|
|
32
|
-
add_breadcrumb I18n.t('integral.navigation.list'),
|
|
33
|
-
add_breadcrumb I18n.t('integral.actions.view')
|
|
32
|
+
add_breadcrumb I18n.t('integral.navigation.list'), list_backend_resources_url
|
|
33
|
+
add_breadcrumb I18n.t('integral.actions.view')
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
# GET /
|
|
37
|
-
#
|
|
38
|
-
def index
|
|
39
|
-
# TODO: This default behaviour will switch to 'list' action
|
|
40
|
-
|
|
41
|
-
respond_to do |format|
|
|
42
|
-
format.html do
|
|
43
|
-
set_grid
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
format.json do
|
|
47
|
-
if params[:gridview].present?
|
|
48
|
-
set_grid
|
|
49
|
-
render json: { content: render_to_string(partial: "integral/backend/#{controller_name}/grid", locals: { grid: @grid }) }
|
|
50
|
-
else
|
|
51
|
-
respond_to_record_selector
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
37
|
+
# Resource dashboard
|
|
38
|
+
def index; end
|
|
56
39
|
|
|
57
40
|
# GET /list
|
|
58
41
|
# Lists all resources
|
|
59
42
|
def list
|
|
60
|
-
add_breadcrumb I18n.t('integral.navigation.list'),
|
|
43
|
+
add_breadcrumb I18n.t('integral.navigation.list'), list_backend_resources_url
|
|
61
44
|
|
|
62
45
|
respond_to do |format|
|
|
63
|
-
format.html
|
|
64
|
-
set_grid
|
|
65
|
-
end
|
|
66
|
-
|
|
46
|
+
format.html
|
|
67
47
|
format.json do
|
|
68
48
|
if params[:gridview].present?
|
|
69
|
-
|
|
70
|
-
render json: { content: render_to_string(partial: "integral/backend/#{controller_name}/grid", locals: { grid: @grid }) }
|
|
49
|
+
render json: { content: render_to_string(partial: "integral/backend/shared/grid/grid") }
|
|
71
50
|
else
|
|
72
51
|
respond_to_record_selector
|
|
73
52
|
end
|
|
@@ -85,13 +64,13 @@ module Integral
|
|
|
85
64
|
# POST /
|
|
86
65
|
# Resource creation
|
|
87
66
|
def create
|
|
88
|
-
add_breadcrumb I18n.t('integral.navigation.create')
|
|
67
|
+
add_breadcrumb I18n.t('integral.navigation.create')
|
|
89
68
|
@resource = resource_klass.new(resource_params)
|
|
90
69
|
|
|
91
70
|
yield if block_given?
|
|
92
71
|
|
|
93
72
|
if @resource.save
|
|
94
|
-
respond_successfully(notification_message('creation_success'),
|
|
73
|
+
respond_successfully(notification_message('creation_success'), edit_backend_resource_url(@resource))
|
|
95
74
|
else
|
|
96
75
|
respond_failure(notification_message('creation_failure'), :new)
|
|
97
76
|
end
|
|
@@ -100,8 +79,8 @@ module Integral
|
|
|
100
79
|
# GET /:id/edit
|
|
101
80
|
# Resource edit screen
|
|
102
81
|
def edit
|
|
103
|
-
add_breadcrumb I18n.t('integral.actions.view'),
|
|
104
|
-
add_breadcrumb I18n.t('integral.
|
|
82
|
+
add_breadcrumb I18n.t('integral.actions.view'), backend_resource_url(@resource)
|
|
83
|
+
add_breadcrumb I18n.t('integral.actions.edit')
|
|
105
84
|
end
|
|
106
85
|
|
|
107
86
|
# PUT /:id
|
|
@@ -153,7 +132,7 @@ module Integral
|
|
|
153
132
|
def activities
|
|
154
133
|
authorize Version
|
|
155
134
|
|
|
156
|
-
add_breadcrumb I18n.t('integral.
|
|
135
|
+
add_breadcrumb I18n.t('integral.actions.view'), backend_resource_url(@resource)
|
|
157
136
|
add_breadcrumb I18n.t('integral.navigation.activity')
|
|
158
137
|
|
|
159
138
|
@grid = Integral::Grids::ActivitiesGrid.new(activity_grid_options.except('page')) do |scope|
|
|
@@ -161,7 +140,7 @@ module Integral
|
|
|
161
140
|
end
|
|
162
141
|
|
|
163
142
|
respond_to do |format|
|
|
164
|
-
format.html { render template: 'integral/backend/activities/shared/index', locals: { form_url:
|
|
143
|
+
format.html { render template: 'integral/backend/activities/shared/index', locals: { form_url: activities_backend_resource_url(@resource) } }
|
|
165
144
|
format.json { render json: { content: render_to_string(partial: 'integral/backend/activities/shared/grid', locals: { grid: @grid }) } }
|
|
166
145
|
end
|
|
167
146
|
end
|
|
@@ -170,7 +149,7 @@ module Integral
|
|
|
170
149
|
def activity
|
|
171
150
|
authorize Version
|
|
172
151
|
|
|
173
|
-
add_breadcrumb I18n.t('integral.navigation.activity'),
|
|
152
|
+
add_breadcrumb I18n.t('integral.navigation.activity'), activities_backend_resource_url(@resource)
|
|
174
153
|
add_breadcrumb I18n.t('integral.actions.view')
|
|
175
154
|
|
|
176
155
|
@activity = resource_version_klass.find(params[:activity_id]).decorate
|
|
@@ -180,6 +159,13 @@ module Integral
|
|
|
180
159
|
|
|
181
160
|
private
|
|
182
161
|
|
|
162
|
+
# Redirect user to integral dashboard after successful signup
|
|
163
|
+
def after_accept_path_for(user)
|
|
164
|
+
user.active!
|
|
165
|
+
|
|
166
|
+
integral.backend_dashboard_path
|
|
167
|
+
end
|
|
168
|
+
|
|
183
169
|
# Redirect user to integral dashboard after successful login
|
|
184
170
|
def after_sign_in_path_for(_resource)
|
|
185
171
|
integral.backend_dashboard_path
|
|
@@ -246,17 +232,81 @@ module Integral
|
|
|
246
232
|
default: I18n.t("integral.backend.notifications.#{type_namespace}", type: resource_klass.model_name.human))
|
|
247
233
|
end
|
|
248
234
|
|
|
249
|
-
|
|
250
|
-
|
|
235
|
+
helper_method :decorated_resource
|
|
236
|
+
def decorated_resource
|
|
237
|
+
@decorated_resource ||= @resource.decorate
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
helper_method :resource_grid
|
|
241
|
+
def resource_grid
|
|
242
|
+
@resource_grid ||= resource_grid_klass.new(grid_options.except('page')) do |scope|
|
|
251
243
|
scope.page(grid_options['page']).per_page(25)
|
|
252
244
|
end
|
|
253
245
|
end
|
|
254
246
|
|
|
247
|
+
helper_method :resource_grid_columns
|
|
248
|
+
def resource_grid_columns
|
|
249
|
+
[]
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
helper_method :render_default_action_bar?
|
|
253
|
+
def render_default_action_bar?
|
|
254
|
+
action_name == 'index' || action_name == 'show'
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
helper_method :new_backend_resource_url
|
|
258
|
+
def new_backend_resource_url
|
|
259
|
+
send("new_backend_#{resource_klass.model_name.singular_route_key}_url")
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
helper_method :list_backend_resources_url
|
|
263
|
+
def list_backend_resources_url
|
|
264
|
+
send("list_backend_#{resource_klass.model_name.route_key}_url")
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
helper_method :activities_backend_resource_url
|
|
268
|
+
def activities_backend_resource_url(resource)
|
|
269
|
+
send("activities_backend_#{controller_name.singularize}_url", resource.id)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
helper_method :backend_resource_url
|
|
273
|
+
def backend_resource_url(resource)
|
|
274
|
+
send("backend_#{resource_klass.model_name.singular_route_key}_url", resource)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
helper_method :edit_backend_resource_url
|
|
278
|
+
def edit_backend_resource_url(resource)
|
|
279
|
+
send("edit_backend_#{resource_klass.model_name.singular_route_key}_url", resource)
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
helper_method :duplicate_backend_resource_url
|
|
283
|
+
def duplicate_backend_resource_url(resource)
|
|
284
|
+
send("duplicate_backend_#{resource_klass.model_name.singular_route_key}_url", resource)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
helper_method :activities_backend_resource_url
|
|
288
|
+
def activities_backend_resource_url(resource)
|
|
289
|
+
send("activities_backend_#{resource_klass.model_name.singular_route_key}_url", resource)
|
|
290
|
+
end
|
|
291
|
+
|
|
255
292
|
helper_method :resource_klass
|
|
256
293
|
def resource_klass
|
|
257
294
|
controller_name.classify.constantize
|
|
258
295
|
end
|
|
259
296
|
|
|
297
|
+
helper_method :dataset_at_a_glance
|
|
298
|
+
def dataset_at_a_glance
|
|
299
|
+
if resource_klass.respond_to?(:statuses)
|
|
300
|
+
resource_klass.statuses.keys.map do |status|
|
|
301
|
+
{ scope: resource_klass.send(status), label: t("integral.statuses.#{status}") }
|
|
302
|
+
end
|
|
303
|
+
else
|
|
304
|
+
[
|
|
305
|
+
{ scope: resource_klass.all, label: "All #{resource_klass.model_name.human.pluralize}" }
|
|
306
|
+
]
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
|
|
260
310
|
helper_method :cast_activities
|
|
261
311
|
def cast_activities(activites)
|
|
262
312
|
activites.map do |version|
|
|
@@ -2,8 +2,8 @@ module Integral
|
|
|
2
2
|
module Backend
|
|
3
3
|
# Images controller
|
|
4
4
|
class ImagesController < BaseController
|
|
5
|
-
before_action :
|
|
6
|
-
before_action :
|
|
5
|
+
before_action :set_resource, except: %i[create index new list]
|
|
6
|
+
before_action :authorize_with_klass, except: %i[activities activity]
|
|
7
7
|
|
|
8
8
|
# GET /new
|
|
9
9
|
# Image creation form
|
|
@@ -32,12 +32,6 @@ module Integral
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
# GET /:id/edit
|
|
36
|
-
# Image edit form
|
|
37
|
-
def edit
|
|
38
|
-
add_breadcrumb I18n.t('integral.navigation.edit'), :edit_backend_img_path
|
|
39
|
-
end
|
|
40
|
-
|
|
41
35
|
# PUT /:id
|
|
42
36
|
# Updating an image
|
|
43
37
|
def update
|
|
@@ -64,6 +58,30 @@ module Integral
|
|
|
64
58
|
Integral::Image
|
|
65
59
|
end
|
|
66
60
|
|
|
61
|
+
def new_backend_resource_url
|
|
62
|
+
new_backend_img_url
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def activities_backend_resource_url(resource)
|
|
66
|
+
activities_backend_img_url(resource)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def list_backend_resources_url
|
|
70
|
+
list_backend_img_index_url
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def backend_resources_url
|
|
74
|
+
backend_img_index_url
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def backend_resource_url(resource)
|
|
78
|
+
backend_img_url(resource)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def edit_backend_resource_url(resource)
|
|
82
|
+
edit_backend_img_url(resource)
|
|
83
|
+
end
|
|
84
|
+
|
|
67
85
|
def remote_request?
|
|
68
86
|
params[:image][:remote].present?
|
|
69
87
|
end
|
|
@@ -2,20 +2,8 @@ module Integral
|
|
|
2
2
|
module Backend
|
|
3
3
|
# List controller
|
|
4
4
|
class ListsController < BaseController
|
|
5
|
-
before_action :set_resource,
|
|
6
|
-
before_action :authorize_with_klass
|
|
7
|
-
before_action -> { set_grid }, only: [:index]
|
|
8
|
-
|
|
9
|
-
# GET /
|
|
10
|
-
# Lists all lists
|
|
11
|
-
def index
|
|
12
|
-
respond_to do |format|
|
|
13
|
-
format.html
|
|
14
|
-
format.json do
|
|
15
|
-
render json: { content: render_to_string(partial: 'integral/backend/lists/grid', locals: { grid: @grid }) }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
5
|
+
before_action :set_resource, except: %i[create index new list]
|
|
6
|
+
before_action :authorize_with_klass, except: %i[activities activity]
|
|
19
7
|
|
|
20
8
|
# POST /:id/duplicate
|
|
21
9
|
# Duplicate a resource
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Integral
|
|
2
|
+
module Backend
|
|
3
|
+
class NotificationSubscriptionsController < BaseController
|
|
4
|
+
def update
|
|
5
|
+
subscription = current_user.own_notification_subscriptions.find_or_initialize_by(resource_params.except('state'))
|
|
6
|
+
subscription.state = resource_params['state']
|
|
7
|
+
|
|
8
|
+
if subscription.save
|
|
9
|
+
head :ok
|
|
10
|
+
else
|
|
11
|
+
head :unprocessable_entity
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def resource_params
|
|
18
|
+
# Must be nicer way to do this, just want to switch out empty subscribable_id for nil
|
|
19
|
+
params[:subscription].permit(:state, :subscribable_type, :subscribable_id).to_h.inject({}) { |h, (k, v)| k == 'subscribable_id' && v =='' ? h[k] = nil : h[k] = v; h }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -12,6 +12,12 @@ module Integral
|
|
|
12
12
|
|
|
13
13
|
private
|
|
14
14
|
|
|
15
|
+
def dataset_at_a_glance
|
|
16
|
+
ActsAsIntegral.backend_at_a_glance_card_items.map do |item|
|
|
17
|
+
{ scope: item, label: "Total #{item.model_name.human.pluralize}" }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
15
21
|
def set_breadcrumbs; end
|
|
16
22
|
end
|
|
17
23
|
end
|
|
@@ -2,28 +2,9 @@ module Integral
|
|
|
2
2
|
module Backend
|
|
3
3
|
# Users controller
|
|
4
4
|
class UsersController < BaseController
|
|
5
|
-
before_action :set_resource, except: %i[create new index list]
|
|
6
|
-
before_action :authorize_with_klass, except: %i[activities activity show edit update]
|
|
5
|
+
before_action :set_resource, except: %i[create new index list account]
|
|
6
|
+
before_action :authorize_with_klass, except: %i[activities activity show edit update account notifications read_notification]
|
|
7
7
|
before_action :authorize_with_instance, only: %i[show edit update]
|
|
8
|
-
before_action -> { set_grid }, only: [:index]
|
|
9
|
-
|
|
10
|
-
# GET /
|
|
11
|
-
# Lists all users
|
|
12
|
-
def index
|
|
13
|
-
respond_to do |format|
|
|
14
|
-
format.html
|
|
15
|
-
format.json do
|
|
16
|
-
render json: { content: render_to_string(partial: 'integral/backend/users/grid', locals: { grid: @grid }) }
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# GET /:id
|
|
22
|
-
# Show specific user
|
|
23
|
-
#
|
|
24
|
-
def show
|
|
25
|
-
add_breadcrumb @resource.name, :backend_user_path
|
|
26
|
-
end
|
|
27
8
|
|
|
28
9
|
# GET /:id/edit
|
|
29
10
|
# Resource edit screen
|
|
@@ -34,7 +15,6 @@ module Integral
|
|
|
34
15
|
|
|
35
16
|
# GET /account
|
|
36
17
|
# Show specific users account page
|
|
37
|
-
#
|
|
38
18
|
def account
|
|
39
19
|
@resource = current_user
|
|
40
20
|
add_breadcrumb @resource.name, :backend_account_path
|
|
@@ -67,8 +47,47 @@ module Integral
|
|
|
67
47
|
end
|
|
68
48
|
end
|
|
69
49
|
|
|
50
|
+
# GET /:id/notifications
|
|
51
|
+
def notifications
|
|
52
|
+
load_more_url = notifications_backend_user_url(current_user, page: current_page+1) if current_user.notifications.count > current_page * Notification::Notification.per_page
|
|
53
|
+
render json: { content: render_to_string(current_user.notifications.recent.page(current_page).decorate, cached: true), load_more_url: load_more_url }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# PUT /:id/read_notification
|
|
57
|
+
def read_notification
|
|
58
|
+
if current_user.notifications.find(params[:notification_id]).read!
|
|
59
|
+
head :ok
|
|
60
|
+
else
|
|
61
|
+
head :unprocessable_entity
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# PUT /:id/block
|
|
66
|
+
# Block a user
|
|
67
|
+
def block
|
|
68
|
+
if @resource.blocked!
|
|
69
|
+
respond_successfully(notification_message('edit_success'), backend_user_path(@resource))
|
|
70
|
+
else
|
|
71
|
+
respond_failure(notification_message('edit_failure'), 'edit')
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# PUT /:id/unblock
|
|
76
|
+
# Unblock a user
|
|
77
|
+
def unblock
|
|
78
|
+
if @resource.active!
|
|
79
|
+
respond_successfully(notification_message('edit_success'), backend_user_path(@resource))
|
|
80
|
+
else
|
|
81
|
+
respond_failure(notification_message('edit_failure'), 'edit')
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
70
85
|
private
|
|
71
86
|
|
|
87
|
+
def current_page
|
|
88
|
+
params[:page].to_i
|
|
89
|
+
end
|
|
90
|
+
|
|
72
91
|
def white_listed_grid_params
|
|
73
92
|
%i[descending order page user action object name status]
|
|
74
93
|
end
|
|
@@ -79,10 +98,10 @@ module Integral
|
|
|
79
98
|
|
|
80
99
|
def resource_params
|
|
81
100
|
unless params[:user][:password].present?
|
|
82
|
-
return params.require(:user).permit(:name, :email, :avatar, :locale, role_ids: [])
|
|
101
|
+
return params.require(:user).permit(:name, :email, :avatar, :locale, :notify_me, role_ids: [])
|
|
83
102
|
end
|
|
84
103
|
|
|
85
|
-
params.require(:user).permit(:name, :email, :avatar, :locale, :password, :password_confirmation, role_ids: [])
|
|
104
|
+
params.require(:user).permit(:name, :email, :avatar, :locale, :notify_me, :password, :password_confirmation, role_ids: [])
|
|
86
105
|
end
|
|
87
106
|
|
|
88
107
|
def authorize_with_instance
|