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
@@ -2,10 +2,44 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module DecidimAwesome
|
5
|
+
# This class adds some attributes to the proposal model in a different table
|
6
|
+
# in particular, it adds a private_body field that should be encrypted
|
7
|
+
# private_body is not translatable, nor is intended to be as it won't be shown to the public
|
5
8
|
class ProposalExtraField < ApplicationRecord
|
9
|
+
include Decidim::RecordEncryptor
|
10
|
+
|
6
11
|
self.table_name = "decidim_awesome_proposal_extra_fields"
|
7
12
|
|
8
|
-
belongs_to :proposal, foreign_key: "decidim_proposal_id",
|
13
|
+
belongs_to :proposal, foreign_key: "decidim_proposal_id", foreign_type: "decidim_proposal_type", polymorphic: true
|
14
|
+
|
15
|
+
encrypt_attribute :private_body, type: :string
|
16
|
+
|
17
|
+
after_initialize :store_private_body
|
18
|
+
before_save :update_private_body_updated_at
|
19
|
+
|
20
|
+
# validate not more than one extra field can be associated to a proposal
|
21
|
+
# validates :proposal, uniqueness: true
|
22
|
+
validate :no_more_than_one_extra_field
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def store_private_body
|
27
|
+
@initial_private_body = private_body
|
28
|
+
end
|
29
|
+
|
30
|
+
# using private_body_changed? does not sufice as the encrypted value is always updated on saving
|
31
|
+
def update_private_body_updated_at
|
32
|
+
if private_body != @initial_private_body
|
33
|
+
self.private_body_updated_at = Time.current
|
34
|
+
@initial_private_body = private_body
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def no_more_than_one_extra_field
|
39
|
+
return unless ProposalExtraField.where(proposal:).where.not(id:).exists?
|
40
|
+
|
41
|
+
errors.add(:proposal, :invalid)
|
42
|
+
end
|
9
43
|
end
|
10
44
|
end
|
11
45
|
end
|
@@ -12,7 +12,7 @@ module Decidim
|
|
12
12
|
after_save :update_vote_weight_totals!
|
13
13
|
|
14
14
|
def update_vote_weight_totals!
|
15
|
-
extra = Decidim::DecidimAwesome::ProposalExtraField.find_or_initialize_by(proposal:
|
15
|
+
extra = Decidim::DecidimAwesome::ProposalExtraField.find_or_initialize_by(proposal:)
|
16
16
|
extra.vote_weight_totals = extra.vote_weight_totals || {}
|
17
17
|
|
18
18
|
prev = weight_previous_change&.first
|
@@ -20,7 +20,7 @@ module Decidim
|
|
20
20
|
extra.vote_weight_totals[prev.to_s] = Decidim::DecidimAwesome::VoteWeight.where(vote: proposal.votes, weight: prev).count
|
21
21
|
extra.vote_weight_totals.delete(prev.to_s) if extra.vote_weight_totals[prev.to_s].zero?
|
22
22
|
end
|
23
|
-
extra.vote_weight_totals[weight.to_s] = Decidim::DecidimAwesome::VoteWeight.where(vote: proposal.votes, weight:
|
23
|
+
extra.vote_weight_totals[weight.to_s] = Decidim::DecidimAwesome::VoteWeight.where(vote: proposal.votes, weight:).count
|
24
24
|
extra.vote_weight_totals.delete(weight.to_s) if extra.vote_weight_totals[weight.to_s].zero?
|
25
25
|
extra.weight_total = extra.vote_weight_totals.inject(0) { |sum, (weight, count)| sum + (weight.to_i * count) }
|
26
26
|
extra.save!
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<!-- replace "erb[loud]:contains('simple_format(present(proposal).body(strip_tags: true))')" -->
|
2
|
+
|
3
|
+
<% if awesome_proposal_custom_fields.blank? %>
|
4
|
+
<%= simple_format(present(proposal).body(strip_tags: true)) %>
|
5
|
+
<% else %>
|
6
|
+
<%= render_proposal_body(proposal) %>
|
7
|
+
<% end %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<!-- insert_before "erb[silent]:contains('presented_endorsers = endorsers_presenters_for(proposal)')" -->
|
2
|
+
|
3
|
+
<% unless awesome_proposal_private_custom_fields.blank? %>
|
4
|
+
<%= render partial: "decidim/decidim_awesome/admin/proposals/private_body", locals: { proposal: proposal } %>
|
5
|
+
<% end %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<!-- replace "erb[loud]:contains('amend_button_for @proposal')" -->
|
2
|
+
|
3
|
+
<%= amend_button_for @proposal %>
|
4
|
+
|
5
|
+
<%= render "decidim/decidim_awesome/amendments/modal" if @proposal.emendations.not_hidden.where(decidim_amendments: { state: Decidim::Amendment.states["evaluating"] }).count.positive? && @proposal.amendable? %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<!-- insert_after "erb[loud]:contains('layouts/decidim/js_configuration')" -->
|
2
|
+
|
3
|
+
<%= render partial: "layouts/decidim/decidim_awesome/awesome_config" %>
|
4
|
+
<% if show_public_intergram? %>
|
5
|
+
<%= render partial: "layouts/decidim/decidim_awesome/intergram_widget", locals: { settings: organization_awesome_config[:intergram_for_public_settings] } %>
|
6
|
+
<% end %>
|
@@ -1,14 +1,7 @@
|
|
1
|
-
<!--
|
1
|
+
<!-- insert_after "erb[loud]:contains('append_stylesheet_pack_tag')" -->
|
2
2
|
|
3
|
-
|
3
|
+
<% append_stylesheet_pack_tag "decidim_decidim_awesome", media: "all" %>
|
4
4
|
<%= render(partial: "layouts/decidim/decidim_awesome/custom_styles") if awesome_custom_styles.present? %>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
<% content_for :js_content do %>
|
9
|
-
<%= javascript_pack_tag "decidim_decidim_awesome", defer: false %>
|
10
|
-
<%= javascript_pack_tag("decidim_decidim_awesome_custom_fields") if Decidim::DecidimAwesome.enabled?(:proposal_custom_fields) %>
|
11
|
-
<% if show_public_intergram? %>
|
12
|
-
<%= render partial: "layouts/decidim/decidim_awesome/intergram_widget", locals: { settings: organization_awesome_config[:intergram_for_public_settings] } %>
|
13
|
-
<% end %>
|
14
|
-
<% end %>
|
6
|
+
<% append_javascript_pack_tag "decidim_decidim_awesome", defer: false %>
|
7
|
+
<% append_javascript_pack_tag("decidim_decidim_awesome_custom_fields") if Decidim::DecidimAwesome.enabled?(:proposal_custom_fields) %>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<!--
|
1
|
+
<!-- insert_after "erb[loud]:contains('append_stylesheet_pack_tag')" -->
|
2
2
|
|
3
3
|
<%= render partial: "layouts/decidim/decidim_awesome/awesome_config" %>
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
<% append_stylesheet_pack_tag("decidim_admin_decidim_awesome_global") %>
|
5
|
+
<% append_javascript_pack_tag("decidim_admin_decidim_awesome_global") %>
|
6
|
+
<% append_javascript_pack_tag("decidim_decidim_awesome_custom_fields") if Decidim::DecidimAwesome.enabled?(:proposal_custom_fields) %>
|
7
7
|
<% if awesome_config[:intergram_for_admins] %>
|
8
8
|
<%= render partial: "layouts/decidim/decidim_awesome/intergram_widget", locals: { settings: organization_awesome_config[:intergram_for_admins_settings] } %>
|
9
9
|
<% end %>
|
@@ -1,6 +1,5 @@
|
|
1
|
+
// DO NOT include any javascript file here, but inside the following file instead
|
1
2
|
import "src/decidim/decidim_awesome/awesome_admin";
|
2
|
-
// This is needed by custom fields builder but if loader there duplicates the jQuery inclusion
|
3
|
-
import "jquery-ui/ui/widgets/sortable";
|
4
3
|
|
5
4
|
// CSS
|
6
5
|
import "entrypoints/decidim_admin_decidim_awesome.scss";
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "stylesheets/decidim/decidim_awesome/awesome_admin_global";
|
@@ -1 +1 @@
|
|
1
|
-
@import "stylesheets/decidim/decidim_awesome/awesome_map/map"
|
1
|
+
@import "stylesheets/decidim/decidim_awesome/awesome_map/map";
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import createEditor from "src/decidim/decidim_awesome/editor";
|
2
|
+
import DecidimKit from "src/decidim/editor/extensions/decidim_kit";
|
3
|
+
|
4
|
+
// CSS
|
5
|
+
import "stylesheets/decidim/editor.scss"
|
6
|
+
|
7
|
+
window.DecidimKit = DecidimKit;
|
8
|
+
window.currentEditors = window.currentEditors || [];
|
9
|
+
|
10
|
+
window.createEditor = (container) => {
|
11
|
+
let editor = createEditor(container);
|
12
|
+
window.currentEditors.push(editor);
|
13
|
+
return editor;
|
14
|
+
}
|
@@ -1,82 +1,109 @@
|
|
1
|
-
|
1
|
+
document.addEventListener("DOMContentLoaded", () => {
|
2
2
|
let CustomFieldsBuilders = window.CustomFieldsBuilders || [];
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if ($target.length === 0) {
|
11
|
-
return;
|
12
|
-
}
|
4
|
+
document.querySelectorAll("a.awesome-auto-edit").forEach((link) => {
|
5
|
+
link.addEventListener("click", (ev) => {
|
6
|
+
ev.preventDefault();
|
7
|
+
const scope = link.dataset.scope;
|
8
|
+
const target = document.querySelector(`span.awesome-auto-edit[data-scope="${scope}"]`);
|
9
|
+
const constraints = document.querySelector(`.constraints-editor[data-key="${scope}"]`);
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
const $hidden = $(`[name="config[${attribute}][${key}]"]`);
|
17
|
-
const $multiple = $(`[name="config[${attribute}][${key}][]"]`);
|
18
|
-
const $container = $(`.${attribute}_container[data-key="${key}"]`);
|
19
|
-
const $delete = $(".delete-box", $container);
|
20
|
-
|
21
|
-
const rebuildLabel = (text, withScope) => {
|
22
|
-
$target.text(text);
|
23
|
-
$target.attr("data-key", text);
|
24
|
-
$target.data("key", text);
|
25
|
-
if (withScope) {
|
26
|
-
$target.attr("data-scope", withScope);
|
27
|
-
$target.data("scope", withScope);
|
28
|
-
$link.attr("data-scope", withScope);
|
29
|
-
$link.data("scope", withScope);
|
11
|
+
if (!target) {
|
12
|
+
return;
|
30
13
|
}
|
31
|
-
$link.show();
|
32
|
-
};
|
33
14
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
if (
|
45
|
-
|
15
|
+
const key = target.dataset.key;
|
16
|
+
const attribute = target.dataset.var;
|
17
|
+
const inputField = document.querySelector(`[name="config[${attribute}][${key}]"]`);
|
18
|
+
const multipleField = document.querySelector(`[name="config[${attribute}][${key}][]"]`);
|
19
|
+
const container = document.querySelector(`.js-box-container[data-key="${key}"]`);
|
20
|
+
const deleteBox = container.querySelector(".awesome-auto-delete");
|
21
|
+
|
22
|
+
const rebuildLabel = (text, withScope) => {
|
23
|
+
target.innerText = text;
|
24
|
+
target.dataset.key = text;
|
25
|
+
if (withScope) {
|
26
|
+
target.dataset.scope = withScope;
|
27
|
+
link.dataset.scope = withScope;
|
46
28
|
}
|
47
|
-
|
48
|
-
|
29
|
+
link.style.display = "";
|
30
|
+
};
|
31
|
+
|
32
|
+
const rebuildHtml = (result) => {
|
33
|
+
rebuildLabel(result.key, result.scope);
|
34
|
+
constraints.outerHTML = result.html;
|
35
|
+
if (inputField) {
|
36
|
+
inputField.setAttribute("name", `config[${attribute}][${result.key}]`);
|
37
|
+
}
|
38
|
+
if (multipleField) {
|
39
|
+
multipleField.setAttribute("name", `config[${attribute}][${result.key}][]`);
|
40
|
+
}
|
41
|
+
container.dataset.key = result.key;
|
42
|
+
container.setAttribute("data-key", result.key);
|
43
|
+
deleteBox.setAttribute("href", deleteBox.getAttribute("href").replace(`key=${key}`, `key=${result.key}`));
|
44
|
+
CustomFieldsBuilders.forEach((builder) => {
|
45
|
+
if (builder.key === key) {
|
46
|
+
builder.key = result.key;
|
47
|
+
}
|
48
|
+
});
|
49
|
+
// Reinitialize Decidim DOM events
|
50
|
+
// console.log("Reinitializing Decidim DOM events", "constraints", constraints, "container", container);
|
51
|
+
// Remove existing dialogs
|
52
|
+
Reflect.deleteProperty(window.Decidim.currentDialogs, `edit-modal-${scope}`);
|
53
|
+
Reflect.deleteProperty(window.Decidim.currentDialogs, `new-modal-${scope}`);
|
54
|
+
const editModal = document.getElementById(`edit-modal-${result.scope}`);
|
55
|
+
const newModal = document.getElementById(`new-modal-${result.scope}`);
|
56
|
+
if (container) {
|
57
|
+
// reloads dialogs (modals)
|
58
|
+
document.dispatchEvent(new CustomEvent("ajax:loaded", { detail: container }));
|
59
|
+
}
|
60
|
+
// Rebuild the manual handling of remote modals
|
61
|
+
document.dispatchEvent(new CustomEvent("ajax:loaded:modals", { detail: [editModal, newModal] }));
|
62
|
+
};
|
49
63
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
64
|
+
target.innerHTML = `<input class="awesome-auto-edit" data-scope="${scope}" type="text" size="${key.length}" value="${key}">`;
|
65
|
+
const input = target.querySelector(`input.awesome-auto-edit[data-scope="${scope}"]`);
|
66
|
+
link.style.display = "none";
|
67
|
+
input.focus();
|
68
|
+
let config = {};
|
69
|
+
config[attribute] = true;
|
70
|
+
let token = document.querySelector('meta[name="csrf-token"]');
|
71
|
+
input.addEventListener("keypress", (evt) => {
|
72
|
+
if (evt.key === "Enter" || evt.keyCode === 13 || evt.keyCode === 10) {
|
73
|
+
if (key === input.value) {
|
74
|
+
rebuildLabel(key);
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
// console.log("Saving key", key, "to", input.value, "with scope", scope);
|
78
|
+
evt.preventDefault();
|
79
|
+
fetch(window.DecidimAwesome.renameScopeLabelPath, {
|
80
|
+
method: "POST",
|
62
81
|
headers: {
|
63
|
-
"
|
82
|
+
"Accept": "application/json, text/plain, */*",
|
83
|
+
"Content-Type": "application/json",
|
84
|
+
"X-CSRF-Token": token && token.getAttribute("content")
|
64
85
|
},
|
65
|
-
|
66
|
-
scope: scope,
|
67
|
-
attribute: attribute,
|
68
|
-
text: $input.val()
|
69
|
-
}
|
86
|
+
body: JSON.stringify({ key: key, scope: scope, attribute: attribute, text: input.value, config: config })
|
70
87
|
}).
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
88
|
+
then((response) => {
|
89
|
+
if (!response.ok) {
|
90
|
+
throw response;
|
91
|
+
}
|
92
|
+
return response.json()
|
93
|
+
}).
|
94
|
+
then((result) => {
|
95
|
+
rebuildHtml(result)
|
96
|
+
}).
|
97
|
+
catch((err) => {
|
98
|
+
console.error("Error saving key", key, "ERR:", err);
|
99
|
+
rebuildLabel(key);
|
100
|
+
});
|
101
|
+
}
|
102
|
+
});
|
103
|
+
|
104
|
+
input.addEventListener("blur", () => {
|
105
|
+
rebuildLabel(key);
|
106
|
+
});
|
80
107
|
});
|
81
108
|
});
|
82
109
|
});
|
@@ -1,48 +1,53 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
const getReport = (tr, response) => {
|
12
|
-
const item = $(tr).data("item");
|
13
|
-
const $td = $(tr).find(".redirect-status");
|
14
|
-
|
15
|
-
let type = response.type;
|
16
|
-
let status = response.status;
|
17
|
-
if (response.type === "opaqueredirect") {
|
18
|
-
type = "redirect";
|
19
|
-
status = "302";
|
1
|
+
document.addEventListener("DOMContentLoaded", () => {
|
2
|
+
const checkCustomRedirections = document.querySelector(".check-custom-redirections");
|
3
|
+
|
4
|
+
if (checkCustomRedirections) {
|
5
|
+
checkCustomRedirections.addEventListener("click", (evt) => {
|
6
|
+
evt.preventDefault();
|
7
|
+
|
8
|
+
if (evt.target.classList.contains("disabled")) {
|
9
|
+
return;
|
20
10
|
}
|
21
11
|
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
evt.target.classList.add("disabled");
|
13
|
+
|
14
|
+
const getReport = (tr, response) => {
|
15
|
+
const item = JSON.parse(tr.dataset.item);
|
16
|
+
const td = tr.querySelector(".redirect-status");
|
17
|
+
|
18
|
+
let type = response.type;
|
19
|
+
let status = response.status;
|
20
|
+
if (response.type === "opaqueredirect") {
|
21
|
+
type = "redirect";
|
22
|
+
status = "302";
|
23
|
+
}
|
24
|
+
|
25
|
+
if (item.active) {
|
26
|
+
if (type === "redirect") {
|
27
|
+
td.classList.add("text-success");
|
28
|
+
} else {
|
29
|
+
td.classList.add("text-alert");
|
30
|
+
}
|
25
31
|
} else {
|
26
|
-
|
32
|
+
td.classList.add("text-gray");
|
27
33
|
}
|
28
|
-
} else {
|
29
|
-
$td.addClass("muted");
|
30
|
-
}
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
return `${type} (${status})`;
|
36
|
+
};
|
37
|
+
|
38
|
+
document.querySelectorAll("tr.custom-redirection").forEach((tr) => {
|
39
|
+
const td = tr.querySelector(".redirect-status");
|
40
|
+
td.innerHTML = '<span class="loading-spinner"></span>';
|
41
|
+
|
42
|
+
fetch(tr.dataset.origin, { method: "HEAD", redirect: "manual" }).
|
43
|
+
then((response) => {
|
44
|
+
td.innerHTML = getReport(tr, response);
|
45
|
+
}).
|
46
|
+
catch((error) => {
|
47
|
+
console.error("ERROR", error);
|
48
|
+
td.classList.remove("loading");
|
49
|
+
});
|
50
|
+
});
|
46
51
|
});
|
47
|
-
}
|
52
|
+
}
|
48
53
|
});
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import CodeMirror from "codemirror"
|
2
2
|
import "codemirror/mode/css/css"
|
3
3
|
import "codemirror/keymap/sublime"
|
4
|
-
import "
|
4
|
+
import "codemirror/lib/codemirror.css";
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
document.addEventListener("DOMContentLoaded", () => {
|
7
|
+
document.querySelectorAll(".awesome-edit-config .scoped_styles_container textarea").forEach((el) => {
|
8
8
|
CodeMirror.fromTextArea(el, {
|
9
9
|
lineNumbers: true,
|
10
10
|
mode: "css",
|
@@ -0,0 +1,115 @@
|
|
1
|
+
/* eslint no-use-before-define: "off" */
|
2
|
+
|
3
|
+
// This script manually handles the "edit" button from the constraints editor by loading the content into the modal after the modal (operated by Dialog) is opened.
|
4
|
+
// We don't use the RemoteModal class because it chaches the modal content and the "fetch" operation does not specify the "no-cache" headers.
|
5
|
+
|
6
|
+
const fetchConstraints = (url, callback = () => {}) => {
|
7
|
+
fetch(url, { cache: "no-cache" }).
|
8
|
+
then((res) => {
|
9
|
+
if (!res.ok) {
|
10
|
+
throw res;
|
11
|
+
}
|
12
|
+
return res.text();
|
13
|
+
}).
|
14
|
+
then((text) => {
|
15
|
+
callback(text);
|
16
|
+
}).
|
17
|
+
catch((err) => {
|
18
|
+
console.error("dialog open failed", err);
|
19
|
+
});
|
20
|
+
};
|
21
|
+
|
22
|
+
const renderModal = (element, html) => {
|
23
|
+
element.innerHTML = html;
|
24
|
+
bindModalEvents(element)
|
25
|
+
};
|
26
|
+
|
27
|
+
const constraintChange = (modalId, data) => {
|
28
|
+
const modal = window.Decidim.currentDialogs[modalId];
|
29
|
+
const constraintsUrl = modal.openingTrigger.dataset.constraintsUrl;
|
30
|
+
|
31
|
+
// Prepare parameters to request the modal content again, but updated based on the user selections
|
32
|
+
const vars = data.map((setting) => `${setting.key}=${setting.value}`);
|
33
|
+
const url = `${constraintsUrl}&${vars.join("&")}`;
|
34
|
+
|
35
|
+
fetchConstraints(url, (res) => renderModal(modal.dialog, res));
|
36
|
+
};
|
37
|
+
|
38
|
+
const bindModalEvents = (detail) => {
|
39
|
+
const div = detail.querySelector("[id^=constraint-form]");
|
40
|
+
const spaceManifest = div.getElementsByTagName("select")[0];
|
41
|
+
const spaceSlug = div.getElementsByTagName("select")[1];
|
42
|
+
const componentManifest = div.getElementsByTagName("select")[2];
|
43
|
+
const componentId = div.getElementsByTagName("select")[3];
|
44
|
+
|
45
|
+
spaceManifest.addEventListener("change", (event) => {
|
46
|
+
constraintChange(detail.id, [{
|
47
|
+
key: "participatory_space_manifest",
|
48
|
+
value: event.target.value
|
49
|
+
}])
|
50
|
+
});
|
51
|
+
|
52
|
+
spaceSlug.addEventListener("change", (event) => {
|
53
|
+
constraintChange(detail.id, [{
|
54
|
+
key: "participatory_space_manifest",
|
55
|
+
value: spaceManifest.value
|
56
|
+
}, {
|
57
|
+
key: "participatory_space_slug",
|
58
|
+
value: event.target.value
|
59
|
+
}])
|
60
|
+
});
|
61
|
+
|
62
|
+
// Component manfiest and component id are mutually exclusive
|
63
|
+
componentManifest.addEventListener("change", (event) => {
|
64
|
+
if (event.target.value) {
|
65
|
+
componentId.value = "";
|
66
|
+
}
|
67
|
+
});
|
68
|
+
|
69
|
+
componentId.addEventListener("change", (event) => {
|
70
|
+
if (event.target.value) {
|
71
|
+
componentManifest.value = "";
|
72
|
+
}
|
73
|
+
});
|
74
|
+
};
|
75
|
+
|
76
|
+
|
77
|
+
const initializeDialog = (dialog) => {
|
78
|
+
dialog.addEventListener("open.dialog", async (el) => {
|
79
|
+
const currentDialog = window.Decidim.currentDialogs[el.target.id];
|
80
|
+
const button = currentDialog && currentDialog.openingTrigger;
|
81
|
+
const url = button.dataset.constraintsUrl;
|
82
|
+
// console.log("open.dialog", el, url, "currentDialog",currentDialog);
|
83
|
+
fetchConstraints(url, (res) => renderModal(el.target, res));
|
84
|
+
});
|
85
|
+
};
|
86
|
+
|
87
|
+
document.addEventListener("DOMContentLoaded", () => {
|
88
|
+
document.querySelectorAll("[data-constraint][data-dialog]").forEach((dialog) => {
|
89
|
+
initializeDialog(dialog);
|
90
|
+
});
|
91
|
+
});
|
92
|
+
|
93
|
+
document.addEventListener("ajax:loaded:modals", (event) => {
|
94
|
+
event.detail.forEach((modal) => initializeDialog(modal));
|
95
|
+
});
|
96
|
+
|
97
|
+
// Rails AJAX events, this will update the parent page constrains
|
98
|
+
document.body.addEventListener("ajax:error", (responseText) => {
|
99
|
+
// console.log("ajax:error", responseText)
|
100
|
+
const container = document.querySelector(`.constraints-editor[data-key="${responseText.detail[0].key}"]`);
|
101
|
+
const callout = container.querySelector(".flash");
|
102
|
+
callout.hidden = false;
|
103
|
+
callout.classList.add("alert");
|
104
|
+
callout.getElementsByTagName("p")[0].innerHTML = `${responseText.detail[0].message}: <strong>${responseText.detail[0].error}</strong>`;
|
105
|
+
});
|
106
|
+
|
107
|
+
document.body.addEventListener("ajax:success", (responseText) => {
|
108
|
+
// console.log("ajax:success", responseText)
|
109
|
+
let container = document.querySelector(`.constraints-editor[data-key="${responseText.detail[0].key}"]`);
|
110
|
+
const callout = container.querySelector(".flash");
|
111
|
+
callout.hidden = false;
|
112
|
+
callout.classList.add("success");
|
113
|
+
callout.getElementsByTagName("p")[0].innerHTML = responseText.detail[0].message;
|
114
|
+
container.outerHTML = responseText.detail[0].html;
|
115
|
+
});
|
@@ -1,21 +1,26 @@
|
|
1
|
-
|
1
|
+
import "formBuilder/dist/form-builder.min.js";
|
2
2
|
import "src/decidim/decidim_awesome/forms/rich_text_plugin"
|
3
|
+
// formBuilder uses jquery-ui-sortable which is a very dirty npm package with no neat source code available, and causes problems with the webpacker configuration of Decidim.
|
4
|
+
// For the moment, we'll remove the sortable functionality with a dummy jQuery plugin until we find another sortable plugin (or keep it disabled for good)
|
5
|
+
jQuery.fn.sortable = () => {}
|
3
6
|
|
4
7
|
window.CustomFieldsBuilders = window.CustomFieldsBuilders || [];
|
5
8
|
|
6
9
|
$(() => {
|
7
10
|
$(".awesome-edit-config .proposal_custom_fields_editor").each((_idx, el) => {
|
8
11
|
const key = $(el).closest(".proposal_custom_fields_container").data("key");
|
12
|
+
const configVar = $(el).closest(".proposal_custom_fields_container").data("var");
|
9
13
|
// DOCS: https://formbuilder.online/docs
|
10
14
|
window.CustomFieldsBuilders.push({
|
11
15
|
el: el,
|
12
16
|
key: key,
|
17
|
+
var: configVar,
|
13
18
|
config: {
|
14
19
|
i18n: {
|
15
20
|
locale: "en-US",
|
16
21
|
location: "https://cdn.jsdelivr.net/npm/formbuilder-languages@1.1.0/"
|
17
22
|
},
|
18
|
-
formData: $(`input[name="config[
|
23
|
+
formData: $(`input[name="config[${configVar}][${key}]"]`).val(),
|
19
24
|
disableFields: ["button", "file"],
|
20
25
|
disabledActionButtons: ["save", "data", "clear"],
|
21
26
|
disabledAttrs: [
|
@@ -37,7 +42,7 @@ $(() => {
|
|
37
42
|
],
|
38
43
|
disabledSubtypes: {
|
39
44
|
// default color as it generate hashtags in decidim (TODO: fix hashtag generator with this)
|
40
|
-
text: ["color"],
|
45
|
+
text: ["color"],
|
41
46
|
// disable default wysiwyg editors as they present problems
|
42
47
|
textarea: ["tinymce", "quill"]
|
43
48
|
}
|
@@ -71,8 +76,7 @@ $(() => {
|
|
71
76
|
|
72
77
|
$("form.awesome-edit-config").on("submit", () => {
|
73
78
|
window.CustomFieldsBuilders.forEach((builder) => {
|
74
|
-
$(`input[name="config[
|
79
|
+
$(`input[name="config[${builder.var}][${builder.key}]"]`).val(builder.instance.actions.getData("json"));
|
75
80
|
});
|
76
81
|
});
|
77
82
|
});
|
78
|
-
|