decidim-admin 0.20.1 → 0.23.1
Sign up to get free protection for your applications and to get access to all the features.
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 +52 -47
- data/config/locales/bg-BG.yml +16 -0
- data/config/locales/bg.yml +135 -0
- data/config/locales/ca.yml +127 -48
- data/config/locales/cs.yml +182 -103
- 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.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 +127 -48
- data/config/locales/es-PY.yml +127 -48
- data/config/locales/es.yml +127 -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 +127 -48
- data/config/locales/fi.yml +140 -61
- data/config/locales/fr-CA.yml +849 -0
- data/config/locales/fr.yml +133 -53
- 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 +100 -48
- data/config/locales/id-ID.yml +21 -47
- data/config/locales/is-IS.yml +19 -45
- data/config/locales/is.yml +568 -0
- data/config/locales/it.yml +132 -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 +102 -48
- data/config/locales/no.yml +147 -84
- 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 +140 -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 +98 -30
- 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
@@ -49,7 +49,11 @@ $process-title-height: 3rem;
|
|
49
49
|
|
50
50
|
.secondary-nav--subnav,
|
51
51
|
.process-content{
|
52
|
-
padding-top:
|
52
|
+
padding-top: 1rem;
|
53
|
+
|
54
|
+
& > .card:first-child{
|
55
|
+
margin-top: -2rem;
|
56
|
+
}
|
53
57
|
|
54
58
|
@include breakpoint(large){
|
55
59
|
min-height: calc(100% - #{$process-title-height});
|
@@ -60,7 +64,6 @@ $process-title-height: 3rem;
|
|
60
64
|
.secondary-nav__title,
|
61
65
|
.process-title-content{
|
62
66
|
margin-bottom: 1.5rem;
|
63
|
-
text-transform: uppercase;
|
64
67
|
font-size: .8rem;
|
65
68
|
letter-spacing: .1em;
|
66
69
|
font-weight: bold;
|
@@ -7,10 +7,7 @@
|
|
7
7
|
//Table list
|
8
8
|
.table-list{
|
9
9
|
border-collapse: collapse;
|
10
|
-
|
11
|
-
th{
|
12
|
-
text-transform: uppercase;
|
13
|
-
}
|
10
|
+
border-spacing: 0;
|
14
11
|
|
15
12
|
th,
|
16
13
|
td{
|
@@ -24,18 +21,18 @@
|
|
24
21
|
|
25
22
|
th:first-child,
|
26
23
|
td:first-child{
|
27
|
-
padding-left:
|
24
|
+
padding-left: $global-padding;
|
28
25
|
}
|
29
26
|
|
30
27
|
th:last-child,
|
31
28
|
td:last-child{
|
32
|
-
padding-right:
|
29
|
+
padding-right: $global-padding;
|
33
30
|
text-align: right;
|
34
31
|
}
|
35
32
|
|
36
33
|
th [type="checkbox"]:only-child,
|
37
34
|
td [type="checkbox"]:only-child{
|
38
|
-
margin-bottom:
|
35
|
+
margin-bottom: .5rem;
|
39
36
|
}
|
40
37
|
|
41
38
|
&.table-list--lastcenter{
|
@@ -115,3 +112,22 @@
|
|
115
112
|
.table-list__state{
|
116
113
|
text-align: center;
|
117
114
|
}
|
115
|
+
|
116
|
+
.table-list__type-icon{
|
117
|
+
position: relative;
|
118
|
+
top: 1px;
|
119
|
+
cursor: pointer;
|
120
|
+
}
|
121
|
+
|
122
|
+
.table-list__type-label{
|
123
|
+
display: none;
|
124
|
+
position: relative;
|
125
|
+
top: -1px;
|
126
|
+
margin-left: -1.5 * $global-padding;
|
127
|
+
font-size: 80%;
|
128
|
+
font-weight: 600;
|
129
|
+
|
130
|
+
&.expanded{
|
131
|
+
display: inline-block;
|
132
|
+
}
|
133
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
.table-list.users_count tbody tr td.title{
|
2
|
+
text-align: center;
|
3
|
+
color: $medium-gray;
|
4
|
+
}
|
5
|
+
|
6
|
+
.table-list.users_count th:not(:first-child),
|
7
|
+
.table-list.users_count td:not(:first-child){
|
8
|
+
text-align: center;
|
9
|
+
}
|
10
|
+
|
11
|
+
.table-list.users_count th:last-child,
|
12
|
+
.table-list.users_count td:last-child{
|
13
|
+
text-align: center;
|
14
|
+
}
|
15
|
+
|
16
|
+
.table-list.users_count th{
|
17
|
+
text-transform: capitalize;
|
18
|
+
}
|
@@ -18,6 +18,13 @@
|
|
18
18
|
font-size: .9em;
|
19
19
|
}
|
20
20
|
|
21
|
+
//Small emphasis
|
22
|
+
@mixin smallemphasis{
|
23
|
+
font-weight: 600;
|
24
|
+
letter-spacing: .1em;
|
25
|
+
font-size: .9em;
|
26
|
+
}
|
27
|
+
|
21
28
|
// Status modifier mixin
|
22
29
|
$palette: $foundation-palette;
|
23
30
|
|
@@ -80,3 +87,38 @@ $side:(
|
|
80
87
|
}
|
81
88
|
|
82
89
|
@include make-spaces()
|
90
|
+
|
91
|
+
@mixin animation($animation){
|
92
|
+
-webkit-animation: $animation;
|
93
|
+
-o-animation: $animation;
|
94
|
+
animation: $animation;
|
95
|
+
}
|
96
|
+
|
97
|
+
@mixin spinner($size, $orbit, $satellite, $time){
|
98
|
+
@include animation( animation-spin $time infinite linear );
|
99
|
+
@include square($size);
|
100
|
+
|
101
|
+
box-sizing: border-box;
|
102
|
+
border-radius: 50%;
|
103
|
+
border: floor(($size / 8)) solid $orbit;
|
104
|
+
border-right-color: $satellite;
|
105
|
+
display: inline-block;
|
106
|
+
position: relative;
|
107
|
+
}
|
108
|
+
|
109
|
+
@mixin size($width, $height){
|
110
|
+
width: $width;
|
111
|
+
height: $height;
|
112
|
+
}
|
113
|
+
|
114
|
+
@mixin square($size){
|
115
|
+
@include size($size, $size);
|
116
|
+
}
|
117
|
+
|
118
|
+
@keyframes animation-spin{
|
119
|
+
to{ transform: rotate(1turn); }
|
120
|
+
}
|
121
|
+
|
122
|
+
@-webkit-keyframes animation-spin{
|
123
|
+
to{ -webkit-transform: rotate(1turn); }
|
124
|
+
}
|
@@ -276,7 +276,7 @@ $breadcrumbs-item-color: $primary-color;
|
|
276
276
|
$breadcrumbs-item-color-current: $black;
|
277
277
|
$breadcrumbs-item-color-disabled: $medium-gray;
|
278
278
|
$breadcrumbs-item-margin: .75rem;
|
279
|
-
$breadcrumbs-item-uppercase:
|
279
|
+
$breadcrumbs-item-uppercase: false;
|
280
280
|
$breadcrumbs-item-separator: true;
|
281
281
|
$breadcrumbs-item-separator-color: $medium-gray;
|
282
282
|
|
@@ -443,6 +443,9 @@ $input-background-focus: $white;
|
|
443
443
|
$input-background-disabled: $light-gray;
|
444
444
|
$input-border: 1px solid $light-gray;
|
445
445
|
$input-border-focus: 1px solid map-get($foundation-palette, primary);
|
446
|
+
$input-outline: 0;
|
447
|
+
$input-outline-focus: 2px solid $primary-color;
|
448
|
+
$input-outline-offset: 2px;
|
446
449
|
$input-padding: $form-spacing / 2;
|
447
450
|
$input-shadow: inset 0 1px 2px rgba($black, .1);
|
448
451
|
$input-shadow-focus: 0 0 5px $medium-gray;
|
@@ -4,10 +4,10 @@
|
|
4
4
|
<div>
|
5
5
|
<% if has_settings? %>
|
6
6
|
<%= link_to decidim_admin.edit_organization_homepage_content_block_path(manifest_name), class: "mr-s text-muted" do %>
|
7
|
-
<%= icon "pencil" %>
|
7
|
+
<%= icon "pencil", role: "img" %>
|
8
8
|
<% end %>
|
9
9
|
<% end %>
|
10
|
-
<%= icon "menu" %>
|
10
|
+
<%= icon "menu", role: "img" %>
|
11
11
|
</div>
|
12
12
|
</div>
|
13
13
|
</li>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<span class="dropdown-menu-inverted_label"><%= t("decidim.admin.actions.per_page") %> :</span>
|
2
|
+
<ul class="results-per-page__dropdown dropdown menu dropdown-inverted" data-dropdown-menu data-close-on-click-inside="false">
|
3
|
+
<li class="is-dropdown-submenu-parent">
|
4
|
+
<a title="<%= %{#{per_page} #{t("decidim.admin.actions.per_page")}} %>">
|
5
|
+
<%= per_page %>
|
6
|
+
</a>
|
7
|
+
|
8
|
+
<ul class="menu">
|
9
|
+
<% per_page_range.each do |num_per_page| %>
|
10
|
+
<li>
|
11
|
+
<%= link_to num_per_page, path_for_num_per_page(num_per_page) %>
|
12
|
+
</li>
|
13
|
+
<% end %>
|
14
|
+
</ul>
|
15
|
+
</li>
|
16
|
+
</ul>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
class ResultsPerPageCell < Decidim::ViewModel
|
6
|
+
property :per_page, :per_page_range
|
7
|
+
delegate :params, to: :controller, prefix: false
|
8
|
+
|
9
|
+
def path_for_num_per_page(num_per_page = per_page_range.first)
|
10
|
+
controller.url_for(params.to_unsafe_h.merge(per_page: num_per_page))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -43,10 +43,10 @@ module Decidim
|
|
43
43
|
@attachment = Attachment.new(
|
44
44
|
title: form.title,
|
45
45
|
description: form.description,
|
46
|
-
file: form.file,
|
47
46
|
attached_to: @attached_to,
|
48
47
|
weight: form.weight,
|
49
|
-
attachment_collection: form.attachment_collection
|
48
|
+
attachment_collection: form.attachment_collection,
|
49
|
+
file: form.file # Define attached_to before this
|
50
50
|
)
|
51
51
|
end
|
52
52
|
|
@@ -8,25 +8,50 @@ module Decidim
|
|
8
8
|
# Initializes the command.
|
9
9
|
#
|
10
10
|
# form - The source fo data for this newsletter.
|
11
|
+
# content_block - An instance of `Decidim::ContentBlock` that holds the
|
12
|
+
# newsletter attributes.
|
11
13
|
# user - The User that authored this newsletter.
|
12
|
-
def initialize(form, user)
|
14
|
+
def initialize(form, content_block, user)
|
13
15
|
@form = form
|
16
|
+
@content_block = content_block
|
14
17
|
@user = user
|
15
18
|
end
|
16
19
|
|
17
20
|
def call
|
18
|
-
return broadcast(:invalid) unless
|
21
|
+
return broadcast(:invalid) unless form.valid?
|
19
22
|
|
20
|
-
|
23
|
+
transaction do
|
24
|
+
create_newsletter
|
25
|
+
create_content_block
|
26
|
+
end
|
27
|
+
|
28
|
+
broadcast(:ok, newsletter)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :user, :form, :newsletter, :content_block
|
34
|
+
|
35
|
+
def create_newsletter
|
36
|
+
@newsletter = Decidim.traceability.create!(
|
21
37
|
Newsletter,
|
22
|
-
|
23
|
-
subject:
|
24
|
-
|
25
|
-
|
26
|
-
organization: @user.organization
|
38
|
+
user,
|
39
|
+
subject: form.subject,
|
40
|
+
author: user,
|
41
|
+
organization: user.organization
|
27
42
|
)
|
43
|
+
end
|
28
44
|
|
29
|
-
|
45
|
+
def create_content_block
|
46
|
+
UpdateContentBlock.call(form, content_block, user) do
|
47
|
+
on(:ok) do |content_block|
|
48
|
+
content_block.update(scoped_resource_id: newsletter.id)
|
49
|
+
@content_block = content_block
|
50
|
+
end
|
51
|
+
on(:invalid) do
|
52
|
+
raise "There was a problem persisting the changes to the content block"
|
53
|
+
end
|
54
|
+
end
|
30
55
|
end
|
31
56
|
end
|
32
57
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# A command with all the business logic to destroy a share token.
|
6
|
+
class DestroyShareToken < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# share_token - The share_token to destroy
|
10
|
+
# current_user - the user performing the action
|
11
|
+
def initialize(share_token, current_user)
|
12
|
+
@share_token = share_token
|
13
|
+
@current_user = current_user
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if the form wasn't valid and we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
begin
|
24
|
+
destroy_share_token
|
25
|
+
rescue StandardError
|
26
|
+
broadcast(:invalid)
|
27
|
+
end
|
28
|
+
broadcast(:ok)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :current_user
|
34
|
+
|
35
|
+
def destroy_share_token
|
36
|
+
Decidim.traceability.perform_action!(
|
37
|
+
"delete",
|
38
|
+
@share_token,
|
39
|
+
current_user
|
40
|
+
) do
|
41
|
+
@share_token.destroy!
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -33,13 +33,15 @@ module Decidim
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def update_component
|
36
|
-
@previous_settings = @component.attributes["settings"].
|
37
|
-
|
36
|
+
@previous_settings = @component.attributes["settings"].with_indifferent_access
|
38
37
|
@component.name = form.name
|
38
|
+
@component.weight = form.weight
|
39
|
+
|
40
|
+
restore_readonly_settings!
|
41
|
+
|
39
42
|
@component.settings = form.settings
|
40
43
|
@component.default_step_settings = form.default_step_settings
|
41
44
|
@component.step_settings = form.step_settings
|
42
|
-
@component.weight = form.weight
|
43
45
|
|
44
46
|
@settings_changed = @component.settings_changed?
|
45
47
|
|
@@ -57,6 +59,28 @@ module Decidim
|
|
57
59
|
def current_settings
|
58
60
|
@component.attributes["settings"]
|
59
61
|
end
|
62
|
+
|
63
|
+
# Keep previous values for readonly settings
|
64
|
+
def restore_readonly_settings!
|
65
|
+
browse_readonly_settings("global") do |attribute|
|
66
|
+
form.settings[attribute] = @previous_settings.dig("global", attribute)
|
67
|
+
end
|
68
|
+
|
69
|
+
browse_readonly_settings("step") do |attribute|
|
70
|
+
form.default_step_settings[attribute] = @previous_settings.dig("default_step", attribute) if form.default_step_settings.present?
|
71
|
+
if form.step_settings.present?
|
72
|
+
form.step_settings.each do |step_name, step|
|
73
|
+
step[attribute] = @previous_settings.dig("steps", step_name, attribute)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def browse_readonly_settings(settings_name)
|
80
|
+
@component.manifest.settings(settings_name).attributes
|
81
|
+
.select { |_attribute, obj| obj.readonly?(component: @component) }
|
82
|
+
.each { |attribute, _obj| yield(attribute) }
|
83
|
+
end
|
60
84
|
end
|
61
85
|
end
|
62
86
|
end
|
@@ -24,13 +24,37 @@ module Decidim
|
|
24
24
|
def call
|
25
25
|
return broadcast(:invalid) if form.invalid?
|
26
26
|
|
27
|
+
images_valid = true
|
28
|
+
|
27
29
|
transaction do
|
28
30
|
update_content_block_settings
|
31
|
+
content_block.save!
|
32
|
+
|
33
|
+
# Saving the images will cause the image file validations to run
|
34
|
+
# according to their uploader settings and the organization settings.
|
35
|
+
# The content block validation will fail in case there are processing
|
36
|
+
# errors on the image files.
|
37
|
+
#
|
38
|
+
# NOTE:
|
39
|
+
# The images can be only stored correctly if the content block is
|
40
|
+
# already persisted. This is not the case e.g. when creating a new
|
41
|
+
# newsletter which uses the content blocks through newsletter
|
42
|
+
# templates. This is why this needs to happen after the initial
|
43
|
+
# `content_block.save!` call.
|
29
44
|
update_content_block_images
|
45
|
+
unless content_block.valid?
|
46
|
+
images_valid = false
|
47
|
+
raise ActiveRecord::Rollback
|
48
|
+
end
|
49
|
+
|
50
|
+
# The save method needs to be called another time in order to store
|
51
|
+
# the image information.
|
30
52
|
content_block.save!
|
31
53
|
end
|
32
54
|
|
33
|
-
broadcast(:
|
55
|
+
return broadcast(:invalid) unless images_valid
|
56
|
+
|
57
|
+
broadcast(:ok, content_block)
|
34
58
|
end
|
35
59
|
|
36
60
|
private
|