decidim-decidim_awesome 0.10.2 → 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 +24 -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_m_cell_override.rb → proposal_l_cell_override.rb} +10 -4
- 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 +1 -1
- 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/proposal_votes_controller_override.rb +3 -3
- 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 +3 -3
- 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 +28 -17
- data/config/locales/cs.yml +39 -14
- data/config/locales/de.yml +25 -15
- data/config/locales/en.yml +125 -35
- data/config/locales/es.yml +26 -16
- data/config/locales/eu.yml +7 -3
- data/config/locales/fr.yml +25 -16
- data/config/locales/hu.yml +43 -8
- data/config/locales/it.yml +8 -15
- data/config/locales/ja.yml +26 -15
- data/config/locales/lt.yml +0 -4
- data/config/locales/nl.yml +9 -14
- data/config/locales/pt-BR.yml +9 -14
- data/config/locales/ro-RO.yml +0 -3
- data/config/locales/sv.yml +9 -9
- 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 +70 -19
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +6 -2
- data/lib/decidim/decidim_awesome/checksums.yml +46 -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 +83 -60
- 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,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
|
+
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
1
|
+
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
|
|
@@ -56,13 +55,13 @@ export default class CustomFieldsRenderer { // eslint-disable-line no-unused-var
|
|
56
55
|
*/
|
57
56
|
dataToXML(data) {
|
58
57
|
const $dl = $("<dl/>");
|
59
|
-
let $dd = null,
|
60
|
-
$div = null,
|
61
|
-
$dt = null,
|
62
|
-
datum = null,
|
63
|
-
key = null,
|
64
|
-
label = null,
|
65
|
-
text = null,
|
58
|
+
let $dd = null,
|
59
|
+
$div = null,
|
60
|
+
$dt = null,
|
61
|
+
datum = null,
|
62
|
+
key = null,
|
63
|
+
label = null,
|
64
|
+
text = null,
|
66
65
|
val = null;
|
67
66
|
$dl.attr("class", "decidim_awesome-custom_fields");
|
68
67
|
$dl.attr("data-generator", "decidim_awesome");
|
@@ -113,21 +112,23 @@ 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
|
|
119
119
|
fixBuggyFields() {
|
120
|
-
if (!this.$
|
120
|
+
if (!this.$element) {
|
121
121
|
return false;
|
122
122
|
}
|
123
123
|
|
124
124
|
/**
|
125
125
|
* Hack to fix required checkboxes being reset
|
126
|
-
* Issue: https://github.com/
|
126
|
+
* Issue: https://github.com/decidim-ice/decidim-module-decidim_awesome/issues/82
|
127
127
|
*/
|
128
|
-
this.$
|
128
|
+
this.$element.find(".formbuilder-checkbox-group").each((_key, group) => {
|
129
129
|
const inputs = $(".formbuilder-checkbox input", group);
|
130
|
-
const
|
130
|
+
const $label = $(group).find("label");
|
131
|
+
const data = this.spec.find((obj) => obj.type === "checkbox-group" && obj.name === $label.attr("for"));
|
131
132
|
let values = data.userData;
|
132
133
|
if (!inputs.length || !data || !values) {
|
133
134
|
return;
|
@@ -164,9 +165,9 @@ export default class CustomFieldsRenderer { // eslint-disable-line no-unused-var
|
|
164
165
|
|
165
166
|
/**
|
166
167
|
* Hack to fix required radio buttons "other" value
|
167
|
-
* Issue: https://github.com/
|
168
|
+
* Issue: https://github.com/decidim-ice/decidim-module-decidim_awesome/issues/133
|
168
169
|
*/
|
169
|
-
this.$
|
170
|
+
this.$element.find(".formbuilder-radio input.other-val").on("input", (input) => {
|
170
171
|
const $input = $(input.currentTarget);
|
171
172
|
const $group = $input.closest(".formbuilder-radio-group");
|
172
173
|
$group.find("input").each((_key, radio) => {
|
@@ -181,10 +182,10 @@ export default class CustomFieldsRenderer { // eslint-disable-line no-unused-var
|
|
181
182
|
|
182
183
|
// Saves xml to the hidden input
|
183
184
|
storeData() {
|
184
|
-
if (!this.$
|
185
|
+
if (!this.$element) {
|
185
186
|
return false;
|
186
187
|
}
|
187
|
-
const $form = this.$
|
188
|
+
const $form = this.$element.closest("form");
|
188
189
|
const $body = $form.find(`input[name="${this.$element.data("name")}"]`);
|
189
190
|
if ($body.length && this.instance) {
|
190
191
|
this.spec = this.instance.userData;
|
@@ -198,18 +199,21 @@ export default class CustomFieldsRenderer { // eslint-disable-line no-unused-var
|
|
198
199
|
init($element) {
|
199
200
|
this.$element = $element;
|
200
201
|
this.spec = $element.data("spec");
|
201
|
-
if (!this.$container) {
|
202
|
-
this.$container = $(this.containerSelector);
|
203
|
-
}
|
204
202
|
// console.log("init", $element, "this", this)
|
205
|
-
//
|
206
|
-
this.instance =
|
203
|
+
// in case of multilang tabs we only render one form due a limitation in the library for handling several instances
|
204
|
+
this.instance = $element.formRender({
|
207
205
|
i18n: {
|
208
206
|
locale: this.lang,
|
209
|
-
location:
|
207
|
+
location: window.DecidimAwesome.formBuilderLangsLocation
|
210
208
|
},
|
211
209
|
formData: this.spec,
|
212
|
-
render: true
|
210
|
+
render: true,
|
211
|
+
disableInjectedStyle: true,
|
212
|
+
controlConfig: {
|
213
|
+
"textarea.richtext": {
|
214
|
+
editorOptions: $element.data("editorOptions")
|
215
|
+
}
|
216
|
+
}
|
213
217
|
});
|
214
218
|
this.fixBuggyFields();
|
215
219
|
}
|
@@ -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,22 +1,38 @@
|
|
1
1
|
import CustomFieldsRenderer from "src/decidim/decidim_awesome/forms/custom_fields_renderer"
|
2
2
|
|
3
|
-
window.DecidimAwesome.CustomFieldsRenderer = window.DecidimAwesome.CustomFieldsRenderer || new CustomFieldsRenderer();
|
4
|
-
|
5
3
|
$(() => {
|
4
|
+
window.DecidimAwesome.CustomFieldsRenderer = window.DecidimAwesome.CustomFieldsRenderer || new CustomFieldsRenderer();
|
5
|
+
window.DecidimAwesome.PrivateCustomFieldsRenderer = window.DecidimAwesome.PrivateCustomFieldsRenderer || new CustomFieldsRenderer();
|
6
|
+
|
6
7
|
// use admin multilang specs if exists
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
const $public = $(".proposal_custom_field:first");
|
9
|
+
const $private = $(".proposal_custom_field.proposal_custom_field--private_body:first");
|
10
|
+
let $form = null;
|
11
|
+
if ($public.length) {
|
12
|
+
window.DecidimAwesome.CustomFieldsRenderer.init($public);
|
13
|
+
$form = window.DecidimAwesome.CustomFieldsRenderer.$element.closest("form");
|
10
14
|
}
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
// save current editor
|
16
|
-
window.DecidimAwesome.CustomFieldsRenderer.storeData();
|
17
|
-
} else {
|
18
|
-
evt.preventDefault();
|
19
|
-
evt.target.reportValidity();
|
15
|
+
if ($private.length) {
|
16
|
+
window.DecidimAwesome.PrivateCustomFieldsRenderer.init($private);
|
17
|
+
if (!$form) {
|
18
|
+
$form = window.DecidimAwesome.PrivateCustomFieldsRenderer.$element.closest("form");
|
20
19
|
}
|
21
|
-
}
|
20
|
+
}
|
21
|
+
|
22
|
+
if ($form) {
|
23
|
+
$form.on("submit", (evt) => {
|
24
|
+
if (evt.target.checkValidity()) {
|
25
|
+
// save current editors
|
26
|
+
if ($public.length) {
|
27
|
+
window.DecidimAwesome.CustomFieldsRenderer.storeData();
|
28
|
+
}
|
29
|
+
if ($private.length) {
|
30
|
+
window.DecidimAwesome.PrivateCustomFieldsRenderer.storeData();
|
31
|
+
}
|
32
|
+
} else {
|
33
|
+
evt.preventDefault();
|
34
|
+
evt.target.reportValidity();
|
35
|
+
}
|
36
|
+
});
|
37
|
+
}
|
22
38
|
});
|