diff --git a/Gemfile.lock b/Gemfile.lock index c74731d7..73549b16 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - decidim-reporting_proposals (0.4.1) + decidim-reporting_proposals (0.4.2) decidim-admin (>= 0.25.0, < 0.27) decidim-core (>= 0.25.0, < 0.27) decidim-participatory_processes (>= 0.25.0, < 0.27) diff --git a/README.md b/README.md index 6314ed3f..fdd10b28 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ This module creates a new component to be used in participatory spaces that allows to create proposals orientated to manage geolocated issues in a city. For instance Damages or new ideas of improving a particular street or public good. +[👉 See features & screenshots](#features) + ## Installation Add this line to your application's Gemfile: @@ -34,7 +36,7 @@ bundle exec rails decidim_reporting_proposals:install:migrations > **IMPORTANT:** > > This module makes use of the [Deface](https://github.com/spree/deface) gem. -> In conjuntion with other modules (we know [Term Customizer](https://github.com/mainio/decidim-module-term_customizer/) is one of them) it might cause errors when precompiling assets for production sites. But only if during this process the compiling machine does not have access to the database. +> In conjunction with other modules (we know [Term Customizer](https://github.com/mainio/decidim-module-term_customizer/) is one of them) it might cause errors when precompiling assets for production sites. But only if during this process the compiling machine does not have access to the database. > > It is easy to overcome this problem. Just add the following line to your `config/environments/production.rb` file: > @@ -50,6 +52,13 @@ bundle exec rails decidim_reporting_proposals:install:migrations > > Alternatively, use any other ENV var to set up the `config.deface.enabled` to `false` during the precompilation phase. +Depending on your Decidim version, you can choose the corresponding version to ensure compatibility: + +| Version | Compatible Decidim versions | +|---|---| +| 0.5.x | 0.27.x | +| 0.4.x | 0.26.x | + ## Usage This module works very similarly as the Proposals module, in fact, it extends it to provide additional features and some different defaults. @@ -58,11 +67,34 @@ It provides a new component called "Reporting Proposals" that can be added in ad ### Features -TODO... +This module provides the following features: + +1. **Reporting Proposals Component**: A new component that can be added to any participatory space. It allows to create proposals in one-step form with some optimization for mobile devices. Users can add photos using the phone's camera directly and also use the device's GPS to establish a precise a geolocated address with one click. Some of the options can be used in the normal proposal's component too (but in this case they 2 steps behavior is maintained). + ![Reporting proposal creationg](features/proposal.png) + +2. **Comparison by proximity**: By default, reporting proposals are compared by proximity before publishing (as they are geolocated by default). This can be disabled in the component's settings. + ![Compare by proximity](features/proximity.png) + +3. **Automatic assignation of valuators**: When a proposal is created, admins usually have to assign valuators manually to it. This module allows admins to assign valuators to a category directly. This will automatically assign all valuators in that category to any proposal/reporting proposal created under it (and also existing proposals). This avoids the need of manually assign proposals to valuators. This behavior can be disabled in the component's settings. + ![Valuators in categories](features/categories.png) + +4. **Valuators empowerment**: A number of features allow valuators to have more control over the proposals they are evaluating. They can assign other valuators (instead of themselves) and they can change or add photos to a proposal. All of it is configurable. Also, valuators can be assigned directly in the proposal's answering page instead of using the bulk assignation feature. Additionally, privates note can be edited and links in it are clickable. + ![Valuators empowerment](features/answering1.png) + +5. **Overdue proposals**: This module allows to set a number of days after which a proposal is considered overdue. This is configurable and can be disabled. This feature affects the admin list of proposals, adding visual notes, color coded, to facilitate the identification of overdue proposals and preventing admins to leave unanswered proposals for a long time. + ![Overdue proposals](features/overdues.png) + +6. **Improved notifications**: Some notifications are added, and some existing ones are improved. For instance, valuators and admins can receive notifications after a proposal has been added and it's content includes a direct link to the proposal and its answering page. + +7. **Hide proposals without reporting**: Administrators can hide proposals directly, without using the reporting process. Also, authors who's content has been hidden receive a notification. + +8. **Proposal answers templates**: Administrators can create templates for the answers to proposals. This is useful to provide a standard answer to proposals that are similar. This feature requires to enable the `decidim-templates` official module. + ![Templates for proposals answers](features/templates1.png) + ![Applying a template](features/templates2.png) ### Customization -Almost all the features of this module can be customized through an initializer. +Almost all the features of this module can be customized/disabled through an initializer. For instance, you can create an initializer an change some of the available options as follows (**This is optional, you don't need to do this, by default all options are enabled**): @@ -89,9 +121,6 @@ Decidim::ReportingProposals.configure do |config| # Public Setting that adds a button next to the "add image" input[type=file] to open the camera directly config.use_camera_button = [:proposals, :reporting_proposals] - # Public Setting to prevent adding the camera button on not photo/image input[type=file] - config.camera_button_on_attachments = false - # Public setting to prevent valuators or admins to modify the photos attached to a proposal # otherwise can be configured at the component level config.allow_proposal_photo_editing = true @@ -101,6 +130,8 @@ Decidim::ReportingProposals.configure do |config| end ``` +Find all the available options in the [config.rb](lib/decidim/reporting_proposals/config.rb) file. + ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/openpoke/decidim-module-reporting_proposals. diff --git a/app/forms/concerns/decidim/reporting_proposals/form_builder_override.rb b/app/forms/concerns/decidim/reporting_proposals/form_builder_override.rb index dc5e65ed..6f5864f5 100644 --- a/app/forms/concerns/decidim/reporting_proposals/form_builder_override.rb +++ b/app/forms/concerns/decidim/reporting_proposals/form_builder_override.rb @@ -38,9 +38,7 @@ def use_camera_button?(object_name) return unless Decidim::ReportingProposals.use_camera_button.include?(@template.current_component.manifest_name.to_sym) - return object_name == :add_photos unless Decidim::ReportingProposals.camera_button_on_attachments - - true + object_name == :add_photos end end end diff --git a/app/packs/src/decidim/reporting_proposals/user_camera_inputs.js b/app/packs/src/decidim/reporting_proposals/user_camera_inputs.js index 9a460756..7357d664 100644 --- a/app/packs/src/decidim/reporting_proposals/user_camera_inputs.js +++ b/app/packs/src/decidim/reporting_proposals/user_camera_inputs.js @@ -1,49 +1,47 @@ $(() => { - $('input[type="file"]').each((_i, el) => { - const $input = $(el); - const $inputField = $input.closest(".row.column"); - const $button = $inputField.find("button:first"); - const $checkbox = $inputField.find("input:checkbox[name$='[has_no_image]']"); - const $formError = $inputField.find("span.form-error") - const $labelInput = $("label[for='proposal_add_photos']") + const $input = $("#proposal_add_photos"); + const $inputField = $input.closest(".row.column"); + const $button = $inputField.find("button:first"); + const $checkbox = $inputField.find("input:checkbox[name$='[has_no_image]']"); + const $formError = $inputField.find("span.form-error") + const $labelInput = $("label[for='proposal_add_photos']") - const removeErrors = () => { - $input.removeClass("is-invalid-input"); - $formError.removeClass("is-visible"); - $labelInput.removeClass("is-invalid-label"); - }; + const removeErrors = () => { + $input.removeClass("is-invalid-input"); + $formError.removeClass("is-visible"); + $labelInput.removeClass("is-invalid-label"); + }; - const toggleInput = () => { - if ($checkbox[0].checked) { - removeErrors(); - $input.prop("disabled", true); - $button.prop("disabled", true); - } else { - $input.prop("disabled", false); - $button.prop("disabled", false); - } + const toggleInput = () => { + if ($checkbox[0].checked) { + removeErrors(); + $input.prop("disabled", true); + $button.prop("disabled", true); + } else { + $input.prop("disabled", false); + $button.prop("disabled", false); } + } - $input.attr("accept", "image/*"); + $input.attr("accept", "image/*"); - $button.on("click", () => { - console.log("click button") - $input.attr("capture", "camera"); - $input.click(); - $input.removeAttr("capture", "camera"); - }); + $button.on("click", () => { + console.log("click button") + $input.attr("capture", "camera"); + $input.click(); + $input.removeAttr("capture", "camera"); + }); - $input.on("click", () => { - console.log("click", $input); - $input.one("blur", () => { - console.log("blur", $input); - removeErrors(); - }); + $input.on("click", () => { + console.log("click", $input); + $input.one("blur", () => { + console.log("blur", $input); + removeErrors(); }); - - if ($checkbox.length > 0) { - $checkbox.on("change", toggleInput); - toggleInput(); - } }); + + if ($checkbox.length > 0) { + $checkbox.on("change", toggleInput); + toggleInput(); + } }); diff --git a/features/answering1.png b/features/answering1.png new file mode 100644 index 00000000..7cc2c341 Binary files /dev/null and b/features/answering1.png differ diff --git a/features/categories.png b/features/categories.png new file mode 100644 index 00000000..93042b4e Binary files /dev/null and b/features/categories.png differ diff --git a/features/overdues.png b/features/overdues.png new file mode 100644 index 00000000..197be432 Binary files /dev/null and b/features/overdues.png differ diff --git a/features/proposal.png b/features/proposal.png new file mode 100644 index 00000000..617a0ca7 Binary files /dev/null and b/features/proposal.png differ diff --git a/features/proximity.png b/features/proximity.png new file mode 100644 index 00000000..a658feed Binary files /dev/null and b/features/proximity.png differ diff --git a/features/templates1.png b/features/templates1.png new file mode 100644 index 00000000..ab005c21 Binary files /dev/null and b/features/templates1.png differ diff --git a/features/templates2.png b/features/templates2.png new file mode 100644 index 00000000..4d8914c1 Binary files /dev/null and b/features/templates2.png differ diff --git a/lib/decidim/reporting_proposals/config.rb b/lib/decidim/reporting_proposals/config.rb index f4dabe44..1d546a03 100644 --- a/lib/decidim/reporting_proposals/config.rb +++ b/lib/decidim/reporting_proposals/config.rb @@ -34,11 +34,6 @@ module ReportingProposals [:proposals, :reporting_proposals] end - # Public Setting to prevent adding the camera button on not photo/image input[type=file] - config_accessor :camera_button_on_attachments do - false - end - # Public setting to prevent valuators or admins to modify the photos attached to a proposal # otherwise can be configured at the component level config_accessor :allow_proposal_photo_editing do diff --git a/lib/decidim/reporting_proposals/version.rb b/lib/decidim/reporting_proposals/version.rb index 407f56b4..8907d80f 100644 --- a/lib/decidim/reporting_proposals/version.rb +++ b/lib/decidim/reporting_proposals/version.rb @@ -2,7 +2,7 @@ module Decidim module ReportingProposals - VERSION = "0.4.1" + VERSION = "0.4.2" DECIDIM_VERSION = "0.26.5" COMPAT_DECIDIM_VERSION = [">= 0.25.0", "< 0.27"].freeze diff --git a/spec/system/device_camera_spec.rb b/spec/system/device_camera_spec.rb index 2d9ced9a..51845c03 100644 --- a/spec/system/device_camera_spec.rb +++ b/spec/system/device_camera_spec.rb @@ -15,26 +15,16 @@ let(:proposal) { Decidim::Proposals::Proposal.last } let(:all_manifests) { [:proposals, :reporting_proposals] } let(:manifests) { all_manifests } - let(:camera_on_attachments) { true } before do allow(Decidim::ReportingProposals).to receive(:use_camera_button).and_return(manifests) - allow(Decidim::ReportingProposals).to receive(:camera_button_on_attachments).and_return(camera_on_attachments) switch_to_host(organization.host) login_as user, scope: :user end shared_examples "uses device camera" do - it "has two cameras button" do - expect(page).to have_button("Use my camera", count: 2) - end - - context "when no camera on attachments" do - let(:camera_on_attachments) { false } - - it "has one camera button" do - expect(page).to have_button("Use my camera", count: 1) - end + it "has one camera button" do + expect(page).to have_button("Use my camera", count: 1) end context "when option disabled" do