decidim-decidim_awesome 0.10.3 → 0.11.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-decidim_awesome might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -5
- data/README.md +65 -67
- data/app/cells/concerns/decidim/decidim_awesome/global_menu_cell_override.rb +20 -0
- data/app/cells/concerns/decidim/decidim_awesome/proposal_l_cell_override.rb +44 -0
- data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +5 -12
- data/app/cells/decidim/decidim_awesome/voting/proposal_metadata_cell.rb +54 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/modal.erb +18 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb +37 -32
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_cell.rb +9 -4
- data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +1 -1
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +2 -2
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +2 -2
- data/app/commands/decidim/decidim_awesome/admin/create_constraint.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/update_constraint.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +2 -2
- data/app/commands/decidim/decidim_awesome/command.rb +1 -7
- data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +1 -1
- data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +3 -4
- data/app/controllers/concerns/decidim/decidim_awesome/content_security_policy.rb +34 -0
- data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +1 -1
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +22 -9
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/proposal_votes_controller_override.rb +3 -3
- data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +7 -7
- data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +7 -7
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +8 -10
- data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +20 -19
- data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +6 -8
- data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +2 -2
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +6 -8
- data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +2 -2
- data/app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb +2 -2
- data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +2 -2
- data/app/controllers/decidim/decidim_awesome/blank_component_controller.rb +8 -3
- data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +3 -3
- data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +11 -5
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +1 -1
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +13 -25
- data/app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb +2 -2
- data/app/forms/decidim/decidim_awesome/admin/intergram_form.rb +4 -0
- data/app/forms/decidim/decidim_awesome/admin/menu_form.rb +4 -4
- data/app/helpers/concerns/decidim/decidim_awesome/amendments_helper_override.rb +8 -1
- data/app/helpers/concerns/decidim/decidim_awesome/breadcrumb_helper_override.rb +23 -0
- data/app/helpers/concerns/decidim/decidim_awesome/proposals/application_helper_override.rb +23 -39
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +2 -2
- data/app/helpers/decidim/decidim_awesome/map_helper.rb +8 -27
- data/app/jobs/decidim/decidim_awesome/migrate_legacy_images_job.rb +5 -4
- data/app/middleware/decidim/decidim_awesome/current_config.rb +3 -5
- data/app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb +1 -1
- data/app/models/decidim/decidim_awesome/awesome_config.rb +1 -1
- data/app/models/decidim/decidim_awesome/paper_trail_version.rb +4 -8
- data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +1 -1
- data/app/models/decidim/decidim_awesome/vote_weight.rb +2 -2
- data/app/overrides/decidim/proposals/proposals/{show → _proposal_aside}/limit_amendments_modal.html.erb.deface +1 -1
- data/app/overrides/decidim/proposals/proposals/_vote_button/replace_vote_button.html.erb.deface +1 -1
- data/app/overrides/layouts/decidim/_decidim_javascript/add_awesome_tags.html.erb.deface +6 -0
- data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +4 -11
- data/app/overrides/layouts/decidim/admin/_header/{replace_scripts.html.erb.deface → add_awesome_tags.html.erb.deface} +4 -4
- data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +1 -2
- data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.js +4 -0
- data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.scss +1 -0
- data/app/packs/entrypoints/decidim_decidim_awesome.js +2 -2
- data/app/packs/entrypoints/decidim_editor.js +14 -0
- data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +95 -70
- data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +46 -41
- data/app/packs/src/decidim/decidim_awesome/admin/codemirror.js +3 -3
- data/app/packs/src/decidim/decidim_awesome/admin/constraint_form_events.js +115 -0
- data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +4 -1
- data/app/packs/src/decidim/decidim_awesome/admin/form_exit_warn.js +22 -11
- data/app/packs/src/decidim/decidim_awesome/admin/proposal_sortings.js +26 -8
- data/app/packs/src/decidim/decidim_awesome/admin/user_picker.js +34 -21
- data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +20 -22
- data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +5 -16
- data/app/packs/src/decidim/decidim_awesome/awesome_admin_global.js +1 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_application.js +0 -15
- data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +33 -11
- data/app/packs/src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher.js +9 -12
- data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +28 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +3 -4
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +12 -12
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/meetings_controller.js +11 -7
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +6 -13
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +51 -20
- data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +27 -18
- data/app/packs/src/decidim/decidim_awesome/editor/index.js +94 -0
- data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +28 -23
- data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +9 -14
- data/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js +27 -32
- data/app/packs/src/decidim/decidim_awesome/proposals/images.js +16 -10
- data/app/packs/src/decidim/decidim_awesome/voting/voting_cards.js +47 -38
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +11 -12
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/check_redirections.scss +15 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +19 -12
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +8 -32
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +28 -78
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_styles.scss +48 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/intergram_fixes.scss +11 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +15 -24
- data/app/packs/stylesheets/decidim/decidim_awesome/amendments/modal.scss +5 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +9 -47
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +3 -12
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +3 -19
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_iframe/iframe.scss +1 -1
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +27 -21
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +6 -6
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +32 -101
- data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +5 -26
- data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +34 -52
- data/app/permissions/decidim/decidim_awesome/permissions.rb +3 -4
- data/app/presenters/concerns/decidim/decidim_awesome/breadcrumb_root_menu_item_presenter_override.rb +23 -0
- data/app/presenters/concerns/decidim/decidim_awesome/menu_item_presenter_override.rb +10 -2
- data/app/presenters/concerns/decidim/decidim_awesome/menu_presenter_override.rb +8 -0
- data/app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb +1 -1
- data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +11 -11
- data/app/presenters/decidim/decidim_awesome/user_entity_presenter.rb +1 -1
- data/app/queries/decidim/decidim_awesome/private_data_finder.rb +1 -1
- data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +0 -8
- data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +23 -17
- data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +1 -3
- data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +3 -3
- data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +20 -21
- data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +6 -5
- data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +2 -2
- data/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb +39 -23
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +4 -6
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +64 -76
- data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +15 -11
- data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +8 -6
- data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +22 -12
- data/app/views/decidim/decidim_awesome/admin/constraints/_form.html.erb +1 -49
- data/app/views/decidim/decidim_awesome/admin/constraints/new.html.erb +14 -9
- data/app/views/decidim/decidim_awesome/admin/constraints/show.html.erb +14 -9
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/_form.html.erb +20 -5
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +5 -5
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +15 -15
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +5 -5
- data/app/views/decidim/decidim_awesome/admin/maintenance/_private_data.html.erb +4 -4
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/_form.html.erb +6 -6
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/edit.html.erb +21 -12
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +16 -18
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +21 -12
- data/app/views/decidim/decidim_awesome/admin/shared/_filters_with_date.html.erb +14 -18
- data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +18 -11
- data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +3 -5
- data/app/views/decidim/decidim_awesome/iframe_component/iframe/show.html.erb +7 -12
- data/app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb +53 -37
- data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +14 -5
- data/app/views/decidim/decidim_awesome/voting/voting_cards/_show_vote_button.html.erb +0 -3
- data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +9 -7
- data/app/views/layouts/decidim/decidim_awesome/_intergram_widget.html.erb +9 -6
- data/app/views/layouts/decidim/decidim_awesome/admin/_base.html.erb +3 -12
- data/config/assets.rb +3 -33
- data/config/i18n-tasks.yml +1 -0
- data/config/locales/ca.yml +17 -94
- data/config/locales/cs.yml +15 -93
- data/config/locales/de.yml +15 -91
- data/config/locales/en.yml +24 -28
- data/config/locales/es.yml +18 -96
- data/config/locales/eu.yml +8 -18
- data/config/locales/fr.yml +15 -94
- data/config/locales/hu.yml +4 -18
- data/config/locales/it.yml +9 -26
- data/config/locales/ja.yml +16 -93
- data/config/locales/lt.yml +2 -4
- data/config/locales/nl.yml +8 -18
- data/config/locales/pt-BR.yml +11 -25
- data/config/locales/ro-RO.yml +2 -14
- data/config/locales/sv.yml +10 -21
- data/config/rubocop/disabled.yml +11 -0
- data/config/rubocop/faker.yml +480 -0
- data/config/rubocop/rails.yml +88 -0
- data/config/rubocop/rspec.yml +65 -0
- data/config/rubocop/ruby.yml +1210 -0
- data/db/migrate/20240306175331_rename_editor_images_awesome_config.rb +18 -0
- data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +1 -1
- data/db/seeds.rb +3 -3
- data/lib/decidim/decidim_awesome/admin_engine.rb +4 -1
- data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +2 -3
- data/lib/decidim/decidim_awesome/awesome.rb +42 -28
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +1 -1
- data/lib/decidim/decidim_awesome/checksums.yml +39 -60
- data/lib/decidim/decidim_awesome/config.rb +1 -1
- data/lib/decidim/decidim_awesome/custom_fields.rb +5 -5
- data/lib/decidim/decidim_awesome/engine.rb +24 -6
- data/lib/decidim/decidim_awesome/iframe_component/component.rb +1 -2
- data/lib/decidim/decidim_awesome/lock.rb +2 -2
- data/lib/decidim/decidim_awesome/map_component/component.rb +1 -1
- data/lib/decidim/decidim_awesome/menu.rb +33 -14
- data/lib/decidim/decidim_awesome/menu_hacker.rb +4 -8
- data/lib/decidim/decidim_awesome/system_checker.rb +2 -4
- data/lib/decidim/decidim_awesome/test/factories.rb +10 -10
- data/lib/decidim/decidim_awesome/test/initializer.rb +3 -11
- data/lib/decidim/decidim_awesome/test/layouts/decidim/_head.html.erb +2 -2
- data/lib/decidim/decidim_awesome/test/layouts/decidim/admin/_header.html.erb +2 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/box_label_editor_examples.rb +18 -18
- data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +3 -3
- data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +11 -11
- data/lib/decidim/decidim_awesome/test/shared_examples/custom_redirects_contexts.rb +7 -7
- data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +26 -66
- data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +10 -9
- data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +30 -20
- data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +19 -10
- data/lib/decidim/decidim_awesome/version.rb +2 -2
- data/lib/decidim/decidim_awesome/voting_manifest.rb +5 -10
- data/lib/decidim/decidim_awesome.rb +1 -2
- data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +1 -1
- data/lib/tasks/decidim_awesome_upgrade_tasks.rake +4 -0
- data/package.json +19 -28
- metadata +40 -56
- data/app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb +0 -18
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/show.erb +0 -15
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/vote_button.erb +0 -15
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter_cell.rb +0 -21
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal/show.erb +0 -16
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal_cell.rb +0 -20
- data/app/cells/decidim/proposals/proposal_m/footer.erb +0 -13
- data/app/overrides/layouts/decidim/_head/add_awesome_legacy_scripts.rb +0 -14
- data/app/overrides/layouts/decidim/admin/_header/replace_styles.html.erb.deface +0 -3
- data/app/packs/entrypoints/decidim_admin_decidim_awesome_custom_fields.js +0 -2
- data/app/packs/entrypoints/decidim_decidim_awesome_admin_form_exit_warn.js +0 -1
- data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +0 -55
- data/app/packs/src/decidim/decidim_awesome/editors/editor.js +0 -213
- data/app/packs/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +0 -19
- data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +0 -58
- data/app/packs/stylesheets/vendor/select2-foundation-theme.scss +0 -348
- data/app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb +0 -65
- data/app/views/decidim/decidim_awesome/admin/config/_modal.html.erb +0 -11
- data/app/views/decidim/decidim_awesome/voting/voting_cards/_proposal_m_cell_footer.erb +0 -15
- /data/app/packs/src/decidim/decidim_awesome/{editors/tabs_focus.js → admin/tabs_change.js} +0 -0
@@ -14,10 +14,10 @@ export default class ControlsUI {
|
|
14
14
|
});
|
15
15
|
|
16
16
|
if (this.awesomeMap.config.hideControls) {
|
17
|
-
|
17
|
+
this.main.getContainer().style.display = "none";
|
18
18
|
}
|
19
19
|
|
20
|
-
this
|
20
|
+
this.loading = document.querySelector("#awesome-map .loading-spinner");
|
21
21
|
this.onHashtag = this._orderHashtags;
|
22
22
|
|
23
23
|
this.awesomeMap.map.on("overlayadd", () => {
|
@@ -38,8 +38,14 @@ export default class ControlsUI {
|
|
38
38
|
$("#awesome-map").on("click", ".awesome_map-title-control", (evt) => {
|
39
39
|
evt.preventDefault();
|
40
40
|
evt.stopPropagation();
|
41
|
-
|
42
|
-
|
41
|
+
const categories = document.getElementById("awesome_map-categories-control");
|
42
|
+
const hashtags = document.getElementById("awesome_map-hashtags-control");
|
43
|
+
if (categories) {
|
44
|
+
categories.classList.toggle("active");
|
45
|
+
}
|
46
|
+
if (hashtags) {
|
47
|
+
hashtags.classList.toggle("active");
|
48
|
+
}
|
43
49
|
});
|
44
50
|
|
45
51
|
// hashtag events
|
@@ -60,11 +66,27 @@ export default class ControlsUI {
|
|
60
66
|
$("#awesome-map .awesome_map-hashtags-selector").prop("checked", $("#awesome-map .awesome_map-hashtags-selector:checked").length < $("#awesome-map .awesome_map-hashtags-selector").length);
|
61
67
|
this.updateHashtagLayers();
|
62
68
|
});
|
69
|
+
|
70
|
+
this.awesomeMap.map.on("popupopen", () => {
|
71
|
+
// console.log("popup open");
|
72
|
+
// hide Controls
|
73
|
+
document.querySelector(".leaflet-control-layers.leaflet-control").style.display = "none";
|
74
|
+
});
|
75
|
+
this.awesomeMap.map.on("popupclose", () => {
|
76
|
+
// console.log("popup close");
|
77
|
+
// restore controls
|
78
|
+
document.querySelector(".leaflet-control-layers.leaflet-control").style.display = "block";
|
79
|
+
});
|
63
80
|
}
|
64
81
|
|
65
82
|
addSearchControls() {
|
66
|
-
|
67
|
-
|
83
|
+
const section = this.main.getContainer().querySelector(".leaflet-control-layers-list");
|
84
|
+
if (section) {
|
85
|
+
section.insertAdjacentHTML("beforeend", `<div id="awesome_map-categories-control" class="active"><b class="awesome_map-title-control">${window.DecidimAwesome.texts.categories}</b><div class="categories-container"></div></div>
|
86
|
+
<div id="awesome_map-hashtags-control"><b class="awesome_map-title-control">${window.DecidimAwesome.texts.hashtags}</b><div class="hashtags-container"></div><a href="#" class="awesome_map-toggle_all_tags">${window.DecidimAwesome.texts.selectDeselectAll}</a></div>`);
|
87
|
+
} else {
|
88
|
+
console.error("Can't find the section to insert the controls");
|
89
|
+
}
|
68
90
|
}
|
69
91
|
|
70
92
|
addCategoriesControls() {
|
@@ -76,7 +98,12 @@ export default class ControlsUI {
|
|
76
98
|
group: new L.FeatureGroup.SubGroup(this.awesomeMap.cluster)
|
77
99
|
};
|
78
100
|
this.awesomeMap.layers[category.id].group.addTo(this.awesomeMap.map);
|
79
|
-
|
101
|
+
const categories = document.querySelector("#awesome_map-categories-control .categories-container");
|
102
|
+
if (categories) {
|
103
|
+
categories.insertAdjacentHTML("beforeend", `<label data-layer="${category.id}" class="awesome_map-category-${category.id}${category.parent ? " subcategory" : ""}" data-parent="${category.parent}"><input type="checkbox" class="awesome_map-categories-selector" checked><span>${label}</span></label>`);
|
104
|
+
} else {
|
105
|
+
console.error("Can't find the section to insert the categories");
|
106
|
+
}
|
80
107
|
})
|
81
108
|
|
82
109
|
// category events
|
@@ -114,7 +141,7 @@ export default class ControlsUI {
|
|
114
141
|
addHashtagsControls(hashtags, marker) {
|
115
142
|
// show hashtag layer
|
116
143
|
if (hashtags && hashtags.length) {
|
117
|
-
|
144
|
+
document.getElementById("awesome_map-hashtags-control").style.display = "block";
|
118
145
|
hashtags.forEach((hashtag) => {
|
119
146
|
// Add layer if not exists, otherwise just add the marker to the group
|
120
147
|
if (!this.awesomeMap.layers[hashtag.tag]) {
|
@@ -123,30 +150,34 @@ export default class ControlsUI {
|
|
123
150
|
group: new L.FeatureGroup.SubGroup(this.awesomeMap.cluster)
|
124
151
|
};
|
125
152
|
this.awesomeMap.map.addLayer(this.awesomeMap.layers[hashtag.tag].group);
|
126
|
-
|
153
|
+
document.querySelector("#awesome_map-hashtags-control .hashtags-container").insertAdjacentHTML("beforeend", `<label data-layer="${hashtag.tag}" class="awesome_map-hashtag-${hashtag.tag}"><input type="checkbox" class="awesome_map-hashtags-selector" checked><span>${hashtag.name}</span></label>`);
|
127
154
|
// Call a trigger, might be in service for customizations
|
128
155
|
this.onHashtag(hashtag, $("#awesome_map-hashtags-control .hashtags-container"));
|
129
156
|
}
|
130
157
|
this.awesomeMap.layers[hashtag.tag].group.addLayer(marker);
|
131
158
|
|
132
|
-
const
|
159
|
+
const label = document.querySelector(`label.awesome_map-hashtag-${hashtag.tag}`);
|
133
160
|
// update number of items
|
134
|
-
|
161
|
+
label.setAttribute("title", `${parseInt(label.title || 0, 10) + 1} ${window.DecidimAwesome.texts.items}`);
|
135
162
|
});
|
136
163
|
}
|
137
164
|
}
|
138
165
|
|
139
166
|
showCategory(cat) {
|
140
|
-
|
167
|
+
document.getElementById("awesome_map-categories-control").style.display = "block";
|
141
168
|
// show category if hidden
|
142
|
-
const
|
143
|
-
const
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
169
|
+
const label = document.querySelector(`label.awesome_map-category-${cat.id}`);
|
170
|
+
const parent = document.querySelector(`label.awesome_map-category-${cat.parent}`);
|
171
|
+
if (label) {
|
172
|
+
label.style.display = "block";
|
173
|
+
// update number of items
|
174
|
+
label.setAttribute("title", `${parseInt(label.title || 0, 10) + 1} ${window.DecidimAwesome.texts.items}`);
|
175
|
+
}
|
176
|
+
if (parent) {
|
177
|
+
// show parent if apply
|
178
|
+
parent.style.display = "block"
|
179
|
+
parent.setAttribute("title", `${parseInt(parent.title || 0, 10) + 1} ${window.DecidimAwesome.texts.items}`);
|
180
|
+
}
|
150
181
|
}
|
151
182
|
|
152
183
|
removeHiddenComponents() {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import AwesomeMap from "src/decidim/decidim_awesome/awesome_map/awesome_map"
|
2
2
|
|
3
|
-
|
3
|
+
document.addEventListener("DOMContentLoaded", () => {
|
4
4
|
const sanitizeCenter = (string) => {
|
5
5
|
if (string) {
|
6
6
|
const parts = string.split(",")
|
@@ -15,31 +15,40 @@ $(() => {
|
|
15
15
|
return null;
|
16
16
|
};
|
17
17
|
|
18
|
+
const parse = (string) => {
|
19
|
+
if (!string) {
|
20
|
+
return null;
|
21
|
+
}
|
22
|
+
return JSON.parse(string);
|
23
|
+
}
|
24
|
+
|
25
|
+
const dataset = document.getElementById("awesome-map").dataset;
|
18
26
|
const config = {
|
19
|
-
length:
|
20
|
-
center: sanitizeCenter(
|
21
|
-
zoom:
|
27
|
+
length: parse(dataset.truncate) || 254,
|
28
|
+
center: sanitizeCenter(parse(dataset.mapCenter)),
|
29
|
+
zoom: parse(dataset.mapZoom),
|
22
30
|
menu: {
|
23
|
-
amendments:
|
24
|
-
meetings:
|
25
|
-
categories:
|
26
|
-
hashtags:
|
27
|
-
mergeComponents:
|
31
|
+
amendments: parse(dataset.menuAmendments),
|
32
|
+
meetings: parse(dataset.menuMeetings),
|
33
|
+
categories: parse(dataset.menuCategories),
|
34
|
+
hashtags: parse(dataset.menuHashtags),
|
35
|
+
mergeComponents: parse(dataset.menuMergeComponents)
|
28
36
|
},
|
29
37
|
show: {
|
30
|
-
withdrawn:
|
31
|
-
accepted:
|
32
|
-
evaluating:
|
33
|
-
notAnswered:
|
34
|
-
rejected:
|
38
|
+
withdrawn: parse(dataset.showWithdrawn),
|
39
|
+
accepted: parse(dataset.showAccepted),
|
40
|
+
evaluating: parse(dataset.showEvaluating),
|
41
|
+
notAnswered: parse(dataset.showNotAnswered),
|
42
|
+
rejected: parse(dataset.showRejected)
|
35
43
|
},
|
36
|
-
hideControls:
|
37
|
-
collapsedMenu:
|
38
|
-
components:
|
44
|
+
hideControls: parse(dataset.hideCcontrols),
|
45
|
+
collapsedMenu: parse(dataset.collapsed),
|
46
|
+
components: parse(dataset.components)
|
39
47
|
};
|
40
48
|
|
41
49
|
// build awesome map (if exist)
|
42
|
-
|
50
|
+
// This event is still launched using JQuery in version 0.28
|
51
|
+
$("#awesome-map .dynamic-map").on("ready.decidim", (evt, map) => {
|
43
52
|
// bindPopup doesn't work for some unknown cause and these handler neither so we're cancelling them
|
44
53
|
map.off("popupopen");
|
45
54
|
map.off("popupclose");
|
@@ -0,0 +1,94 @@
|
|
1
|
+
/* eslint-disable require-jsdoc */
|
2
|
+
|
3
|
+
import { Editor } from "@tiptap/core";
|
4
|
+
|
5
|
+
import DecidimKit from "src/decidim/editor/extensions/decidim_kit";
|
6
|
+
|
7
|
+
import createEditorToolbar from "src/decidim/editor/toolbar";
|
8
|
+
import { uniqueId } from "src/decidim/editor/common/helpers";
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Creates a new rich text editor instance and takes into account Awesome configuration for it (so user can upload images if configured)
|
12
|
+
*
|
13
|
+
* @param {HTMLElement} container The element that contains the editor.
|
14
|
+
* @return {Editor} The rich text editor instance.
|
15
|
+
*/
|
16
|
+
|
17
|
+
export default function createEditor(container) {
|
18
|
+
const DecidimAwesome = window.DecidimAwesome || {};
|
19
|
+
console.log("Using DecidimAwesome createEditor")
|
20
|
+
const input = container.parentElement.querySelector("input[type=hidden]");
|
21
|
+
const label = container.parentElement.querySelector("label");
|
22
|
+
const editorContainer = container.querySelector(".editor-input");
|
23
|
+
|
24
|
+
const editorAttributes = { role: "textbox", "aria-multiline": true };
|
25
|
+
if (label) {
|
26
|
+
const labelId = uniqueId("editorlabel");
|
27
|
+
label.setAttribute("id", labelId);
|
28
|
+
editorAttributes["aria-labelledby"] = labelId;
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Toolbar features can be one of:
|
33
|
+
*
|
34
|
+
* - basic = only basic controls without headings
|
35
|
+
* - content = basic + headings
|
36
|
+
* - full = basic + headings + image + video
|
37
|
+
*/
|
38
|
+
const features = container.dataset?.toolbar || "basic";
|
39
|
+
const options = JSON.parse(container.dataset.options);
|
40
|
+
// console.log("options for this editor", options, "container", container, "editorContainer", editorContainer, "input", input, "label", label)
|
41
|
+
const { context, contentTypes } = options;
|
42
|
+
|
43
|
+
const decidimOptions = {};
|
44
|
+
|
45
|
+
if (context !== "participant") {
|
46
|
+
decidimOptions.link = { allowTargetControl: true };
|
47
|
+
}
|
48
|
+
|
49
|
+
if (input.hasAttribute("maxlength")) {
|
50
|
+
decidimOptions.characterCount = { limit: parseInt(input.getAttribute("maxlength"), 10) };
|
51
|
+
}
|
52
|
+
|
53
|
+
if (features === "basic") {
|
54
|
+
decidimOptions.heading = false;
|
55
|
+
}
|
56
|
+
|
57
|
+
if (features === "full" || DecidimAwesome.allow_videos_in_editors) {
|
58
|
+
decidimOptions.videoEmbed = true;
|
59
|
+
}
|
60
|
+
|
61
|
+
if (features === "full" || DecidimAwesome.allow_images_in_editors) {
|
62
|
+
const { uploadImagesPath, uploadDialogSelector } = options;
|
63
|
+
decidimOptions.image = {
|
64
|
+
uploadDialogSelector,
|
65
|
+
contentTypes: contentTypes.image,
|
66
|
+
uploadImagesPath
|
67
|
+
};
|
68
|
+
}
|
69
|
+
|
70
|
+
if (container.classList.contains("js-hashtags")) {
|
71
|
+
decidimOptions.hashtag = true;
|
72
|
+
}
|
73
|
+
if (container.classList.contains("js-mentions")) {
|
74
|
+
decidimOptions.mention = true;
|
75
|
+
}
|
76
|
+
if (container.classList.contains("js-emojis")) {
|
77
|
+
decidimOptions.emoji = true;
|
78
|
+
}
|
79
|
+
|
80
|
+
const editor = new Editor({
|
81
|
+
element: editorContainer,
|
82
|
+
editorProps: { attributes: editorAttributes },
|
83
|
+
content: input.value,
|
84
|
+
editable: !input.disabled,
|
85
|
+
extensions: [DecidimKit.configure(decidimOptions)]
|
86
|
+
});
|
87
|
+
|
88
|
+
const toolbar = createEditorToolbar(editor);
|
89
|
+
container.insertBefore(toolbar, editorContainer);
|
90
|
+
|
91
|
+
editor.on("update", () => (input.value = editor.getHTML()));
|
92
|
+
|
93
|
+
return editor;
|
94
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import FormStorage from "form-storage"
|
1
|
+
import FormStorage from "form-storage";
|
2
2
|
|
3
|
-
|
3
|
+
document.addEventListener("DOMContentLoaded", () => {
|
4
4
|
window.DecidimAwesome = window.DecidimAwesome || {};
|
5
5
|
if (!window.DecidimAwesome.auto_save_forms) {
|
6
6
|
return;
|
@@ -14,9 +14,9 @@ $(() => {
|
|
14
14
|
|
15
15
|
const storeId = `awesome_autosave:${questionnaireId}`;
|
16
16
|
const storeCheckboxesId = `awesome_autosave:checkboxes:${questionnaireId}`;
|
17
|
-
const
|
17
|
+
const form = document.querySelector("form.answer-questionnaire");
|
18
18
|
|
19
|
-
if (
|
19
|
+
if (!form) {
|
20
20
|
if (window.DecidimAwesome.questionnaire_answered) {
|
21
21
|
// console.log("Questionnaire already answered, remove any data saved");
|
22
22
|
window.localStorage.removeItem(storeId);
|
@@ -26,7 +26,7 @@ $(() => {
|
|
26
26
|
return;
|
27
27
|
}
|
28
28
|
|
29
|
-
const store = new FormStorage(`#${
|
29
|
+
const store = new FormStorage(`#${form.id}`, {
|
30
30
|
name: storeId,
|
31
31
|
ignores: [
|
32
32
|
// '[type="hidden"]',
|
@@ -34,27 +34,33 @@ $(() => {
|
|
34
34
|
'[name="authenticity_token"]',
|
35
35
|
"[disabled]",
|
36
36
|
// there are problems with matrix questions
|
37
|
-
'[type="checkbox"]'
|
37
|
+
'[type="checkbox"]'
|
38
38
|
]
|
39
39
|
});
|
40
40
|
|
41
41
|
const showMsg = (msg, error = false, defaultTime = 700) => {
|
42
|
-
const time = error
|
43
|
-
|
42
|
+
const time = error
|
43
|
+
? 5000
|
44
|
+
: defaultTime;
|
45
|
+
const div = document.createElement("div");
|
46
|
+
div.className = `awesome_autosave-notice${error
|
47
|
+
? " error"
|
48
|
+
: ""}`;
|
49
|
+
div.innerHTML = msg;
|
50
|
+
form.appendChild(div);
|
51
|
+
// console.log("showMsg", "form", form, "div", div, "msg", msg, "error", error, "defaultTime", defaultTime, "time", time);
|
44
52
|
setTimeout(() => {
|
45
|
-
|
46
|
-
$div.remove();
|
47
|
-
});
|
53
|
+
div.remove();
|
48
54
|
}, time);
|
49
55
|
};
|
50
56
|
|
51
57
|
if (!window.localStorage) {
|
52
|
-
showMsg(window.DecidimAwesome.texts.
|
58
|
+
showMsg(window.DecidimAwesome.texts.autosavedError, true);
|
53
59
|
return;
|
54
60
|
}
|
55
61
|
|
56
62
|
if (window.localStorage.getItem(storeId)) {
|
57
|
-
showMsg(window.DecidimAwesome.texts.
|
63
|
+
showMsg(window.DecidimAwesome.texts.autosavedRetrieved, false, 5000);
|
58
64
|
}
|
59
65
|
|
60
66
|
// restore if available
|
@@ -62,28 +68,27 @@ $(() => {
|
|
62
68
|
// restore checkboxes
|
63
69
|
try {
|
64
70
|
let checkboxes = JSON.parse(window.localStorage.getItem(storeCheckboxesId));
|
65
|
-
|
66
|
-
|
67
|
-
|
71
|
+
Object.keys(checkboxes).forEach((id) => {
|
72
|
+
if (Object.prototype.hasOwnProperty.call(checkboxes, id)) {// eslint-disable-line prefer-reflect
|
73
|
+
document.getElementById(id).checked = checkboxes[id];
|
74
|
+
}
|
75
|
+
});
|
68
76
|
} catch (evt) {
|
69
77
|
console.log("No checkboxes found");
|
70
78
|
}
|
71
|
-
// this trigger the "change" event, it seems that it is too much
|
72
|
-
// $form.find('input, textarea, select').change();
|
73
79
|
|
74
80
|
const save = () => {
|
75
81
|
store.save();
|
76
82
|
// save checkbox manually
|
77
83
|
let checkboxes = {};
|
78
|
-
|
84
|
+
form.querySelectorAll('input[type="checkbox"]').forEach((el) => {
|
79
85
|
checkboxes[el.id] = el.checked;
|
80
86
|
});
|
81
87
|
window.localStorage.setItem(storeCheckboxesId, JSON.stringify(checkboxes));
|
82
|
-
showMsg(window.DecidimAwesome.texts.
|
88
|
+
showMsg(window.DecidimAwesome.texts.autosavedSuccess);
|
83
89
|
};
|
84
90
|
|
85
91
|
// save changes when modifications
|
86
|
-
|
87
|
-
save();
|
88
|
-
});
|
92
|
+
form.addEventListener("change", save);
|
89
93
|
});
|
94
|
+
|
@@ -2,8 +2,7 @@ import "formBuilder/dist/form-render.min.js";
|
|
2
2
|
import "src/decidim/decidim_awesome/forms/rich_text_plugin"
|
3
3
|
|
4
4
|
export default class CustomFieldsRenderer { // eslint-disable-line no-unused-vars
|
5
|
-
constructor(
|
6
|
-
this.containerSelector = containerSelector || ".proposal_custom_field:last";
|
5
|
+
constructor() {
|
7
6
|
this.lang = this.getLang(window.DecidimAwesome.currentLocale);
|
8
7
|
}
|
9
8
|
|
@@ -113,6 +112,7 @@ export default class CustomFieldsRenderer { // eslint-disable-line no-unused-var
|
|
113
112
|
$dl.append($dd);
|
114
113
|
}
|
115
114
|
}
|
115
|
+
// console.log("dataToXML", $dl[0].outerHTML);
|
116
116
|
return `<xml>${$dl[0].outerHTML}</xml>`;
|
117
117
|
}
|
118
118
|
|
@@ -122,9 +122,9 @@ export default class CustomFieldsRenderer { // eslint-disable-line no-unused-var
|
|
122
122
|
}
|
123
123
|
|
124
124
|
/**
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
* Hack to fix required checkboxes being reset
|
126
|
+
* Issue: https://github.com/decidim-ice/decidim-module-decidim_awesome/issues/82
|
127
|
+
*/
|
128
128
|
this.$element.find(".formbuilder-checkbox-group").each((_key, group) => {
|
129
129
|
const inputs = $(".formbuilder-checkbox input", group);
|
130
130
|
const $label = $(group).find("label");
|
@@ -164,9 +164,9 @@ export default class CustomFieldsRenderer { // eslint-disable-line no-unused-var
|
|
164
164
|
});
|
165
165
|
|
166
166
|
/**
|
167
|
-
|
168
|
-
|
169
|
-
|
167
|
+
* Hack to fix required radio buttons "other" value
|
168
|
+
* Issue: https://github.com/decidim-ice/decidim-module-decidim_awesome/issues/133
|
169
|
+
*/
|
170
170
|
this.$element.find(".formbuilder-radio input.other-val").on("input", (input) => {
|
171
171
|
const $input = $(input.currentTarget);
|
172
172
|
const $group = $input.closest(".formbuilder-radio-group");
|
@@ -189,7 +189,6 @@ export default class CustomFieldsRenderer { // eslint-disable-line no-unused-var
|
|
189
189
|
const $body = $form.find(`input[name="${this.$element.data("name")}"]`);
|
190
190
|
if ($body.length && this.instance) {
|
191
191
|
this.spec = this.instance.userData;
|
192
|
-
console.log("Spec data:", this.spec);
|
193
192
|
$body.val(this.dataToXML(this.spec));
|
194
193
|
this.$element.data("spec", this.spec);
|
195
194
|
}
|
@@ -198,18 +197,14 @@ export default class CustomFieldsRenderer { // eslint-disable-line no-unused-var
|
|
198
197
|
}
|
199
198
|
|
200
199
|
init($element) {
|
201
|
-
console.log("CustomFieldsRenderer init");
|
202
200
|
this.$element = $element;
|
203
|
-
console.log("Element for rendering:", $element);
|
204
|
-
|
205
201
|
this.spec = $element.data("spec");
|
206
|
-
console.log("Spec data:", this.spec);
|
207
202
|
// console.log("init", $element, "this", this)
|
208
203
|
// in case of multilang tabs we only render one form due a limitation in the library for handling several instances
|
209
204
|
this.instance = $element.formRender({
|
210
205
|
i18n: {
|
211
206
|
locale: this.lang,
|
212
|
-
location:
|
207
|
+
location: window.DecidimAwesome.formBuilderLangsLocation
|
213
208
|
},
|
214
209
|
formData: this.spec,
|
215
210
|
render: true,
|
@@ -4,7 +4,8 @@
|
|
4
4
|
*
|
5
5
|
* Registers Decidim Richtext as a subtype for the textarea control
|
6
6
|
*/
|
7
|
-
|
7
|
+
|
8
|
+
import createEditor from "src/decidim/decidim_awesome/editor";
|
8
9
|
|
9
10
|
// configure the class for runtime loading
|
10
11
|
if (!window.fbControls) {
|
@@ -40,7 +41,7 @@ window.fbControls.push(function(controlClass, allControlClasses) {
|
|
40
41
|
* @return {void}
|
41
42
|
*/
|
42
43
|
configure() {
|
43
|
-
window.fbEditors.
|
44
|
+
window.fbEditors.tiptap = {};
|
44
45
|
}
|
45
46
|
|
46
47
|
/**
|
@@ -60,19 +61,24 @@ window.fbControls.push(function(controlClass, allControlClasses) {
|
|
60
61
|
value: (userData && userData[0]) || value || ""
|
61
62
|
});
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
64
|
+
this.editorInput = this.markup("div", null, {
|
65
|
+
style: "height: 25rem",
|
66
|
+
class: "editor-input"
|
67
|
+
});
|
68
|
+
|
69
|
+
const options = this.classConfig && this.classConfig.editorOptions || {"contentTypes": {image: ["image/jpeg", "image/png"]}};
|
70
|
+
const wrapperAttrs = {
|
71
|
+
"id": attrs.id,
|
72
|
+
"name": attrs.name,
|
73
|
+
"type": attrs.type,
|
74
|
+
"className": "editor-container",
|
75
|
+
"data-toolbar": "basic",
|
76
|
+
"data-disabled": "false",
|
77
|
+
"data-options": JSON.stringify(options)
|
78
|
+
};
|
79
|
+
// console.log("build value", value, "userData", userData, "attrs", attrs, attrs.id, "wrapperAttrs", wrapperAttrs,"this",this);
|
80
|
+
this.wrapper = this.markup("div", this.editorInput, wrapperAttrs);
|
81
|
+
return this.markup("div", [this.input, this.wrapper], {style: "margin-top: 1rem"});
|
76
82
|
}
|
77
83
|
|
78
84
|
/**
|
@@ -81,26 +87,15 @@ window.fbControls.push(function(controlClass, allControlClasses) {
|
|
81
87
|
* @return {Object} evt - event
|
82
88
|
*/
|
83
89
|
onRender(evt) {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
// window.fbEditors.richtext[this.id].richtext('destroy')
|
90
|
+
if (window.fbEditors.tiptap[this.id]) {
|
91
|
+
console.log("destroying editor", window.fbEditors.tiptap[this.id]);
|
92
|
+
window.fbEditors.tiptap[this.id].instance.destroy();
|
88
93
|
}
|
89
94
|
|
90
|
-
window.fbEditors.
|
91
|
-
const editor = window.fbEditors.
|
92
|
-
|
93
|
-
editor.instance = createQuillEditor(this.wrapper);
|
94
|
-
// editor.data = new Delta();
|
95
|
-
// if (value) {
|
96
|
-
// editor.instance.setContents(window.JSON.parse(this.parsedHtml(value)));
|
97
|
-
// }
|
98
|
-
// editor.instance.on('text-change', function(delta) {
|
99
|
-
// console.log("text-change", "delta", delta, "editor", editor);
|
100
|
-
// // // editor.data = editor.data.compose(delta);
|
101
|
-
// });
|
95
|
+
window.fbEditors.tiptap[this.id] = {};
|
96
|
+
const editor = window.fbEditors.tiptap[this.id];
|
97
|
+
editor.instance = createEditor(this.wrapper);
|
102
98
|
|
103
|
-
// console.log("render! editor", editor, "this", this, "value", value);
|
104
99
|
return evt;
|
105
100
|
}
|
106
101
|
}
|
@@ -1,24 +1,30 @@
|
|
1
|
-
|
1
|
+
import { attach } from "inline-attacher";
|
2
|
+
|
3
|
+
document.addEventListener("DOMContentLoaded", () => {
|
2
4
|
window.DecidimAwesome = window.DecidimAwesome || {};
|
3
5
|
|
4
|
-
const token =
|
5
|
-
const
|
6
|
-
const text = window.DecidimAwesome.texts.drag_and_drop_image;
|
6
|
+
const token = document.querySelector('meta[name="csrf-token"]') && document.querySelector('meta[name="csrf-token"]').getAttribute("content");
|
7
|
+
const textarea = document.querySelector("textarea#proposal_body");
|
7
8
|
|
8
|
-
if (
|
9
|
+
if (!textarea) {
|
9
10
|
return;
|
10
11
|
}
|
11
12
|
|
12
13
|
if (window.DecidimAwesome.allow_images_in_proposals) {
|
13
14
|
// Add the capability to upload images only (they will be presented as links)
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
const span = document.createElement("span");
|
17
|
+
span.className = "input-character-counter__text";
|
18
|
+
span.innerHTML = window.DecidimAwesome.texts.dragAndDropImage;
|
19
|
+
textarea.parentNode.appendChild(span);
|
20
|
+
attach(textarea, {
|
21
|
+
uploadUrl: window.DecidimAwesome.editorUploaderPath,
|
18
22
|
uploadFieldName: "image",
|
19
|
-
|
23
|
+
responseUrlKey: "url",
|
20
24
|
progressText: "[Uploading file...]",
|
21
|
-
urlText:
|
25
|
+
urlText: (url, response) => {
|
26
|
+
return response.url;
|
27
|
+
},
|
22
28
|
extraHeaders: { "X-CSRF-Token": token }
|
23
29
|
});
|
24
30
|
}
|