decidim-accountability 0.29.2 → 0.30.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/accountability/project/show.erb +6 -0
- data/app/cells/decidim/accountability/project_cell.rb +23 -42
- data/app/cells/decidim/accountability/result_history_cell.rb +57 -0
- data/app/cells/decidim/accountability/result_metadata_cell.rb +17 -17
- data/app/cells/decidim/accountability/status_cell.rb +9 -13
- data/app/commands/decidim/accountability/admin/create_imported_result.rb +1 -1
- data/app/commands/decidim/accountability/admin/create_result.rb +3 -2
- data/app/commands/decidim/accountability/admin/import_component_to_accountability.rb +47 -0
- data/app/commands/decidim/accountability/admin/update_imported_result.rb +1 -1
- data/app/commands/decidim/accountability/admin/update_result.rb +3 -2
- data/app/commands/decidim/accountability/admin/update_result_dates.rb +56 -0
- data/app/commands/decidim/accountability/admin/update_result_status.rb +61 -0
- data/app/commands/decidim/accountability/admin/update_result_taxonomies.rb +18 -0
- data/app/controllers/concerns/decidim/accountability/admin/filterable.rb +8 -6
- data/app/controllers/decidim/accountability/admin/import_components_controller.rb +36 -0
- data/app/controllers/decidim/accountability/admin/results_bulk_actions_controller.rb +102 -0
- data/app/controllers/decidim/accountability/admin/results_controller.rb +21 -11
- data/app/controllers/decidim/accountability/results_controller.rb +10 -7
- data/app/forms/decidim/accountability/admin/import_component_form.rb +98 -0
- data/app/forms/decidim/accountability/admin/result_bulk_actions_form.rb +18 -0
- data/app/forms/decidim/accountability/admin/result_form.rb +17 -23
- data/app/helpers/decidim/accountability/admin/application_helper.rb +0 -1
- data/app/helpers/decidim/accountability/application_helper.rb +1 -32
- data/app/helpers/decidim/accountability/breadcrumb_helper.rb +10 -14
- data/app/jobs/decidim/accountability/admin/import_projects_job.rb +5 -3
- data/app/jobs/decidim/accountability/admin/import_proposals_job.rb +70 -0
- data/app/mailers/decidim/accountability/import_proposals_mailer.rb +28 -0
- data/app/models/decidim/accountability/result.rb +23 -1
- data/app/models/decidim/accountability/status.rb +4 -0
- data/app/packs/entrypoints/decidim_accountability_admin_form.js +1 -0
- data/app/packs/src/decidim/accountability/admin/imports.js +37 -14
- data/app/packs/src/decidim/accountability/admin/index/action_button.js +42 -0
- data/app/packs/src/decidim/accountability/admin/index/action_form.js +46 -0
- data/app/packs/src/decidim/accountability/admin/index/action_selector.js +37 -0
- data/app/packs/src/decidim/accountability/admin/index/counter.js +40 -0
- data/app/packs/src/decidim/accountability/admin/index/select_all.js +29 -0
- data/app/packs/src/decidim/accountability/admin/index.js +17 -7
- data/app/packs/src/decidim/accountability/admin/result_form.js +21 -0
- data/app/packs/stylesheets/accountability.scss +5 -0
- data/app/permissions/decidim/accountability/admin/permissions.rb +3 -2
- data/app/presenters/decidim/accountability/admin_log/result_presenter.rb +1 -1
- data/app/presenters/decidim/accountability/result_presenter.rb +30 -0
- data/app/queries/decidim/accountability/metrics/results_metric_manage.rb +6 -6
- data/app/services/decidim/accountability/results_calculator.rb +4 -6
- data/app/services/decidim/accountability/results_csv_importer.rb +1 -1
- data/app/views/decidim/accountability/admin/import_components/_filters.html.erb +26 -0
- data/app/views/decidim/accountability/admin/import_components/_form.html.erb +26 -0
- data/app/views/decidim/accountability/admin/import_components/new.html.erb +14 -0
- data/app/views/decidim/accountability/admin/results/_actions.html.erb +29 -0
- data/app/views/decidim/accountability/admin/results/_form.html.erb +15 -8
- data/app/views/decidim/accountability/admin/results/_result-tr.html.erb +32 -0
- data/app/views/decidim/accountability/admin/results/_results-thead.html.erb +26 -0
- data/app/views/decidim/accountability/admin/results/bulk_actions/_dates_form.html.erb +19 -0
- data/app/views/decidim/accountability/admin/results/bulk_actions/_dropdown.html.erb +40 -0
- data/app/views/decidim/accountability/admin/results/bulk_actions/_status_form.html.erb +16 -0
- data/app/views/decidim/accountability/admin/results/bulk_actions/_submit_buttons.html.erb +4 -0
- data/app/views/decidim/accountability/admin/results/bulk_actions/_taxonomies_form.html.erb +18 -0
- data/app/views/decidim/accountability/admin/results/edit.html.erb +2 -2
- data/app/views/decidim/accountability/admin/results/index.html.erb +50 -111
- data/app/views/decidim/accountability/admin/results/manage_trash.html.erb +26 -0
- data/app/views/decidim/accountability/admin/results/new.html.erb +2 -2
- data/app/views/decidim/accountability/import_proposals_mailer/import.html.erb +2 -0
- data/app/views/decidim/accountability/results/{_home_categories.html.erb → _home_taxonomies.html.erb} +6 -8
- data/app/views/decidim/accountability/results/_project.html.erb +1 -3
- data/app/views/decidim/accountability/results/_projects_aside.html.erb +9 -7
- data/app/views/decidim/accountability/results/home.html.erb +18 -6
- data/app/views/decidim/accountability/results/index.html.erb +8 -2
- data/app/views/decidim/accountability/results/show.html.erb +5 -5
- data/config/assets.rb +3 -2
- data/config/locales/ar.yml +97 -55
- data/config/locales/bg.yml +0 -50
- data/config/locales/bs-BA.yml +0 -16
- data/config/locales/ca.yml +128 -40
- data/config/locales/cs.yml +147 -56
- data/config/locales/da.yml +0 -20
- data/config/locales/de.yml +126 -39
- data/config/locales/el.yml +0 -48
- data/config/locales/en.yml +128 -40
- data/config/locales/es-MX.yml +129 -41
- data/config/locales/es-PY.yml +129 -41
- data/config/locales/es.yml +129 -41
- data/config/locales/eu.yml +140 -53
- data/config/locales/fi-plain.yml +136 -49
- data/config/locales/fi.yml +136 -49
- data/config/locales/fr-CA.yml +111 -54
- data/config/locales/fr.yml +111 -54
- data/config/locales/ga-IE.yml +0 -13
- data/config/locales/gl.yml +0 -17
- data/config/locales/gn-PY.yml +0 -11
- data/config/locales/he-IL.yml +45 -54
- data/config/locales/hu.yml +0 -50
- data/config/locales/id-ID.yml +0 -16
- data/config/locales/is-IS.yml +0 -17
- data/config/locales/it.yml +0 -18
- data/config/locales/ja.yml +132 -47
- data/config/locales/kaa.yml +0 -8
- data/config/locales/ko.yml +0 -47
- data/config/locales/lb.yml +0 -17
- data/config/locales/lt.yml +0 -50
- data/config/locales/lv.yml +0 -19
- data/config/locales/nl.yml +0 -17
- data/config/locales/no.yml +0 -17
- data/config/locales/pl.yml +0 -47
- data/config/locales/pt-BR.yml +6 -50
- data/config/locales/pt.yml +35 -23
- data/config/locales/ro-RO.yml +0 -29
- data/config/locales/ru.yml +0 -16
- data/config/locales/si-LK.yml +0 -11
- data/config/locales/sk.yml +0 -19
- data/config/locales/sl.yml +0 -17
- data/config/locales/sq-AL.yml +0 -50
- data/config/locales/sr-CS.yml +0 -16
- data/config/locales/sv.yml +124 -36
- data/config/locales/th-TH.yml +0 -50
- data/config/locales/tr-TR.yml +0 -47
- data/config/locales/uk.yml +0 -16
- data/config/locales/zh-CN.yml +0 -20
- data/config/locales/zh-TW.yml +0 -47
- data/db/migrate/20200827154103_add_commentable_counter_cache_to_results.rb +1 -1
- data/db/migrate/20240828103202_add_deleted_at_to_decidim_accountability_results.rb +8 -0
- data/db/migrate/20240916112128_add_geolocation_fields_to_results.rb +9 -0
- data/decidim-accountability.gemspec +1 -1
- data/lib/decidim/accountability/admin_engine.rb +16 -2
- data/lib/decidim/accountability/component.rb +3 -3
- data/lib/decidim/accountability/result_serializer.rb +9 -13
- data/lib/decidim/accountability/seeds.rb +28 -21
- data/lib/decidim/accountability/test/factories.rb +6 -4
- data/lib/decidim/accountability/version.rb +1 -1
- data/lib/decidim/api/accountability_type.rb +4 -5
- data/lib/decidim/api/result_type.rb +10 -13
- data/lib/decidim/api/status_type.rb +3 -4
- data/lib/decidim/api/timeline_entry_type.rb +5 -6
- metadata +58 -30
- data/app/commands/decidim/accountability/admin/import_projects_to_accountability.rb +0 -37
- data/app/controllers/decidim/accountability/admin/projects_import_controller.rb +0 -31
- data/app/forms/decidim/accountability/admin/result_import_projects_form.rb +0 -51
- data/app/views/decidim/accountability/admin/projects_import/new.html.erb +0 -45
- data/app/views/decidim/accountability/results/_nav_breadcrumb.html.erb +0 -37
- data/app/views/decidim/accountability/results/_scope_filters.html.erb +0 -31
- /data/app/packs/entrypoints/{decidim_accountability_admin.js → decidim_accountability_admin_index.js} +0 -0
@@ -22,6 +22,10 @@ module Decidim
|
|
22
22
|
# Allow ransacker to search for a key in a hstore column (`name`.`en`)
|
23
23
|
ransacker_i18n :name
|
24
24
|
|
25
|
+
def self.ransackable_attributes(_auth_object = nil)
|
26
|
+
%w(id name)
|
27
|
+
end
|
28
|
+
|
25
29
|
def self.log_presenter_class_for(_log)
|
26
30
|
Decidim::Accountability::AdminLog::StatusPresenter
|
27
31
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
import "src/decidim/accountability/admin/result_form"
|
@@ -1,15 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
class AdminAccountabilityImportsComponent {
|
2
|
+
run() {
|
3
|
+
this.bindEvents();
|
4
|
+
}
|
5
|
+
|
6
|
+
bindEvents() {
|
7
|
+
const form = this.getForm();
|
8
|
+
const selects = form.querySelectorAll("select");
|
9
|
+
|
10
|
+
selects.forEach((select) => {
|
11
|
+
select.addEventListener("change", this.onSelectChange.bind(this));
|
12
|
+
});
|
13
|
+
}
|
14
|
+
|
15
|
+
onSelectChange() {
|
16
|
+
const form = this.getForm();
|
17
|
+
const formUrl = form.dataset.formUrl;
|
18
|
+
|
19
|
+
// Remove authenticity token input if it exists
|
20
|
+
const tokenInput = form.querySelector("input[name='authenticity_token']");
|
21
|
+
if (tokenInput) {
|
22
|
+
tokenInput.remove();
|
7
23
|
}
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
24
|
+
|
25
|
+
form.setAttribute("action", formUrl);
|
26
|
+
form.setAttribute("method", "get");
|
27
|
+
form.submit();
|
28
|
+
}
|
29
|
+
|
30
|
+
getForm() {
|
31
|
+
return document.getElementById("new_import_component");
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
window.Decidim.AdminAccountabilityImportsComponent = AdminAccountabilityImportsComponent;
|
36
|
+
const component = new AdminAccountabilityImportsComponent();
|
37
|
+
|
38
|
+
component.run();
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class ActionButton {
|
2
|
+
constructor(counter) {
|
3
|
+
this.counter = counter;
|
4
|
+
this.actionButton = document.querySelector("[data-action-button]");
|
5
|
+
this.actionForms = document.querySelectorAll("[data-action-form]");
|
6
|
+
}
|
7
|
+
|
8
|
+
init() {
|
9
|
+
this.counter.checkboxes.forEach((checkbox) => {
|
10
|
+
checkbox.addEventListener("change", () => this.onCheckboxChange());
|
11
|
+
});
|
12
|
+
|
13
|
+
this.toggleActionButton();
|
14
|
+
}
|
15
|
+
|
16
|
+
onCheckboxChange() {
|
17
|
+
this.toggleActionButton();
|
18
|
+
this.toggleActionForms();
|
19
|
+
}
|
20
|
+
|
21
|
+
toggleActionButton() {
|
22
|
+
const selectedIds = this.counter.getSelectedItems();
|
23
|
+
|
24
|
+
if (selectedIds.length > 0) {
|
25
|
+
this.actionButton.classList.remove("hide");
|
26
|
+
} else {
|
27
|
+
this.actionButton.classList.add("hide");
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
toggleActionForms() {
|
32
|
+
const selectedIds = this.counter.getSelectedItems();
|
33
|
+
|
34
|
+
if (selectedIds.length === 0) {
|
35
|
+
this.actionForms.forEach((form) => {
|
36
|
+
form.classList.add("hide");
|
37
|
+
});
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
export default ActionButton;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class ActionForm {
|
2
|
+
constructor(counter) {
|
3
|
+
this.counter = counter;
|
4
|
+
this.checkboxes = document.querySelectorAll("[data-result-checkbox]");
|
5
|
+
this.idFields = document.querySelectorAll("[data-result-ids-field]");
|
6
|
+
this.cancelButtons = document.querySelectorAll("[data-cancel-button]");
|
7
|
+
}
|
8
|
+
|
9
|
+
init() {
|
10
|
+
this.checkboxes.forEach((checkbox) => {
|
11
|
+
checkbox.addEventListener("change", () => this.onCheckboxChange());
|
12
|
+
});
|
13
|
+
|
14
|
+
this.cancelButtons.forEach((button) => {
|
15
|
+
button.addEventListener("click", () => this.onCancelButtonClick());
|
16
|
+
});
|
17
|
+
|
18
|
+
this.updateResultIdsHiddenField();
|
19
|
+
}
|
20
|
+
|
21
|
+
onCheckboxChange() {
|
22
|
+
this.updateResultIdsHiddenField();
|
23
|
+
}
|
24
|
+
|
25
|
+
onCancelButtonClick() {
|
26
|
+
this.hideAllForms();
|
27
|
+
}
|
28
|
+
|
29
|
+
hideAllForms() {
|
30
|
+
const forms = document.querySelectorAll("[data-action-form]");
|
31
|
+
forms.forEach((form) => {
|
32
|
+
form.classList.add("hide");
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
updateResultIdsHiddenField() {
|
37
|
+
const selectedIds = this.counter.getSelectedItems().
|
38
|
+
map((checkbox) => checkbox.dataset.resultId);
|
39
|
+
|
40
|
+
this.idFields.forEach((field) => {
|
41
|
+
field.value = selectedIds.join(",");
|
42
|
+
});
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
export default ActionForm;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class ActionSelector {
|
2
|
+
init() {
|
3
|
+
this.dropdownElement = document.querySelector("#js-bulk-actions-dropdown");
|
4
|
+
const buttons = this.dropdownElement.querySelectorAll("button");
|
5
|
+
|
6
|
+
buttons.forEach((button) => {
|
7
|
+
button.addEventListener("click", this.onActionClick.bind(this));
|
8
|
+
});
|
9
|
+
}
|
10
|
+
|
11
|
+
onActionClick(event) {
|
12
|
+
const action = event.target.dataset.action;
|
13
|
+
|
14
|
+
this.closeDropdown();
|
15
|
+
this.hideAllForms();
|
16
|
+
this.showForm(action);
|
17
|
+
}
|
18
|
+
|
19
|
+
closeDropdown() {
|
20
|
+
this.dropdownElement.classList.remove("is-open");
|
21
|
+
}
|
22
|
+
|
23
|
+
showForm(action) {
|
24
|
+
const form = document.querySelector(`[data-action-form="${action}"]`);
|
25
|
+
|
26
|
+
form.classList.remove("hide");
|
27
|
+
}
|
28
|
+
|
29
|
+
hideAllForms() {
|
30
|
+
const forms = document.querySelectorAll("[data-action-form]");
|
31
|
+
forms.forEach((form) => {
|
32
|
+
form.classList.add("hide");
|
33
|
+
});
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
export default ActionSelector;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/**
|
2
|
+
* Counter class handles the selection of results and updates the counter
|
3
|
+
*/
|
4
|
+
class Counter {
|
5
|
+
constructor() {
|
6
|
+
this.checkboxes = document.querySelectorAll("[data-result-checkbox]");
|
7
|
+
this.counterElement = document.querySelector("[data-selected-count]");
|
8
|
+
}
|
9
|
+
|
10
|
+
init() {
|
11
|
+
if (!this.checkboxes.length) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
|
15
|
+
this.checkboxes.forEach((checkbox) => {
|
16
|
+
checkbox.addEventListener("change", () => this.updateCounter());
|
17
|
+
});
|
18
|
+
|
19
|
+
this.updateCounter();
|
20
|
+
}
|
21
|
+
|
22
|
+
updateCounter() {
|
23
|
+
if (this.counterElement) {
|
24
|
+
const count = this.getSelectedItems().length;
|
25
|
+
this.counterElement.textContent = count;
|
26
|
+
|
27
|
+
if (count === 0) {
|
28
|
+
this.counterElement.classList.add("hide");
|
29
|
+
} else {
|
30
|
+
this.counterElement.classList.remove("hide");
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
getSelectedItems() {
|
36
|
+
return Array.from(this.checkboxes).filter((checkbox) => checkbox.checked);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
export default Counter;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class SelectAll {
|
2
|
+
constructor(counter) {
|
3
|
+
this.counter = counter;
|
4
|
+
this.checkboxes = this.counter.checkboxes;
|
5
|
+
this.selectAllButton = document.querySelector("[data-select-all]");
|
6
|
+
}
|
7
|
+
|
8
|
+
init() {
|
9
|
+
if (this.selectAllButton) {
|
10
|
+
this.selectAllButton.addEventListener("click", (event) => this.onSelectAllClick(event));
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
onSelectAllClick(event) {
|
15
|
+
event.preventDefault();
|
16
|
+
|
17
|
+
const someUnchecked = Array.from(this.checkboxes).some((checkbox) => !checkbox.checked);
|
18
|
+
|
19
|
+
// If some checkboxes are unchecked, check all of them
|
20
|
+
// Otherwise, uncheck all checkboxes
|
21
|
+
this.checkboxes.forEach((checkbox) => {
|
22
|
+
checkbox.checked = someUnchecked;
|
23
|
+
// Trigger change event to update other components
|
24
|
+
checkbox.dispatchEvent(new Event("change"));
|
25
|
+
});
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
export default SelectAll;
|
@@ -1,9 +1,19 @@
|
|
1
|
+
import Counter from "src/decidim/accountability/admin/index/counter";
|
2
|
+
import ActionButton from "src/decidim/accountability/admin/index/action_button";
|
3
|
+
import ActionForm from "src/decidim/accountability/admin/index/action_form";
|
4
|
+
import ActionSelector from "src/decidim/accountability/admin/index/action_selector";
|
5
|
+
import SelectAll from "src/decidim/accountability/admin/index/select_all";
|
6
|
+
|
1
7
|
$(() => {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
const counter = new Counter();
|
9
|
+
const actionButton = new ActionButton(counter);
|
10
|
+
const actionForm = new ActionForm(counter);
|
11
|
+
const actionSelector = new ActionSelector();
|
12
|
+
const selectAll = new SelectAll(counter);
|
13
|
+
|
14
|
+
counter.init();
|
15
|
+
actionButton.init();
|
16
|
+
actionForm.init();
|
17
|
+
actionSelector.init();
|
18
|
+
selectAll.init();
|
9
19
|
})
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import attachGeocoding from "src/decidim/geocoding/attach_input"
|
2
|
+
|
3
|
+
$(() => {
|
4
|
+
const $form = $(".result_form_admin");
|
5
|
+
|
6
|
+
if ($form.length > 0) {
|
7
|
+
const $resultAddress = $form.find("#result_address");
|
8
|
+
|
9
|
+
if ($resultAddress.length !== 0) {
|
10
|
+
attachGeocoding($resultAddress);
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
$("#result_decidim_accountability_status_id").change(function () {
|
15
|
+
/* eslint-disable no-invalid-this */
|
16
|
+
const progress = $(this).find(":selected").data("progress")
|
17
|
+
if (progress || progress === 0) {
|
18
|
+
$("#result_progress").val(progress);
|
19
|
+
}
|
20
|
+
});
|
21
|
+
});
|
@@ -10,7 +10,8 @@ module Decidim
|
|
10
10
|
permission_action.allow! if can_perform_actions_on?(:result, result)
|
11
11
|
permission_action.allow! if can_perform_actions_on?(:status, status)
|
12
12
|
permission_action.allow! if can_perform_actions_on?(:timeline_entry, timeline_entry)
|
13
|
-
permission_action.allow! if can_perform_actions_on?(:
|
13
|
+
permission_action.allow! if can_perform_actions_on?(:bulk_update, nil)
|
14
|
+
permission_action.allow! if can_perform_actions_on?(:import_component, nil)
|
14
15
|
|
15
16
|
permission_action
|
16
17
|
end
|
@@ -34,7 +35,7 @@ module Decidim
|
|
34
35
|
return false if can_create_grandchildren_results?
|
35
36
|
|
36
37
|
case permission_action.subject
|
37
|
-
when :
|
38
|
+
when :import_component
|
38
39
|
case permission_action.action
|
39
40
|
when :create, :new
|
40
41
|
true if defined?(Decidim::Budgets::Project)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Accountability
|
5
|
+
#
|
6
|
+
# Decorator for results
|
7
|
+
#
|
8
|
+
class ResultPresenter < Decidim::ResourcePresenter
|
9
|
+
include Rails.application.routes.mounted_helpers
|
10
|
+
include ActionView::Helpers::UrlHelper
|
11
|
+
include Decidim::SanitizeHelper
|
12
|
+
|
13
|
+
def result
|
14
|
+
__getobj__
|
15
|
+
end
|
16
|
+
|
17
|
+
# Render the result title
|
18
|
+
#
|
19
|
+
# links - should render hashtags as links?
|
20
|
+
# extras - should include extra hashtags?
|
21
|
+
#
|
22
|
+
# Returns a String.
|
23
|
+
def title(links: false, extras: true, html_escape: false, all_locales: false)
|
24
|
+
return unless result
|
25
|
+
|
26
|
+
super(result.title, links, html_escape, all_locales, extras:)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -13,11 +13,11 @@ module Decidim
|
|
13
13
|
next if cumulative_value.zero?
|
14
14
|
|
15
15
|
quantity_value = quantity[key] || 0
|
16
|
-
|
16
|
+
taxonomy_id, space_type, space_id, related_object_id = key
|
17
17
|
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s,
|
18
18
|
metric_type: @metric_name,
|
19
19
|
organization: @organization,
|
20
|
-
|
20
|
+
decidim_taxonomy_id: taxonomy_id,
|
21
21
|
participatory_space_type: space_type,
|
22
22
|
participatory_space_id: space_id,
|
23
23
|
related_object_type: "Decidim::Component",
|
@@ -38,9 +38,9 @@ module Decidim
|
|
38
38
|
@query = Decidim::Accountability::Result.select(:decidim_component_id)
|
39
39
|
.where(component: visible_components_from_spaces(spaces))
|
40
40
|
.joins(:component)
|
41
|
-
.left_outer_joins(:
|
42
|
-
@query = @query.where(
|
43
|
-
@query = @query.group("
|
41
|
+
.left_outer_joins(:taxonomizations)
|
42
|
+
@query = @query.where(decidim_accountability_results: { created_at: ..end_time })
|
43
|
+
@query = @query.group("decidim_taxonomizations.taxonomy_id",
|
44
44
|
:participatory_space_type,
|
45
45
|
:participatory_space_id,
|
46
46
|
:decidim_component_id)
|
@@ -48,7 +48,7 @@ module Decidim
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def quantity
|
51
|
-
@quantity ||= query.where(
|
51
|
+
@quantity ||= query.where(decidim_accountability_results: { created_at: start_time.. }).count
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -5,10 +5,9 @@ module Decidim
|
|
5
5
|
# This class handles the calculation of progress for a set of results
|
6
6
|
class ResultsCalculator
|
7
7
|
# Public: Initializes the service.
|
8
|
-
def initialize(component,
|
8
|
+
def initialize(component, taxonomy_id)
|
9
9
|
@component = component
|
10
|
-
@
|
11
|
-
@category_id = category_id
|
10
|
+
@taxonomy_id = taxonomy_id
|
12
11
|
end
|
13
12
|
|
14
13
|
delegate :count, to: :results
|
@@ -19,7 +18,7 @@ module Decidim
|
|
19
18
|
|
20
19
|
private
|
21
20
|
|
22
|
-
attr_reader :component, :
|
21
|
+
attr_reader :component, :taxonomy_id
|
23
22
|
|
24
23
|
def results
|
25
24
|
@results ||= begin
|
@@ -27,8 +26,7 @@ module Decidim
|
|
27
26
|
parent_id: nil,
|
28
27
|
component:
|
29
28
|
)
|
30
|
-
query = query.
|
31
|
-
query = query.with_any_category(category_id) if category_id
|
29
|
+
query = query.with_taxonomies(taxonomy_id) if taxonomy_id
|
32
30
|
|
33
31
|
query
|
34
32
|
end
|
@@ -80,7 +80,7 @@ module Decidim
|
|
80
80
|
available_locales = component.participatory_space.organization.available_locales
|
81
81
|
params["result"].merge!(get_locale_attributes(default_locale, available_locales, :title, row))
|
82
82
|
params["result"].merge!(get_locale_attributes(default_locale, available_locales, :description, row))
|
83
|
-
params["result"]["
|
83
|
+
params["result"]["taxonomies"] = row["taxonomies/ids"].split(",") if row["taxonomies/ids"].present?
|
84
84
|
params["result"]["decidim_accountability_status_id"] = row["status/id"] if row["status/id"].present?
|
85
85
|
params["result"].merge!(get_proposal_ids(row["proposal_urls"]))
|
86
86
|
params
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<% if component.manifest_name == "proposals" %>
|
2
|
+
<div class="row column">
|
3
|
+
<%= f.select :proposal_state_id,
|
4
|
+
form.proposal_states_collection,
|
5
|
+
include_blank: t(".select_state"),
|
6
|
+
label: t(".proposal_state") %>
|
7
|
+
</div>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% if component.has_taxonomy_settings? %>
|
11
|
+
<% component.available_taxonomy_filters.each do |filter| %>
|
12
|
+
<div class="row column">
|
13
|
+
<%= filter_taxonomy_items_select_field f, :taxonomies, filter %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<div class="row column">
|
19
|
+
<small class="help-text">
|
20
|
+
<% if component.manifest_name == "proposals" %>
|
21
|
+
<%= t(".new_items_proposals", count: form.filtered_items_count) %>
|
22
|
+
<% elsif component.manifest_name == "budgets" %>
|
23
|
+
<%= t(".new_items_projects", count: form.filtered_items_count) %>
|
24
|
+
<% end %>
|
25
|
+
</small>
|
26
|
+
</div>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%= form_for(@form, url: import_components_path(@accountability),
|
2
|
+
html: { class: "form form-defaults", id: "new_import_component", data: { form_url: new_import_component_path(@accountability) } },
|
3
|
+
method: :post) do |f| %>
|
4
|
+
<% if @form.origin_components.any? %>
|
5
|
+
<div class="form__wrapper">
|
6
|
+
<div class="card pt-4">
|
7
|
+
<div class="card-section">
|
8
|
+
<div class="row column">
|
9
|
+
<%= f.select :origin_component_id, @form.origin_components_collection, prompt: t(".select_component"), label: t(".origin_component_id") %>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<% if @form.origin_component %>
|
13
|
+
<%= render partial: "filters", locals: { f:, form: @form, component: @form.origin_component } %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
<div class="item__edit-sticky">
|
19
|
+
<div class="item__edit-sticky-container">
|
20
|
+
<%= f.submit t(".create"), class: "button button__sm button__secondary" %>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
<% else %>
|
24
|
+
<p><%= t(".no_components") %></p>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% add_decidim_page_title(t(".title")) %>
|
2
|
+
<div class="item_show__header">
|
3
|
+
<h1 class="item_show__header-title">
|
4
|
+
<%= t(".title") %>
|
5
|
+
</h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="item__edit item__edit-1col">
|
9
|
+
<div class="item__edit-form">
|
10
|
+
<%= render "form" %>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= append_javascript_pack_tag "decidim_accountability_admin_imports" %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<% if view == :deleted %>
|
2
|
+
<% if allowed_to? :restore, :result, trashable_deleted_resource: result %>
|
3
|
+
<%= icon_link_to "refresh-line", url_for(action: :restore, id: result, controller: "results"), t("decidim.admin.actions.restore"), method: :patch, class: "action-icon--restore" %>
|
4
|
+
<% end %>
|
5
|
+
<% else %>
|
6
|
+
<% if allowed_to? :update, :result, result: result %>
|
7
|
+
<%= icon_link_to "pencil-line", edit_result_path(result), t("actions.edit", scope: "decidim.accountability"), class: "action-icon--edit" %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% if allowed_to? :create_children, :result, result: result %>
|
11
|
+
<%= icon_link_to "add-line", results_path(parent_id: result.id), t("actions.new_result", scope: "decidim.accountability"), class: "action-icon--plus" %>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<% if allowed_to? :update, :result, result: result %>
|
15
|
+
<%= icon_link_to "time-line", result_timeline_entries_path(result), t("actions.timeline_entries", scope: "decidim.accountability"), class: "action-icon--clock" %>
|
16
|
+
<%= icon_link_to "folder-line", result_attachment_collections_path(result), t("actions.attachment_collections", scope: "decidim.accountability"), class: "action-icon--attachment_collections" %>
|
17
|
+
<%= icon_link_to "attachment-line", result_attachments_path(result), t("actions.attachments", scope: "decidim.accountability"), class: "action-icon--attachments" %>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<%= icon_link_to "eye-line", resource_locator(result).path, t("actions.preview", scope: "decidim.accountability"), class: "action-icon--preview", target: :blank, data: { "external-link": false } %>
|
21
|
+
|
22
|
+
<%= resource_permissions_link(result) %>
|
23
|
+
|
24
|
+
<% if allowed_to? :soft_delete, :result, trashable_deleted_resource: result %>
|
25
|
+
<%= icon_link_to "delete-bin-line", soft_delete_result_path(result), t("actions.soft_delete", scope: "decidim.admin"), method: :patch, class: "action-icon--delete", data: { confirm: t("actions.confirm_delete_result", scope: "decidim.accountability") } %>
|
26
|
+
<% else %>
|
27
|
+
<%= icon "delete-bin-line", class: "action-icon action-icon--disabled", role: "img", aria_label: t("actions.soft_delete", scope: "decidim.admin") %>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
@@ -18,15 +18,14 @@
|
|
18
18
|
|
19
19
|
<% else %>
|
20
20
|
|
21
|
-
<% if
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
<div class="row column">
|
28
|
-
<%= form.categories_select :decidim_category_id, current_participatory_space.categories, include_blank: true, disable_parents: false %>
|
21
|
+
<% if @form.taxonomy_filters&.any? %>
|
22
|
+
<% @form.taxonomy_filters.each do |filter| %>
|
23
|
+
<div class="row column">
|
24
|
+
<%= filter_taxonomy_items_select_field form, :taxonomies, filter %>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
29
27
|
</div>
|
28
|
+
<% end %>
|
30
29
|
|
31
30
|
<% end %>
|
32
31
|
|
@@ -40,6 +39,14 @@
|
|
40
39
|
</div>
|
41
40
|
</div>
|
42
41
|
|
42
|
+
<% if @form.geocoding_enabled? %>
|
43
|
+
<div class="row">
|
44
|
+
<div class="columns">
|
45
|
+
<%= form.geocoding_field(:address) %>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
<% end %>
|
49
|
+
|
43
50
|
<div class="row">
|
44
51
|
<div class="columns">
|
45
52
|
<%= form.select :decidim_accountability_status_id, statuses.map { |status| [translated_attribute(status.name), status.id, { "data-progress" => status.progress }] }, include_blank: true %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<tr data-id="<%= result.id %>">
|
2
|
+
<td>
|
3
|
+
<%= check_box_tag "result_ids_s[]", result.id, false, data: { result_id: result.id, result_checkbox: true } %><br>
|
4
|
+
</td>
|
5
|
+
<td>
|
6
|
+
<%= result.id %><br>
|
7
|
+
</td>
|
8
|
+
<td class="!text-left">
|
9
|
+
<% if result.parent_id.nil? %>
|
10
|
+
<%= link_to translated_attribute(result.title), results_path(parent_id: result.id) %><br>
|
11
|
+
<% else %>
|
12
|
+
<%= translated_attribute(result.title) %>
|
13
|
+
<% end %>
|
14
|
+
</td>
|
15
|
+
<td>
|
16
|
+
<%= result.taxonomies.map { |taxonomy| decidim_sanitize_translated(taxonomy.name) }.join(", ") %>
|
17
|
+
</td>
|
18
|
+
<td>
|
19
|
+
<% if result.status %>
|
20
|
+
<%= translated_attribute result.status.name %>
|
21
|
+
<% end %>
|
22
|
+
</td>
|
23
|
+
<td>
|
24
|
+
<%= result.progress&.to_i %>
|
25
|
+
</td>
|
26
|
+
<td>
|
27
|
+
<%= l result.created_at, format: :decidim_short %>
|
28
|
+
</td>
|
29
|
+
<td class="table-list__actions">
|
30
|
+
<%= render partial: "decidim/accountability/admin/results/actions", locals: { result:, view: } %>
|
31
|
+
</td>
|
32
|
+
</tr>
|