decidim-enhanced_textwork 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +64 -0
- data/Rakefile +3 -0
- data/app/cells/decidim/enhanced_textwork/amendment/show.erb +14 -0
- data/app/cells/decidim/enhanced_textwork/amendment_cell.rb +39 -0
- data/app/cells/decidim/enhanced_textwork/collaborative_draft_cell.rb +49 -0
- data/app/cells/decidim/enhanced_textwork/collaborative_draft_link_to_paragraph/show.erb +13 -0
- data/app/cells/decidim/enhanced_textwork/collaborative_draft_link_to_paragraph_cell.rb +57 -0
- data/app/cells/decidim/enhanced_textwork/collaborative_draft_m/footer.erb +6 -0
- data/app/cells/decidim/enhanced_textwork/collaborative_draft_m/tags.erb +1 -0
- data/app/cells/decidim/enhanced_textwork/collaborative_draft_m_cell.rb +44 -0
- data/app/cells/decidim/enhanced_textwork/collaborative_drafts/reported_content/show.erb +3 -0
- data/app/cells/decidim/enhanced_textwork/collaborative_drafts/reported_content_cell.rb +15 -0
- data/app/cells/decidim/enhanced_textwork/comments/show.erb +33 -0
- data/app/cells/decidim/enhanced_textwork/comments_cell.rb +8 -0
- data/app/cells/decidim/enhanced_textwork/content_blocks/highlighted_paragraphs/elements.erb +5 -0
- data/app/cells/decidim/enhanced_textwork/content_blocks/highlighted_paragraphs/heading.erb +1 -0
- data/app/cells/decidim/enhanced_textwork/content_blocks/highlighted_paragraphs_cell.rb +19 -0
- data/app/cells/decidim/enhanced_textwork/cost_report/show.erb +35 -0
- data/app/cells/decidim/enhanced_textwork/cost_report_cell.rb +42 -0
- data/app/cells/decidim/enhanced_textwork/highlighted_paragraphs/show.erb +3 -0
- data/app/cells/decidim/enhanced_textwork/highlighted_paragraphs_cell.rb +25 -0
- data/app/cells/decidim/enhanced_textwork/highlighted_paragraphs_for_component/show.erb +19 -0
- data/app/cells/decidim/enhanced_textwork/highlighted_paragraphs_for_component_cell.rb +41 -0
- data/app/cells/decidim/enhanced_textwork/irreversible_action_modal/show.erb +27 -0
- data/app/cells/decidim/enhanced_textwork/irreversible_action_modal_cell.rb +80 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_activity_cell.rb +35 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_cell.rb +53 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_link_to_collaborative_draft_cell.rb +26 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_link_to_rejected_emendation/show.erb +9 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_link_to_rejected_emendation_cell.rb +34 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_linked_resources/show.erb +9 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_linked_resources_cell.rb +14 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_m/footer.erb +26 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_m/tags.erb +1 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_m_cell.rb +152 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_tags/show.erb +33 -0
- data/app/cells/decidim/enhanced_textwork/paragraph_tags_cell.rb +35 -0
- data/app/cells/decidim/enhanced_textwork/paragraphs_picker/paragraphs.erb +12 -0
- data/app/cells/decidim/enhanced_textwork/paragraphs_picker/show.erb +14 -0
- data/app/cells/decidim/enhanced_textwork/paragraphs_picker_cell.rb +72 -0
- data/app/cells/decidim/enhanced_textwork/participatory_text_paragraph/buttons.erb +33 -0
- data/app/cells/decidim/enhanced_textwork/participatory_text_paragraph/show.erb +38 -0
- data/app/cells/decidim/enhanced_textwork/participatory_text_paragraph_cell.rb +104 -0
- data/app/cells/decidim/enhanced_textwork/reported_content/show.erb +4 -0
- data/app/cells/decidim/enhanced_textwork/reported_content_cell.rb +13 -0
- data/app/commands/decidim/enhanced_textwork/accept_access_to_collaborative_draft.rb +70 -0
- data/app/commands/decidim/enhanced_textwork/admin/answer_paragraph.rb +74 -0
- data/app/commands/decidim/enhanced_textwork/admin/assign_paragraphs_to_valuator.rb +61 -0
- data/app/commands/decidim/enhanced_textwork/admin/create_paragraph.rb +97 -0
- data/app/commands/decidim/enhanced_textwork/admin/create_paragraph_note.rb +67 -0
- data/app/commands/decidim/enhanced_textwork/admin/destroy_paragraph.rb +32 -0
- data/app/commands/decidim/enhanced_textwork/admin/discard_participatory_text.rb +40 -0
- data/app/commands/decidim/enhanced_textwork/admin/import_from_editor_participatory_text.rb +53 -0
- data/app/commands/decidim/enhanced_textwork/admin/import_paragraphs.rb +101 -0
- data/app/commands/decidim/enhanced_textwork/admin/import_participatory_text.rb +55 -0
- data/app/commands/decidim/enhanced_textwork/admin/merge_paragraphs.rb +69 -0
- data/app/commands/decidim/enhanced_textwork/admin/notify_paragraph_answer.rb +85 -0
- data/app/commands/decidim/enhanced_textwork/admin/publish_answers.rb +67 -0
- data/app/commands/decidim/enhanced_textwork/admin/publish_participatory_text.rb +81 -0
- data/app/commands/decidim/enhanced_textwork/admin/split_paragraphs.rb +67 -0
- data/app/commands/decidim/enhanced_textwork/admin/unassign_paragraphs_from_valuator.rb +62 -0
- data/app/commands/decidim/enhanced_textwork/admin/update_paragraph.rb +86 -0
- data/app/commands/decidim/enhanced_textwork/admin/update_paragraph_category.rb +68 -0
- data/app/commands/decidim/enhanced_textwork/admin/update_paragraph_scope.rb +75 -0
- data/app/commands/decidim/enhanced_textwork/admin/update_participatory_text.rb +68 -0
- data/app/commands/decidim/enhanced_textwork/create_collaborative_draft.rb +81 -0
- data/app/commands/decidim/enhanced_textwork/create_paragraph.rb +106 -0
- data/app/commands/decidim/enhanced_textwork/destroy_paragraph.rb +33 -0
- data/app/commands/decidim/enhanced_textwork/gallery_methods.rb +18 -0
- data/app/commands/decidim/enhanced_textwork/hashtags_methods.rb +36 -0
- data/app/commands/decidim/enhanced_textwork/publish_collaborative_draft.rb +93 -0
- data/app/commands/decidim/enhanced_textwork/publish_paragraph.rb +105 -0
- data/app/commands/decidim/enhanced_textwork/reject_access_to_collaborative_draft.rb +62 -0
- data/app/commands/decidim/enhanced_textwork/request_access_to_collaborative_draft.rb +49 -0
- data/app/commands/decidim/enhanced_textwork/unvote_paragraph.rb +65 -0
- data/app/commands/decidim/enhanced_textwork/update_collaborative_draft.rb +63 -0
- data/app/commands/decidim/enhanced_textwork/update_paragraph.rb +135 -0
- data/app/commands/decidim/enhanced_textwork/vote_paragraph.rb +77 -0
- data/app/commands/decidim/enhanced_textwork/withdraw_collaborative_draft.rb +65 -0
- data/app/commands/decidim/enhanced_textwork/withdraw_paragraph.rb +50 -0
- data/app/controllers/concerns/decidim/enhanced_textwork/admin/filterable.rb +82 -0
- data/app/controllers/concerns/decidim/enhanced_textwork/admin/picker.rb +21 -0
- data/app/controllers/concerns/decidim/enhanced_textwork/collaborative_orderable.rb +42 -0
- data/app/controllers/concerns/decidim/enhanced_textwork/orderable.rb +78 -0
- data/app/controllers/decidim/enhanced_textwork/admin/application_controller.rb +16 -0
- data/app/controllers/decidim/enhanced_textwork/admin/paragraph_answers_controller.rb +50 -0
- data/app/controllers/decidim/enhanced_textwork/admin/paragraph_notes_controller.rb +39 -0
- data/app/controllers/decidim/enhanced_textwork/admin/paragraphs_controller.rb +237 -0
- data/app/controllers/decidim/enhanced_textwork/admin/paragraphs_imports_controller.rb +33 -0
- data/app/controllers/decidim/enhanced_textwork/admin/paragraphs_merges_controller.rb +30 -0
- data/app/controllers/decidim/enhanced_textwork/admin/paragraphs_splits_controller.rb +30 -0
- data/app/controllers/decidim/enhanced_textwork/admin/participatory_texts_controller.rb +128 -0
- data/app/controllers/decidim/enhanced_textwork/admin/valuation_assignments_controller.rb +58 -0
- data/app/controllers/decidim/enhanced_textwork/application_controller.rb +31 -0
- data/app/controllers/decidim/enhanced_textwork/collaborative_draft_collaborator_requests_controller.rb +53 -0
- data/app/controllers/decidim/enhanced_textwork/collaborative_drafts_controller.rb +161 -0
- data/app/controllers/decidim/enhanced_textwork/paragraph_votes_controller.rb +65 -0
- data/app/controllers/decidim/enhanced_textwork/paragraphs_controller.rb +316 -0
- data/app/controllers/decidim/enhanced_textwork/versions_controller.rb +21 -0
- data/app/controllers/decidim/enhanced_textwork/widgets_controller.rb +19 -0
- data/app/events/decidim/enhanced_textwork/accepted_paragraph_event.rb +17 -0
- data/app/events/decidim/enhanced_textwork/admin/paragraph_note_created_event.rb +27 -0
- data/app/events/decidim/enhanced_textwork/admin/update_paragraph_category_event.rb +11 -0
- data/app/events/decidim/enhanced_textwork/admin/update_paragraph_scope_event.rb +11 -0
- data/app/events/decidim/enhanced_textwork/collaborative_draft_access_accepted_event.rb +8 -0
- data/app/events/decidim/enhanced_textwork/collaborative_draft_access_rejected_event.rb +8 -0
- data/app/events/decidim/enhanced_textwork/collaborative_draft_access_request_event.rb +27 -0
- data/app/events/decidim/enhanced_textwork/collaborative_draft_access_requested_event.rb +8 -0
- data/app/events/decidim/enhanced_textwork/collaborative_draft_access_requester_accepted_event.rb +8 -0
- data/app/events/decidim/enhanced_textwork/collaborative_draft_access_requester_rejected_event.rb +8 -0
- data/app/events/decidim/enhanced_textwork/collaborative_draft_withdrawn_event.rb +29 -0
- data/app/events/decidim/enhanced_textwork/creation_enabled_event.rb +8 -0
- data/app/events/decidim/enhanced_textwork/endorsing_enabled_event.rb +8 -0
- data/app/events/decidim/enhanced_textwork/evaluating_paragraph_event.rb +11 -0
- data/app/events/decidim/enhanced_textwork/paragraph_endorsed_event.rb +33 -0
- data/app/events/decidim/enhanced_textwork/paragraph_mentioned_event.rb +21 -0
- data/app/events/decidim/enhanced_textwork/publish_paragraph_event.rb +25 -0
- data/app/events/decidim/enhanced_textwork/rejected_paragraph_event.rb +17 -0
- data/app/events/decidim/enhanced_textwork/voting_enabled_event.rb +8 -0
- data/app/forms/decidim/enhanced_textwork/accept_access_to_collaborative_draft_form.rb +10 -0
- data/app/forms/decidim/enhanced_textwork/access_to_collaborative_draft_form.rb +33 -0
- data/app/forms/decidim/enhanced_textwork/admin/import_editor_participatory_text_form.rb +35 -0
- data/app/forms/decidim/enhanced_textwork/admin/import_participatory_text_form.rb +68 -0
- data/app/forms/decidim/enhanced_textwork/admin/paragraph_answer_form.rb +44 -0
- data/app/forms/decidim/enhanced_textwork/admin/paragraph_base_form.rb +137 -0
- data/app/forms/decidim/enhanced_textwork/admin/paragraph_form.rb +32 -0
- data/app/forms/decidim/enhanced_textwork/admin/paragraph_note_form.rb +16 -0
- data/app/forms/decidim/enhanced_textwork/admin/paragraphs_fork_form.rb +63 -0
- data/app/forms/decidim/enhanced_textwork/admin/paragraphs_import_form.rb +67 -0
- data/app/forms/decidim/enhanced_textwork/admin/paragraphs_merge_form.rb +13 -0
- data/app/forms/decidim/enhanced_textwork/admin/paragraphs_split_form.rb +12 -0
- data/app/forms/decidim/enhanced_textwork/admin/participatory_text_paragraph_form.rb +20 -0
- data/app/forms/decidim/enhanced_textwork/admin/preview_participatory_text_form.rb +21 -0
- data/app/forms/decidim/enhanced_textwork/admin/valuation_assignment_form.rb +37 -0
- data/app/forms/decidim/enhanced_textwork/collaborative_draft_form.rb +20 -0
- data/app/forms/decidim/enhanced_textwork/paragraph_form.rb +126 -0
- data/app/forms/decidim/enhanced_textwork/paragraph_wizard_create_step_form.rb +41 -0
- data/app/forms/decidim/enhanced_textwork/reject_access_to_collaborative_draft_form.rb +9 -0
- data/app/forms/decidim/enhanced_textwork/request_access_to_collaborative_draft_form.rb +20 -0
- data/app/helpers/decidim/enhanced_textwork/admin/filterable_helper.rb +17 -0
- data/app/helpers/decidim/enhanced_textwork/admin/paragraph_bulk_actions_helper.rb +35 -0
- data/app/helpers/decidim/enhanced_textwork/admin/paragraph_rankings_helper.rb +63 -0
- data/app/helpers/decidim/enhanced_textwork/admin/paragraphs_helper.rb +144 -0
- data/app/helpers/decidim/enhanced_textwork/admin/paragraphs_picker_helper.rb +30 -0
- data/app/helpers/decidim/enhanced_textwork/application_helper.rb +191 -0
- data/app/helpers/decidim/enhanced_textwork/collaborative_draft_cells_helper.rb +48 -0
- data/app/helpers/decidim/enhanced_textwork/collaborative_draft_helper.rb +29 -0
- data/app/helpers/decidim/enhanced_textwork/control_version_helper.rb +12 -0
- data/app/helpers/decidim/enhanced_textwork/map_helper.rb +48 -0
- data/app/helpers/decidim/enhanced_textwork/paragraph_cells_helper.rb +75 -0
- data/app/helpers/decidim/enhanced_textwork/paragraph_votes_helper.rb +103 -0
- data/app/helpers/decidim/enhanced_textwork/paragraph_wizard_helper.rb +140 -0
- data/app/helpers/decidim/enhanced_textwork/paragraphs_helper.rb +63 -0
- data/app/helpers/decidim/enhanced_textwork/participatory_texts_helper.rb +49 -0
- data/app/jobs/decidim/enhanced_textwork/notify_paragraphs_mentioned_job.rb +27 -0
- data/app/jobs/decidim/enhanced_textwork/settings_change_job.rb +50 -0
- data/app/models/decidim/enhanced_textwork/application_record.rb +10 -0
- data/app/models/decidim/enhanced_textwork/collaborative_draft.rb +73 -0
- data/app/models/decidim/enhanced_textwork/collaborative_draft_collaborator_request.rb +13 -0
- data/app/models/decidim/enhanced_textwork/paragraph.rb +411 -0
- data/app/models/decidim/enhanced_textwork/paragraph_note.rb +20 -0
- data/app/models/decidim/enhanced_textwork/paragraph_vote.rb +50 -0
- data/app/models/decidim/enhanced_textwork/participatory_text.rb +16 -0
- data/app/models/decidim/enhanced_textwork/valuation_assignment.rb +24 -0
- data/app/packs/documents/decidim/enhanced_textwork/participatory_texts/participatory_text.md +52 -0
- data/app/packs/documents/decidim/enhanced_textwork/participatory_texts/participatory_text.odt +0 -0
- data/app/packs/entrypoints/decidim_enhanced_textwork.js +17 -0
- data/app/packs/entrypoints/decidim_enhanced_textwork_admin.js +3 -0
- data/app/packs/images/decidim/enhanced_textwork/decidim_paragraphs.svg +1 -0
- data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_accepted_paragraphs.svg +1 -0
- data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_paragraph_votes.svg +1 -0
- data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_paragraphs.svg +1 -0
- data/app/packs/src/decidim/enhanced_textwork/add_paragraph.js +49 -0
- data/app/packs/src/decidim/enhanced_textwork/admin/paragraphs.js +143 -0
- data/app/packs/src/decidim/enhanced_textwork/admin/paragraphs_form.js +29 -0
- data/app/packs/src/decidim/enhanced_textwork/admin/paragraphs_picker.js +35 -0
- data/app/packs/src/decidim/enhanced_textwork/toggle_element.js +21 -0
- data/app/packs/src/decidim/enhanced_textwork/utils.js +11 -0
- data/app/packs/stylesheets/decidim/enhanced_textwork/_paragraphs.scss +208 -0
- data/app/packs/stylesheets/decidim/enhanced_textwork/paragraphs/_preview.scss +3 -0
- data/app/permissions/decidim/enhanced_textwork/admin/permissions.rb +147 -0
- data/app/permissions/decidim/enhanced_textwork/permissions.rb +163 -0
- data/app/presenters/decidim/enhanced_textwork/admin_log/paragraph_note_presenter.rb +39 -0
- data/app/presenters/decidim/enhanced_textwork/admin_log/paragraph_presenter.rb +51 -0
- data/app/presenters/decidim/enhanced_textwork/admin_log/valuation_assignment_presenter.rb +51 -0
- data/app/presenters/decidim/enhanced_textwork/admin_log/value_types/paragraph_state_presenter.rb +17 -0
- data/app/presenters/decidim/enhanced_textwork/admin_log/value_types/paragraph_title_body_presenter.rb +23 -0
- data/app/presenters/decidim/enhanced_textwork/admin_log/value_types/valuator_role_user_presenter.rb +19 -0
- data/app/presenters/decidim/enhanced_textwork/collaborative_draft_presenter.rb +25 -0
- data/app/presenters/decidim/enhanced_textwork/log/resource_presenter.rb +22 -0
- data/app/presenters/decidim/enhanced_textwork/log/valuation_assignment_presenter.rb +22 -0
- data/app/presenters/decidim/enhanced_textwork/official_author_presenter.rb +14 -0
- data/app/presenters/decidim/enhanced_textwork/paragraph_presenter.rb +146 -0
- data/app/queries/decidim/enhanced_textwork/filtered_paragraphs.rb +37 -0
- data/app/queries/decidim/enhanced_textwork/metrics/accepted_paragraphs_metric_manage.rb +32 -0
- data/app/queries/decidim/enhanced_textwork/metrics/endorsements_metric_manage.rb +58 -0
- data/app/queries/decidim/enhanced_textwork/metrics/paragraph_followers_metric_measure.rb +58 -0
- data/app/queries/decidim/enhanced_textwork/metrics/paragraph_participants_metric_measure.rb +74 -0
- data/app/queries/decidim/enhanced_textwork/metrics/paragraphs_metric_manage.rb +48 -0
- data/app/queries/decidim/enhanced_textwork/metrics/votes_metric_manage.rb +52 -0
- data/app/queries/decidim/enhanced_textwork/similar_paragraphs.rb +67 -0
- data/app/services/decidim/enhanced_textwork/collaborative_draft_search.rb +59 -0
- data/app/services/decidim/enhanced_textwork/diff_renderer.rb +74 -0
- data/app/services/decidim/enhanced_textwork/paragraph_builder.rb +132 -0
- data/app/services/decidim/enhanced_textwork/paragraph_search.rb +85 -0
- data/app/validators/paragraph_length_validator.rb +40 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraph_answers/_form.html.erb +35 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraph_notes/_form.html.erb +8 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraph_notes/_paragraph_notes.html.erb +45 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/_bulk-actions.html.erb +33 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/_form.html.erb +101 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/_js-callout.html.erb +6 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/_paragraph-tr.html.erb +76 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/bulk_actions/_assign_to_valuator.html.erb +15 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/bulk_actions/_dropdown.html.erb +56 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/bulk_actions/_merge.html.erb +15 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/bulk_actions/_publish_answers.html.erb +14 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/bulk_actions/_recategorize.html.erb +15 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/bulk_actions/_scope-change.html.erb +25 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/bulk_actions/_split.html.erb +15 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/bulk_actions/_unassign_from_valuator.html.erb +15 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/edit.html.erb +7 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/index.html.erb +84 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/new.html.erb +7 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/publish_answers.js.erb +12 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/show.html.erb +186 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/update_category.js.erb +26 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs/update_scope.js.erb +27 -0
- data/app/views/decidim/enhanced_textwork/admin/paragraphs_imports/new.html.erb +37 -0
- data/app/views/decidim/enhanced_textwork/admin/participatory_texts/_article-preview.html.erb +16 -0
- data/app/views/decidim/enhanced_textwork/admin/participatory_texts/_bulk-actions.html.erb +3 -0
- data/app/views/decidim/enhanced_textwork/admin/participatory_texts/index.html.erb +55 -0
- data/app/views/decidim/enhanced_textwork/admin/participatory_texts/new_editor.html.erb +39 -0
- data/app/views/decidim/enhanced_textwork/admin/participatory_texts/new_import.html.erb +39 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_accept_request_access_form.html.erb +8 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_collaborative_drafts.html.erb +16 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_collaborator_requests.html.erb +20 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_count.html.erb +1 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_edit_form_fields.html.erb +83 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_filters.html.erb +32 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_filters_small_view.html.erb +18 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_new_collaborative_draft_button.html.erb +11 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_reject_request_access_form.html.erb +10 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_request_access_form.html.erb +7 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_wizard_aside.html.erb +13 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/_wizard_header.html.erb +14 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/edit.html.erb +31 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/index.html.erb +23 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/index.js.erb +10 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/new.html.erb +24 -0
- data/app/views/decidim/enhanced_textwork/collaborative_drafts/show.html.erb +128 -0
- data/app/views/decidim/enhanced_textwork/paragraph_votes/update_buttons_and_counters.js.erb +41 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_count.html.erb +1 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_dynamic_map_instructions.html.erb +4 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_edit_form_fields.html.erb +115 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_endorsements_card_row.html.erb +0 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_filters.html.erb +48 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_filters_small_view.html.erb +18 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_linked_paragraphs.html.erb +34 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_paragraph.html.erb +1 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_paragraph_badge.html.erb +3 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_paragraph_similar.html.erb +22 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_paragraphs.html.erb +46 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_remaining_votes_count.html.erb +3 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_vote_button.html.erb +61 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_votes_count.html.erb +18 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_voting_rules.html.erb +50 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_wizard_aside.html.erb +20 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/_wizard_header.html.erb +42 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/compare.html.erb +23 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/complete.html.erb +24 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/edit.html.erb +31 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/edit_draft.html.erb +26 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/index.html.erb +56 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/index.js.erb +10 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/new.html.erb +38 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/participatory_texts/_index.html.erb +20 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/participatory_texts/_overview.html.erb +35 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/participatory_texts/_paragraph_vote_button.html.erb +53 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/participatory_texts/_paragraph_vote_button_chevron.html.erb +72 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/participatory_texts/_paragraph_votes_count.html.erb +41 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/participatory_texts/_view_index.html.erb +10 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/participatory_texts/participatory_text.html.erb +29 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/preview.html.erb +41 -0
- data/app/views/decidim/enhanced_textwork/paragraphs/show.html.erb +143 -0
- data/app/views/decidim/enhanced_textwork/versions/index.html.erb +16 -0
- data/app/views/decidim/enhanced_textwork/versions/show.html.erb +18 -0
- data/config/assets.rb +10 -0
- data/config/locales/de.yml +927 -0
- data/config/locales/en.yml +967 -0
- data/config/locales/todo/am-ET.yml +1 -0
- data/config/locales/todo/ar-SA.yml +801 -0
- data/config/locales/todo/ar.yml +791 -0
- data/config/locales/todo/bg-BG.yml +237 -0
- data/config/locales/todo/bg.yml +238 -0
- data/config/locales/todo/ca.yml +908 -0
- data/config/locales/todo/cs-CZ.yml +787 -0
- data/config/locales/todo/cs.yml +969 -0
- data/config/locales/todo/da-DK.yml +1 -0
- data/config/locales/todo/da.yml +1 -0
- data/config/locales/todo/el-GR.yml +1 -0
- data/config/locales/todo/el.yml +848 -0
- data/config/locales/todo/eo-UY.yml +1 -0
- data/config/locales/todo/eo.yml +1 -0
- data/config/locales/todo/es-MX.yml +908 -0
- data/config/locales/todo/es-PY.yml +908 -0
- data/config/locales/todo/es.yml +908 -0
- data/config/locales/todo/et-EE.yml +1 -0
- data/config/locales/todo/et.yml +1 -0
- data/config/locales/todo/eu.yml +717 -0
- data/config/locales/todo/fi-pl.yml +763 -0
- data/config/locales/todo/fi-plain.yml +920 -0
- data/config/locales/todo/fi.yml +920 -0
- data/config/locales/todo/fr-CA.yml +936 -0
- data/config/locales/todo/fr-LU.yml +903 -0
- data/config/locales/todo/fr.yml +936 -0
- data/config/locales/todo/ga-IE.yml +275 -0
- data/config/locales/todo/gl.yml +808 -0
- data/config/locales/todo/hr-HR.yml +1 -0
- data/config/locales/todo/hr.yml +1 -0
- data/config/locales/todo/hu.yml +847 -0
- data/config/locales/todo/id-ID.yml +704 -0
- data/config/locales/todo/is-IS.yml +269 -0
- data/config/locales/todo/is.yml +274 -0
- data/config/locales/todo/it.yml +908 -0
- data/config/locales/todo/ja.yml +922 -0
- data/config/locales/todo/ko-KR.yml +1 -0
- data/config/locales/todo/ko.yml +1 -0
- data/config/locales/todo/lb-LU.yml +1 -0
- data/config/locales/todo/lb.yml +40 -0
- data/config/locales/todo/lt-LT.yml +1 -0
- data/config/locales/todo/lt.yml +1 -0
- data/config/locales/todo/lv.yml +838 -0
- data/config/locales/todo/mt-MT.yml +1 -0
- data/config/locales/todo/mt.yml +1 -0
- data/config/locales/todo/nl.yml +882 -0
- data/config/locales/todo/no.yml +770 -0
- data/config/locales/todo/om-ET.yml +1 -0
- data/config/locales/todo/pl.yml +927 -0
- data/config/locales/todo/pt-BR.yml +908 -0
- data/config/locales/todo/pt.yml +945 -0
- data/config/locales/todo/ro-RO.yml +886 -0
- data/config/locales/todo/ru.yml +379 -0
- data/config/locales/todo/si-LK.yml +1 -0
- data/config/locales/todo/sk-SK.yml +896 -0
- data/config/locales/todo/sk.yml +851 -0
- data/config/locales/todo/sl.yml +26 -0
- data/config/locales/todo/so-SO.yml +1 -0
- data/config/locales/todo/sr-CS.yml +125 -0
- data/config/locales/todo/sv.yml +908 -0
- data/config/locales/todo/sw-KE.yml +1 -0
- data/config/locales/todo/ti-ER.yml +1 -0
- data/config/locales/todo/tr-TR.yml +890 -0
- data/config/locales/todo/uk.yml +379 -0
- data/config/locales/todo/vi-VN.yml +1 -0
- data/config/locales/todo/vi.yml +1 -0
- data/config/locales/todo/zh-CN.yml +857 -0
- data/config/locales/todo/zh-TW.yml +1 -0
- data/db/migrate/20161212110850_create_decidim_paragraphs.rb +16 -0
- data/db/migrate/20170112115253_create_paragraph_votes.rb +14 -0
- data/db/migrate/20170113114245_add_enhanced_textwork_text_search_indexes.rb +8 -0
- data/db/migrate/20170118120151_add_counter_cache_votes_to_paragraphs.rb +7 -0
- data/db/migrate/20170120151202_add_user_group_id_to_paragraphs.rb +7 -0
- data/db/migrate/20170131092413_add_answers_to_paragraphs.rb +9 -0
- data/db/migrate/20170205082832_add_index_to_decidim_enhanced_textwork_paragraphs_paragraph_votes_count.rb +9 -0
- data/db/migrate/20170215113152_create_paragraph_reports.rb +16 -0
- data/db/migrate/20170215131720_add_report_count_to_paragraphs.rb +7 -0
- data/db/migrate/20170215132030_add_reference_to_paragraphs.rb +13 -0
- data/db/migrate/20170220152416_add_hidden_at_to_paragraphs.rb +7 -0
- data/db/migrate/20170228105156_add_geolocalization_fields_to_paragraphs.rb +9 -0
- data/db/migrate/20170307085300_migrate_paragraph_reports_data_to_reports.rb +24 -0
- data/db/migrate/20170410073742_remove_not_null_reference_paragraphs.rb +7 -0
- data/db/migrate/20170612101809_migrate_paragraphs_category.rb +15 -0
- data/db/migrate/20171201115434_create_paragraph_endorsements.rb +16 -0
- data/db/migrate/20171201122623_add_counter_cache_endorsements_to_paragraphs.rb +8 -0
- data/db/migrate/20171212102250_enable_pg_trgm_extension_for_paragraphs.rb +18 -0
- data/db/migrate/20171220084719_add_published_at_to_paragraphs.rb +14 -0
- data/db/migrate/20180111110204_create_decidim_paragraph_notes.rb +15 -0
- data/db/migrate/20180115155220_add_index_created_at_paragraph_notes.rb +7 -0
- data/db/migrate/20180305133811_rename_features_to_components_at_paragraphs.rb +11 -0
- data/db/migrate/20180326091532_create_decidim_enhanced_textwork_collaborative_drafts.rb +29 -0
- data/db/migrate/20180413135249_fix_nil_threshold_per_paragraph.rb +18 -0
- data/db/migrate/20180529101323_add_counter_cache_coauthorships_to_paragraphs.rb +8 -0
- data/db/migrate/20180529110230_move_enhanced_textwork_authorships_to_coauthorships.rb +28 -0
- data/db/migrate/20180529110830_remove_authorships_from_paragraphs.rb +8 -0
- data/db/migrate/20180613151121_create_enhanced_textwork_collaborative_draft_collaborator_requests.rb +12 -0
- data/db/migrate/20180711074134_add_enhanced_textwork_counter_cache_coauthorships_to_collaborative_drafts.rb +7 -0
- data/db/migrate/20180711075004_remove_index_counter_cache_coauthorships_to_paragraphs.rb +7 -0
- data/db/migrate/20180927111721_create_enhanced_textwork_participatory_texts.rb +13 -0
- data/db/migrate/20180930125321_add_participatory_text_level_to_paragraphs.rb +7 -0
- data/db/migrate/20180930125321_add_position_to_paragraphs.rb +7 -0
- data/db/migrate/20181003074440_fix_user_groups_ids_in_paragraphs_endorsements.rb +20 -0
- data/db/migrate/20181010114622_add_enhanced_textwork_temporary_votes.rb +9 -0
- data/db/migrate/20181016132225_add_enhanced_textwork_organization_as_author.rb +13 -0
- data/db/migrate/20181017084221_make_author_polymorhpic_for_paragraph_endorsements.rb +31 -0
- data/db/migrate/20181026073215_add_enhanced_textwork_created_in_meeting.rb +7 -0
- data/db/migrate/20190215113158_use_enhanced_textwork_md5_indexes.rb +17 -0
- data/db/migrate/20191206154128_add_endorsements_counter_cache_to_paragraphs.rb +7 -0
- data/db/migrate/20200120215928_move_paragraph_endorsements_to_core_endorsements.rb +54 -0
- data/db/migrate/20200120230130_drop_paragraph_endorsements.rb +8 -0
- data/db/migrate/20200203111239_add_paragraph_valuation_assignments.rb +12 -0
- data/db/migrate/20200210135152_add_costs_to_paragraphs.rb +9 -0
- data/db/migrate/20200212120110_sync_paragraphs_state_with_amendments_state.rb +28 -0
- data/db/migrate/20200227175922_add_state_published_at_to_paragraphs.rb +7 -0
- data/db/migrate/20200306123652_publish_existing_paragraphs_state.rb +15 -0
- data/db/migrate/20200708091228_move_paragraphs_fields_to_i18n.rb +86 -0
- data/db/migrate/20200730131631_move_paragraph_endorsed_event_notifications_to_resource_endorsed_event.rb +20 -0
- data/db/migrate/20200827154156_add_commentable_counter_cache_to_paragraphs.rb +12 -0
- data/db/migrate/20201002085508_fix_paragraphs_data.rb +36 -0
- data/db/migrate/20210127115628_fix_answered_paragraphs_after_copy.rb +14 -0
- data/db/migrate/20210310102839_add_followable_counter_cache_to_paragraphs.rb +16 -0
- data/db/migrate/20210310120812_add_enhanced_textwork_followable_counter_cache_to_collaborative_drafts.rb +16 -0
- data/db/migrate/20210318082934_fix_counters_for_copied_paragraphs.rb +19 -0
- data/lib/decidim/api/paragraph_input_filter.rb +29 -0
- data/lib/decidim/api/paragraph_input_sort.rb +20 -0
- data/lib/decidim/api/paragraph_type.rb +56 -0
- data/lib/decidim/api/paragraphs_type.rb +43 -0
- data/lib/decidim/content_parsers/paragraph_parser.rb +101 -0
- data/lib/decidim/content_renderers/paragraph_renderer.rb +33 -0
- data/lib/decidim/enhanced_textwork/admin.rb +10 -0
- data/lib/decidim/enhanced_textwork/admin_engine.rb +52 -0
- data/lib/decidim/enhanced_textwork/api.rb +10 -0
- data/lib/decidim/enhanced_textwork/commentable_collaborative_draft.rb +38 -0
- data/lib/decidim/enhanced_textwork/commentable_paragraph.rb +36 -0
- data/lib/decidim/enhanced_textwork/component.rb +448 -0
- data/lib/decidim/enhanced_textwork/doc_to_markdown.rb +50 -0
- data/lib/decidim/enhanced_textwork/engine.rb +204 -0
- data/lib/decidim/enhanced_textwork/html_to_markdown.rb +22 -0
- data/lib/decidim/enhanced_textwork/markdown_to_paragraphs.rb +153 -0
- data/lib/decidim/enhanced_textwork/odt_to_markdown.rb +46 -0
- data/lib/decidim/enhanced_textwork/paragraph_creator.rb +98 -0
- data/lib/decidim/enhanced_textwork/paragraph_serializer.rb +95 -0
- data/lib/decidim/enhanced_textwork/participatory_text_section.rb +21 -0
- data/lib/decidim/enhanced_textwork/test/capybara_paragraphs_picker.rb +59 -0
- data/lib/decidim/enhanced_textwork/test/factories.rb +492 -0
- data/lib/decidim/enhanced_textwork/valuatable.rb +21 -0
- data/lib/decidim/enhanced_textwork/version.rb +14 -0
- data/lib/decidim/enhanced_textwork.rb +58 -0
- data/lib/decidim/exporters/word.rb +309 -0
- metadata +704 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module EnhancedTextwork
|
7
|
+
# Common logic to ordering resources
|
8
|
+
module CollaborativeOrderable
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include Decidim::Orderable
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Available orders based on enabled settings
|
17
|
+
def available_orders
|
18
|
+
@available_orders ||= begin
|
19
|
+
available_orders = %w(random recent)
|
20
|
+
available_orders << "most_contributed"
|
21
|
+
available_orders
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def default_order
|
26
|
+
detect_order("most_contributed")
|
27
|
+
end
|
28
|
+
|
29
|
+
def reorder(drafts)
|
30
|
+
case order
|
31
|
+
when "random"
|
32
|
+
drafts.order_randomly(random_seed)
|
33
|
+
when "most_contributed"
|
34
|
+
drafts.order(contributions_count: :desc)
|
35
|
+
when "recent"
|
36
|
+
drafts.order(created_at: :desc)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module EnhancedTextwork
|
7
|
+
# Common logic to ordering resources
|
8
|
+
module Orderable
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include Decidim::Orderable
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Available orders based on enabled settings
|
17
|
+
def available_orders
|
18
|
+
@available_orders ||= [default_order] + possible_orders.excluding(default_order)
|
19
|
+
end
|
20
|
+
|
21
|
+
def possible_orders
|
22
|
+
@possible_orders ||= begin
|
23
|
+
possible_orders = %w(random recent)
|
24
|
+
possible_orders << "most_voted" if most_voted_order_available?
|
25
|
+
possible_orders << "most_endorsed" if current_settings.endorsements_enabled?
|
26
|
+
possible_orders << "most_commented" if component_settings.comments_enabled?
|
27
|
+
possible_orders << "most_followed" << "with_more_authors"
|
28
|
+
possible_orders
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def default_order
|
33
|
+
@default_order ||= begin
|
34
|
+
default_order = current_settings.default_sort_order.presence || component_settings.default_sort_order
|
35
|
+
return order_by_default if default_order == "default"
|
36
|
+
|
37
|
+
possible_orders.include?(default_order) ? default_order : order_by_default
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def order_by_default
|
42
|
+
if order_by_votes?
|
43
|
+
"most_voted"
|
44
|
+
else
|
45
|
+
"random"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def most_voted_order_available?
|
50
|
+
current_settings.votes_enabled? && !current_settings.votes_hidden?
|
51
|
+
end
|
52
|
+
|
53
|
+
def order_by_votes?
|
54
|
+
most_voted_order_available? && current_settings.votes_blocked?
|
55
|
+
end
|
56
|
+
|
57
|
+
def reorder(paragraphs)
|
58
|
+
case order
|
59
|
+
when "most_commented"
|
60
|
+
paragraphs.left_joins(:comments).group(:id).order(Arel.sql("COUNT(decidim_comments_comments.id) DESC"))
|
61
|
+
when "most_endorsed"
|
62
|
+
paragraphs.order(endorsements_count: :desc)
|
63
|
+
when "most_followed"
|
64
|
+
paragraphs.left_joins(:follows).group(:id).order(Arel.sql("COUNT(decidim_follows.id) DESC"))
|
65
|
+
when "most_voted"
|
66
|
+
paragraphs.order(paragraph_votes_count: :desc)
|
67
|
+
when "random"
|
68
|
+
paragraphs.order_randomly(random_seed)
|
69
|
+
when "recent"
|
70
|
+
paragraphs.order(published_at: :desc)
|
71
|
+
when "with_more_authors"
|
72
|
+
paragraphs.order(coauthorships_count: :desc)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module EnhancedTextwork
|
5
|
+
module Admin
|
6
|
+
# This controller is the abstract class from which all other controllers of
|
7
|
+
# this engine inherit.
|
8
|
+
#
|
9
|
+
# Note that it inherits from `Decidim::Admin::Components::BaseController`, which
|
10
|
+
# override its layout and provide all kinds of useful methods.
|
11
|
+
class ApplicationController < Decidim::Admin::Components::BaseController
|
12
|
+
helper Decidim::ApplicationHelper
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module EnhancedTextwork
|
5
|
+
module Admin
|
6
|
+
# This controller allows admins to answer paragraphs in a participatory process.
|
7
|
+
class ParagraphAnswersController < Admin::ApplicationController
|
8
|
+
helper_method :paragraph
|
9
|
+
|
10
|
+
helper EnhancedTextwork::ApplicationHelper
|
11
|
+
helper Decidim::EnhancedTextwork::Admin::ParagraphsHelper
|
12
|
+
helper Decidim::EnhancedTextwork::Admin::ParagraphRankingsHelper
|
13
|
+
helper Decidim::Messaging::ConversationHelper
|
14
|
+
|
15
|
+
def edit
|
16
|
+
enforce_permission_to :create, :paragraph_answer, paragraph: paragraph
|
17
|
+
@form = form(Admin::ParagraphAnswerForm).from_model(paragraph)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
enforce_permission_to :create, :paragraph_answer, paragraph: paragraph
|
22
|
+
@notes_form = form(ParagraphNoteForm).instance
|
23
|
+
@answer_form = form(Admin::ParagraphAnswerForm).from_params(params)
|
24
|
+
|
25
|
+
Admin::AnswerParagraph.call(@answer_form, paragraph) do
|
26
|
+
on(:ok) do
|
27
|
+
flash[:notice] = I18n.t("paragraphs.answer.success", scope: "decidim.enhanced_textwork.admin")
|
28
|
+
redirect_to paragraphs_path
|
29
|
+
end
|
30
|
+
|
31
|
+
on(:invalid) do
|
32
|
+
flash.keep[:alert] = I18n.t("paragraphs.answer.invalid", scope: "decidim.enhanced_textwork.admin")
|
33
|
+
render template: "decidim/enhanced_textwork/admin/paragraphs/show"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def skip_manage_component_permission
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
def paragraph
|
45
|
+
@paragraph ||= Paragraph.where(component: current_component).find(params[:id])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module EnhancedTextwork
|
5
|
+
module Admin
|
6
|
+
# This controller allows admins to make private notes on paragraphs in a participatory process.
|
7
|
+
class ParagraphNotesController < Admin::ApplicationController
|
8
|
+
helper_method :paragraph
|
9
|
+
|
10
|
+
def create
|
11
|
+
enforce_permission_to :create, :paragraph_note, paragraph: paragraph
|
12
|
+
@form = form(ParagraphNoteForm).from_params(params)
|
13
|
+
|
14
|
+
CreateParagraphNote.call(@form, paragraph) do
|
15
|
+
on(:ok) do
|
16
|
+
flash[:notice] = I18n.t("paragraph_notes.create.success", scope: "decidim.enhanced_textwork.admin")
|
17
|
+
redirect_to paragraph_path(id: paragraph.id)
|
18
|
+
end
|
19
|
+
|
20
|
+
on(:invalid) do
|
21
|
+
flash.keep[:alert] = I18n.t("paragraph_notes.create.error", scope: "decidim.enhanced_textwork.admin")
|
22
|
+
redirect_to paragraph_path(id: paragraph.id)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def skip_manage_component_permission
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def paragraph
|
34
|
+
@paragraph ||= Paragraph.where(component: current_component).find(params[:paragraph_id])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module EnhancedTextwork
|
5
|
+
module Admin
|
6
|
+
# This controller allows admins to manage paragraphs in a participatory process.
|
7
|
+
class ParagraphsController < Admin::ApplicationController
|
8
|
+
include Decidim::ApplicationHelper
|
9
|
+
include Decidim::EnhancedTextwork::Admin::Filterable
|
10
|
+
|
11
|
+
helper EnhancedTextwork::ApplicationHelper
|
12
|
+
helper Decidim::EnhancedTextwork::Admin::ParagraphRankingsHelper
|
13
|
+
helper Decidim::Messaging::ConversationHelper
|
14
|
+
helper_method :paragraphs, :query, :form_presenter, :paragraph, :paragraph_ids
|
15
|
+
helper EnhancedTextwork::Admin::ParagraphBulkActionsHelper
|
16
|
+
|
17
|
+
def show
|
18
|
+
@notes_form = form(ParagraphNoteForm).instance
|
19
|
+
@answer_form = form(Admin::ParagraphAnswerForm).from_model(paragraph)
|
20
|
+
end
|
21
|
+
|
22
|
+
def new
|
23
|
+
enforce_permission_to :create, :paragraph
|
24
|
+
@form = form(Decidim::EnhancedTextwork::Admin::ParagraphForm).from_params(
|
25
|
+
attachment: form(AttachmentForm).from_params({})
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create
|
30
|
+
enforce_permission_to :create, :paragraph
|
31
|
+
@form = form(Decidim::EnhancedTextwork::Admin::ParagraphForm).from_params(params)
|
32
|
+
|
33
|
+
Admin::CreateParagraph.call(@form) do
|
34
|
+
on(:ok) do
|
35
|
+
flash[:notice] = I18n.t("paragraphs.create.success", scope: "decidim.enhanced_textwork.admin")
|
36
|
+
redirect_to paragraphs_path
|
37
|
+
end
|
38
|
+
|
39
|
+
on(:invalid) do
|
40
|
+
flash.now[:alert] = I18n.t("paragraphs.create.invalid", scope: "decidim.enhanced_textwork.admin")
|
41
|
+
render action: "new"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_category
|
47
|
+
enforce_permission_to :update, :paragraph_category
|
48
|
+
|
49
|
+
Admin::UpdateParagraphCategory.call(params[:category][:id], paragraph_ids) do
|
50
|
+
on(:invalid_category) do
|
51
|
+
flash.now[:error] = I18n.t(
|
52
|
+
"paragraphs.update_category.select_a_category",
|
53
|
+
scope: "decidim.enhanced_textwork.admin"
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
on(:invalid_paragraph_ids) do
|
58
|
+
flash.now[:alert] = I18n.t(
|
59
|
+
"paragraphs.update_category.select_a_paragraph",
|
60
|
+
scope: "decidim.enhanced_textwork.admin"
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
on(:update_paragraphs_category) do
|
65
|
+
flash.now[:notice] = update_paragraphs_bulk_response_successful(@response, :category)
|
66
|
+
flash.now[:alert] = update_paragraphs_bulk_response_errored(@response, :category)
|
67
|
+
end
|
68
|
+
respond_to do |format|
|
69
|
+
format.js
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def publish_answers
|
75
|
+
enforce_permission_to :publish_answers, :paragraphs
|
76
|
+
|
77
|
+
Decidim::EnhancedTextwork::Admin::PublishAnswers.call(current_component, current_user, paragraph_ids) do
|
78
|
+
on(:invalid) do
|
79
|
+
flash.now[:alert] = t(
|
80
|
+
"paragraphs.publish_answers.select_a_paragraph",
|
81
|
+
scope: "decidim.enhanced_textwork.admin"
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
on(:ok) do
|
86
|
+
flash.now[:notice] = I18n.t("paragraphs.publish_answers.success", scope: "decidim")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
respond_to do |format|
|
91
|
+
format.js
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def update_scope
|
96
|
+
enforce_permission_to :update, :paragraph_scope
|
97
|
+
|
98
|
+
Admin::UpdateParagraphScope.call(params[:scope_id], paragraph_ids) do
|
99
|
+
on(:invalid_scope) do
|
100
|
+
flash.now[:error] = t(
|
101
|
+
"paragraphs.update_scope.select_a_scope",
|
102
|
+
scope: "decidim.enhanced_textwork.admin"
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
on(:invalid_paragraph_ids) do
|
107
|
+
flash.now[:alert] = t(
|
108
|
+
"paragraphs.update_scope.select_a_paragraph",
|
109
|
+
scope: "decidim.enhanced_textwork.admin"
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
on(:update_paragraphs_scope) do
|
114
|
+
flash.now[:notice] = update_paragraphs_bulk_response_successful(@response, :scope)
|
115
|
+
flash.now[:alert] = update_paragraphs_bulk_response_errored(@response, :scope)
|
116
|
+
end
|
117
|
+
|
118
|
+
respond_to do |format|
|
119
|
+
format.js
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def edit
|
125
|
+
enforce_permission_to :edit, :paragraph, paragraph: paragraph
|
126
|
+
@form = form(Admin::ParagraphForm).from_model(paragraph)
|
127
|
+
end
|
128
|
+
|
129
|
+
def update
|
130
|
+
enforce_permission_to :edit, :paragraph, paragraph: paragraph
|
131
|
+
|
132
|
+
@form = form(Admin::ParagraphForm).from_params(params)
|
133
|
+
|
134
|
+
Admin::UpdateParagraph.call(@form, @paragraph) do
|
135
|
+
on(:ok) do |_paragraph|
|
136
|
+
flash[:notice] = t("paragraphs.update.success", scope: "decidim")
|
137
|
+
redirect_to paragraphs_path
|
138
|
+
end
|
139
|
+
|
140
|
+
on(:invalid) do
|
141
|
+
flash.now[:alert] = t("paragraphs.update.error", scope: "decidim")
|
142
|
+
render :edit
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def destroy_draft
|
148
|
+
enforce_permission_to :edit, :paragraph, paragraph: draft
|
149
|
+
|
150
|
+
Admin::DestroyParagraph.call(draft) do
|
151
|
+
on(:ok) do
|
152
|
+
flash[:notice] = I18n.t("paragraphs.destroy_draft.success", scope: "decidim")
|
153
|
+
redirect_to participatory_texts_path
|
154
|
+
end
|
155
|
+
|
156
|
+
on(:invalid) do
|
157
|
+
flash.now[:alert] = I18n.t("paragraphs.destroy_draft.error", scope: "decidim")
|
158
|
+
redirect_to participatory_texts_path
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
def collection
|
166
|
+
@collection ||= Paragraph.where(component: current_component).not_hidden.published
|
167
|
+
end
|
168
|
+
|
169
|
+
def paragraphs
|
170
|
+
@paragraphs ||= filtered_collection
|
171
|
+
end
|
172
|
+
|
173
|
+
def paragraph
|
174
|
+
@paragraph ||= collection.find(params[:id])
|
175
|
+
end
|
176
|
+
|
177
|
+
def paragraph_ids
|
178
|
+
@paragraph_ids ||= params[:paragraph_ids]
|
179
|
+
end
|
180
|
+
|
181
|
+
def drafts
|
182
|
+
Paragraph.where(component: current_component).drafts
|
183
|
+
end
|
184
|
+
|
185
|
+
def draft
|
186
|
+
@draft ||= drafts.find(params[:id])
|
187
|
+
end
|
188
|
+
|
189
|
+
def update_paragraphs_bulk_response_successful(response, subject)
|
190
|
+
return if response[:successful].blank?
|
191
|
+
|
192
|
+
case subject
|
193
|
+
when :category
|
194
|
+
t(
|
195
|
+
"paragraphs.update_category.success",
|
196
|
+
subject_name: response[:subject_name],
|
197
|
+
paragraphs: response[:successful].to_sentence,
|
198
|
+
scope: "decidim.enhanced_textwork.admin"
|
199
|
+
)
|
200
|
+
when :scope
|
201
|
+
t(
|
202
|
+
"paragraphs.update_scope.success",
|
203
|
+
subject_name: response[:subject_name],
|
204
|
+
paragraphs: response[:successful].to_sentence,
|
205
|
+
scope: "decidim.enhanced_textwork.admin"
|
206
|
+
)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def update_paragraphs_bulk_response_errored(response, subject)
|
211
|
+
return if response[:errored].blank?
|
212
|
+
|
213
|
+
case subject
|
214
|
+
when :category
|
215
|
+
t(
|
216
|
+
"paragraphs.update_category.invalid",
|
217
|
+
subject_name: response[:subject_name],
|
218
|
+
paragraphs: response[:errored].to_sentence,
|
219
|
+
scope: "decidim.enhanced_textwork.admin"
|
220
|
+
)
|
221
|
+
when :scope
|
222
|
+
t(
|
223
|
+
"paragraphs.update_scope.invalid",
|
224
|
+
subject_name: response[:subject_name],
|
225
|
+
paragraphs: response[:errored].to_sentence,
|
226
|
+
scope: "decidim.enhanced_textwork.admin"
|
227
|
+
)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
def form_presenter
|
232
|
+
@form_presenter ||= present(@form, presenter_class: Decidim::EnhancedTextwork::ParagraphPresenter)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module EnhancedTextwork
|
5
|
+
module Admin
|
6
|
+
class ParagraphsImportsController < Admin::ApplicationController
|
7
|
+
def new
|
8
|
+
enforce_permission_to :import, :paragraphs
|
9
|
+
|
10
|
+
@form = form(Admin::ParagraphsImportForm).instance
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
enforce_permission_to :import, :paragraphs
|
15
|
+
|
16
|
+
@form = form(Admin::ParagraphsImportForm).from_params(params)
|
17
|
+
|
18
|
+
Admin::ImportParagraphs.call(@form) do
|
19
|
+
on(:ok) do |paragraphs|
|
20
|
+
flash[:notice] = I18n.t("paragraphs_imports.create.success", scope: "decidim.enhanced_textwork.admin", number: paragraphs.length)
|
21
|
+
redirect_to EngineRouter.admin_proxy(current_component).root_path
|
22
|
+
end
|
23
|
+
|
24
|
+
on(:invalid) do
|
25
|
+
flash.now[:alert] = I18n.t("paragraphs_imports.create.invalid", scope: "decidim.enhanced_textwork.admin")
|
26
|
+
render action: "new"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module EnhancedTextwork
|
5
|
+
module Admin
|
6
|
+
class ParagraphsMergesController < Admin::ApplicationController
|
7
|
+
def create
|
8
|
+
enforce_permission_to :merge, :paragraphs
|
9
|
+
|
10
|
+
@form = form(Admin::ParagraphsMergeForm).from_params(params)
|
11
|
+
|
12
|
+
Admin::MergeParagraphs.call(@form) do
|
13
|
+
on(:ok) do |_paragraph|
|
14
|
+
flash[:notice] = I18n.t("paragraphs_merges.create.success", scope: "decidim.enhanced_textwork.admin")
|
15
|
+
redirect_to EngineRouter.admin_proxy(@form.target_component).root_path
|
16
|
+
end
|
17
|
+
|
18
|
+
on(:invalid) do
|
19
|
+
flash[:alert_html] = Decidim::ValidationErrorsPresenter.new(
|
20
|
+
I18n.t("paragraphs_merges.create.invalid", scope: "decidim.enhanced_textwork.admin"),
|
21
|
+
@form
|
22
|
+
).message
|
23
|
+
redirect_to EngineRouter.admin_proxy(current_component).root_path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module EnhancedTextwork
|
5
|
+
module Admin
|
6
|
+
class ParagraphsSplitsController < Admin::ApplicationController
|
7
|
+
def create
|
8
|
+
enforce_permission_to :split, :paragraphs
|
9
|
+
|
10
|
+
@form = form(Admin::ParagraphsSplitForm).from_params(params)
|
11
|
+
|
12
|
+
Admin::SplitParagraphs.call(@form) do
|
13
|
+
on(:ok) do |_paragraph|
|
14
|
+
flash[:notice] = I18n.t("paragraphs_splits.create.success", scope: "decidim.enhanced_textwork.admin")
|
15
|
+
redirect_to EngineRouter.admin_proxy(@form.target_component).root_path
|
16
|
+
end
|
17
|
+
|
18
|
+
on(:invalid) do
|
19
|
+
flash[:alert_html] = Decidim::ValidationErrorsPresenter.new(
|
20
|
+
I18n.t("paragraphs_splits.create.invalid", scope: "decidim.enhanced_textwork.admin"),
|
21
|
+
@form
|
22
|
+
).message
|
23
|
+
redirect_to EngineRouter.admin_proxy(current_component).root_path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module EnhancedTextwork
|
5
|
+
module Admin
|
6
|
+
# This controller manages the participatory texts area.
|
7
|
+
class ParticipatoryTextsController < Admin::ApplicationController
|
8
|
+
helper_method :paragraph
|
9
|
+
helper ParticipatoryTextsHelper
|
10
|
+
|
11
|
+
def index
|
12
|
+
@drafts = Paragraph.where(component: current_component).drafts.order(:position)
|
13
|
+
@preview_form = form(Admin::PreviewParticipatoryTextForm).instance
|
14
|
+
@preview_form.from_models(@drafts)
|
15
|
+
end
|
16
|
+
|
17
|
+
def new_import
|
18
|
+
enforce_permission_to :manage, :participatory_texts
|
19
|
+
participatory_text = Decidim::EnhancedTextwork::ParticipatoryText.find_by(component: current_component)
|
20
|
+
@import = form(Admin::ImportParticipatoryTextForm).from_model(participatory_text)
|
21
|
+
end
|
22
|
+
|
23
|
+
def import
|
24
|
+
enforce_permission_to :manage, :participatory_texts
|
25
|
+
@import = form(Admin::ImportParticipatoryTextForm).from_params(params)
|
26
|
+
|
27
|
+
Admin::ImportParticipatoryText.call(@import) do
|
28
|
+
on(:ok) do
|
29
|
+
flash[:notice] = I18n.t("participatory_texts.import.success", scope: "decidim.enhanced_textwork.admin")
|
30
|
+
redirect_to EngineRouter.admin_proxy(current_component).participatory_texts_path
|
31
|
+
end
|
32
|
+
|
33
|
+
on(:invalid) do
|
34
|
+
flash.now[:alert] = I18n.t("participatory_texts.import.invalid", scope: "decidim.enhanced_textwork.admin")
|
35
|
+
render action: "new_import"
|
36
|
+
end
|
37
|
+
|
38
|
+
on(:invalid_file) do
|
39
|
+
flash.now[:alert] = I18n.t("participatory_texts.import.invalid_file", scope: "decidim.enhanced_textwork.admin")
|
40
|
+
render action: "new_import"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def new_editor
|
46
|
+
enforce_permission_to :manage, :participatory_texts
|
47
|
+
participatory_text = Decidim::EnhancedTextwork::ParticipatoryText.find_by(component: current_component)
|
48
|
+
@import = form(Admin::ImportEditorParticipatoryTextForm).from_model(participatory_text)
|
49
|
+
end
|
50
|
+
|
51
|
+
def import_from_editor
|
52
|
+
enforce_permission_to :manage, :participatory_texts
|
53
|
+
@import = form(Admin::ImportEditorParticipatoryTextForm).from_params(params)
|
54
|
+
|
55
|
+
Admin::ImportFromEditorParticipatoryText.call(@import) do
|
56
|
+
on(:ok) do
|
57
|
+
flash[:notice] = I18n.t("participatory_texts.import.success", scope: "decidim.enhanced_textwork.admin")
|
58
|
+
redirect_to EngineRouter.admin_proxy(current_component).participatory_texts_path
|
59
|
+
end
|
60
|
+
|
61
|
+
on(:invalid) do
|
62
|
+
flash.now[:alert] = I18n.t("participatory_texts.import.invalid", scope: "decidim.enhanced_textwork.admin")
|
63
|
+
render action: "new_editor"
|
64
|
+
end
|
65
|
+
|
66
|
+
on(:invalid_file) do
|
67
|
+
flash.now[:alert] = I18n.t("participatory_texts.import.invalid_file", scope: "decidim.enhanced_textwork.admin")
|
68
|
+
render action: "new_editor"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# When `save_draft` param exists, paragraphs are only saved.
|
74
|
+
# When no `save_draft` param is set, paragraphs are saved and published.
|
75
|
+
def update
|
76
|
+
enforce_permission_to :manage, :participatory_texts
|
77
|
+
|
78
|
+
form_params = params.require(:preview_participatory_text).permit!
|
79
|
+
@preview_form = form(Admin::PreviewParticipatoryTextForm).from_params(paragraphs: form_params[:paragraphs_attributes]&.values)
|
80
|
+
|
81
|
+
if params.has_key?("save_draft")
|
82
|
+
UpdateParticipatoryText.call(@preview_form) do
|
83
|
+
on(:ok) do
|
84
|
+
flash[:notice] = I18n.t("participatory_texts.update.success", scope: "decidim.enhanced_textwork.admin")
|
85
|
+
redirect_to EngineRouter.admin_proxy(current_component).participatory_texts_path
|
86
|
+
end
|
87
|
+
|
88
|
+
on(:invalid) do |failures|
|
89
|
+
alert_msg = [I18n.t("participatory_texts.publish.invalid", scope: "decidim.enhanced_textwork.admin")]
|
90
|
+
failures.each_pair { |id, msg| alert_msg << "ID:[#{id}] #{msg}" }
|
91
|
+
flash.now[:alert] = alert_msg.join("<br/>").html_safe
|
92
|
+
index
|
93
|
+
render action: "index"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
else
|
97
|
+
PublishParticipatoryText.call(@preview_form) do
|
98
|
+
on(:ok) do
|
99
|
+
flash[:notice] = I18n.t("participatory_texts.publish.success", scope: "decidim.enhanced_textwork.admin")
|
100
|
+
redirect_to paragraphs_path
|
101
|
+
end
|
102
|
+
|
103
|
+
on(:invalid) do |failures|
|
104
|
+
alert_msg = [I18n.t("participatory_texts.publish.invalid", scope: "decidim.enhanced_textwork.admin")]
|
105
|
+
failures.each_pair { |id, msg| alert_msg << "ID:[#{id}] #{msg}" }
|
106
|
+
flash.now[:alert] = alert_msg.join("<br/>").html_safe
|
107
|
+
index
|
108
|
+
render action: "index"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Removes all the unpublished paragraphs (drafts).
|
115
|
+
def discard
|
116
|
+
enforce_permission_to :manage, :participatory_texts
|
117
|
+
|
118
|
+
DiscardParticipatoryText.call(current_component) do
|
119
|
+
on(:ok) do
|
120
|
+
flash[:notice] = I18n.t("participatory_texts.discard.success", scope: "decidim.enhanced_textwork.admin")
|
121
|
+
redirect_to EngineRouter.admin_proxy(current_component).participatory_texts_path
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|