decidim-core 0.31.7 → 0.31.9

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.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/address_cell.rb +7 -3
  3. data/app/cells/decidim/card_metadata_cell.rb +3 -1
  4. data/app/cells/decidim/content_blocks/participatory_space_main_data/title.erb +1 -14
  5. data/app/cells/decidim/date_range/show.erb +6 -6
  6. data/app/cells/decidim/date_range_cell.rb +7 -2
  7. data/app/cells/decidim/following_cell.rb +1 -1
  8. data/app/cells/decidim/nav_links/show.erb +3 -1
  9. data/app/cells/decidim/participatory_space_private_user/show.erb +1 -1
  10. data/app/cells/decidim/share_text_widget/modal.erb +1 -0
  11. data/app/cells/decidim/share_widget/modal.erb +1 -0
  12. data/app/cells/decidim/share_widget/qr_code_modal.erb +2 -4
  13. data/app/commands/decidim/create_follow.rb +3 -7
  14. data/app/commands/decidim/create_omniauth_registration.rb +19 -7
  15. data/app/commands/decidim/create_user_report.rb +1 -1
  16. data/app/commands/decidim/destroy_account.rb +6 -6
  17. data/app/commands/decidim/destroy_ephemeral_user.rb +2 -0
  18. data/app/commands/decidim/invite_user.rb +1 -1
  19. data/app/commands/decidim/multiple_attachments_methods.rb +17 -3
  20. data/app/commands/decidim/update_resources_taxonomies.rb +2 -1
  21. data/app/controllers/concerns/decidim/devise_authentication_methods.rb +4 -0
  22. data/app/controllers/concerns/decidim/devise_controllers.rb +4 -0
  23. data/app/controllers/concerns/decidim/direct_upload.rb +12 -6
  24. data/app/controllers/concerns/decidim/disable_redirection_to_external_host.rb +2 -0
  25. data/app/controllers/concerns/decidim/filter_resource.rb +2 -0
  26. data/app/controllers/concerns/decidim/impersonate_users.rb +4 -4
  27. data/app/controllers/concerns/decidim/locale_switcher.rb +62 -11
  28. data/app/controllers/concerns/decidim/needs_organization.rb +15 -0
  29. data/app/controllers/concerns/decidim/needs_permission.rb +22 -10
  30. data/app/controllers/concerns/decidim/onboarding_action_methods.rb +2 -0
  31. data/app/controllers/concerns/decidim/paginable.rb +7 -3
  32. data/app/controllers/concerns/decidim/payload_info.rb +2 -0
  33. data/app/controllers/concerns/decidim/resource_versions_concern.rb +14 -0
  34. data/app/controllers/decidim/amendments_controller.rb +34 -6
  35. data/app/controllers/decidim/application_controller.rb +2 -6
  36. data/app/controllers/decidim/authorization_modals_controller.rb +3 -1
  37. data/app/controllers/decidim/components/base_controller.rb +2 -0
  38. data/app/controllers/decidim/devise/passwords_controller.rb +8 -0
  39. data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +10 -4
  40. data/app/controllers/decidim/doorkeeper/credentials_controller.rb +6 -1
  41. data/app/controllers/decidim/favicon_controller.rb +9 -0
  42. data/app/controllers/decidim/free_resource_authorization_modals_controller.rb +2 -0
  43. data/app/controllers/decidim/gamification/badges_controller.rb +2 -0
  44. data/app/controllers/decidim/homepage_controller.rb +4 -1
  45. data/app/controllers/decidim/likes_controller.rb +1 -1
  46. data/app/controllers/decidim/links_controller.rb +2 -0
  47. data/app/controllers/decidim/manifests_controller.rb +2 -0
  48. data/app/controllers/decidim/messaging/conversations_controller.rb +11 -5
  49. data/app/controllers/decidim/newsletters_controller.rb +4 -0
  50. data/app/controllers/decidim/notifications_subscriptions_controller.rb +4 -0
  51. data/app/controllers/decidim/offline_controller.rb +5 -1
  52. data/app/controllers/decidim/open_data_controller.rb +5 -1
  53. data/app/controllers/decidim/pages_controller.rb +31 -3
  54. data/app/controllers/decidim/private_downloads_controller.rb +2 -0
  55. data/app/controllers/decidim/profiles_controller.rb +11 -1
  56. data/app/controllers/decidim/qr_controller.rb +3 -1
  57. data/app/controllers/decidim/resource_autocomplete_controller.rb +2 -0
  58. data/app/controllers/decidim/searches_controller.rb +2 -0
  59. data/app/controllers/decidim/short_links_controller.rb +4 -0
  60. data/app/controllers/decidim/static_map_controller.rb +2 -0
  61. data/app/controllers/decidim/timeouts_controller.rb +4 -0
  62. data/app/controllers/decidim/tos_controller.rb +2 -0
  63. data/app/controllers/decidim/upload_validations_controller.rb +4 -2
  64. data/app/controllers/decidim/user_activities_controller.rb +2 -0
  65. data/app/forms/decidim/upload_validation_form.rb +16 -10
  66. data/app/helpers/concerns/decidim/user_role_checker.rb +35 -10
  67. data/app/helpers/decidim/cells_paginate_helper.rb +0 -5
  68. data/app/helpers/decidim/layout_helper.rb +1 -0
  69. data/app/helpers/decidim/orders_helper.rb +8 -6
  70. data/app/helpers/decidim/paginate_helper.rb +27 -2
  71. data/app/helpers/decidim/sanitize_helper.rb +11 -1
  72. data/app/helpers/decidim/url_helper.rb +35 -0
  73. data/app/jobs/decidim/application_job.rb +4 -0
  74. data/app/jobs/decidim/open_data_job.rb +21 -5
  75. data/app/models/decidim/action_log.rb +7 -1
  76. data/app/models/decidim/authorization.rb +24 -0
  77. data/app/models/decidim/component.rb +10 -0
  78. data/app/models/decidim/like.rb +1 -1
  79. data/app/models/decidim/oauth_application.rb +1 -0
  80. data/app/models/decidim/user.rb +1 -0
  81. data/app/models/decidim/user_base_entity.rb +1 -1
  82. data/app/packs/src/decidim/callout.js +10 -0
  83. data/app/packs/src/decidim/callout.test.js +32 -0
  84. data/app/packs/src/decidim/controllers/accordion/accordion.test.js +64 -0
  85. data/app/packs/src/decidim/controllers/accordion/controller.js +43 -0
  86. data/app/packs/src/decidim/datepicker/datepicker_functions.js +54 -30
  87. data/app/packs/src/decidim/datepicker/form_datepicker.js +18 -2
  88. data/app/packs/src/decidim/datepicker/generate_datepicker.js +16 -8
  89. data/app/packs/src/decidim/datepicker/generate_timepicker.js +5 -3
  90. data/app/packs/src/decidim/datepicker/test/date.test.js +8 -0
  91. data/app/packs/src/decidim/datepicker/test/time.test.js +39 -24
  92. data/app/packs/src/decidim/utilities/dom.js +2 -2
  93. data/app/packs/stylesheets/decidim/_content_blocks.scss +4 -10
  94. data/app/packs/stylesheets/decidim/_conversations.scss +0 -8
  95. data/app/packs/stylesheets/decidim/_datepicker.scss +3 -3
  96. data/app/packs/stylesheets/decidim/_modal.scss +16 -8
  97. data/app/packs/stylesheets/decidim/_modal_share.scss +0 -22
  98. data/app/packs/stylesheets/decidim/_participatory_spaces.scss +11 -1
  99. data/app/packs/stylesheets/decidim/_rich_text.scss +12 -9
  100. data/app/packs/stylesheets/decidim/_spinner.scss +16 -0
  101. data/app/packs/stylesheets/decidim/_tom_select.scss +1 -1
  102. data/app/packs/stylesheets/decidim/_typography.scss +5 -2
  103. data/app/packs/stylesheets/decidim/legacy/email.scss +0 -5
  104. data/app/permissions/decidim/permissions.rb +20 -0
  105. data/app/presenters/decidim/admin_log/component_presenter.rb +1 -1
  106. data/app/presenters/decidim/log/base_presenter.rb +20 -2
  107. data/app/presenters/decidim/log/user_presenter.rb +2 -2
  108. data/app/serializers/decidim/exporters/open_data_blocked_user_serializer.rb +11 -2
  109. data/app/serializers/decidim/exporters/open_data_moderation_serializer.rb +25 -1
  110. data/app/services/decidim/action_logger.rb +97 -29
  111. data/app/services/decidim/svg_content_validator.rb +889 -0
  112. data/app/uploaders/decidim/application_uploader.rb +2 -2
  113. data/app/validators/uploader_image_content_validator.rb +282 -0
  114. data/app/views/decidim/application/_radio_accordion.html.erb +1 -5
  115. data/app/views/decidim/manifests/show.json.erb +25 -22
  116. data/app/views/decidim/messaging/conversations/create.js.erb +1 -3
  117. data/app/views/decidim/shared/_login_modal.html.erb +12 -14
  118. data/app/views/decidim/shared/_results_per_page.html.erb +1 -1
  119. data/app/views/layouts/decidim/_mailer_logo.html.erb +1 -1
  120. data/config/initializers/rack_attack.rb +10 -0
  121. data/config/locales/bg.yml +1 -4
  122. data/config/locales/ca-IT.yml +8 -4
  123. data/config/locales/ca.yml +10 -6
  124. data/config/locales/cs.yml +16 -4
  125. data/config/locales/de.yml +62 -6
  126. data/config/locales/en.yml +8 -4
  127. data/config/locales/es-MX.yml +8 -4
  128. data/config/locales/es-PY.yml +8 -4
  129. data/config/locales/es.yml +14 -10
  130. data/config/locales/eu.yml +165 -164
  131. data/config/locales/fi-plain.yml +3 -3
  132. data/config/locales/fi.yml +3 -3
  133. data/config/locales/fr-CA.yml +8 -4
  134. data/config/locales/fr.yml +8 -4
  135. data/config/locales/gl.yml +1440 -33
  136. data/config/locales/hu.yml +0 -1
  137. data/config/locales/it.yml +0 -2
  138. data/config/locales/ja.yml +4 -4
  139. data/config/locales/pl.yml +1 -4
  140. data/config/locales/pt-BR.yml +1 -4
  141. data/config/locales/ro-RO.yml +0 -3
  142. data/config/locales/sk.yml +51 -4
  143. data/config/locales/sv.yml +50 -13
  144. data/config/locales/tr-TR.yml +1 -3
  145. data/db/migrate/20250523104311_move_cta_to_hero_content_block.rb +1 -1
  146. data/db/migrate/20250527122040_move_highlighted_content_banner_settings_to_content_block.rb +3 -0
  147. data/db/migrate/20260909000000_add_failed_attempts_and_locked_at_to_decidim_authorizations.rb +8 -0
  148. data/db/migrate/20261007090000_make_user_optional_in_action_logs.rb +12 -0
  149. data/decidim-core.gemspec +1 -1
  150. data/lib/decidim/content_renderers/mention_resource_renderer.rb +6 -3
  151. data/lib/decidim/core/test/factories.rb +2 -2
  152. data/lib/decidim/core/test/shared_examples/participatory_space_members_page_examples.rb +77 -0
  153. data/lib/decidim/core/test/shared_examples/participatory_space_members_shared_examples.rb +85 -6
  154. data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +23 -1
  155. data/lib/decidim/core/version.rb +1 -1
  156. data/lib/decidim/core.rb +10 -1
  157. data/lib/decidim/has_upload_validations.rb +1 -0
  158. data/lib/decidim/legacy_form_builder.rb +4 -0
  159. data/lib/decidim/maintenance/import_models/scope.rb +2 -1
  160. data/lib/decidim/maintenance/taxonomy_importer.rb +4 -1
  161. data/lib/decidim/query_extensions.rb +2 -0
  162. data/lib/decidim/view_model.rb +1 -0
  163. data/lib/tasks/decidim_open_data_tasks.rake +7 -0
  164. metadata +22 -10
@@ -31,6 +31,8 @@ export default class extends Controller {
31
31
 
32
32
  this.fixPanelRole();
33
33
 
34
+ this._setupInertPanels();
35
+
34
36
  this.expandIfNeeded();
35
37
 
36
38
  this.boundReconnect = this.reconnect.bind(this);
@@ -52,6 +54,8 @@ export default class extends Controller {
52
54
  this.toggleButton.removeEventListener("click", this.boundExpand);
53
55
  }
54
56
 
57
+ this._teardownInertPanels();
58
+
55
59
  this._stopListeningForBreakpointChanges();
56
60
  }
57
61
 
@@ -166,6 +170,45 @@ export default class extends Controller {
166
170
  this.previouslyExpanded = this.toggleButton.getAttribute("aria-expanded");
167
171
  }
168
172
 
173
+ /**
174
+ * Syncs the `inert` attribute of partially visible panels (those rendered
175
+ * inert) with their `aria-hidden` state, moving focus to the panel on expand.
176
+ *
177
+ * @returns {void}
178
+ */
179
+ _setupInertPanels() {
180
+ this._panelObservers = [];
181
+
182
+ this.element.querySelectorAll("[data-controls]").forEach((trigger) => {
183
+ const panel = document.getElementById(trigger.dataset.controls);
184
+ if (!panel || (!panel.hasAttribute("inert") && !("inertManaged" in panel.dataset))) {
185
+ return;
186
+ }
187
+
188
+ panel.dataset.inertManaged = "";
189
+ panel.toggleAttribute("inert", panel.getAttribute("aria-hidden") === "true");
190
+
191
+ const observer = new MutationObserver(() => {
192
+ if (panel.getAttribute("aria-hidden") === "true") {
193
+ panel.setAttribute("inert", "");
194
+ } else {
195
+ panel.removeAttribute("inert");
196
+ panel.focus();
197
+ }
198
+ });
199
+ observer.observe(panel, { attributes: true, attributeFilter: ["aria-hidden"] });
200
+
201
+ this._panelObservers.push(observer);
202
+ });
203
+ }
204
+
205
+ _teardownInertPanels() {
206
+ if (this._panelObservers) {
207
+ this._panelObservers.forEach((observer) => observer.disconnect());
208
+ this._panelObservers = [];
209
+ }
210
+ }
211
+
169
212
  fixPanelRole() {
170
213
  const panelRole = this.element.dataset.panelRole;
171
214
  if (!panelRole) {
@@ -50,10 +50,7 @@ export const setMinute = (value) => {
50
50
  };
51
51
 
52
52
  export const formatInputDate = (date, formats) => {
53
- const dateList = date.split("-");
54
- const year = dateList[0];
55
- const month = dateList[1];
56
- const day = dateList[2];
53
+ const [year, month, day] = date.split("-");
57
54
 
58
55
  if (formats.order === "m-d-y") {
59
56
  return `${month}${formats.separator}${day}${formats.separator}${year}`;
@@ -63,10 +60,34 @@ export const formatInputDate = (date, formats) => {
63
60
  return `${day}${formats.separator}${month}${formats.separator}${year}`;
64
61
  };
65
62
 
63
+ /**
64
+ * Splits a time string into two elements: hours and minutes. Ensures a returned
65
+ * array of size 2 for any kind of strings or `null` values.
66
+ *
67
+ * Examples:
68
+ * splitTime("") => ["00", "00"]
69
+ * splitTime(null) => ["00", "00"]
70
+ * splitTime("12") => ["12", "00"]
71
+ * splitTime("12:30") => ["12", "30"]
72
+ * splitTime("2:4") => ["02", "04"]
73
+ * splitTime("12:30:45") => ["12", "30"]
74
+ *
75
+ * @param {String} value The original time string, typically hh:ss.
76
+ * @returns {Array} An array with two elements where the first element is the
77
+ * hour part and the second element is the minute part.
78
+ */
79
+ const splitTime = (value) => {
80
+ return [...(value || "").split(":"), "00"].splice(0, 2).map((part) => part.padStart(2, "0"));
81
+ };
82
+
66
83
  export const formatInputTime = (time, format, input) => {
67
- const timeList = time.split(":");
68
- let hour = timeList[0];
69
- const minute = timeList[1];
84
+ if (!time) {
85
+ return "";
86
+ } else if (time.length < 1) {
87
+ return time;
88
+ }
89
+
90
+ let [hour, minute] = splitTime(time);
70
91
 
71
92
  if (format === 12) {
72
93
  if (Number(hour) === 12) {
@@ -80,11 +101,9 @@ export const formatInputTime = (time, format, input) => {
80
101
  } else if (Number(hour) === 0) {
81
102
  hour = "12";
82
103
  }
83
-
84
- return `${hour}:${minute}`;
85
104
  };
86
105
 
87
- return time;
106
+ return `${hour}:${minute}`;
88
107
  };
89
108
 
90
109
  export const changeHourDisplay = (change, hour, format) => {
@@ -172,16 +191,29 @@ export const updateTimeValue = (time, hour, minute) => {
172
191
  };
173
192
 
174
193
  export const formatDate = (value, formats) => {
175
- let newValue = value;
176
- const splitValue = value.split(formats.separator);
194
+ const splitValue = value.split(formats.separator).splice(0, 3).map((part) => part.replace(/[^0-9]/g, ""));
177
195
 
178
- if (formats.order === "d-m-y") {
179
- newValue = `${splitValue[1]}/${splitValue[0]}/${splitValue[2]}`;
196
+ // Keep an empty date empty instead of silently defaulting to today
197
+ if (splitValue.every((part) => !part)) {
198
+ return "";
199
+ }
200
+
201
+ let newValue = null;
202
+ if (formats.order === "m-d-y") {
203
+ newValue = [splitValue[0], splitValue[1], splitValue[2]];
180
204
  } else if (formats.order === "y-m-d") {
181
- newValue = `${splitValue[1]}/${splitValue[2]}/${splitValue[0]}`
182
- };
205
+ newValue = [splitValue[1], splitValue[2], splitValue[0]];
206
+ } else {
207
+ // Assuming d-m-y
208
+ newValue = [splitValue[1], splitValue[0], splitValue[2]];
209
+ }
210
+
211
+ // Fill missing parts
212
+ let fallback = new Date();
213
+ fallback = [fallback.getMonth() + 1, fallback.getDate(), fallback.getFullYear()];
214
+ newValue = newValue.map((val, idx) => (val || fallback[idx]));
183
215
 
184
- const date = new Date(newValue)
216
+ const date = new Date(newValue.join("/"))
185
217
 
186
218
  let day = date.getDate();
187
219
  let month = date.getMonth() + 1;
@@ -199,29 +231,21 @@ export const formatDate = (value, formats) => {
199
231
  };
200
232
 
201
233
  export const formatTime = (value, format, inputname) => {
234
+ let [hour, minute] = splitTime(value);
235
+
202
236
  if (format === 12) {
203
- const splitValue = value.split(":");
204
- let hour = splitValue[0];
205
- const minute = splitValue[1];
206
237
  if (document.getElementById(`period_am_${inputname}`).checked) {
207
- switch (hour) {
208
- case "12":
238
+ if (hour === "12") {
209
239
  hour = "00";
210
-
211
- return `${hour}:${minute}`;
212
- default:
213
- return value;
214
- };
240
+ }
215
241
  } else if (document.getElementById(`period_pm_${inputname}`).checked) {
216
242
  if (Number(hour) > 0 && Number(hour) < 12) {
217
243
  hour = `${Number(hour) + 12}`;
218
244
  };
219
-
220
- return `${hour}:${minute}`
221
245
  };
222
246
  };
223
247
 
224
- return value;
248
+ return `${hour}:${minute}`;
225
249
  };
226
250
 
227
251
  export const updateInputValue = (input, formats, time) => {
@@ -6,12 +6,28 @@ import { formatInputDate, formatInputTime } from "src/decidim/datepicker/datepic
6
6
  import { getDictionary } from "src/decidim/refactor/moved/i18n";
7
7
 
8
8
  export default function formDatePicker(input) {
9
-
10
9
  const i18nDate = getDictionary("date.formats");
11
10
  const i18nDateHelp = getDictionary("date.formats.help");
12
11
  const i18nTime = getDictionary("time");
13
12
  const i18nTimeHelp = getDictionary("time.formats.help");
14
- const formats = { order: i18nDate.order, separator: i18nDate.separator, time: i18nTime.clock_format || 24 }
13
+ /* eslint-disable dot-location */
14
+ // See: https://docs.ruby-lang.org/en/3.4/strftime_formatting_rdoc.html
15
+ const dateFormat = i18nDate.decidim_short
16
+ // Padding modifiers (removed, not supported by the date picker)
17
+ .replace(/%[0_-]/g, "%")
18
+ // Upcase modifier (removed, not supported by the date picker)
19
+ .replaceAll("%^", "%")
20
+ // Week-based year (converted to regular full year as it is not supported by the date picker)
21
+ .replace(/%[gG]/, "%Y")
22
+ // Shorthand conventions %D, %x, %F
23
+ .replace(/%[Dx]/, "%m/%d/%y")
24
+ .replace("%F", "%Y-%m-%d")
25
+ // VMS date (converted to day-month-year as it is not supported by the date picker)
26
+ .replace("%v", "%d-%m-%Y")
27
+ /* eslint-enable dot-location */
28
+ const dateOrder = dateFormat.replace("%Y", "y").replaceAll("%", "").replace(/[^A-Za-z]/g, "-");
29
+ const dateSeparator = (dateFormat.match(/([^%A-Za-z])/) || ["/"])[0];
30
+ const formats = { order: dateOrder, separator: dateSeparator, time: i18nTime.clock_format || 24 }
15
31
 
16
32
  if (!customElements.get("wc-datepicker")) {
17
33
  defineCustomElements();
@@ -58,7 +58,7 @@ export default function generateDatePicker(input, row, formats) {
58
58
  dateColumn.appendChild(datePickerContainer);
59
59
 
60
60
  let prevDate = null;
61
- let defaultTime = input.getAttribute("default_time") || "00:00"
61
+ let defaultTime = input.dataset.defaultTime || "00:00"
62
62
 
63
63
  const datePickerDisplay = (event) => {
64
64
  if (!dateColumn.contains(event.target)) {
@@ -73,13 +73,16 @@ export default function generateDatePicker(input, row, formats) {
73
73
  date.addEventListener("paste", (event) => {
74
74
  event.preventDefault();
75
75
  const value = event.clipboardData.getData("text/plain");
76
- if ((/^[0-9/.-]+$/).test(value)) {
77
- date.value = value.replaceAll(/[/.-]/g, formats.separator);
76
+ // Only the date part is accepted; any text after it is ignored
77
+ const pastedDate = value.match(/^([0-9]+[^0-9]){2}[0-9]+/);
78
+
79
+ if (pastedDate) {
80
+ date.value = pastedDate[0].replaceAll(/[^0-9]/g, formats.separator);
78
81
 
79
82
  if (input.type === "date") {
80
83
  input.value = `${formatDate(date.value, formats)}`;
81
84
  } else if (input.type === "datetime-local") {
82
- input.value = `${formatDate(date.value, formats)}T${formatTime(document.querySelector(`#${input.id}_time`).value, formats.time, input.id) || defaultTime}`;
85
+ input.value = `${formatDate(date.value, formats)}T${formatTime(document.querySelector(`#${input.id}_time`).value || defaultTime, formats.time, input.id)}`;
83
86
  };
84
87
  };
85
88
  });
@@ -88,14 +91,19 @@ export default function generateDatePicker(input, row, formats) {
88
91
  datePickerContainer.style.display = "none";
89
92
  });
90
93
 
91
- date.addEventListener("keyup", () => {
94
+ date.addEventListener("input", () => {
95
+ if (date.value.length === 0) {
96
+ input.value = "";
97
+ return;
98
+ };
99
+
92
100
  if (date.value.length === 10) {
93
- date.value = date.value.replaceAll(/[/.-]/g, formats.separator);
101
+ date.value = date.value.replaceAll(/[^0-9]/g, formats.separator);
94
102
  prevDate = dateToPicker(date.value, formats);
95
103
  if (input.type === "date") {
96
104
  input.value = `${formatDate(date.value, formats)}`;
97
105
  } else if (input.type === "datetime-local") {
98
- input.value = `${formatDate(date.value, formats)}T${formatTime(document.querySelector(`#${input.id}_time`).value, formats.time, input.id) || defaultTime}`;
106
+ input.value = `${formatDate(date.value, formats)}T${formatTime(document.querySelector(`#${input.id}_time`).value || defaultTime, formats.time, input.id)}`;
99
107
  };
100
108
  };
101
109
  });
@@ -115,7 +123,7 @@ export default function generateDatePicker(input, row, formats) {
115
123
  if (input.type === "date") {
116
124
  input.value = `${pickedDate}`;
117
125
  } else if (input.type === "datetime-local") {
118
- input.value = `${pickedDate}T${formatTime(document.querySelector(`#${input.id}_time`).value, formats.time, input.id) || defaultTime}`;
126
+ input.value = `${pickedDate}T${formatTime(document.querySelector(`#${input.id}_time`).value || defaultTime, formats.time, input.id)}`;
119
127
  };
120
128
  datePickerContainer.style.display = "none";
121
129
  });
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable require-jsdoc */
2
- /* eslint max-lines: ["error", 310] */
2
+ /* eslint max-lines: ["error", 320] */
3
3
 
4
4
  import icon from "src/decidim/refactor/moved/icon"
5
5
  import { changeHourDisplay, changeMinuteDisplay, formatDate, hourDisplay, minuteDisplay, formatTime, setHour, setMinute, updateTimeValue, updateInputValue, adjustPickerPosition } from "src/decidim/datepicker/datepicker_functions"
@@ -96,7 +96,8 @@ export default function generateTimePicker(input, row, formats) {
96
96
  periodAm.setAttribute("name", `period_${input.id}`);
97
97
  periodAm.setAttribute("id", `period_am_${input.id}`);
98
98
  periodAm.setAttribute("class", "datepicker__period-am");
99
- const periodAmLabel = document.createElement("span");
99
+ const periodAmLabel = document.createElement("label");
100
+ periodAmLabel.setAttribute("for", `period_am_${input.id}`);
100
101
  periodAmLabel.innerText = "AM"
101
102
 
102
103
  const periodPm = document.createElement("input");
@@ -104,7 +105,8 @@ export default function generateTimePicker(input, row, formats) {
104
105
  periodPm.setAttribute("name", `period_${input.id}`);
105
106
  periodPm.setAttribute("id", `period_pm_${input.id}`);
106
107
  periodPm.setAttribute("class", "datepicker__period-pm");
107
- const periodPmLabel = document.createElement("span");
108
+ const periodPmLabel = document.createElement("label");
109
+ periodPmLabel.setAttribute("for", `period_pm_${input.id}`);
108
110
  periodPmLabel.innerText = "PM"
109
111
 
110
112
  periodColumn.appendChild(periodAm);
@@ -66,6 +66,14 @@ describe("formatDate", () => {
66
66
 
67
67
  expect(result).toEqual("2023-02-01");
68
68
  });
69
+
70
+ it("should keep a blank date empty instead of defaulting to today", () => {
71
+ const formats = { separator: "/", order: "d-m-y" };
72
+
73
+ const result = formatDate("", formats);
74
+
75
+ expect(result).toEqual("");
76
+ });
69
77
  });
70
78
 
71
79
  describe("formatInputDate", () => {
@@ -49,34 +49,42 @@ describe("setMinute", () => {
49
49
  });
50
50
 
51
51
  describe("formatInputTime", () => {
52
- const setupDOM = () => {
53
- document.body.innerHTML = `
54
- <input type="radio" id="period_am_exampleInput" name="period">
55
- <input type="radio" id="period_pm_exampleInput" name="period">
56
- `;
57
- };
58
-
59
52
  describe("24-hour format", () => {
53
+ const format = 24;
54
+ const input = { id: "exampleInput" };
55
+
60
56
  it("returns the value in correct format", () => {
61
- setupDOM();
62
- const time = "15:30";
63
- const format = 24;
64
- const input = { id: "exampleInput" };
57
+ const result = formatInputTime("15:30", format, input);
65
58
 
66
- const result = formatInputTime(time, format, input);
59
+ expect(result).toBe("15:30");
60
+ });
61
+
62
+ it("returns the value in correct format if seconds are provided", () => {
63
+ const result = formatInputTime("15:30:04", format, input);
67
64
 
68
65
  expect(result).toBe("15:30");
69
66
  });
67
+
68
+ it("returns an empty string if an empty string is provided", () => {
69
+ const result = formatInputTime("", 24, { id: "exampleInput" });
70
+
71
+ expect(result).toBe("");
72
+ });
70
73
  })
71
74
 
72
75
  describe("12-hour format", () => {
73
- it("returns the value in correct format and checks the PM radio-button", () => {
74
- setupDOM();
75
- const time = "12:45";
76
- const format = 12;
77
- const input = { id: "exampleInput" };
76
+ beforeEach(() => {
77
+ document.body.innerHTML = `
78
+ <input type="radio" id="period_am_exampleInput" name="period">
79
+ <input type="radio" id="period_pm_exampleInput" name="period">
80
+ `;
81
+ });
82
+
83
+ const format = 12;
84
+ const input = { id: "exampleInput" };
78
85
 
79
- const result = formatInputTime(time, format, input);
86
+ it("returns the value in correct format and checks the PM radio-button", () => {
87
+ const result = formatInputTime("12:45", format, input);
80
88
 
81
89
  expect(result).toBe("12:45");
82
90
  expect(document.getElementById("period_pm_exampleInput").checked).toBeTruthy();
@@ -84,17 +92,24 @@ describe("formatInputTime", () => {
84
92
  });
85
93
 
86
94
  it("returns the value in correct format", () => {
87
- setupDOM();
88
- const time = "00:25";
89
- const format = 12;
90
- const input = { id: "exampleInput" };
91
-
92
- const result = formatInputTime(time, format, input);
95
+ const result = formatInputTime("00:25", format, input);
93
96
 
94
97
  expect(result).toBe("12:25");
95
98
  // We are not expecting a radio button to be selected here since in a real environment the selected button is not
96
99
  // handled by this method for values < 12
97
100
  });
101
+
102
+ it("returns the value in correct format if seconds are provided", () => {
103
+ const result = formatInputTime("00:25:04", format, input);
104
+
105
+ expect(result).toBe("12:25");
106
+ });
107
+
108
+ it("returns an empty string if an empty string is provided", () => {
109
+ const result = formatInputTime("", 24, { id: "exampleInput" });
110
+
111
+ expect(result).toBe("");
112
+ });
98
113
  })
99
114
  });
100
115
 
@@ -77,7 +77,7 @@ const createUnloadPreventer = () => {
77
77
  ev.preventDefault();
78
78
  ev.stopPropagation();
79
79
 
80
- confirmAction(confirmMessage, link).then((answer) => {
80
+ confirmAction(confirmMessage, link, { iconName: "alert-line" }).then((answer) => {
81
81
  if (!answer) {
82
82
  return;
83
83
  }
@@ -109,7 +109,7 @@ const createUnloadPreventer = () => {
109
109
  ev.stopImmediatePropagation();
110
110
  ev.stopPropagation();
111
111
 
112
- confirmAction(confirmMessage, button).then((answer) => {
112
+ confirmAction(confirmMessage, button, { iconName: "alert-line" }).then((answer) => {
113
113
  if (!answer) {
114
114
  return;
115
115
  }
@@ -13,18 +13,12 @@
13
13
  @apply block max-h-40 overflow-hidden relative first:[&_*]:mt-0 before:content-[''] before:absolute before:inset-0 before:h-full before:w-full before:bg-gradient-to-b before:from-transparent before:to-white after:content-[''] after:absolute after:inset-0 after:h-full after:w-full after:bg-gradient-to-b after:from-transparent after:to-white;
14
14
  }
15
15
 
16
- [aria-expanded="false"] > svg:last-of-type,
17
- [aria-expanded="false"] > span:last-of-type,
18
- [aria-expanded="true"] > span:first-of-type,
19
- [aria-expanded="true"] > svg:first-of-type {
20
- @apply hidden;
16
+ [aria-expanded] > svg {
17
+ @apply transition-transform;
21
18
  }
22
19
 
23
- [aria-expanded="true"] > svg:last-of-type,
24
- [aria-expanded="true"] > span:last-of-type,
25
- [aria-expanded="false"] > span:first-of-type,
26
- [aria-expanded="false"] > svg:first-of-type {
27
- @apply block;
20
+ [aria-expanded="true"] > svg {
21
+ @apply rotate-180;
28
22
  }
29
23
  }
30
24
 
@@ -92,14 +92,6 @@
92
92
  [data-dialog-closable] {
93
93
  @apply top-6 right-6;
94
94
  }
95
-
96
- [data-dialog-container] {
97
- @apply inline grid-cols-none;
98
- }
99
-
100
- [data-dialog-title] {
101
- @apply col-span-2 md:col-span-1 md:col-start-2 grid grid-cols-[auto_1fr] items-start md:items-center gap-2 pb-4 text-left text-xl text-gray-2 md:border-b md:border-gray-3;
102
- }
103
95
  }
104
96
 
105
97
  &-results {
@@ -70,7 +70,7 @@
70
70
  }
71
71
 
72
72
  &__period-column {
73
- @apply w-28 h-8 top-1 right-10 my-2 mx-1 absolute;
73
+ @apply w-28 h-8 top-0 right-6 my-2 mx-1 absolute;
74
74
  }
75
75
 
76
76
  &__calendar-button {
@@ -155,11 +155,11 @@
155
155
  }
156
156
 
157
157
  &__period-am {
158
- @apply ml-1 accent-secondary bg-secondary;
158
+ @apply ml-1 !mt-3 accent-secondary bg-secondary;
159
159
  }
160
160
 
161
161
  &__period-pm {
162
- @apply ml-1;
162
+ @apply ml-1 !mt-3;
163
163
  }
164
164
 
165
165
  &__label-row {
@@ -22,19 +22,27 @@
22
22
  }
23
23
 
24
24
  [data-dialog-container] {
25
- @apply grid grid-cols-[auto_1fr] items-start md:items-center gap-2 text-left;
25
+ @apply block text-left;
26
26
 
27
- > svg {
28
- @apply w-6 h-6 text-gray fill-current flex-none;
29
- }
27
+ &:has(> svg) {
28
+ @apply grid grid-cols-[auto_1fr] items-start md:items-center gap-2;
29
+
30
+ > svg {
31
+ @apply w-6 h-6 text-gray fill-current flex-none mb-6;
32
+ }
30
33
 
31
- > :last-child {
32
- @apply col-span-2 md:col-span-1 md:col-start-2;
34
+ > :last-child {
35
+ @apply col-span-2 md:col-span-1 md:col-start-2;
36
+ }
33
37
  }
34
38
  }
35
39
 
36
40
  [data-dialog-title] {
37
- @apply text-2xl text-black font-semibold focus:outline-none;
41
+ @apply flex items-center gap-2 text-xl text-gray-2 font-semibold focus:outline-none pb-2 mb-4 md:border-b md:border-gray-3;
42
+
43
+ > svg {
44
+ @apply w-6 h-6 text-gray fill-current flex-none;
45
+ }
38
46
  }
39
47
 
40
48
  [data-dialog-actions] {
@@ -59,7 +67,7 @@
59
67
  }
60
68
 
61
69
  [data-dialog-container] {
62
- @apply grid-cols-none;
70
+ @apply grid grid-cols-none;
63
71
 
64
72
  &.layout-content {
65
73
  @apply bg-white;
@@ -1,21 +1,7 @@
1
1
  .qr-modal {
2
2
  @apply md:p-6 lg:p-8;
3
3
 
4
- [data-dialog-title] {
5
- @apply flex justify-start items-center text-2xl text-black font-semibold focus:outline-none;
6
-
7
- > svg {
8
- @apply w-10 h-10 text-gray fill-current flex-none;
9
- }
10
-
11
- > :last-child {
12
- @apply ml-1;
13
- }
14
- }
15
-
16
4
  [data-dialog-container] {
17
- @apply inline grid-cols-none;
18
-
19
5
  .content {
20
6
  @apply md:grid md:grid-cols-2 gap-5 md:py-4;
21
7
 
@@ -59,14 +45,6 @@
59
45
  @apply top-6 right-6;
60
46
  }
61
47
 
62
- [data-dialog-container] {
63
- @apply inline grid-cols-none;
64
- }
65
-
66
- [data-dialog-title] {
67
- @apply col-span-2 md:col-span-1 md:col-start-2 grid grid-cols-[auto_1fr] items-start md:items-center gap-2 pb-4 text-left text-xl text-gray-2 md:border-b md:border-gray-3;
68
- }
69
-
70
48
  &__list {
71
49
  @apply my-6 flex flex-wrap justify-center items-center md:grid grid-cols-4 md:grid-cols-5 gap-3 md:gap-6 max-w-96 mx-auto text-secondary;
72
50
 
@@ -111,7 +111,17 @@
111
111
  }
112
112
 
113
113
  &-item {
114
- @apply flex items-center gap-1 text-white font-semibold hover:underline [&>svg]:fill-current;
114
+ @apply flex items-center gap-1 text-white font-semibold hover:underline;
115
+ }
116
+
117
+ &-label {
118
+ @apply flex-1 min-w-0 overflow-hidden text-ellipsis;
119
+
120
+ overflow-wrap: anywhere;
121
+ }
122
+
123
+ &-item > svg {
124
+ @apply shrink-0 fill-current;
115
125
  }
116
126
  }
117
127
 
@@ -7,18 +7,21 @@
7
7
  .editor-content-videoEmbed {
8
8
  @apply my-10 mx-auto;
9
9
  }
10
+ }
10
11
 
11
- .editor-mention {
12
- @apply inline-flex items-center align-bottom font-semibold underline text-secondary;
12
+ // Resource mentions are rendered both inside rich text (`.rich-text-display`)
13
+ // and inside comments (`.editor-content`), so they cannot be scoped to one of
14
+ // those wrappers.
15
+ .editor-mention {
16
+ @apply inline-flex items-center align-bottom font-semibold underline text-secondary;
13
17
 
14
- img,
15
- svg {
16
- @apply w-5 h-5 rounded-full;
17
- }
18
+ img,
19
+ svg {
20
+ @apply w-5 h-5 m-0 rounded-full;
21
+ }
18
22
 
19
- span {
20
- @apply ml-1;
21
- }
23
+ span {
24
+ @apply ml-1;
22
25
  }
23
26
  }
24
27
 
@@ -9,3 +9,19 @@
9
9
  @apply content-[""] sticky top-[50vh] ml-[50%] md:ml-[calc(50%-4rem)] block w-6 h-6 -mt-6 rounded-full animate-spin border-4 border-l-background border-y-background border-r-secondary z-20;
10
10
  }
11
11
  }
12
+
13
+ // Pseudo-elements on table rows generate anonymous table cells, which shift
14
+ // the row content. Render the spinner in the first cell instead.
15
+ tr.spinner-container {
16
+ &::before {
17
+ @apply hidden;
18
+ }
19
+
20
+ td:first-child {
21
+ @apply relative;
22
+
23
+ &::after {
24
+ @apply content-[""] absolute top-1/2 left-1/2 -mt-3 -ml-3 block w-6 h-6 rounded-full animate-spin border-4 border-l-background border-y-background border-r-secondary z-20;
25
+ }
26
+ }
27
+ }
@@ -1,4 +1,4 @@
1
- @use "tom-select/dist/scss/tom-select";
1
+ @use "tom-select/dist/css/tom-select";
2
2
 
3
3
  .ts {
4
4
  &-control {