decidim-decidim_awesome 0.7.0 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -9
- data/app/assets/config/decidim_admin_decidim_awesome_manifest.css +2 -2
- data/app/assets/config/decidim_admin_decidim_awesome_manifest.js +1 -2
- data/app/assets/config/decidim_decidim_awesome_manifest.css +2 -2
- data/app/assets/config/decidim_decidim_awesome_manifest.js +3 -2
- data/app/assets/config/legacy_decidim_admin_decidim_awesome_manifest.js +2 -0
- data/app/assets/config/legacy_decidim_decidim_awesome_manifest.js +4 -0
- data/app/assets/javascripts/decidim/decidim_awesome/admin/auto_edit.js.es6 +77 -0
- data/app/assets/javascripts/decidim/decidim_awesome/admin/codemirror.js.es6 +2 -3
- data/app/assets/javascripts/decidim/decidim_awesome/admin/form_builder.js.es6 +80 -0
- data/app/assets/javascripts/decidim/decidim_awesome/admin/legacy_form_builder.js.es6 +80 -0
- data/app/assets/javascripts/decidim/decidim_awesome/admin/user_picker.js.es6 +24 -0
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_admin.js +7 -0
- data/app/assets/javascripts/decidim/decidim_awesome/{application.js → awesome_application.js} +1 -2
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/layers.js.es6 +3 -2
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/load_map.js.es6 +15 -0
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/map.js.es6 +52 -56
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/meetings.js.es6 +2 -2
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/proposals.js.es6 +1 -1
- data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/utilities.js.es6 +33 -24
- data/app/assets/javascripts/decidim/decidim_awesome/editors/legacy_quill_editor.js.es6 +14 -2
- data/app/assets/javascripts/decidim/decidim_awesome/editors/quill_editor.js.es6 +18 -4
- data/app/assets/javascripts/decidim/decidim_awesome/editors/tabs_focus.js.es6 +24 -0
- data/app/assets/javascripts/decidim/decidim_awesome/forms/custom_fields_builder.js.es6 +211 -0
- data/app/assets/javascripts/decidim/decidim_awesome/forms/rich_text_plugin.js.es6 +106 -0
- data/app/assets/javascripts/decidim/decidim_awesome/legacy_admin.js +5 -1
- data/app/assets/javascripts/decidim/decidim_awesome/legacy_application.js +0 -1
- data/app/assets/javascripts/decidim/decidim_awesome/proposals/custom_fields.js.es6 +21 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +15 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +15 -4
- data/app/assets/stylesheets/decidim/decidim_awesome/admin/constraints.scss +12 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +66 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +35 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/{admin.scss → awesome_admin.scss} +12 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/awesome_application.scss +22 -0
- data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +0 -1
- data/app/assets/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +16 -1
- data/app/awesome_overrides/forms/decidim/proposals/proposal_wizard_create_step_form_override.rb +28 -0
- data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +74 -0
- data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +54 -0
- data/app/cells/decidim/decidim_awesome/content_blocks/map_form/show.erb +61 -0
- data/app/cells/decidim/decidim_awesome/content_blocks/map_form_cell.rb +19 -0
- data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +32 -0
- data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +45 -0
- data/app/commands/decidim/decidim_awesome/admin/create_scoped_admin.rb +38 -0
- data/app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb +4 -0
- data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +40 -0
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb +40 -0
- data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +58 -0
- data/app/commands/decidim/decidim_awesome/admin/update_config.rb +1 -0
- data/app/controllers/concerns/decidim/decidim_awesome/admin_not_found_redirect.rb +39 -0
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +31 -18
- data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +4 -0
- data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +38 -0
- data/app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb +38 -0
- data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +38 -0
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +39 -0
- data/app/forms/decidim/decidim_awesome/admin/constraint_form.rb +3 -1
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +11 -7
- data/app/helpers/decidim/decidim_awesome/amendments_helper_override.rb +48 -0
- data/app/helpers/decidim/decidim_awesome/map_helper.rb +67 -16
- data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +78 -0
- data/app/middleware/decidim/decidim_awesome/current_config.rb +182 -0
- data/app/models/decidim/decidim_awesome/awesome_config.rb +15 -0
- data/app/models/decidim/decidim_awesome/user_override.rb +25 -0
- data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +2 -0
- data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -0
- data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +2 -2
- data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +21 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +0 -3
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +25 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +0 -2
- data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +4 -7
- data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +4 -0
- data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +6 -0
- data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +0 -2
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +101 -0
- data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +83 -0
- data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -0
- data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +25 -11
- data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +4 -0
- data/app/views/layouts/decidim/decidim_awesome/_custom_styles.html.erb +1 -1
- data/app/views/v0.23/decidim/proposals/collaborative_drafts/_show.html.erb +134 -0
- data/app/views/v0.23/layouts/decidim/_head.html.erb +1 -1
- data/app/views/v0.23/layouts/decidim/admin/_header.html.erb +1 -1
- data/app/views/v0.24/decidim/proposals/collaborative_drafts/_show.html.erb +128 -0
- data/app/views/v0.24/layouts/decidim/_head.html.erb +2 -2
- data/app/views/v0.24/layouts/decidim/admin/_header.html.erb +2 -2
- data/config/locales/ca.yml +62 -3
- data/config/locales/cs.yml +62 -3
- data/config/locales/en.yml +90 -11
- data/config/locales/es.yml +61 -2
- data/config/locales/eu.yml +63 -4
- data/config/locales/fr.yml +62 -3
- data/config/locales/it.yml +284 -0
- data/config/locales/ja.yml +284 -0
- data/config/locales/nl.yml +62 -3
- data/config/locales/sv.yml +62 -3
- data/db/migrate/20210628150825_change_awesome_config_var_type.rb +12 -0
- data/lib/decidim/decidim_awesome/admin_engine.rb +16 -4
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +17 -10
- data/lib/decidim/decidim_awesome/checksums.yml +17 -4
- data/lib/decidim/decidim_awesome/config.rb +53 -6
- data/lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb +27 -21
- data/lib/decidim/decidim_awesome/custom_fields.rb +94 -0
- data/lib/decidim/decidim_awesome/engine.rb +62 -6
- data/lib/decidim/decidim_awesome/test/shared_examples/box_label_editor.rb +116 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/current_config_examples.rb +143 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +4 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +428 -0
- data/lib/decidim/decidim_awesome/version.rb +1 -1
- data/lib/decidim/decidim_awesome.rb +41 -8
- data/vendor/assets/javascripts/delta.min.js +405 -0
- data/vendor/assets/javascripts/delta.min.js.map +1 -0
- data/vendor/assets/javascripts/europa.min.js +4 -0
- data/vendor/assets/javascripts/form-builder.min.js +19 -0
- data/vendor/assets/javascripts/form-render.min.js +19 -0
- data/vendor/assets/javascripts/inscrybmde.min.js +1 -1
- data/vendor/assets/javascripts/jquery-ui.min.js +13 -0
- data/vendor/assets/javascripts/select2.js +6147 -0
- data/vendor/assets/langs/en-US.lang +110 -0
- data/vendor/assets/stylesheets/inscrybmde.min.scss +14 -0
- data/vendor/assets/stylesheets/jquery-ui.min.css +7 -0
- data/vendor/assets/stylesheets/select2-foundation-theme.css +249 -0
- data/vendor/assets/stylesheets/select2.css +515 -0
- metadata +68 -27
- data/app/assets/images/decidim/decidim_awesome/loading.gif +0 -0
- data/app/assets/javascripts/decidim/decidim_awesome/admin.js +0 -3
- data/app/assets/javascripts/decidim/decidim_awesome/editors/markdown_view.js.es6 +0 -12
- data/app/assets/stylesheets/decidim/decidim_awesome/application.scss +0 -8
- data/app/assets/stylesheets/decidim/decidim_awesome/editors/markdown_view.scss +0 -27
- data/app/awesome_overrides/presenters/decidim/proposals/proposal_presenter_override.rb +0 -58
- data/lib/decidim/decidim_awesome/content_renderers/markdown_renderer.rb +0 -18
- data/lib/decidim/decidim_awesome/content_renderers.rb +0 -9
@@ -0,0 +1,66 @@
|
|
1
|
+
// hide custom-fields inside tabs, an extra (unique) container is used instead
|
2
|
+
.tabs-content {
|
3
|
+
.proposal_custom_field {
|
4
|
+
display: none;
|
5
|
+
}
|
6
|
+
}
|
7
|
+
|
8
|
+
.proposal_custom_fields{
|
9
|
+
&_editor{
|
10
|
+
background-color: #e0e0e0;
|
11
|
+
padding: .5em .5em 1em;
|
12
|
+
border-top-left-radius: 5px;
|
13
|
+
border-top-right-radius: 5px;
|
14
|
+
|
15
|
+
label{
|
16
|
+
display: inline-block;
|
17
|
+
max-width: 100%;
|
18
|
+
font-weight: 600 !important;
|
19
|
+
}
|
20
|
+
|
21
|
+
li[type]{
|
22
|
+
display: inherit;
|
23
|
+
width: 100%;
|
24
|
+
height: inherit;
|
25
|
+
margin: inherit;
|
26
|
+
border: inherit;
|
27
|
+
box-shadow: inherit;
|
28
|
+
font-size: inherit;
|
29
|
+
font-weight: inherit;
|
30
|
+
line-height: inherit;
|
31
|
+
color: inherit;
|
32
|
+
}
|
33
|
+
|
34
|
+
.form-group{
|
35
|
+
background-color: inherit;
|
36
|
+
margin: 0;
|
37
|
+
padding: 0;
|
38
|
+
}
|
39
|
+
|
40
|
+
.form-wrap.form-builder .form-group{
|
41
|
+
margin-bottom: 10px !important;
|
42
|
+
}
|
43
|
+
|
44
|
+
.form-control{
|
45
|
+
color: #555;
|
46
|
+
background-color: #fff;
|
47
|
+
border: 1px solid #ccc;
|
48
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
|
49
|
+
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
|
50
|
+
margin: 0;
|
51
|
+
padding: 6px 12px;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
&_container{
|
56
|
+
.constraints-editor{
|
57
|
+
border-top-left-radius: 0;
|
58
|
+
border-top-right-radius: 0;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
// Custom fields tunning
|
64
|
+
.rendered-form .form-control.ql-container{
|
65
|
+
height: auto !important;
|
66
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
@import "select2";
|
2
|
+
@import "select2-foundation-theme";
|
3
|
+
|
4
|
+
.multiusers-select-container{
|
5
|
+
form label{
|
6
|
+
margin-bottom: 1rem;
|
7
|
+
}
|
8
|
+
|
9
|
+
.switch-paddle{
|
10
|
+
display: inline-block;
|
11
|
+
vertical-align: middle;
|
12
|
+
margin-right: 1em;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
.select2-container--foundation .select2-selection--multiple .select2-selection__choice{
|
17
|
+
display: inline-block;
|
18
|
+
float: none;
|
19
|
+
font-weight: normal;
|
20
|
+
|
21
|
+
.is-admin{
|
22
|
+
&::before{
|
23
|
+
content: '⛔';
|
24
|
+
display: inline-block;
|
25
|
+
margin-right: .3em;
|
26
|
+
}
|
27
|
+
|
28
|
+
text-decoration: line-through;
|
29
|
+
color: #bbb;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
.form-conversations-submit{
|
34
|
+
margin-top: 2rem;
|
35
|
+
}
|
@@ -8,6 +8,9 @@
|
|
8
8
|
@import "decidim/utils/mixins";
|
9
9
|
@import "./admin/constraints";
|
10
10
|
@import "./admin/codemirror";
|
11
|
+
@import "./admin/user_picker";
|
12
|
+
@import "./admin/custom_fields";
|
13
|
+
@import "./admin/auto_edits";
|
11
14
|
@import "./editors/quill_editor";
|
12
15
|
@import "./editors/markdown_editor";
|
13
16
|
|
@@ -39,6 +42,9 @@
|
|
39
42
|
margin-bottom: 2em;
|
40
43
|
border-bottom: 1px solid #999;
|
41
44
|
padding-bottom: 1.5em;
|
45
|
+
.help-text {
|
46
|
+
white-space: pre-wrap;
|
47
|
+
}
|
42
48
|
}
|
43
49
|
|
44
50
|
&-form:last-child{
|
@@ -50,3 +56,9 @@
|
|
50
56
|
tbody tr.menu_hack-addition{
|
51
57
|
background: rgb(255, 248, 222);
|
52
58
|
}
|
59
|
+
|
60
|
+
.secondary-nav {
|
61
|
+
li .icon {
|
62
|
+
margin-right: 0.5rem;
|
63
|
+
}
|
64
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
//= require github.min
|
2
|
+
//= require inscrybmde.min
|
3
|
+
//= require_self
|
4
|
+
|
5
|
+
@import "./editors/quill_editor";
|
6
|
+
@import "./editors/markdown_editor";
|
7
|
+
@import "./forms/autosave";
|
8
|
+
|
9
|
+
.decidim_awesome-custom_fields{
|
10
|
+
dd{
|
11
|
+
>div:last-child{
|
12
|
+
margin-bottom: 1rem;
|
13
|
+
}
|
14
|
+
|
15
|
+
&[name="textarea"]{
|
16
|
+
>div > p{
|
17
|
+
margin-top: 1rem;
|
18
|
+
margin-bottom: 0;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
@@ -1,7 +1,22 @@
|
|
1
|
+
@import "decidim/variables";
|
2
|
+
@import "decidim/utils/settings";
|
3
|
+
@import "decidim/utils/mixins";
|
4
|
+
|
1
5
|
.editor-loading{
|
2
|
-
|
6
|
+
&::before{
|
7
|
+
@include spinner(25px, $medium-gray, var(--primary), 800ms);
|
8
|
+
|
9
|
+
float: right;
|
10
|
+
content: "";
|
11
|
+
vertical-align: middle;
|
12
|
+
}
|
3
13
|
}
|
4
14
|
|
5
15
|
.editor-container{
|
6
16
|
overflow: hidden;
|
7
17
|
}
|
18
|
+
|
19
|
+
.editor.hashtags__container>p.help-text {
|
20
|
+
margin-top: -1rem;
|
21
|
+
margin-bottom: 1.5rem;
|
22
|
+
}
|
data/app/awesome_overrides/forms/decidim/proposals/proposal_wizard_create_step_form_override.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Recreate validations to take into account custom fields and ignore the length limit in proposals
|
4
|
+
Decidim::Proposals::ProposalWizardCreateStepForm.class_eval do
|
5
|
+
clear_validators!
|
6
|
+
|
7
|
+
validates :title, presence: true, etiquette: true
|
8
|
+
validates :title, length: { in: 15..150 }
|
9
|
+
validates :body, presence: true, etiquette: true, unless: ->(form) { form.override_validations? }
|
10
|
+
validates :body, proposal_length: {
|
11
|
+
minimum: 15,
|
12
|
+
maximum: ->(record) { record.override_validations? ? 0 : record.component.settings.proposal_length }
|
13
|
+
}
|
14
|
+
|
15
|
+
validate :body_is_not_bare_template, unless: ->(form) { form.override_validations? }
|
16
|
+
|
17
|
+
def override_validations?
|
18
|
+
return false if context.current_component.settings.participatory_texts_enabled
|
19
|
+
|
20
|
+
custom_fields.present?
|
21
|
+
end
|
22
|
+
|
23
|
+
def custom_fields
|
24
|
+
awesome_config = Decidim::DecidimAwesome::Config.new(context.current_organization)
|
25
|
+
awesome_config.context_from_component(context.current_component)
|
26
|
+
awesome_config.collect_sub_configs_values("proposal_custom_field")
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<section class="wrapper-home map-block home-section">
|
2
|
+
<div class="row">
|
3
|
+
|
4
|
+
<%= section_title %></h3>
|
5
|
+
|
6
|
+
<div class="row">
|
7
|
+
<div class="columns medium-12">
|
8
|
+
<%= awesome_map_for global_map_components do %>
|
9
|
+
<script id="marker-proposal-popup" type="text/x-jsrender">
|
10
|
+
<div class="map-info__content">
|
11
|
+
<h3>{{>title.translation}}</h3>
|
12
|
+
<div id="bodyContent">
|
13
|
+
<div class="description">{{:body.translation}}</div>
|
14
|
+
<div class="map__date-adress">
|
15
|
+
<div class="address card__extra">
|
16
|
+
<div class="address__icon">{{:icon}}</div>
|
17
|
+
<div class="address__details">
|
18
|
+
<span>{{>address}}</span><br>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<div class="map-info__button">
|
23
|
+
<a href="{{>link}}" class="button button--sc">
|
24
|
+
<%= t("view_proposal", scope: "decidim.decidim_awesome.map_component.map.show") %>
|
25
|
+
</a>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</script>
|
30
|
+
|
31
|
+
<script id="marker-meeting-popup" type="text/x-jsrender">
|
32
|
+
<div class="map-info__content">
|
33
|
+
<h3>{{>title.translation}}</h3>
|
34
|
+
<div id="bodyContent">
|
35
|
+
<div class="description">{{:description.translation}}</div>
|
36
|
+
<div class="map__date-adress">
|
37
|
+
<div class="card__datetime">
|
38
|
+
<div class="card__datetime__date">
|
39
|
+
{{>startTimeDay}} <span class="card__datetime__month">{{>startTimeMonth}} {{>startTimeYear}}</span>
|
40
|
+
</div>
|
41
|
+
<div class="card__datetime__time">{{>starTime}}</div>
|
42
|
+
</div>
|
43
|
+
<div class="address card__extra">
|
44
|
+
<div class="address__icon">{{:icon}}</div>
|
45
|
+
<div class="address__details">
|
46
|
+
<strong>{{:location.translation}}</strong><br>
|
47
|
+
<span>{{>address}}</span><br>
|
48
|
+
<span>{{:locationHints.translation}}</span>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
</div>
|
52
|
+
<div class="map-info__button">
|
53
|
+
<a href="{{>link}}" class="button button--sc">
|
54
|
+
<%= t("decidim.meetings.meetings_map.view_meeting") %>
|
55
|
+
</a>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
</script>
|
60
|
+
|
61
|
+
<style type="text/css">
|
62
|
+
#awesome-map .leaflet-container {
|
63
|
+
height: <%= model.settings.map_height %>px;
|
64
|
+
}
|
65
|
+
</style>
|
66
|
+
<script>
|
67
|
+
window.AwesomeMap = window.AwesomeMap || {};
|
68
|
+
window.AwesomeMap.categories = <%= all_categories.to_json.html_safe %>;
|
69
|
+
</script>
|
70
|
+
<% end %>
|
71
|
+
</div>
|
72
|
+
</div>
|
73
|
+
</div>
|
74
|
+
</section>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module ContentBlocks
|
6
|
+
class MapCell < Decidim::ViewModel
|
7
|
+
include Decidim::DecidimAwesome::MapHelper
|
8
|
+
include Decidim::CardHelper
|
9
|
+
|
10
|
+
delegate :snippets, to: :controller
|
11
|
+
delegate :settings, to: :model
|
12
|
+
alias current_settings settings
|
13
|
+
|
14
|
+
def hide_controls
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def all_categories
|
19
|
+
return if @all_categories.present?
|
20
|
+
|
21
|
+
@category_ids ||= Decidim::Category.pluck(:id, :decidim_participatory_space_type, :decidim_participatory_space_id).select do |category|
|
22
|
+
_id, space_type, space_id = category
|
23
|
+
space = space_type.constantize.find(space_id)
|
24
|
+
space.organization == current_organization
|
25
|
+
end.map(&:first)
|
26
|
+
|
27
|
+
@all_categories ||= Decidim::Category.where(id: @category_ids)
|
28
|
+
end
|
29
|
+
|
30
|
+
def global_map_components
|
31
|
+
@global_map_components ||= Decidim::Component.where(manifest_name: [:meetings, :proposals]).published.filter do |component|
|
32
|
+
case component.manifest.name
|
33
|
+
when :meetings
|
34
|
+
true
|
35
|
+
when :proposals
|
36
|
+
component.settings.geocoding_enabled
|
37
|
+
else
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def section_title
|
44
|
+
return if model.settings.title.blank?
|
45
|
+
return if model.settings.title.values.join.blank?
|
46
|
+
|
47
|
+
content_tag :h3, class: "section-heading" do
|
48
|
+
translated_attribute(model.settings.title)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<% form.fields_for :settings, form.object.settings do |settings_fields| %>
|
2
|
+
<h3><%= t("text_settings", scope: i18n_scope) %></h3>
|
3
|
+
|
4
|
+
<div class="row">
|
5
|
+
<%= settings_fields.translated :text_field, :title, label: t("title", scope: i18n_scope) %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<h3 class="mt-m"><%= t("map_settings", scope: i18n_scope) %></h3>
|
9
|
+
|
10
|
+
<div class="row two-buttons">
|
11
|
+
<div>
|
12
|
+
<%= settings_fields.number_field :truncate, label: t("truncate", scope: i18n_scope) %>
|
13
|
+
</div>
|
14
|
+
<div>
|
15
|
+
<%= settings_fields.number_field :map_height, label: t("map_height", scope: i18n_scope) %>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="row two-buttons">
|
20
|
+
<div>
|
21
|
+
<%= settings_fields.text_field :map_center, label: t("map_center", scope: i18n_scope) %>
|
22
|
+
<%= t("map_center_help", scope: i18n_scope) %>
|
23
|
+
</div>
|
24
|
+
<div><%= settings_fields.number_field :map_zoom, label: t("map_zoom", scope: i18n_scope) %>
|
25
|
+
<%= t("map_zoom_help", scope: i18n_scope) %>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<div class="row two-buttons">
|
29
|
+
<div>
|
30
|
+
<%= settings_fields.check_box :menu_amendments, label: t("menu_amendments", scope: i18n_scope) %>
|
31
|
+
</div>
|
32
|
+
<div><%= settings_fields.check_box :menu_meetings, label: t("menu_meetings", scope: i18n_scope) %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<div class="row two-buttons">
|
36
|
+
<div><%= settings_fields.check_box :show_not_answered, label: t("show_not_answered", scope: i18n_scope) %></div>
|
37
|
+
<div><%= settings_fields.check_box :show_accepted, label: t("show_accepted", scope: i18n_scope) %>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
<div class="row two-buttons">
|
41
|
+
<div><%= settings_fields.check_box :show_withdrawn, label: t("show_withdrawn", scope: i18n_scope) %></div>
|
42
|
+
<div><%= settings_fields.check_box :show_evaluating, label: t("show_evaluating", scope: i18n_scope) %>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
<div class="row">
|
46
|
+
<%= settings_fields.check_box :show_rejected, label: t("show_rejected", scope: i18n_scope) %>
|
47
|
+
</div>
|
48
|
+
<% end %>
|
49
|
+
|
50
|
+
<style>
|
51
|
+
.two-buttons {
|
52
|
+
width: 100%;
|
53
|
+
display: flex;
|
54
|
+
justify-content: center;
|
55
|
+
align-items: center;
|
56
|
+
gap: 1em;
|
57
|
+
}
|
58
|
+
.two-buttons > div {
|
59
|
+
width: 50%;
|
60
|
+
}
|
61
|
+
</style>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module ContentBlocks
|
6
|
+
class MapFormCell < Decidim::ViewModel
|
7
|
+
alias form model
|
8
|
+
|
9
|
+
def content_block
|
10
|
+
options[:content_block]
|
11
|
+
end
|
12
|
+
|
13
|
+
def i18n_scope
|
14
|
+
"decidim.decidim_awesome.content_blocks.map"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
module NeedsConstraintHelpers
|
7
|
+
private
|
8
|
+
|
9
|
+
def create_constraint_never(var)
|
10
|
+
settings = { "participatory_space_manifest" => "none" }
|
11
|
+
subconfig = AwesomeConfig.find_or_initialize_by(var: "#{var}_#{@ident}", organization: @organization)
|
12
|
+
@constraint = ConfigConstraint.create!(
|
13
|
+
awesome_config: subconfig,
|
14
|
+
settings: settings
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def constraint_can_be_destroyed?(constraint)
|
19
|
+
return true if constraint.awesome_config.blank?
|
20
|
+
return true if constraint.awesome_config.constraints.count > 1
|
21
|
+
|
22
|
+
case constraint.awesome_config.var.to_s
|
23
|
+
when /^proposal_custom_field/
|
24
|
+
false
|
25
|
+
else
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
class CreateProposalCustomField < Rectify::Command
|
7
|
+
include NeedsConstraintHelpers
|
8
|
+
|
9
|
+
# Public: Initializes the command.
|
10
|
+
#
|
11
|
+
def initialize(organization)
|
12
|
+
@organization = organization
|
13
|
+
@ident = rand(36**8).to_s(36)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
fields = AwesomeConfig.find_or_initialize_by(var: :proposal_custom_fields, organization: @organization)
|
24
|
+
fields.value = {} unless fields.value.is_a? Hash
|
25
|
+
# TODO: prevent (unlikely) colisions with exisiting values
|
26
|
+
fields.value[@ident] = default_definition
|
27
|
+
fields.save!
|
28
|
+
|
29
|
+
create_constraint_never(:proposal_custom_field)
|
30
|
+
|
31
|
+
broadcast(:ok, @ident)
|
32
|
+
rescue StandardError => e
|
33
|
+
broadcast(:invalid, e.message)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def default_definition
|
39
|
+
# '[{"type":"textarea","required":true,"label":"Body","className":"form-control","name":"body","subtype":"textarea"}]'
|
40
|
+
"[]"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
class CreateScopedAdmin < Rectify::Command
|
7
|
+
include NeedsConstraintHelpers
|
8
|
+
|
9
|
+
# Public: Initializes the command.
|
10
|
+
#
|
11
|
+
def initialize(organization)
|
12
|
+
@organization = organization
|
13
|
+
@ident = rand(36**8).to_s(36)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
admins = AwesomeConfig.find_or_initialize_by(var: :scoped_admins, organization: @organization)
|
24
|
+
admins.value = {} unless admins.value.is_a? Hash
|
25
|
+
# TODO: prevent (unlikely) colisions with exisiting values
|
26
|
+
admins.value[@ident] = []
|
27
|
+
admins.save!
|
28
|
+
|
29
|
+
create_constraint_never(:scoped_admin)
|
30
|
+
|
31
|
+
broadcast(:ok, @ident)
|
32
|
+
rescue StandardError => e
|
33
|
+
broadcast(:invalid, e.message)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -4,6 +4,8 @@ module Decidim
|
|
4
4
|
module DecidimAwesome
|
5
5
|
module Admin
|
6
6
|
class DestroyConstraint < Rectify::Command
|
7
|
+
include NeedsConstraintHelpers
|
8
|
+
|
7
9
|
# Public: Initializes the command.
|
8
10
|
#
|
9
11
|
# constraint - A constraint constraint
|
@@ -18,6 +20,8 @@ module Decidim
|
|
18
20
|
#
|
19
21
|
# Returns nothing.
|
20
22
|
def call
|
23
|
+
return broadcast(:invalid, I18n.t("cannot_be_destroyed", scope: "decidim.decidim_awesome.admin.config.constraints")) unless constraint_can_be_destroyed?(constraint)
|
24
|
+
|
21
25
|
constraint.destroy!
|
22
26
|
broadcast(:ok)
|
23
27
|
rescue StandardError => e
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
class DestroyProposalCustomField < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# key - the key to destroy inise proposal_custom_fields
|
10
|
+
# organization
|
11
|
+
def initialize(key, organization)
|
12
|
+
@key = key
|
13
|
+
@organization = organization
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
fields = AwesomeConfig.find_by(var: :proposal_custom_fields, organization: @organization)
|
24
|
+
return broadcast(:invalid, "Not a hash") unless fields&.value.is_a? Hash
|
25
|
+
return broadcast(:invalid, "#{key} key invalid") unless fields.value.has_key?(@key)
|
26
|
+
|
27
|
+
fields.value.except!(@key)
|
28
|
+
fields.save!
|
29
|
+
# remove constrains associated (a new config var is generated automatically, by removing it, it will trigger destroy on dependents)
|
30
|
+
constraint = AwesomeConfig.find_by(var: "proposal_custom_field_#{@key}", organization: @organization)
|
31
|
+
constraint.destroy! if constraint.present?
|
32
|
+
|
33
|
+
broadcast(:ok, @key)
|
34
|
+
rescue StandardError => e
|
35
|
+
broadcast(:invalid, e.message)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Admin
|
6
|
+
class DestroyScopedAdmin < Rectify::Command
|
7
|
+
# Public: Initializes the command.
|
8
|
+
#
|
9
|
+
# key - the key to destroy inside scoped_admins
|
10
|
+
# organization
|
11
|
+
def initialize(key, organization)
|
12
|
+
@key = key
|
13
|
+
@organization = organization
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes the command. Broadcasts these events:
|
17
|
+
#
|
18
|
+
# - :ok when everything is valid.
|
19
|
+
# - :invalid if we couldn't proceed.
|
20
|
+
#
|
21
|
+
# Returns nothing.
|
22
|
+
def call
|
23
|
+
admins = AwesomeConfig.find_by(var: :scoped_admins, organization: @organization)
|
24
|
+
return broadcast(:invalid, "Not a hash") unless admins&.value.is_a? Hash
|
25
|
+
return broadcast(:invalid, "#{key} key invalid") unless admins.value.has_key?(@key)
|
26
|
+
|
27
|
+
admins.value.except!(@key)
|
28
|
+
admins.save!
|
29
|
+
# remove constrains associated (a new config var is generated automatically, by removing it, it will trigger destroy on dependents)
|
30
|
+
constraint = AwesomeConfig.find_by(var: "scoped_admin_#{@key}", organization: @organization)
|
31
|
+
constraint.destroy! if constraint.present?
|
32
|
+
|
33
|
+
broadcast(:ok, @key)
|
34
|
+
rescue StandardError => e
|
35
|
+
broadcast(:invalid, e.message)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -6,7 +6,7 @@ module Decidim
|
|
6
6
|
class DestroyScopedStyle < Rectify::Command
|
7
7
|
# Public: Initializes the command.
|
8
8
|
#
|
9
|
-
# key - the key to destroy
|
9
|
+
# key - the key to destroy inside scoped_styles
|
10
10
|
# organization
|
11
11
|
def initialize(key, organization)
|
12
12
|
@key = key
|