decidim-admin 0.20.0 → 0.23.1.rc1
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.
Potentially problematic release.
This version of decidim-admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/app/assets/javascripts/decidim/admin/application.js.es6 +8 -0
- data/app/assets/javascripts/decidim/admin/budget_rule_toggler.component.js.es6 +52 -0
- data/app/assets/javascripts/decidim/admin/bundle.js +26 -32
- data/app/assets/javascripts/decidim/admin/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/admin/choose_language.js +12 -0
- data/app/assets/javascripts/decidim/admin/dynamic_fields.component.js.es6 +24 -5
- data/app/assets/javascripts/decidim/admin/form.js.es6 +24 -10
- data/app/assets/javascripts/decidim/admin/gallery.js.es6 +5 -0
- data/app/assets/javascripts/decidim/admin/newsletters.js.es6 +12 -0
- data/app/assets/javascripts/decidim/admin/officializations.js.es6 +20 -0
- data/app/assets/javascripts/decidim/admin/scope_picker_enabler.component.js.es6 +14 -0
- data/app/assets/stylesheets/decidim/admin/_decidim.scss +2 -0
- data/app/assets/stylesheets/decidim/admin/_variables.scss +2 -2
- data/app/assets/stylesheets/decidim/admin/extra/_action-icon.scss +6 -0
- data/app/assets/stylesheets/decidim/admin/extra/_cards.scss +11 -0
- data/app/assets/stylesheets/decidim/admin/extra/_newsletter-templates-gallery.scss +3 -0
- data/app/assets/stylesheets/decidim/admin/extra/_organization-appearance.scss +141 -0
- data/app/assets/stylesheets/decidim/admin/extra/_show_email.scss +31 -0
- data/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +4 -0
- data/app/assets/stylesheets/decidim/admin/modules/_buttons.scss +15 -1
- data/app/assets/stylesheets/decidim/admin/modules/_callouts.scss +11 -0
- data/app/assets/stylesheets/decidim/admin/modules/_cards.scss +13 -2
- data/app/assets/stylesheets/decidim/admin/modules/_filters.scss +78 -1
- data/app/assets/stylesheets/decidim/admin/modules/_forms.scss +16 -2
- data/app/assets/stylesheets/decidim/admin/modules/_import_result.scss +10 -0
- data/app/assets/stylesheets/decidim/admin/modules/_layout.scss +1 -1
- data/app/assets/stylesheets/decidim/admin/modules/_loading-spinner.scss +19 -0
- data/app/assets/stylesheets/decidim/admin/modules/_main-nav.scss +0 -1
- data/app/assets/stylesheets/decidim/admin/modules/_modules.scss +5 -1
- data/app/assets/stylesheets/decidim/admin/modules/_process-header.scss +0 -1
- data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +5 -2
- data/app/assets/stylesheets/decidim/admin/modules/_table-list.scss +23 -7
- data/app/assets/stylesheets/decidim/admin/modules/_tabs.scss +7 -0
- data/app/assets/stylesheets/decidim/admin/modules/_users_statistics.scss +18 -0
- data/app/assets/stylesheets/decidim/admin/utils/_mixins.scss +42 -0
- data/app/assets/stylesheets/decidim/admin/utils/_settings.scss +4 -1
- data/app/cells/decidim/admin/content_block/show.erb +2 -2
- data/app/cells/decidim/admin/results_per_page/show.erb +16 -0
- data/app/cells/decidim/admin/results_per_page_cell.rb +14 -0
- data/app/commands/decidim/admin/create_attachment.rb +2 -2
- data/app/commands/decidim/admin/create_newsletter.rb +34 -9
- data/app/commands/decidim/admin/deliver_newsletter.rb +1 -1
- data/app/commands/decidim/admin/destroy_share_token.rb +46 -0
- data/app/commands/decidim/admin/reorder_content_blocks.rb +1 -1
- data/app/commands/decidim/admin/update_component.rb +27 -3
- data/app/commands/decidim/admin/update_content_block.rb +25 -1
- data/app/commands/decidim/admin/update_newsletter.rb +31 -9
- data/app/commands/decidim/admin/update_organization.rb +15 -1
- data/app/commands/decidim/admin/update_organization_appearance.rb +3 -1
- data/app/controllers/concerns/decidim/admin/filterable.rb +152 -0
- data/app/controllers/concerns/decidim/admin/officializations/filterable.rb +31 -0
- data/app/controllers/concerns/decidim/admin/paginable.rb +20 -0
- data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +8 -2
- data/app/controllers/decidim/admin/admin_terms_controller.rb +20 -0
- data/app/controllers/decidim/admin/application_controller.rb +3 -0
- data/app/controllers/decidim/admin/authorization_workflows_controller.rb +6 -0
- data/app/controllers/decidim/admin/components/base_controller.rb +5 -1
- data/app/controllers/decidim/admin/components_controller.rb +30 -23
- data/app/controllers/decidim/admin/concerns/has_private_users.rb +4 -0
- data/app/controllers/decidim/admin/dashboard_controller.rb +33 -1
- data/app/controllers/decidim/admin/metrics_controller.rb +22 -0
- data/app/controllers/decidim/admin/newsletter_templates_controller.rb +41 -0
- data/app/controllers/decidim/admin/newsletters_controller.rb +43 -4
- data/app/controllers/decidim/admin/officializations_controller.rb +15 -6
- data/app/controllers/decidim/admin/organization_appearance_controller.rb +1 -0
- data/app/controllers/decidim/admin/organization_controller.rb +4 -3
- data/app/controllers/decidim/admin/organization_homepage_content_blocks_controller.rb +2 -1
- data/app/controllers/decidim/admin/share_tokens_controller.rb +30 -0
- data/app/forms/decidim/admin/attachment_form.rb +3 -0
- data/app/forms/decidim/admin/component_form.rb +5 -22
- data/app/forms/decidim/admin/newsletter_form.rb +15 -3
- data/app/forms/decidim/admin/organization_appearance_form.rb +7 -4
- data/app/forms/decidim/admin/organization_form.rb +27 -0
- data/app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb +14 -0
- data/app/forms/decidim/admin/participatory_space_private_user_form.rb +8 -2
- data/app/frontend/components/autocomplete.component.test.tsx +2 -1
- data/app/frontend/components/autocomplete.component.tsx +29 -0
- data/app/helpers/decidim/admin/admin_terms_helper.rb +47 -0
- data/app/helpers/decidim/admin/application_helper.rb +2 -0
- data/app/helpers/decidim/admin/dashboard_helper.rb +25 -0
- data/app/helpers/decidim/admin/filterable_helper.rb +129 -0
- data/app/helpers/decidim/admin/icon_link_helper.rb +1 -1
- data/app/helpers/decidim/admin/newsletters_helper.rb +20 -0
- data/app/helpers/decidim/admin/paginable/per_page_helper.rb +22 -0
- data/app/helpers/decidim/admin/resource_scope_helper.rb +43 -0
- data/app/helpers/decidim/admin/scopes_helper.rb +6 -0
- data/app/helpers/decidim/admin/settings_helper.rb +56 -47
- data/app/helpers/decidim/admin/uploader_image_dimensions_helper.rb +30 -0
- data/app/helpers/decidim/admin/user_roles_helper.rb +19 -0
- data/app/models/decidim/admin/fake_newsletter.rb +49 -0
- data/app/permissions/decidim/admin/permissions.rb +30 -7
- data/app/presenters/decidim/admin/dashboard_metric_charts_presenter.rb +57 -0
- data/app/queries/decidim/admin/active_users_counter.rb +35 -0
- data/app/queries/decidim/admin/newsletter_recipients.rb +20 -9
- data/app/views/decidim/admin/admin_terms/show.html.erb +26 -0
- data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
- data/app/views/decidim/admin/authorization_workflows/index.html.erb +1 -0
- data/app/views/decidim/admin/categories/index.html.erb +1 -1
- data/app/views/decidim/admin/components/_component.html.erb +40 -33
- data/app/views/decidim/admin/components/_form.html.erb +4 -0
- data/app/views/decidim/admin/components/_settings_fields.html.erb +2 -2
- data/app/views/decidim/admin/components/index.html.erb +11 -8
- data/app/views/decidim/admin/dashboard/show.html.erb +49 -9
- data/app/views/decidim/admin/exports/_dropdown.html.erb +6 -2
- data/app/views/decidim/admin/impersonatable_users/index.html.erb +2 -2
- data/app/views/decidim/admin/metrics/_metrics.html.erb +21 -0
- data/app/views/decidim/admin/metrics/index.html.erb +7 -0
- data/app/views/decidim/admin/newsletter_templates/index.html.erb +28 -0
- data/app/views/decidim/admin/newsletter_templates/show.html.erb +12 -0
- data/app/views/decidim/admin/newsletters/_form.html.erb +1 -7
- data/app/views/decidim/admin/newsletters/edit.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/index.html.erb +9 -3
- data/app/views/decidim/admin/newsletters/new.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +4 -4
- data/app/views/decidim/admin/officializations/_show_email_modal.html.erb +31 -0
- data/app/views/decidim/admin/officializations/index.html.erb +9 -41
- data/app/views/decidim/admin/officializations/show_email.html.erb +2 -0
- data/app/views/decidim/admin/organization/_form.html.erb +37 -0
- data/app/views/decidim/admin/organization_appearance/_form.html.erb +2 -72
- data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +23 -0
- data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +38 -0
- data/app/views/decidim/admin/organization_appearance/form/_minimap.html.erb +46 -0
- data/app/views/decidim/admin/resource_permissions/_options_form.html.erb +1 -1
- data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +57 -0
- data/app/views/decidim/admin/shared/_filters.html.erb +40 -0
- data/app/views/decidim/admin/shared/_gallery.html.erb +21 -0
- data/app/views/decidim/admin/static_pages/_form.html.erb +1 -1
- data/app/views/decidim/admin/user_groups/index.html.erb +4 -4
- data/app/views/decidim/admin/users_statistics/_users_count.html.erb +39 -0
- data/app/views/layouts/decidim/admin/_application.html.erb +2 -1
- data/app/views/layouts/decidim/admin/_header.html.erb +3 -0
- data/app/views/layouts/decidim/admin/_title_bar.html.erb +20 -10
- data/app/views/layouts/decidim/admin/newsletters.erb +1 -1
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +57 -49
- data/config/locales/bg-BG.yml +16 -0
- data/config/locales/bg.yml +135 -0
- data/config/locales/ca.yml +130 -50
- data/config/locales/cs.yml +184 -104
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +145 -47
- data/config/locales/el-GR.yml +1 -0
- data/config/locales/el.yml +819 -0
- data/config/locales/en.yml +127 -48
- data/config/locales/eo-UY.yml +0 -1
- data/config/locales/eo.yml +51 -0
- data/config/locales/es-MX.yml +128 -48
- data/config/locales/es-PY.yml +128 -48
- data/config/locales/es.yml +128 -48
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +21 -47
- data/config/locales/fi-plain.yml +128 -48
- data/config/locales/fi.yml +141 -61
- data/config/locales/fr-CA.yml +849 -0
- data/config/locales/fr.yml +128 -48
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +21 -47
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +112 -59
- data/config/locales/id-ID.yml +21 -47
- data/config/locales/is-IS.yml +534 -0
- data/config/locales/is.yml +568 -0
- data/config/locales/it.yml +133 -83
- data/config/locales/ja-JP.yml +855 -0
- data/config/locales/ja.yml +849 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +799 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +103 -48
- data/config/locales/no.yml +603 -32
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +364 -238
- data/config/locales/pt-BR.yml +22 -48
- data/config/locales/pt.yml +334 -237
- data/config/locales/ro-RO.yml +814 -0
- data/config/locales/ru.yml +20 -46
- data/config/locales/sk-SK.yml +823 -0
- data/config/locales/sk.yml +806 -0
- data/config/locales/sl.yml +166 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +590 -0
- data/config/locales/sv.yml +134 -55
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +21 -47
- data/config/locales/uk.yml +19 -48
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +849 -0
- data/config/locales/zh-TW.yml +1 -0
- data/config/routes.rb +20 -3
- data/db/migrate/20191118112040_add_accepted_admin_terms_at_field_to_users.rb +7 -0
- data/lib/decidim/admin.rb +17 -0
- data/lib/decidim/admin/engine.rb +12 -9
- data/lib/decidim/admin/form_builder.rb +7 -2
- data/lib/decidim/admin/test.rb +2 -0
- data/lib/decidim/admin/test/filterable_examples.rb +129 -0
- data/lib/decidim/admin/test/manage_attachment_collections_examples.rb +1 -1
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +15 -15
- data/lib/decidim/admin/test/manage_paginated_collection_examples.rb +22 -0
- data/lib/decidim/admin/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.serializejson.js +344 -0
- metadata +101 -31
- data/app/commands/decidim/admin/create_oauth_application.rb +0 -36
- data/app/commands/decidim/admin/destroy_oauth_application.rb +0 -39
- data/app/commands/decidim/admin/update_oauth_application.rb +0 -39
- data/app/controllers/decidim/admin/oauth_applications_controller.rb +0 -90
- data/app/forms/decidim/admin/oauth_application_form.rb +0 -32
- data/app/views/decidim/admin/oauth_applications/_form.html.erb +0 -19
- data/app/views/decidim/admin/oauth_applications/edit.html.erb +0 -13
- data/app/views/decidim/admin/oauth_applications/index.html.erb +0 -40
- data/app/views/decidim/admin/oauth_applications/new.html.erb +0 -13
- data/app/views/decidim/admin/oauth_applications/show.html.erb +0 -27
@@ -0,0 +1 @@
|
|
1
|
+
zh-TW:
|
data/config/routes.rb
CHANGED
@@ -23,6 +23,7 @@ Decidim::Admin::Engine.routes.draw do
|
|
23
23
|
resources :scopes, except: [:show] do
|
24
24
|
resources :scopes, except: [:show]
|
25
25
|
end
|
26
|
+
resources :metrics, only: [:index]
|
26
27
|
resources :logs, only: [:index]
|
27
28
|
resources :area_types, except: [:show]
|
28
29
|
resources :areas, except: [:show]
|
@@ -39,7 +40,9 @@ Decidim::Admin::Engine.routes.draw do
|
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
resources :officializations, only: [:new, :create, :index, :destroy], param: :user_id
|
43
|
+
resources :officializations, only: [:new, :create, :index, :destroy], param: :user_id do
|
44
|
+
get :show_email, on: :member
|
45
|
+
end
|
43
46
|
|
44
47
|
resources :impersonatable_users, only: [:index] do
|
45
48
|
resources :promotions, controller: "managed_users/promotions", only: [:new, :create]
|
@@ -51,9 +54,18 @@ Decidim::Admin::Engine.routes.draw do
|
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
54
|
-
resources :
|
57
|
+
resources :newsletter_templates, only: [:index, :show] do
|
58
|
+
resources :newsletters, only: [:new, :create]
|
59
|
+
|
55
60
|
member do
|
56
61
|
get :preview
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
resources :newsletters, except: [:new, :create] do
|
66
|
+
member do
|
67
|
+
get :recipients_count
|
68
|
+
get :preview
|
57
69
|
get :select_recipients_to_deliver
|
58
70
|
post :deliver
|
59
71
|
end
|
@@ -71,7 +83,12 @@ Decidim::Admin::Engine.routes.draw do
|
|
71
83
|
|
72
84
|
resource :help_sections, only: [:show, :update]
|
73
85
|
|
74
|
-
|
86
|
+
namespace :admin_terms do
|
87
|
+
get :show
|
88
|
+
put :accept
|
89
|
+
end
|
90
|
+
|
91
|
+
resources :share_tokens, only: :destroy
|
75
92
|
|
76
93
|
root to: "dashboard#show"
|
77
94
|
end
|
data/lib/decidim/admin.rb
CHANGED
@@ -11,5 +11,22 @@ module Decidim
|
|
11
11
|
module Admin
|
12
12
|
autoload :Components, "decidim/admin/components"
|
13
13
|
autoload :FormBuilder, "decidim/admin/form_builder"
|
14
|
+
|
15
|
+
include ActiveSupport::Configurable
|
16
|
+
|
17
|
+
# Public Setting that configures Kaminari configuration options
|
18
|
+
# https://github.com/kaminari/kaminari#general-configuration-options
|
19
|
+
|
20
|
+
# Range of number of results per_page. Defaults to [15, 50, 100].
|
21
|
+
# per_page_range.first sets the default number per page
|
22
|
+
# per_page_range.last sets the default max_per_page
|
23
|
+
config_accessor :per_page_range do
|
24
|
+
[15, 50, 100]
|
25
|
+
end
|
26
|
+
|
27
|
+
Kaminari.configure do |config|
|
28
|
+
config.default_per_page = Decidim::Admin.per_page_range.first
|
29
|
+
config.max_per_page = Decidim::Admin.per_page_range.last
|
30
|
+
end
|
14
31
|
end
|
15
32
|
end
|
data/lib/decidim/admin/engine.rb
CHANGED
@@ -54,14 +54,24 @@ module Decidim
|
|
54
54
|
allowed_to?(:read, :admin_user) ? decidim_admin.users_path : decidim_admin.impersonatable_users_path,
|
55
55
|
icon_name: "person",
|
56
56
|
position: 5,
|
57
|
-
active: [%w(
|
57
|
+
active: [%w(
|
58
|
+
decidim/admin/users
|
59
|
+
decidim/admin/user_groups
|
60
|
+
decidim/admin/user_groups_csv_verifications
|
61
|
+
decidim/admin/officializations
|
62
|
+
decidim/admin/impersonatable_users
|
63
|
+
decidim/admin/managed_users/impersonation_logs
|
64
|
+
decidim/admin/managed_users/promotions
|
65
|
+
decidim/admin/authorization_workflows
|
66
|
+
), []],
|
58
67
|
if: allowed_to?(:read, :admin_user) || allowed_to?(:read, :managed_user)
|
59
68
|
|
60
69
|
menu.item I18n.t("menu.newsletters", scope: "decidim.admin"),
|
61
70
|
decidim_admin.newsletters_path,
|
62
71
|
icon_name: "envelope-closed",
|
63
72
|
position: 6,
|
64
|
-
active: :inclusive
|
73
|
+
active: is_active_link?(decidim_admin.newsletters_path, :inclusive) ||
|
74
|
+
is_active_link?(decidim_admin.newsletter_templates_path, :inclusive),
|
65
75
|
if: allowed_to?(:index, :newsletter)
|
66
76
|
|
67
77
|
menu.item I18n.t("menu.settings", scope: "decidim.admin"),
|
@@ -88,13 +98,6 @@ module Decidim
|
|
88
98
|
position: 10,
|
89
99
|
active: [%w(decidim/admin/logs), []],
|
90
100
|
if: allowed_to?(:read, :admin_log)
|
91
|
-
|
92
|
-
menu.item I18n.t("menu.oauth_applications", scope: "decidim.admin"),
|
93
|
-
decidim_admin.oauth_applications_path,
|
94
|
-
icon_name: "dashboard",
|
95
|
-
position: 11,
|
96
|
-
active: [%w(decidim/admin/oauth_applications), []],
|
97
|
-
if: allowed_to?(:read, :oauth_application)
|
98
101
|
end
|
99
102
|
end
|
100
103
|
|
@@ -41,15 +41,15 @@ module Decidim
|
|
41
41
|
#
|
42
42
|
def autocomplete_select(attribute, selected = nil, options = {}, prompt_options = {})
|
43
43
|
selected = yield(selected) if selected
|
44
|
-
|
45
44
|
template = ""
|
46
45
|
template += label(attribute, (options[:label] || label_for(attribute)) + required_for_attribute(attribute)) unless options[:label] == false
|
47
46
|
template += content_tag(:div, nil, class: options[:class], data: {
|
48
47
|
autocomplete: {
|
49
48
|
name: options[:name] || "#{@object_name}[#{attribute}]",
|
50
|
-
options: [selected].compact,
|
49
|
+
options: (options[:default_options].to_a + [selected]).compact,
|
51
50
|
placeholder: prompt_options[:placeholder],
|
52
51
|
searchURL: prompt_options[:url],
|
52
|
+
changeURL: prompt_options[:change_url],
|
53
53
|
selected: selected ? selected[:value] : "",
|
54
54
|
searchPromptText: options[:search_prompt] || I18n.t("autocomplete.search_prompt", scope: "decidim.admin"),
|
55
55
|
noResultsText: options[:no_results] || I18n.t("autocomplete.no_results", scope: "decidim.admin")
|
@@ -60,6 +60,11 @@ module Decidim
|
|
60
60
|
template += error_for(attribute, options) if error?(attribute)
|
61
61
|
template.html_safe
|
62
62
|
end
|
63
|
+
|
64
|
+
# Calls Decidim::FormBuilder#editor with default options for admin.
|
65
|
+
def editor(name, options = {})
|
66
|
+
super(name, { toolbar: :full, lines: 25 }.merge(options))
|
67
|
+
end
|
63
68
|
end
|
64
69
|
end
|
65
70
|
end
|
data/lib/decidim/admin/test.rb
CHANGED
@@ -5,3 +5,5 @@ require "decidim/admin/test/manage_attachment_collections_examples"
|
|
5
5
|
require "decidim/admin/test/manage_categories_examples"
|
6
6
|
require "decidim/admin/test/manage_component_permissions_examples"
|
7
7
|
require "decidim/admin/test/manage_moderations_examples"
|
8
|
+
require "decidim/admin/test/manage_paginated_collection_examples"
|
9
|
+
require "decidim/admin/test/filterable_examples"
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_context "with filterable context" do
|
4
|
+
let(:factory_name) { model_name.singular_route_key }
|
5
|
+
let(:module_name) { model_name.route_key.camelize }
|
6
|
+
let(:filterable_concern) { "Decidim::#{module_name}::Admin::Filterable".constantize }
|
7
|
+
|
8
|
+
let(:filterable_fake_controller) do
|
9
|
+
FILTERABLE_CONCERN ||= filterable_concern
|
10
|
+
class FilterableFakeController < Decidim::ApplicationController; include FILTERABLE_CONCERN; end
|
11
|
+
end
|
12
|
+
|
13
|
+
def filterable_method(method_name)
|
14
|
+
(@controller ||= filterable_fake_controller.new).send(method_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def apply_filter(options, filter)
|
18
|
+
within(".filters__section") do
|
19
|
+
find_link("Filter").hover
|
20
|
+
find_link(options).hover
|
21
|
+
click_link(filter, href: /q/)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def remove_applied_filter(filter)
|
26
|
+
within(".label", text: /#{filter}/i) do
|
27
|
+
click_link("Cancel")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def search_by_text(text)
|
32
|
+
within(".filters__section") do
|
33
|
+
fill_in("q[#{filterable_method(:search_field_predicate)}]", with: text)
|
34
|
+
find("*[type=submit]").click
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
shared_examples "paginating a collection" do
|
39
|
+
unless block_given?
|
40
|
+
let!(:collection) do
|
41
|
+
create_list(factory_name, 50, organization: organization)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it_behaves_like "a paginated collection"
|
46
|
+
end
|
47
|
+
|
48
|
+
shared_examples "searching by text" do
|
49
|
+
before { search_by_text(text) }
|
50
|
+
|
51
|
+
it { expect(page).to have_content(text) }
|
52
|
+
|
53
|
+
after { search_by_text("") }
|
54
|
+
end
|
55
|
+
|
56
|
+
shared_examples "a filtered collection" do |options:, filter:|
|
57
|
+
before { apply_filter(options, filter) }
|
58
|
+
|
59
|
+
it { expect(page).to have_content(in_filter) }
|
60
|
+
it { expect(page).not_to have_content(not_in_filter) }
|
61
|
+
|
62
|
+
it_behaves_like "searching by text" do
|
63
|
+
let(:text) { in_filter }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when removing applied filter" do
|
67
|
+
before { remove_applied_filter(filter) }
|
68
|
+
|
69
|
+
it { expect(page).to have_content(in_filter) }
|
70
|
+
it { expect(page).to have_content(not_in_filter) }
|
71
|
+
|
72
|
+
it_behaves_like "searching by text" do
|
73
|
+
let(:text) { not_in_filter }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
shared_examples "filtering collection by published/unpublished" do
|
80
|
+
include_context "with filterable context"
|
81
|
+
|
82
|
+
unless block_given?
|
83
|
+
let!(:published_space) do
|
84
|
+
create(factory_name, published_at: Time.current, organization: organization)
|
85
|
+
end
|
86
|
+
|
87
|
+
let!(:unpublished_space) do
|
88
|
+
create(factory_name, published_at: nil, organization: organization)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it_behaves_like "a filtered collection", options: "Published", filter: "Published" do
|
93
|
+
let(:in_filter) { translated(published_space.title) }
|
94
|
+
let(:not_in_filter) { translated(unpublished_space.title) }
|
95
|
+
end
|
96
|
+
|
97
|
+
it_behaves_like "a filtered collection", options: "Published", filter: "Unpublished" do
|
98
|
+
let(:in_filter) { translated(unpublished_space.title) }
|
99
|
+
let(:not_in_filter) { translated(published_space.title) }
|
100
|
+
end
|
101
|
+
|
102
|
+
it_behaves_like "paginating a collection"
|
103
|
+
end
|
104
|
+
|
105
|
+
shared_examples "filtering collection by private/public" do
|
106
|
+
include_context "with filterable context"
|
107
|
+
|
108
|
+
unless block_given?
|
109
|
+
let!(:public_space) do
|
110
|
+
create(factory_name, private_space: false, organization: organization)
|
111
|
+
end
|
112
|
+
|
113
|
+
let!(:private_space) do
|
114
|
+
create(factory_name, private_space: true, organization: organization)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
it_behaves_like "a filtered collection", options: "Private", filter: "Public" do
|
119
|
+
let(:in_filter) { translated(public_space.title) }
|
120
|
+
let(:not_in_filter) { translated(private_space.title) }
|
121
|
+
end
|
122
|
+
|
123
|
+
it_behaves_like "a filtered collection", options: "Private", filter: "Private" do
|
124
|
+
let(:in_filter) { translated(private_space.title) }
|
125
|
+
let(:not_in_filter) { translated(public_space.title) }
|
126
|
+
end
|
127
|
+
|
128
|
+
it_behaves_like "paginating a collection"
|
129
|
+
end
|
@@ -82,7 +82,7 @@ shared_examples "manage attachment collections examples" do
|
|
82
82
|
context "when deleting a attachment collection" do
|
83
83
|
let!(:attachment_collection2) { create(:attachment_collection, collection_for: collection_for) }
|
84
84
|
|
85
|
-
context "when the attachment collection has no associated content" do
|
85
|
+
context "when the attachment collection has no associated content", :slow do
|
86
86
|
before do
|
87
87
|
visit current_path
|
88
88
|
end
|
@@ -31,7 +31,7 @@ shared_examples "Managing component permissions" do
|
|
31
31
|
within "form.new_component_permissions" do
|
32
32
|
within ".foo-permission" do
|
33
33
|
check "Example authorization (Direct)"
|
34
|
-
fill_in "
|
34
|
+
fill_in "Allowed postal codes", with: "08002"
|
35
35
|
end
|
36
36
|
find("*[type=submit]").click
|
37
37
|
end
|
@@ -42,7 +42,7 @@ shared_examples "Managing component permissions" do
|
|
42
42
|
include(
|
43
43
|
"authorization_handlers" => {
|
44
44
|
"dummy_authorization_handler" => {
|
45
|
-
"options" => { "
|
45
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
46
46
|
}
|
47
47
|
}
|
48
48
|
)
|
@@ -61,7 +61,7 @@ shared_examples "Managing component permissions" do
|
|
61
61
|
within "form.new_component_permissions" do
|
62
62
|
within ".foo-permission" do
|
63
63
|
check "Example authorization (Direct)"
|
64
|
-
fill_in "
|
64
|
+
fill_in "Allowed postal codes", with: "08002"
|
65
65
|
end
|
66
66
|
find("*[type=submit]").click
|
67
67
|
end
|
@@ -79,7 +79,7 @@ shared_examples "Managing component permissions" do
|
|
79
79
|
"foo" => {
|
80
80
|
"authorization_handlers" => {
|
81
81
|
"dummy_authorization_handler" => {
|
82
|
-
"options" => { "
|
82
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
83
83
|
}
|
84
84
|
}
|
85
85
|
}
|
@@ -114,7 +114,7 @@ shared_examples "Managing component permissions" do
|
|
114
114
|
"foo" => {
|
115
115
|
"authorization_handlers" => {
|
116
116
|
"dummy_authorization_handler" => {
|
117
|
-
"options" => { "
|
117
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
118
118
|
}
|
119
119
|
}
|
120
120
|
}
|
@@ -166,7 +166,7 @@ shared_examples "Managing component permissions" do
|
|
166
166
|
include(
|
167
167
|
"authorization_handlers" => {
|
168
168
|
"dummy_authorization_handler" => {
|
169
|
-
"options" => { "
|
169
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
170
170
|
},
|
171
171
|
"another_dummy_authorization_handler" => {
|
172
172
|
"options" => { "passport_number" => "AXXXXXXXX" }
|
@@ -201,7 +201,7 @@ shared_examples "Managing component permissions" do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
it "shows the resource permissions settings" do
|
204
|
-
expect(page).to have_content(resource.title)
|
204
|
+
expect(page).to have_content(translated(resource.title))
|
205
205
|
end
|
206
206
|
|
207
207
|
context "when resources permissions are disabled" do
|
@@ -217,7 +217,7 @@ shared_examples "Managing component permissions" do
|
|
217
217
|
within "form.new_component_permissions" do
|
218
218
|
within ".foo-permission" do
|
219
219
|
check "Example authorization (Direct)"
|
220
|
-
fill_in "
|
220
|
+
fill_in "Allowed postal codes", with: "08002"
|
221
221
|
end
|
222
222
|
find("*[type=submit]").click
|
223
223
|
end
|
@@ -228,7 +228,7 @@ shared_examples "Managing component permissions" do
|
|
228
228
|
include(
|
229
229
|
"authorization_handlers" => {
|
230
230
|
"dummy_authorization_handler" => {
|
231
|
-
"options" => { "
|
231
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
232
232
|
}
|
233
233
|
}
|
234
234
|
)
|
@@ -244,7 +244,7 @@ shared_examples "Managing component permissions" do
|
|
244
244
|
"foo" => {
|
245
245
|
"authorization_handlers" => {
|
246
246
|
"dummy_authorization_handler" => {
|
247
|
-
"options" => { "
|
247
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
248
248
|
}
|
249
249
|
}
|
250
250
|
}
|
@@ -277,7 +277,7 @@ shared_examples "Managing component permissions" do
|
|
277
277
|
"foo" => {
|
278
278
|
"authorization_handlers" => {
|
279
279
|
"dummy_authorization_handler" => {
|
280
|
-
"options" => { "
|
280
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
281
281
|
}
|
282
282
|
}
|
283
283
|
}
|
@@ -327,7 +327,7 @@ shared_examples "Managing component permissions" do
|
|
327
327
|
include(
|
328
328
|
"authorization_handlers" => {
|
329
329
|
"dummy_authorization_handler" => {
|
330
|
-
"options" => { "
|
330
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
331
331
|
},
|
332
332
|
"another_dummy_authorization_handler" => {
|
333
333
|
"options" => { "passport_number" => "AXXXXXXXX" }
|
@@ -345,7 +345,7 @@ shared_examples "Managing component permissions" do
|
|
345
345
|
"foo" => {
|
346
346
|
"authorization_handlers" => {
|
347
347
|
"dummy_authorization_handler" => {
|
348
|
-
"options" => { "
|
348
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
349
349
|
}
|
350
350
|
}
|
351
351
|
}
|
@@ -395,7 +395,7 @@ shared_examples "Managing component permissions" do
|
|
395
395
|
include(
|
396
396
|
"authorization_handlers" => {
|
397
397
|
"dummy_authorization_handler" => {
|
398
|
-
"options" => { "
|
398
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
399
399
|
},
|
400
400
|
"another_dummy_authorization_handler" => {
|
401
401
|
"options" => { "passport_number" => "AXXXXXXXX" }
|
@@ -413,7 +413,7 @@ shared_examples "Managing component permissions" do
|
|
413
413
|
"foo" => {
|
414
414
|
"authorization_handlers" => {
|
415
415
|
"dummy_authorization_handler" => {
|
416
|
-
"options" => { "
|
416
|
+
"options" => { "allowed_postal_codes" => "08002" }
|
417
417
|
}
|
418
418
|
}
|
419
419
|
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_examples "a paginated collection" do
|
4
|
+
before do
|
5
|
+
visit current_path
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "Number of results per page" do
|
9
|
+
it "lists 15 resources per page by default" do
|
10
|
+
expect(page).to have_css(".table-list tbody tr", count: 15)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "changes the number of results per page" do
|
14
|
+
within ".results-per-page__dropdown" do
|
15
|
+
page.find("a", text: "15").click
|
16
|
+
click_link "50"
|
17
|
+
end
|
18
|
+
|
19
|
+
expect(page).to have_selector(".table-list tbody tr", count: 50)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|