decidim-decidim_awesome 0.10.2 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/README.md +177 -60
- 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 +24 -0
- data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +5 -12
- data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +9 -5
- 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 +2 -2
- data/app/commands/concerns/decidim/decidim_awesome/proposals/admin/update_proposal_override.rb +31 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_collaborative_draft_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_collaborative_draft_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +26 -0
- data/app/commands/decidim/decidim_awesome/admin/create_constraint.rb +1 -1
- data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +4 -3
- 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/destroy_proposal_custom_field.rb +6 -3
- 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 +43 -0
- data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +4 -3
- data/app/controllers/concerns/decidim/decidim_awesome/content_security_policy.rb +34 -0
- data/app/controllers/concerns/decidim/decidim_awesome/limit_pending_amendments.rb +35 -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 +9 -22
- 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/application_controller.rb +2 -0
- data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +14 -10
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +10 -9
- data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +23 -20
- data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +6 -10
- data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +76 -0
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +6 -10
- data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +14 -6
- 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 +18 -5
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_override.rb +21 -0
- data/app/forms/{decidim → concerns/decidim}/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +2 -1
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +28 -14
- 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 +65 -0
- 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 +110 -0
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +6 -27
- data/app/helpers/decidim/decidim_awesome/map_helper.rb +8 -27
- data/app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb +22 -0
- 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 +39 -10
- data/app/models/decidim/decidim_awesome/awesome_config.rb +1 -1
- data/app/models/decidim/decidim_awesome/paper_trail_version.rb +8 -4
- data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +35 -1
- data/app/models/decidim/decidim_awesome/vote_weight.rb +2 -2
- data/app/overrides/decidim/proposals/admin/proposals/show/add_private_body.html.erb.deface +7 -0
- data/app/overrides/decidim/proposals/admin/proposals/show/replace_body.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/proposals/_proposal_aside/limit_amendments_modal.html.erb.deface +5 -0
- 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_decidim_awesome_map.scss +1 -1
- data/app/packs/entrypoints/decidim_editor.js +14 -0
- data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +96 -69
- 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 +9 -5
- 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/tabs_change.js +31 -0
- 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 +28 -0
- 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 +1 -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 +29 -25
- data/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js +27 -32
- data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +31 -15
- 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 +24 -12
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +49 -29
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +28 -71
- 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 +17 -26
- data/app/packs/stylesheets/decidim/decidim_awesome/amendments/modal.scss +5 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +11 -49
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +19 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +4 -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 +41 -35
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +6 -6
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +118 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +26 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +41 -59
- data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +14 -3
- 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/{decidim → concerns/decidim}/decidim_awesome/menu_item_presenter_override.rb +10 -2
- data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_presenter_override.rb +8 -0
- data/app/presenters/concerns/decidim/decidim_awesome/proposals/proposal_presenter_override.rb +20 -0
- data/app/presenters/decidim/decidim_awesome/admin_log/component_presenter_override.rb +30 -0
- data/app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb +1 -1
- data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +70 -0
- data/app/presenters/decidim/decidim_awesome/user_entity_presenter.rb +1 -1
- data/app/queries/decidim/decidim_awesome/private_data_finder.rb +19 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +72 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_override.rb +38 -0
- data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +34 -0
- data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_custom_fields.rb +59 -0
- data/app/types/concerns/decidim/decidim_awesome/{proposal_type_override.rb → add_proposal_type_vote_weights.rb} +3 -1
- 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 +50 -48
- data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -2
- data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +25 -18
- data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +7 -6
- data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +12 -16
- 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 +35 -17
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_private_custom_fields.html.erb +1 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +68 -80
- data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +16 -12
- 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 +14 -13
- 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 +44 -0
- data/app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb +44 -0
- 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 +39 -42
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +21 -12
- data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +8 -5
- data/app/views/decidim/decidim_awesome/admin/proposals/_private_body.html.erb +20 -0
- 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 +23 -0
- data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +8 -2
- 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 +12 -0
- data/app/views/layouts/decidim/decidim_awesome/admin/application.html.erb +1 -73
- data/app/views/layouts/decidim/decidim_awesome/admin/maintenance.html.erb +19 -0
- data/config/assets.rb +3 -33
- data/config/i18n-tasks.yml +23 -3
- data/config/locales/ca.yml +110 -23
- data/config/locales/cs.yml +121 -19
- data/config/locales/de.yml +61 -20
- data/config/locales/en.yml +125 -35
- data/config/locales/es.yml +109 -22
- data/config/locales/eu.yml +22 -5
- data/config/locales/fr.yml +107 -20
- data/config/locales/hu.yml +53 -12
- data/config/locales/it.yml +22 -20
- data/config/locales/ja.yml +107 -20
- data/config/locales/lt.yml +0 -8
- data/config/locales/nl.yml +16 -17
- data/config/locales/pt-BR.yml +23 -20
- data/config/locales/pt-PT.yml +0 -1
- data/config/locales/ro-RO.yml +11 -7
- data/config/locales/sv.yml +24 -13
- 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/20240531224204_add_decidim_awesome_proposal_private_fields.rb +29 -0
- data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +20 -0
- data/db/seeds.rb +3 -3
- data/lib/decidim/decidim_awesome/admin_engine.rb +26 -7
- data/lib/decidim/decidim_awesome/api/types/localized_custom_fields_type.rb +22 -0
- data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +51 -0
- data/lib/decidim/decidim_awesome/awesome.rb +74 -23
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +6 -2
- data/lib/decidim/decidim_awesome/checksums.yml +47 -44
- data/lib/decidim/decidim_awesome/config.rb +1 -1
- data/lib/decidim/decidim_awesome/custom_fields.rb +13 -5
- data/lib/decidim/decidim_awesome/engine.rb +165 -56
- data/lib/decidim/decidim_awesome/iframe_component/component.rb +1 -2
- data/lib/decidim/decidim_awesome/lock.rb +47 -0
- data/lib/decidim/decidim_awesome/map_component/component.rb +1 -1
- data/lib/decidim/decidim_awesome/menu.rb +165 -0
- 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 +7 -12
- 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.rb → box_label_editor_examples.rb} +17 -17
- data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +23 -5
- data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +155 -0
- 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 +42 -58
- data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +9 -8
- data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +32 -24
- data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +97 -22
- 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 +21 -30
- metadata +86 -63
- data/app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb +0 -38
- 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/helpers/decidim/decidim_awesome/amendments_helper_override.rb +0 -48
- data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +0 -78
- 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 -218
- data/app/packs/src/decidim/decidim_awesome/editors/tabs_focus.js +0 -22
- 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 -64
- 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
@@ -14,8 +14,8 @@ export default class Controller {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
getLabel() {
|
17
|
-
let text = this.
|
18
|
-
if (!text) {
|
17
|
+
let text = this.component.name;
|
18
|
+
if (!text || this.awesomeMap.config.menu.mergeComponents) {
|
19
19
|
text = window.DecidimAwesome.texts[this.component.type];
|
20
20
|
}
|
21
21
|
return `<span class="awesome_map-component" id="awesome_map-component_${this.component.id}" title="0" data-layer="${this.component.type}">${text}</span>`
|
@@ -96,6 +96,7 @@ export default class Controller {
|
|
96
96
|
|
97
97
|
}).setLatLng(marker.getLatLng()).setContent(dom);
|
98
98
|
this.awesomeMap.map.addLayer(pop);
|
99
|
+
// console.log("marker click", node, "pop", pop, "marker", marker, "dom", dom, "templateId", this.templateId)
|
99
100
|
});
|
100
101
|
node.marker = marker;
|
101
102
|
node.component = this.component;
|
@@ -110,7 +111,7 @@ export default class Controller {
|
|
110
111
|
this.awesomeMap.layers[cat.id].group.addLayer(marker);
|
111
112
|
this.awesomeMap.controls.showCategory(cat);
|
112
113
|
} catch (evt) {
|
113
|
-
console.error("Failed category marker assignation", marker, evt.message);
|
114
|
+
console.error("Failed category marker assignation. category:", category, "marker:", marker, evt.message);
|
114
115
|
}
|
115
116
|
}
|
116
117
|
}
|
@@ -121,7 +122,7 @@ export default class Controller {
|
|
121
122
|
try {
|
122
123
|
this.awesomeMap.controls.addHashtagsControls(hashtags, marker);
|
123
124
|
} catch (evt) {
|
124
|
-
console.error("Failed hashtags marker assignation", marker, evt.message);
|
125
|
+
console.error("Failed hashtags marker assignation. hashtags:", hashtags, "marker:", marker, evt.message);
|
125
126
|
}
|
126
127
|
}
|
127
128
|
}
|
@@ -132,14 +133,13 @@ export default class Controller {
|
|
132
133
|
this.onFinished();
|
133
134
|
}
|
134
135
|
|
135
|
-
createIcon(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
fillOpacity: 0.9
|
136
|
+
createIcon(color) {
|
137
|
+
const size = 36;
|
138
|
+
return L.divIcon({
|
139
|
+
html: `
|
140
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="${size}px" height="${size}px" class="text-secondary" style="color: ${color}"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M18.364 17.364L12 23.728l-6.364-6.364a9 9 0 1 1 12.728 0zM12 15a4 4 0 1 0 0-8 4 4 0 0 0 0 8zm0-2a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"/></svg>`,
|
141
|
+
iconAnchor: [0.5 * size, size],
|
142
|
+
popupAnchor: [0, -0.5 * size]
|
143
143
|
});
|
144
144
|
}
|
145
145
|
}
|
@@ -2,12 +2,6 @@ import * as L from "leaflet";
|
|
2
2
|
import Controller from "src/decidim/decidim_awesome/awesome_map/controllers/controller";
|
3
3
|
import MeetingsFetcher from "src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher";
|
4
4
|
|
5
|
-
const MeetingIcon = L.DivIcon.SVGIcon.DecidimIcon.extend({
|
6
|
-
_createPathDescription: function() {
|
7
|
-
return "M 15.991543,4 C 7.3956015,4 2.9250351,10.5 3.000951,16.999999 3.1063486,26.460968 12.747693,30.000004 15.991543,43 19.242091,30.000004 29,26.255134 29,16.999999 29,10.5 23.951131,4 15.996007,4 m -0.153508,2.6000001 a 2.1720294,2.1076698 0 0 1 2.330514,2.1124998 2.177008,2.1125006 0 0 1 -4.354016,0 2.1720294,2.1076698 0 0 1 2.023502,-2.1124998 m -2.651707,4.8056679 h 5.610202 l 3.935584,7.569899 -1.926038,0.934266 -2.009546,-3.859265 v 14.557403 h -2.484243 v -9.126003 h -0.642162 v 9.126003 H 13.190347 V 16.050568 l -2.009545,3.859265 -1.926036,-0.934266 3.935581,-7.569899";
|
8
|
-
}
|
9
|
-
});
|
10
|
-
|
11
5
|
export default class MeetingsController extends Controller {
|
12
6
|
constructor(awesomeMap, component) {
|
13
7
|
super(awesomeMap, component)
|
@@ -19,7 +13,7 @@ export default class MeetingsController extends Controller {
|
|
19
13
|
// for each meeting, create a marker with an associated popup
|
20
14
|
this.fetcher.onNode = (meeting) => {
|
21
15
|
let marker = new L.Marker([meeting.coordinates.latitude, meeting.coordinates.longitude], {
|
22
|
-
icon: this.createIcon(
|
16
|
+
icon: this.createIcon(this.awesomeMap.getCategory(meeting.category).color),
|
23
17
|
title: meeting.title.translation
|
24
18
|
});
|
25
19
|
// console.log("new meeting", meeting, marker)
|
@@ -28,4 +22,14 @@ export default class MeetingsController extends Controller {
|
|
28
22
|
|
29
23
|
this.fetcher.fetch();
|
30
24
|
}
|
25
|
+
|
26
|
+
createIcon(color) {
|
27
|
+
const size = 36;
|
28
|
+
return L.divIcon({
|
29
|
+
html: `
|
30
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36" width="${size}px" height="${size}px" class="text-primary" style="color: ${color}"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M 15.991543,4 C 7.3956015,4 2.9250351,10.5 3.000951,16.999999 3.1063486,26.460968 12.747693,30.000004 15.991543,43 19.242091,30.000004 29,26.255134 29,16.999999 29,10.5 23.951131,4 15.996007,4 m -0.153508,2.6000001 a 2.1720294,2.1076698 0 0 1 2.330514,2.1124998 2.177008,2.1125006 0 0 1 -4.354016,0 2.1720294,2.1076698 0 0 1 2.023502,-2.1124998 m -2.651707,4.8056679 h 5.610202 l 3.935584,7.569899 -1.926038,0.934266 -2.009546,-3.859265 v 14.557403 h -2.484243 v -9.126003 h -0.642162 v 9.126003 H 13.190347 V 16.050568 l -2.009545,3.859265 -1.926036,-0.934266 3.935581,-7.569899"/></svg>`,
|
31
|
+
iconAnchor: [0.5 * size, size],
|
32
|
+
popupAnchor: [0, -0.5 * size]
|
33
|
+
});
|
34
|
+
}
|
31
35
|
}
|
@@ -2,14 +2,6 @@ import * as L from "leaflet";
|
|
2
2
|
import Controller from "src/decidim/decidim_awesome/awesome_map/controllers/controller";
|
3
3
|
import ProposalsFetcher from "src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher";
|
4
4
|
|
5
|
-
const ProposalIcon = L.DivIcon.SVGIcon.DecidimIcon.extend({
|
6
|
-
options: {
|
7
|
-
fillColor: "#ef604d",
|
8
|
-
fillOpacity: 0.8,
|
9
|
-
strokeWidth: 1,
|
10
|
-
strokeOpcacity: 1
|
11
|
-
}
|
12
|
-
});
|
13
5
|
export default class ProposalsController extends Controller {
|
14
6
|
constructor(awesomeMap, component) {
|
15
7
|
super(awesomeMap, component)
|
@@ -36,12 +28,13 @@ export default class ProposalsController extends Controller {
|
|
36
28
|
// for each proposal, create a marker with an associated popup
|
37
29
|
this.fetcher.onNode = (proposal) => {
|
38
30
|
let marker = new L.Marker([proposal.coordinates.latitude, proposal.coordinates.longitude], {
|
39
|
-
icon: this.createIcon(
|
31
|
+
icon: this.createIcon(this.awesomeMap.getCategory(proposal.category).color),
|
40
32
|
title: proposal.title.translation
|
41
33
|
});
|
42
34
|
|
43
35
|
// Check if it has amendments, add it to a list
|
44
36
|
// also assign parent's proposal categories to it
|
37
|
+
// console.log("onNode proposal", proposal, "amendment:", proposal.amendments)
|
45
38
|
if (proposal.amendments && proposal.amendments.length) {
|
46
39
|
proposal.amendments.forEach((amendment) => {
|
47
40
|
this.amendments[amendment.emendation.id] = proposal;
|
@@ -67,16 +60,16 @@ export default class ProposalsController extends Controller {
|
|
67
60
|
// console.log("marker", marker, "parent proposal", parent)
|
68
61
|
// add marker to amendments layers and remove it from proposals
|
69
62
|
if (marker) {
|
70
|
-
try {
|
71
|
-
marker.marker.removeFrom(this.controls.group)
|
72
|
-
} catch (evt) {
|
63
|
+
try {
|
64
|
+
marker.marker.removeFrom(this.controls.group)
|
65
|
+
} catch (evt) {
|
73
66
|
console.error("error removeFrom marker", marker, "layer", this.controls.group, evt);
|
74
67
|
}
|
75
68
|
if (this.awesomeMap.config.menu.amendments) {
|
76
69
|
marker.marker.addTo(this.awesomeMap.layers.amendments.group);
|
77
70
|
// mimic parent category (amendments doesn't have categories)
|
78
71
|
if (parent.category) {
|
79
|
-
marker.marker.setIcon(this.createIcon(
|
72
|
+
marker.marker.setIcon(this.createIcon("text-secondary"));
|
80
73
|
this.addMarkerCategory(marker.marker, parent.category)
|
81
74
|
}
|
82
75
|
}
|
@@ -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
|
+
|