decidim-stratified_sortitions 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE-AGPLv3.txt +661 -0
- data/README.md +91 -0
- data/Rakefile +42 -0
- data/app/cells/decidim/stratified_sortitions/stratified_sortition_cell.rb +21 -0
- data/app/cells/decidim/stratified_sortitions/stratified_sortition_l_cell.rb +22 -0
- data/app/cells/decidim/stratified_sortitions/stratified_sortition_metadata_cell.rb +63 -0
- data/app/commands/decidim/stratified_sortitions/admin/create_stratified_sortition.rb +84 -0
- data/app/commands/decidim/stratified_sortitions/admin/destroy_stratified_sortition.rb +49 -0
- data/app/commands/decidim/stratified_sortitions/admin/duplicate_stratified_sortition.rb +74 -0
- data/app/commands/decidim/stratified_sortitions/admin/import_sample.rb +40 -0
- data/app/commands/decidim/stratified_sortitions/admin/remove_uploaded_samples.rb +53 -0
- data/app/commands/decidim/stratified_sortitions/admin/update_stratified_sortition.rb +174 -0
- data/app/controllers/concerns/decidim/stratified_sortitions/orderable_stratified_sortitions.rb +37 -0
- data/app/controllers/concerns/decidim/stratified_sortitions/strata_charts_data.rb +91 -0
- data/app/controllers/decidim/stratified_sortitions/admin/application_controller.rb +19 -0
- data/app/controllers/decidim/stratified_sortitions/admin/samples_controller.rb +143 -0
- data/app/controllers/decidim/stratified_sortitions/admin/stratified_sortitions_controller.rb +235 -0
- data/app/controllers/decidim/stratified_sortitions/application_controller.rb +13 -0
- data/app/controllers/decidim/stratified_sortitions/charts_pdf_controller_helper.rb +17 -0
- data/app/controllers/decidim/stratified_sortitions/stratified_sortitions_controller.rb +61 -0
- data/app/forms/decidim/stratified_sortitions/admin/sample_upload_form.rb +15 -0
- data/app/forms/decidim/stratified_sortitions/admin/stratified_sortitions_form.rb +155 -0
- data/app/forms/decidim/stratified_sortitions/admin/stratum_form.rb +69 -0
- data/app/forms/decidim/stratified_sortitions/admin/substratum_form.rb +26 -0
- data/app/helpers/decidim/stratified_sortitions/admin/stratified_sortitions_helper.rb +18 -0
- data/app/helpers/decidim/stratified_sortitions/application_helper.rb +85 -0
- data/app/helpers/decidim/stratified_sortitions/charts_pdf_helper.rb +73 -0
- data/app/helpers/decidim/stratified_sortitions/stratified_sortition_cells_helper.rb +56 -0
- data/app/javascript/channels/sample_import_progress.js +12 -0
- data/app/jobs/decidim/stratified_sortitions/admin/execute_sortition_job.rb +21 -0
- data/app/jobs/decidim/stratified_sortitions/admin/import_sample_job.rb +170 -0
- data/app/jobs/decidim/stratified_sortitions/admin/remove_samples_job.rb +19 -0
- data/app/jobs/decidim/stratified_sortitions/admin/sortition_results_export_job.rb +28 -0
- data/app/mailers/decidim/stratified_sortitions/admin/import_mailer.rb +26 -0
- data/app/models/decidim/stratified_sortitions/application_record.rb +9 -0
- data/app/models/decidim/stratified_sortitions/panel_portfolio.rb +165 -0
- data/app/models/decidim/stratified_sortitions/sample_import.rb +14 -0
- data/app/models/decidim/stratified_sortitions/sample_participant.rb +12 -0
- data/app/models/decidim/stratified_sortitions/sample_participant_stratum.rb +11 -0
- data/app/models/decidim/stratified_sortitions/stratified_sortition.rb +74 -0
- data/app/models/decidim/stratified_sortitions/stratum.rb +22 -0
- data/app/models/decidim/stratified_sortitions/substratum.rb +19 -0
- data/app/packs/entrypoints/decidim_stratified_sortitions.js +10 -0
- data/app/packs/entrypoints/decidim_stratified_sortitions_admin.js +9 -0
- data/app/packs/entrypoints/decidim_stratified_sortitions_admin.scss +1 -0
- data/app/packs/images/decidim/stratified_sortitions/icon.svg +1 -0
- data/app/packs/src/decidim/stratified_sortitions/application.js +3 -0
- data/app/packs/src/decidim/stratified_sortitions/results_tabs.js +59 -0
- data/app/packs/src/decidim/stratified_sortitions/stratum_fields.js +302 -0
- data/app/packs/src/decidim/stratified_sortitions/substratum_fields.js +165 -0
- data/app/packs/src/decidim/stratified_sortitions/upload_sample.js +16 -0
- data/app/packs/stylesheets/decidim/stratified_sortitions/admin/stratified_sortitions.scss +210 -0
- data/app/packs/stylesheets/decidim/stratified_sortitions/charts_pdf.scss +148 -0
- data/app/packs/stylesheets/stratified_sortitions.scss +56 -0
- data/app/permissions/decidim/stratified_sortitions/admin/permissions.rb +74 -0
- data/app/permissions/decidim/stratified_sortitions/permissions.rb +23 -0
- data/app/presenters/decidim/stratified_sortitions/admin_log/stratified_sortition_presenter.rb +35 -0
- data/app/queries/decidim/stratified_sortitions/filtered_stratified_sortitions.rb +39 -0
- data/app/serializers/decidim/stratified_sortitions/sortition_result_serializer.rb +116 -0
- data/app/services/decidim/stratified_sortitions/charts_pdf_generator.rb +96 -0
- data/app/services/decidim/stratified_sortitions/fair_sortition_service.rb +247 -0
- data/app/services/decidim/stratified_sortitions/leximin/constraint_builder.rb +180 -0
- data/app/services/decidim/stratified_sortitions/leximin/distribution_solver.rb +217 -0
- data/app/services/decidim/stratified_sortitions/leximin/feasibility_checker.rb +222 -0
- data/app/services/decidim/stratified_sortitions/leximin/panel_generator.rb +149 -0
- data/app/services/decidim/stratified_sortitions/leximin/panel_sampler.rb +125 -0
- data/app/services/decidim/stratified_sortitions/leximin_selector.rb +136 -0
- data/app/services/decidim/stratified_sortitions/sortition_results_exporter.rb +161 -0
- data/app/views/decidim/admin/components/index.html.erb +54 -0
- data/app/views/decidim/stratified_sortitions/admin/import_mailer/import.html.erb +22 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_confirm_execute_modal.html.erb +19 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_confirm_participants_modal.html.erb +20 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_form.html.erb +55 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_navigation_menu.html.erb +10 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_strata.html.erb +22 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_stratum.html.erb +75 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_substrata.html.erb +34 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_substratum.html.erb +54 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/edit.html.erb +21 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/execute.html.erb +155 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/export_charts_pdf.html.erb +38 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/index.html.erb +75 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/new.html.erb +21 -0
- data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/upload_sample.html.erb +117 -0
- data/app/views/decidim/stratified_sortitions/shared/_strata_charts.html.erb +21 -0
- data/app/views/decidim/stratified_sortitions/stratified_sortitions/_results_count.html.erb +15 -0
- data/app/views/decidim/stratified_sortitions/stratified_sortitions/_stratified_sortition.html.erb +1 -0
- data/app/views/decidim/stratified_sortitions/stratified_sortitions/_stratified_sortitions.html.erb +13 -0
- data/app/views/decidim/stratified_sortitions/stratified_sortitions/_tags.html.erb +9 -0
- data/app/views/decidim/stratified_sortitions/stratified_sortitions/index.html.erb +22 -0
- data/app/views/decidim/stratified_sortitions/stratified_sortitions/index.js.erb +5 -0
- data/app/views/decidim/stratified_sortitions/stratified_sortitions/show.html.erb +142 -0
- data/app/views/layouts/decidim/admin/_sidebar_menu.html.erb +45 -0
- data/app/views/layouts/decidim/stratified_sortitions/charts_pdf.html.erb +14 -0
- data/config/assets.rb +24 -0
- data/config/locales/ca.yml +361 -0
- data/config/locales/en.yml +360 -0
- data/config/locales/es.yml +360 -0
- data/config/locales/oc.yml +2 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20251023103900_create_decidim_stratified_sortitions_stratified_sortitions.rb +18 -0
- data/db/migrate/20251104120000_create_stratified_sortitions_strata_and_substrata.decidim_stratified_sortitions.rb +27 -0
- data/db/migrate/20251219120000_create_sample_imports.rb +17 -0
- data/db/migrate/20251219120100_create_sample_participants.rb +19 -0
- data/db/migrate/20251219120200_create_sample_participant_strata.rb +16 -0
- data/db/migrate/20251230130000_change_value_to_text_in_substrata.rb +11 -0
- data/db/migrate/20260102114744_add_status_to_stratified_sortitions.rb +11 -0
- data/db/migrate/20260109105643_allow_null_value_in_substrata.rb +10 -0
- data/db/migrate/20260113121726_add_position_to_strata_and_substrata.rb +8 -0
- data/db/migrate/20260127100000_rename_weighing_to_max_quota_percentage.rb +12 -0
- data/db/migrate/20260127120000_create_panel_portfolios.rb +46 -0
- data/db/migrate/20260518000000_add_foreign_key_to_stratified_sortitions_component.rb +10 -0
- data/db/migrate/20260521000000_add_cascade_to_stratified_sortitions_foreign_keys.rb +64 -0
- data/db/migrate/20260616000000_add_execution_error_to_stratified_sortitions.rb +11 -0
- data/lib/decidim/stratified_sortitions/admin.rb +10 -0
- data/lib/decidim/stratified_sortitions/admin_engine.rb +49 -0
- data/lib/decidim/stratified_sortitions/component.rb +41 -0
- data/lib/decidim/stratified_sortitions/engine.rb +34 -0
- data/lib/decidim/stratified_sortitions/seeds.rb +24 -0
- data/lib/decidim/stratified_sortitions/test/factories.rb +80 -0
- data/lib/decidim/stratified_sortitions/version.rb +13 -0
- data/lib/decidim/stratified_sortitions.rb +29 -0
- metadata +222 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import AutoButtonsByPositionComponent from "src/decidim/admin/auto_buttons_by_position.component"
|
|
2
|
+
import AutoLabelByPositionComponent from "src/decidim/admin/auto_label_by_position.component"
|
|
3
|
+
import createSortList from "src/decidim/admin/sort_list.component"
|
|
4
|
+
import createDynamicFields from "src/decidim/admin/dynamic_fields.component"
|
|
5
|
+
|
|
6
|
+
const fieldSelector = ".stratified-sortition-substratum";
|
|
7
|
+
|
|
8
|
+
const componentsByWrapper = new Map();
|
|
9
|
+
|
|
10
|
+
const hideDeletedSubstratum = ($target) => {
|
|
11
|
+
const inputDeleted = $target.find("input[name$=\\[deleted\\]]").val();
|
|
12
|
+
|
|
13
|
+
if (inputDeleted === "true") {
|
|
14
|
+
$target.addClass("hidden");
|
|
15
|
+
$target.hide();
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getWrapperForElement = (element) => {
|
|
20
|
+
return $(element).closest(".stratified-sortition-substrata")[0];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const runComponentsForWrapper = (wrapper) => {
|
|
24
|
+
const components = componentsByWrapper.get(wrapper);
|
|
25
|
+
if (components) {
|
|
26
|
+
components.autoLabelByPosition.run();
|
|
27
|
+
components.autoButtonsByPosition.run();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const initializeSubstrataWrapper = (wrapperEl) => {
|
|
32
|
+
if (!wrapperEl) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (componentsByWrapper.has(wrapperEl)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const $wrapper = $(wrapperEl);
|
|
41
|
+
let $container = $wrapper.find(".stratified-sortition-substrata-list");
|
|
42
|
+
|
|
43
|
+
if ($container.length === 0) {
|
|
44
|
+
$container = $('<div class="stratified-sortition-substrata-list"></div>');
|
|
45
|
+
const $template = $wrapper.find("script.decidim-template");
|
|
46
|
+
if ($template.length) {
|
|
47
|
+
$template.after($container);
|
|
48
|
+
} else {
|
|
49
|
+
$wrapper.append($container);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const autoLabelByPosition = new AutoLabelByPositionComponent({
|
|
54
|
+
listSelector: `#${wrapperEl.id} .stratified-sortition-substratum:not(.hidden)`,
|
|
55
|
+
labelSelector: ".card-title span:first",
|
|
56
|
+
onPositionComputed: (el, idx) => {
|
|
57
|
+
$(el).find("input[name$=\\[position\\]]").val(idx);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const autoButtonsByPosition = new AutoButtonsByPositionComponent({
|
|
62
|
+
listSelector: `#${wrapperEl.id} .stratified-sortition-substratum:not(.hidden)`,
|
|
63
|
+
hideOnFirstSelector: ".move-up-substratum",
|
|
64
|
+
hideOnLastSelector: ".move-down-substratum"
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
componentsByWrapper.set(wrapperEl, {
|
|
68
|
+
autoLabelByPosition,
|
|
69
|
+
autoButtonsByPosition
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const createSortableList = () => {
|
|
73
|
+
createSortList(`#${wrapperEl.id} .stratified-sortition-substrata-list:not(.published)`, {
|
|
74
|
+
handle: ".substratum-divider",
|
|
75
|
+
placeholder: '<div style="border-style: dashed; border-color: #000"></div>',
|
|
76
|
+
forcePlaceholderSize: true,
|
|
77
|
+
onSortUpdate: () => { autoLabelByPosition.run() }
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
createSortableList();
|
|
82
|
+
|
|
83
|
+
$container.find(fieldSelector).each((idx, el) => {
|
|
84
|
+
const $target = $(el);
|
|
85
|
+
hideDeletedSubstratum($target);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
autoLabelByPosition.run();
|
|
89
|
+
autoButtonsByPosition.run();
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
$(() => {
|
|
93
|
+
$(".stratified-sortition-substrata").each((idx, wrapperEl) => {
|
|
94
|
+
initializeSubstrataWrapper(wrapperEl);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
$(document).on("click", ".add-substratum", function(e) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
const wrapper = getWrapperForElement(this);
|
|
100
|
+
const $wrapper = $(wrapper);
|
|
101
|
+
const $container = wrapper.id ? $(`#${wrapper.id} .stratified-sortition-substrata-list`) : $wrapper.find(".stratified-sortition-substrata-list");
|
|
102
|
+
const $template = $wrapper.find("script.decidim-template");
|
|
103
|
+
|
|
104
|
+
if ($template.length && $container.length) {
|
|
105
|
+
const templateContent = $template.html();
|
|
106
|
+
const uniqueId = new Date().getTime();
|
|
107
|
+
const newField = templateContent.replace(/SUBSTRATUM_ID/g, uniqueId);
|
|
108
|
+
$container.append(newField);
|
|
109
|
+
|
|
110
|
+
const $stratum = $wrapper.closest(".stratified-sortition-stratum");
|
|
111
|
+
const kind = $stratum.find("select[id$='_kind']").val();
|
|
112
|
+
const $newSubstratum = $container.find(fieldSelector).last();
|
|
113
|
+
|
|
114
|
+
if (kind === "value") {
|
|
115
|
+
$newSubstratum.find(".substratum-value-field").show();
|
|
116
|
+
$newSubstratum.find(".substratum-range-field").hide();
|
|
117
|
+
} else {
|
|
118
|
+
$newSubstratum.find(".substratum-value-field").hide();
|
|
119
|
+
$newSubstratum.find(".substratum-range-field").show();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
$newSubstratum.find('[data-tabs]').each(function() {
|
|
123
|
+
new Foundation.Tabs($(this));
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
runComponentsForWrapper(wrapper);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
$(document).on("click", ".stratified-sortition-substrata .remove-substratum", function(e) {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
const wrapper = getWrapperForElement(this);
|
|
133
|
+
const $field = $(this).closest(fieldSelector);
|
|
134
|
+
|
|
135
|
+
$field.find("input[name$=\\[deleted\\]]").val("true");
|
|
136
|
+
$field.addClass("hidden");
|
|
137
|
+
$field.hide();
|
|
138
|
+
|
|
139
|
+
runComponentsForWrapper(wrapper);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
$(document).on("click", ".stratified-sortition-substrata .move-up-substratum", function(e) {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
const wrapper = getWrapperForElement(this);
|
|
145
|
+
const $field = $(this).closest(fieldSelector);
|
|
146
|
+
const $prev = $field.prevAll(fieldSelector + ":not(.hidden)").first();
|
|
147
|
+
|
|
148
|
+
if ($prev.length) {
|
|
149
|
+
$field.insertBefore($prev);
|
|
150
|
+
runComponentsForWrapper(wrapper);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
$(document).on("click", ".stratified-sortition-substrata .move-down-substratum", function(e) {
|
|
155
|
+
e.preventDefault();
|
|
156
|
+
const wrapper = getWrapperForElement(this);
|
|
157
|
+
const $field = $(this).closest(fieldSelector);
|
|
158
|
+
const $next = $field.nextAll(fieldSelector + ":not(.hidden)").first();
|
|
159
|
+
|
|
160
|
+
if ($next.length) {
|
|
161
|
+
$field.insertAfter($next);
|
|
162
|
+
runComponentsForWrapper(wrapper);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
2
|
+
const form = document.getElementById("sample-upload-form");
|
|
3
|
+
if (!form) return;
|
|
4
|
+
|
|
5
|
+
const modal = form.querySelector("[data-dialog]");
|
|
6
|
+
if (!modal) return;
|
|
7
|
+
|
|
8
|
+
const saveButton = modal.querySelector("[data-dropzone-save]");
|
|
9
|
+
if (!saveButton) return;
|
|
10
|
+
|
|
11
|
+
saveButton.addEventListener("click", () => {
|
|
12
|
+
// Allow Decidim's upload_field.js handler to run first (updateActiveUploads),
|
|
13
|
+
// then submit the form.
|
|
14
|
+
setTimeout(() => form.submit(), 100);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
.stratified_sortition_header {
|
|
2
|
+
border: 0;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.stratified_sortition_nav {
|
|
6
|
+
border-bottom: 2px solid #CCC;
|
|
7
|
+
margin-bottom: 20px;
|
|
8
|
+
overflow: visible;
|
|
9
|
+
|
|
10
|
+
.import-sample-btn {
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
gap: 0.4rem;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
min-width: 200px;
|
|
16
|
+
position: relative;
|
|
17
|
+
top: 3px;
|
|
18
|
+
border-bottom: 2px solid transparent;
|
|
19
|
+
color: #ccc;
|
|
20
|
+
fill: #ccc;
|
|
21
|
+
|
|
22
|
+
button {
|
|
23
|
+
all: unset;
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
gap: 0.4rem;
|
|
26
|
+
align-items: center;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
padding: 0.5rem 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:hover {
|
|
32
|
+
color: rgba(21, 90, 191, 0.7);
|
|
33
|
+
fill: rgba(21, 90, 191, 0.7);
|
|
34
|
+
border-bottom: 2px solid rgba(21, 90, 191, 0.7);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.active {
|
|
39
|
+
color: rgba(21, 90, 191, 1);
|
|
40
|
+
fill: rgba(21, 90, 191, 1);
|
|
41
|
+
border-bottom: 2px solid rgba(21, 90, 191, 1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
button[disabled] {
|
|
45
|
+
cursor: not-allowed !important;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.stratum-fields,
|
|
50
|
+
.substratum-fields {
|
|
51
|
+
display: flex;
|
|
52
|
+
gap: 1rem;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: space-between;
|
|
55
|
+
|
|
56
|
+
.translated-field {
|
|
57
|
+
width: 100%;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
.example-file-census-container {
|
|
63
|
+
padding:1em;
|
|
64
|
+
background:#e2e5ee;
|
|
65
|
+
|
|
66
|
+
td {
|
|
67
|
+
padding-right: 1em;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.form-upload-census-container {
|
|
72
|
+
display:flex;
|
|
73
|
+
gap:1em;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.last-census-upload {
|
|
77
|
+
color: #6b7280;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.chart-row {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-wrap: wrap;
|
|
83
|
+
margin-top: 1em;
|
|
84
|
+
gap: 1em;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.chart-col {
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
margin-top: 1em;
|
|
91
|
+
min-width: 0;
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.charts-column {
|
|
96
|
+
flex: 1 1 0%;
|
|
97
|
+
min-width: 0;
|
|
98
|
+
overflow: hidden;
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
align-items: center;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.target {
|
|
105
|
+
border-left: 1px solid #6B7280CC;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@media (max-width: 900px) {
|
|
109
|
+
.chart-row {
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
gap: 2em;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.charts-column {
|
|
115
|
+
flex: 1 1 auto;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.target {
|
|
119
|
+
border-left: none;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.stratified-sortition-stratum {
|
|
124
|
+
button[aria-expanded="true"] {
|
|
125
|
+
.icon-collapse {
|
|
126
|
+
@apply block;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.icon-expand {
|
|
130
|
+
@apply hidden;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
button[aria-expanded="false"] {
|
|
135
|
+
.icon-collapse {
|
|
136
|
+
@apply hidden;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.icon-expand {
|
|
140
|
+
@apply block;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
input[readonly] {
|
|
146
|
+
cursor: not-allowed;
|
|
147
|
+
background-color: #f3f4f6;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.actions-container {
|
|
151
|
+
justify-content: space-between;
|
|
152
|
+
|
|
153
|
+
.export-buttons {
|
|
154
|
+
display: flex;
|
|
155
|
+
gap: 0.5rem;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.results-sub-nav {
|
|
160
|
+
border-bottom: 2px solid #CCC;
|
|
161
|
+
margin-bottom: 20px;
|
|
162
|
+
margin-top: 8px;
|
|
163
|
+
overflow: visible;
|
|
164
|
+
|
|
165
|
+
.results-tab {
|
|
166
|
+
display: inline-flex;
|
|
167
|
+
gap: 0.4rem;
|
|
168
|
+
align-items: center;
|
|
169
|
+
justify-content: center;
|
|
170
|
+
padding: 0.5rem 1rem;
|
|
171
|
+
position: relative;
|
|
172
|
+
top: 2px;
|
|
173
|
+
border: none;
|
|
174
|
+
border-bottom: 2px solid transparent;
|
|
175
|
+
background: none;
|
|
176
|
+
color: #999;
|
|
177
|
+
fill: #999;
|
|
178
|
+
cursor: pointer;
|
|
179
|
+
font-size: 0.9rem;
|
|
180
|
+
font-weight: 500;
|
|
181
|
+
|
|
182
|
+
&:hover {
|
|
183
|
+
color: rgba(21, 90, 191, 0.7);
|
|
184
|
+
fill: rgba(21, 90, 191, 0.7);
|
|
185
|
+
border-bottom: 2px solid rgba(21, 90, 191, 0.7);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&.active {
|
|
189
|
+
color: rgba(21, 90, 191, 1);
|
|
190
|
+
fill: rgba(21, 90, 191, 1);
|
|
191
|
+
border-bottom: 2px solid rgba(21, 90, 191, 1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.upload-census-btn {
|
|
197
|
+
margin: 0 !important;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.upload-disabled-wrapper {
|
|
201
|
+
cursor: not-allowed;
|
|
202
|
+
width: auto;
|
|
203
|
+
|
|
204
|
+
.upload-census-btn {
|
|
205
|
+
pointer-events: none;
|
|
206
|
+
border: 1px solid #3e4c5c;
|
|
207
|
+
background-color: #efefef;
|
|
208
|
+
color: #3e4c5c;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/* =========================================================
|
|
2
|
+
BASE
|
|
3
|
+
========================================================= */
|
|
4
|
+
* {
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
body {
|
|
11
|
+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
12
|
+
font-size: 12px;
|
|
13
|
+
color: #333;
|
|
14
|
+
padding: 20px 25px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* =========================================================
|
|
18
|
+
TYPOGRAPHY
|
|
19
|
+
========================================================= */
|
|
20
|
+
h1 {
|
|
21
|
+
font-size: 16px;
|
|
22
|
+
text-align: center;
|
|
23
|
+
margin-bottom: 2px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
h2 {
|
|
27
|
+
font-size: 11px;
|
|
28
|
+
text-align: center;
|
|
29
|
+
color: #666;
|
|
30
|
+
font-style: italic;
|
|
31
|
+
margin-bottom: 8px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h3 {
|
|
35
|
+
font-size: 11px;
|
|
36
|
+
margin-bottom: 4px;
|
|
37
|
+
text-transform: uppercase;
|
|
38
|
+
color: #333;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
hr {
|
|
42
|
+
border: none;
|
|
43
|
+
border-top: 1px solid #ccc;
|
|
44
|
+
margin: 6px 0 8px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* =========================================================
|
|
48
|
+
HEADER INFO BLOCK
|
|
49
|
+
========================================================= */
|
|
50
|
+
.info {
|
|
51
|
+
font-size: 9px;
|
|
52
|
+
color: #555;
|
|
53
|
+
line-height: 1.5;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.info p {
|
|
57
|
+
margin: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* =========================================================
|
|
61
|
+
COLUMN HEADERS
|
|
62
|
+
========================================================= */
|
|
63
|
+
.column-headers {
|
|
64
|
+
width: 100%;
|
|
65
|
+
margin-top: 12px;
|
|
66
|
+
border-bottom: 1px solid #ddd;
|
|
67
|
+
padding-bottom: 4px;
|
|
68
|
+
margin-bottom: 8px;
|
|
69
|
+
border-collapse: collapse;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.column-headers .col-header {
|
|
73
|
+
width: 33.33%;
|
|
74
|
+
text-align: center;
|
|
75
|
+
font-weight: bold;
|
|
76
|
+
font-size: 10px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* =========================================================
|
|
80
|
+
STRATUM SECTIONS
|
|
81
|
+
========================================================= */
|
|
82
|
+
.stratum-section {
|
|
83
|
+
margin-bottom: 10px;
|
|
84
|
+
page-break-inside: avoid;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.stratum-title {
|
|
88
|
+
font-size: 11px;
|
|
89
|
+
font-weight: bold;
|
|
90
|
+
text-transform: uppercase;
|
|
91
|
+
color: #333;
|
|
92
|
+
margin-bottom: 4px;
|
|
93
|
+
padding-left: 2px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* =========================================================
|
|
97
|
+
CHARTS TABLE (3-column layout)
|
|
98
|
+
========================================================= */
|
|
99
|
+
.charts-table {
|
|
100
|
+
width: 100%;
|
|
101
|
+
border-collapse: collapse;
|
|
102
|
+
table-layout: fixed;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.chart-cell {
|
|
106
|
+
width: 33.33%;
|
|
107
|
+
text-align: center;
|
|
108
|
+
padding: 4px 8px;
|
|
109
|
+
vertical-align: top;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.chart-cell + .chart-cell {
|
|
113
|
+
border-left: 1px solid #ddd;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* =========================================================
|
|
117
|
+
LEGEND
|
|
118
|
+
========================================================= */
|
|
119
|
+
.legend {
|
|
120
|
+
font-size: 8px;
|
|
121
|
+
text-align: center;
|
|
122
|
+
display: block;
|
|
123
|
+
margin-top: 4px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.legend-item {
|
|
127
|
+
margin-bottom: 4px;
|
|
128
|
+
margin-right: 8px;
|
|
129
|
+
text-align: left;
|
|
130
|
+
display: inline-block;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.legend-color {
|
|
134
|
+
width: 9px;
|
|
135
|
+
height: 9px;
|
|
136
|
+
display: inline-block;
|
|
137
|
+
margin-right: 4px;
|
|
138
|
+
vertical-align: middle;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* =========================================================
|
|
142
|
+
NO DATA STATE
|
|
143
|
+
========================================================= */
|
|
144
|
+
.no-data {
|
|
145
|
+
color: #999;
|
|
146
|
+
font-size: 9px;
|
|
147
|
+
padding: 20px 0;
|
|
148
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.stratified-sortition {
|
|
2
|
+
&__aside-element {
|
|
3
|
+
&-item {
|
|
4
|
+
@apply border-b border-gray-3 py-4 first:pt-0 last:pb-0 last:border-b-0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
&-item__title {
|
|
8
|
+
@apply text-sm block text-gray-2 mb-1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&-item__text {
|
|
12
|
+
@apply text-md block font-semibold text-gray-2;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&-item__numbers {
|
|
16
|
+
@apply text-md block text-gray-2;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__aside__count-number {
|
|
21
|
+
@apply text-5xl block text-center text-gray-2 font-bold;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&__aside__count-text {
|
|
25
|
+
@apply text-gray-2 text-sm block text-center;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
a.stratified-sortition__aside-element-item__title {
|
|
30
|
+
@apply text-secondary underline;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.chart-col {
|
|
34
|
+
margin-bottom: 50px;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.target {
|
|
40
|
+
border-left: 1px solid #6B7280CC;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.public-charts {
|
|
44
|
+
flex-wrap: wrap;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.charts-column {
|
|
48
|
+
flex: 1 1 0%;
|
|
49
|
+
min-width: 0;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
padding: 1rem;
|
|
52
|
+
|
|
53
|
+
h3 {
|
|
54
|
+
text-align: center;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module StratifiedSortitions
|
|
5
|
+
module Admin
|
|
6
|
+
class Permissions < Decidim::DefaultPermissions
|
|
7
|
+
def permissions
|
|
8
|
+
# The public part needs to be implemented yet
|
|
9
|
+
return permission_action if permission_action.scope != :admin
|
|
10
|
+
|
|
11
|
+
allow! if permission_action.subject == :stratified_sortitions && read_permission_action?
|
|
12
|
+
|
|
13
|
+
allow! if permission_action.subject == :stratified_sortition && create_permission_action?
|
|
14
|
+
|
|
15
|
+
allow! if permission_action.subject == :stratified_sortition && edit_permission_action?
|
|
16
|
+
|
|
17
|
+
allow! if permission_action.subject == :stratified_sortition && destroy_permission_action?
|
|
18
|
+
|
|
19
|
+
allow! if permission_action.subject == :stratified_sortition && publish_permission_action?
|
|
20
|
+
|
|
21
|
+
allow! if permission_action.subject == :stratified_sortition && duplicate_permission_action?
|
|
22
|
+
|
|
23
|
+
allow! if permission_action.subject == :stratified_sortition && export_permission_action?
|
|
24
|
+
|
|
25
|
+
allow! if permission_action.subject == :stratified_sortition && upload_sample_permission_action?
|
|
26
|
+
|
|
27
|
+
permission_action
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def read_permission_action?
|
|
33
|
+
permission_action.action == :read
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def create_permission_action?
|
|
37
|
+
permission_action.action == :create
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def edit_permission_action?
|
|
41
|
+
permission_action.action == :edit
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def update_permission_action?
|
|
45
|
+
permission_action.action == :update
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def destroy_permission_action?
|
|
49
|
+
permission_action.action == :destroy
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def publish_permission_action?
|
|
53
|
+
permission_action.action == :publish
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def export_permission_action?
|
|
57
|
+
permission_action.action == :export_surveys
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def upload_sample_permission_action?
|
|
61
|
+
permission_action.action == :upload_sample
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def duplicate_permission_action?
|
|
65
|
+
permission_action.action == :duplicate
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def stratified_sortition
|
|
69
|
+
@stratified_sortition ||= context.fetch(:stratified_sortition, nil)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module StratifiedSortitions
|
|
5
|
+
class Permissions < Decidim::DefaultPermissions
|
|
6
|
+
def permissions
|
|
7
|
+
return permission_action unless user
|
|
8
|
+
# Delegate the admin permission checks to the admin permissions class
|
|
9
|
+
return Decidim::StratifiedSortitions::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin
|
|
10
|
+
|
|
11
|
+
allow! if permission_action.subject == :stratified_sortition
|
|
12
|
+
|
|
13
|
+
permission_action
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def stratified_sortition
|
|
19
|
+
@stratified_sortition ||= context.fetch(:stratified_sortition, nil)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|