decidim-core 0.32.1 → 0.32.3
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 +4 -4
- data/app/cells/decidim/address_cell.rb +7 -3
- data/app/cells/decidim/card_metadata_cell.rb +3 -1
- data/app/cells/decidim/content_blocks/participatory_space_main_data/title.erb +1 -14
- data/app/cells/decidim/date_range/show.erb +6 -6
- data/app/cells/decidim/date_range_cell.rb +7 -2
- data/app/cells/decidim/following_cell.rb +1 -1
- data/app/cells/decidim/member/show.erb +1 -1
- data/app/cells/decidim/nav_links/show.erb +3 -1
- data/app/cells/decidim/share_text_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/modal.erb +1 -0
- data/app/cells/decidim/share_widget/qr_code_modal.erb +2 -4
- data/app/commands/decidim/create_follow.rb +2 -3
- data/app/commands/decidim/create_omniauth_registration.rb +19 -7
- data/app/commands/decidim/create_user_report.rb +1 -1
- data/app/commands/decidim/destroy_account.rb +6 -6
- data/app/commands/decidim/destroy_ephemeral_user.rb +2 -0
- data/app/commands/decidim/invite_user.rb +1 -1
- data/app/commands/decidim/multiple_attachments_methods.rb +17 -3
- data/app/commands/decidim/update_resources_taxonomies.rb +2 -1
- data/app/controllers/concerns/decidim/devise_authentication_methods.rb +4 -0
- data/app/controllers/concerns/decidim/devise_controllers.rb +2 -0
- data/app/controllers/concerns/decidim/direct_upload.rb +12 -6
- data/app/controllers/concerns/decidim/disable_redirection_to_external_host.rb +2 -0
- data/app/controllers/concerns/decidim/filter_resource.rb +2 -0
- data/app/controllers/concerns/decidim/impersonate_users.rb +4 -4
- data/app/controllers/concerns/decidim/locale_switcher.rb +12 -10
- data/app/controllers/concerns/decidim/needs_organization.rb +15 -0
- data/app/controllers/concerns/decidim/needs_permission.rb +22 -10
- data/app/controllers/concerns/decidim/onboarding_action_methods.rb +2 -0
- data/app/controllers/concerns/decidim/paginable.rb +7 -3
- data/app/controllers/concerns/decidim/payload_info.rb +2 -0
- data/app/controllers/concerns/decidim/resource_versions_concern.rb +14 -0
- data/app/controllers/decidim/amendments_controller.rb +34 -6
- data/app/controllers/decidim/application_controller.rb +2 -6
- data/app/controllers/decidim/authorization_modals_controller.rb +3 -1
- data/app/controllers/decidim/components/base_controller.rb +2 -0
- data/app/controllers/decidim/devise/passwords_controller.rb +8 -0
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +10 -4
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +6 -1
- data/app/controllers/decidim/favicon_controller.rb +9 -0
- data/app/controllers/decidim/free_resource_authorization_modals_controller.rb +2 -0
- data/app/controllers/decidim/gamification/badges_controller.rb +2 -0
- data/app/controllers/decidim/homepage_controller.rb +4 -1
- data/app/controllers/decidim/likes_controller.rb +1 -1
- data/app/controllers/decidim/links_controller.rb +2 -0
- data/app/controllers/decidim/manifests_controller.rb +2 -0
- data/app/controllers/decidim/messaging/conversations_controller.rb +11 -5
- data/app/controllers/decidim/newsletters_controller.rb +4 -0
- data/app/controllers/decidim/notifications_subscriptions_controller.rb +4 -0
- data/app/controllers/decidim/offline_controller.rb +5 -1
- data/app/controllers/decidim/open_data_controller.rb +5 -1
- data/app/controllers/decidim/pages_controller.rb +31 -3
- data/app/controllers/decidim/private_downloads_controller.rb +2 -0
- data/app/controllers/decidim/profiles_controller.rb +20 -2
- data/app/controllers/decidim/qr_controller.rb +3 -1
- data/app/controllers/decidim/resource_autocomplete_controller.rb +2 -0
- data/app/controllers/decidim/searches_controller.rb +2 -0
- data/app/controllers/decidim/short_links_controller.rb +4 -0
- data/app/controllers/decidim/static_map_controller.rb +2 -0
- data/app/controllers/decidim/timeouts_controller.rb +4 -0
- data/app/controllers/decidim/tos_controller.rb +2 -0
- data/app/controllers/decidim/upload_validations_controller.rb +4 -2
- data/app/controllers/decidim/user_activities_controller.rb +3 -0
- data/app/forms/decidim/upload_validation_form.rb +16 -10
- data/app/helpers/concerns/decidim/user_role_checker.rb +35 -10
- data/app/helpers/decidim/cells_paginate_helper.rb +0 -5
- data/app/helpers/decidim/decidim_form_helper.rb +1 -1
- data/app/helpers/decidim/layout_helper.rb +1 -0
- data/app/helpers/decidim/orders_helper.rb +8 -6
- data/app/helpers/decidim/paginate_helper.rb +15 -3
- data/app/helpers/decidim/sanitize_helper.rb +11 -1
- data/app/helpers/decidim/url_helper.rb +35 -0
- data/app/jobs/decidim/application_job.rb +4 -0
- data/app/jobs/decidim/open_data_job.rb +21 -5
- data/app/models/decidim/action_log.rb +7 -1
- data/app/models/decidim/authorization.rb +24 -0
- data/app/models/decidim/component.rb +10 -0
- data/app/models/decidim/like.rb +1 -1
- data/app/models/decidim/oauth_application.rb +1 -0
- data/app/models/decidim/user.rb +1 -0
- data/app/models/decidim/user_base_entity.rb +1 -1
- data/app/packs/src/decidim/callout.js +10 -0
- data/app/packs/src/decidim/callout.test.js +32 -0
- data/app/packs/src/decidim/controllers/accordion/accordion.test.js +64 -0
- data/app/packs/src/decidim/controllers/accordion/controller.js +43 -0
- data/app/packs/src/decidim/controllers/autofocus/controller.js +30 -0
- data/app/packs/src/decidim/controllers/language_change/controller.js +21 -8
- data/app/packs/src/decidim/controllers/language_change/language_change.test.js +0 -1
- data/app/packs/src/decidim/controllers/mention/controller.js +32 -3
- data/app/packs/src/decidim/controllers/mention/input_mentions.test.js +8 -5
- data/app/packs/src/decidim/controllers/multiple_mentions/input_multiple_mentions.test.js +1 -1
- data/app/packs/src/decidim/datepicker/datepicker_functions.js +61 -32
- data/app/packs/src/decidim/datepicker/form_datepicker.js +18 -2
- data/app/packs/src/decidim/datepicker/generate_datepicker.js +16 -8
- data/app/packs/src/decidim/datepicker/generate_timepicker.js +5 -3
- data/app/packs/src/decidim/datepicker/test/date.test.js +8 -0
- data/app/packs/src/decidim/datepicker/test/datepicker_functions_adjust_picker_position.test.js +64 -0
- data/app/packs/src/decidim/datepicker/test/time.test.js +39 -24
- data/app/packs/src/decidim/editor/common/suggestion.js +32 -22
- data/app/packs/src/decidim/editor/extensions/mention/index.js +14 -3
- data/app/packs/src/decidim/editor/index.js +4 -0
- data/app/packs/src/decidim/editor/test/extensions/mention.test.js +32 -9
- data/app/packs/src/decidim/refactor/implementation/autofocus.js +22 -0
- data/app/packs/src/decidim/refactor/implementation/autofocus.test.js +171 -0
- data/app/packs/src/decidim/utilities/dom.js +2 -2
- data/app/packs/stylesheets/decidim/_content_blocks.scss +4 -10
- data/app/packs/stylesheets/decidim/_conversations.scss +0 -8
- data/app/packs/stylesheets/decidim/_datepicker.scss +3 -3
- data/app/packs/stylesheets/decidim/_modal.scss +16 -8
- data/app/packs/stylesheets/decidim/_modal_share.scss +0 -22
- data/app/packs/stylesheets/decidim/_participatory_spaces.scss +11 -1
- data/app/packs/stylesheets/decidim/_rich_text.scss +12 -9
- data/app/packs/stylesheets/decidim/_spinner.scss +16 -0
- data/app/packs/stylesheets/decidim/_tom_select.scss +1 -1
- data/app/packs/stylesheets/decidim/_typography.scss +5 -2
- data/app/packs/stylesheets/decidim/application.scss +1 -0
- data/app/packs/stylesheets/decidim/legacy/email.scss +0 -5
- data/app/permissions/decidim/permissions.rb +20 -0
- data/app/presenters/decidim/admin_log/component_presenter.rb +1 -1
- data/app/presenters/decidim/log/base_presenter.rb +20 -2
- data/app/presenters/decidim/log/user_presenter.rb +2 -2
- data/app/presenters/decidim/menu_item_presenter.rb +1 -5
- data/app/presenters/decidim/resource_presenter.rb +11 -0
- data/app/resolvers/decidim/meta_image_url_resolver.rb +7 -1
- data/app/serializers/decidim/exporters/open_data_blocked_user_serializer.rb +11 -2
- data/app/serializers/decidim/exporters/open_data_moderation_serializer.rb +25 -1
- data/app/services/decidim/action_logger.rb +97 -29
- data/app/services/decidim/svg_content_validator.rb +889 -0
- data/app/uploaders/decidim/application_uploader.rb +2 -2
- data/app/validators/uploader_image_content_validator.rb +280 -0
- data/app/views/decidim/application/_radio_accordion.html.erb +1 -5
- data/app/views/decidim/manifests/show.json.erb +25 -22
- data/app/views/decidim/messaging/conversations/_add_conversation_users.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/create.js.erb +1 -3
- data/app/views/decidim/shared/_login_modal.html.erb +12 -14
- data/app/views/decidim/shared/_results_per_page.html.erb +1 -1
- data/app/views/layouts/decidim/_mailer_logo.html.erb +1 -1
- data/app/views/layouts/decidim/header/_menu_breadcrumb_desktop.html.erb +3 -2
- data/config/initializers/rack_attack.rb +10 -0
- data/config/locales/bg.yml +1 -4
- data/config/locales/ca-IT.yml +10 -4
- data/config/locales/ca.yml +17 -11
- data/config/locales/cs.yml +24 -4
- data/config/locales/de.yml +100 -6
- data/config/locales/en.yml +10 -4
- data/config/locales/es-MX.yml +10 -4
- data/config/locales/es-PY.yml +10 -4
- data/config/locales/es.yml +16 -10
- data/config/locales/eu.yml +171 -168
- data/config/locales/fi-plain.yml +5 -3
- data/config/locales/fi.yml +5 -3
- data/config/locales/fr-CA.yml +10 -4
- data/config/locales/fr.yml +10 -4
- data/config/locales/gl.yml +1484 -33
- data/config/locales/hu.yml +0 -1
- data/config/locales/it.yml +0 -2
- data/config/locales/ja.yml +6 -4
- data/config/locales/pl.yml +1 -4
- data/config/locales/pt-BR.yml +1 -4
- data/config/locales/ro-RO.yml +0 -3
- data/config/locales/sk.yml +70 -4
- data/config/locales/sv.yml +71 -15
- data/config/locales/tr-TR.yml +1 -3
- data/config/routes.rb +11 -2
- data/db/migrate/20250523104311_move_cta_to_hero_content_block.rb +1 -1
- data/db/migrate/20250527122040_move_highlighted_content_banner_settings_to_content_block.rb +3 -0
- data/db/migrate/20260909000000_add_failed_attempts_and_locked_at_to_decidim_authorizations.rb +8 -0
- data/db/migrate/20261007090000_make_user_optional_in_action_logs.rb +12 -0
- data/decidim-core.gemspec +1 -1
- data/lib/decidim/api/functions/user_entity_list.rb +1 -0
- data/lib/decidim/api/types/user_moderation_type.rb +2 -2
- data/lib/decidim/content_parsers/user_parser.rb +1 -1
- data/lib/decidim/content_parsers.rb +0 -1
- data/lib/decidim/content_renderers/mention_resource_renderer.rb +19 -5
- data/lib/decidim/content_renderers/user_renderer.rb +15 -4
- data/lib/decidim/core/test/shared_examples/participatory_space_members_page_examples.rb +77 -0
- data/lib/decidim/core/test/shared_examples/participatory_space_members_shared_examples.rb +58 -0
- data/lib/decidim/core/test/shared_examples/versions_controller_examples.rb +23 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +10 -1
- data/lib/decidim/form_builder.rb +9 -1
- data/lib/decidim/has_upload_validations.rb +1 -0
- data/lib/decidim/legacy_form_builder.rb +4 -0
- data/lib/decidim/maintenance/import_models/scope.rb +2 -1
- data/lib/decidim/maintenance/taxonomy_importer.rb +4 -1
- data/lib/decidim/seeds.rb +1 -1
- data/lib/decidim/view_model.rb +1 -0
- data/lib/tasks/decidim_open_data_tasks.rake +7 -0
- metadata +14 -7
- data/lib/decidim/content_parsers/inline_images_parser.rb +0 -68
- data/lib/tasks/upgrade/decidim_active_storage_migration_tasks.rake +0 -79
|
@@ -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) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
import autofocus from "src/decidim/refactor/implementation/autofocus"
|
|
3
|
+
|
|
4
|
+
export default class extends Controller {
|
|
5
|
+
connect() {
|
|
6
|
+
this.handleTabsChange = this.handleTabsChange.bind(this)
|
|
7
|
+
|
|
8
|
+
// Foundation tabs (used for translated fields when locales <= 4)
|
|
9
|
+
this.tabs = Array.from(this.element.querySelectorAll("ul[data-tabs]"))
|
|
10
|
+
if (typeof $ === "function" && this.tabs.length > 0) {
|
|
11
|
+
this.tabs.forEach((tabs) => $(tabs).on("change.zf.tabs", this.handleTabsChange))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Language selector dropdown (used for translated fields when locales > 4)
|
|
15
|
+
if (this.element.querySelector("select.language-change")) {
|
|
16
|
+
autofocus(this.element)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
disconnect() {
|
|
21
|
+
if (typeof $ === "function" && this.tabs && this.tabs.length > 0) {
|
|
22
|
+
this.tabs.forEach((tabs) => $(tabs).off("change.zf.tabs", this.handleTabsChange))
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
handleTabsChange(event) {
|
|
27
|
+
const activePane = $(event.target).parent().next(".tabs-content").find(".tabs-panel.is-active")[0]
|
|
28
|
+
autofocus(activePane)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
import autofocus from "src/decidim/refactor/implementation/autofocus"
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* This controller is used to change the active tab when the language is changed in the admin or system panel.
|
|
@@ -10,30 +11,42 @@ export default class extends Controller {
|
|
|
10
11
|
connect() {
|
|
11
12
|
this.handleChange = this.handleChange.bind(this);
|
|
12
13
|
this.element.addEventListener("change", this.handleChange);
|
|
13
|
-
this.element.
|
|
14
|
+
this.tabsContent = this.element.parentElement.parentElement.nextElementSibling;
|
|
15
|
+
|
|
16
|
+
this.setActiveTab(this.element.value);
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
disconnect() {
|
|
17
20
|
this.element.removeEventListener("change", this.handleChange)
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let tabsContent = event.target.parentElement.parentElement.nextElementSibling;
|
|
23
|
-
|
|
24
|
-
if (!tabsContent) {
|
|
23
|
+
setActiveTab(targetTabPaneSelector) {
|
|
24
|
+
if (!this.tabsContent) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
let activeTabContent = tabsContent.querySelector(".is-active");
|
|
28
|
+
let activeTabContent = this.tabsContent.querySelector(".is-active");
|
|
29
29
|
if (activeTabContent) {
|
|
30
30
|
activeTabContent.ariaHidden = "true";
|
|
31
31
|
activeTabContent.classList.remove("is-active");
|
|
32
32
|
}
|
|
33
|
-
let activePane = tabsContent.querySelector(targetTabPaneSelector);
|
|
33
|
+
let activePane = this.tabsContent.querySelector(targetTabPaneSelector);
|
|
34
34
|
if (activePane) {
|
|
35
35
|
activePane.ariaHidden = "false";
|
|
36
36
|
activePane.classList.add("is-active");
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
handleChange(event) {
|
|
41
|
+
this.setActiveTab(event.target.value);
|
|
42
|
+
|
|
43
|
+
if (!this.tabsContent) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const activePane = this.tabsContent.querySelector(event.target.value);
|
|
48
|
+
if (activePane) {
|
|
49
|
+
autofocus(activePane);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
39
52
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/* eslint max-lines: ["error",
|
|
1
|
+
/* eslint max-lines: ["error", 450] */
|
|
2
2
|
|
|
3
3
|
import { Controller } from "@hotwired/stimulus"
|
|
4
4
|
|
|
5
5
|
export default class extends Controller {
|
|
6
6
|
connect() {
|
|
7
7
|
this.options = {
|
|
8
|
-
noDataFoundMessage: this.element.getAttribute("data-
|
|
8
|
+
noDataFoundMessage: this.element.getAttribute("data-no_results") || "No results found",
|
|
9
|
+
searchPromptMessage: this.element.getAttribute("data-search_prompt") || "Type to search participants",
|
|
9
10
|
debounceDelay: 250,
|
|
10
11
|
menuItemLimit: 5
|
|
11
12
|
};
|
|
@@ -94,6 +95,14 @@ export default class extends Controller {
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
this.currentMentionStart = trigger.start;
|
|
98
|
+
|
|
99
|
+
if (trigger.query.length < 2) {
|
|
100
|
+
// Invalidate any pending debounced searches
|
|
101
|
+
this.requestId += 1;
|
|
102
|
+
this.showMessage(this.options.searchPromptMessage);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
97
106
|
this.performRemoteSearch(trigger.query);
|
|
98
107
|
}
|
|
99
108
|
|
|
@@ -136,7 +145,7 @@ export default class extends Controller {
|
|
|
136
145
|
}
|
|
137
146
|
|
|
138
147
|
const textBeforeCursor = value.slice(0, caretPosition);
|
|
139
|
-
const mentionMatch = textBeforeCursor.match(/(?:^|\s)@([\w.-]{
|
|
148
|
+
const mentionMatch = textBeforeCursor.match(/(?:^|\s)@([\w.-]{1,})$/);
|
|
140
149
|
if (!mentionMatch) {
|
|
141
150
|
return null;
|
|
142
151
|
}
|
|
@@ -257,6 +266,26 @@ export default class extends Controller {
|
|
|
257
266
|
this.suggestion.classList.remove("hidden", "hide");
|
|
258
267
|
}
|
|
259
268
|
|
|
269
|
+
showMessage(message) {
|
|
270
|
+
if (!this.suggestion || !message) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
this.suggestion.innerHTML = "";
|
|
275
|
+
this.isActive = false;
|
|
276
|
+
this.selectedIndex = -1;
|
|
277
|
+
|
|
278
|
+
const item = document.createElement("button");
|
|
279
|
+
item.type = "button";
|
|
280
|
+
item.disabled = true;
|
|
281
|
+
item.classList.add("editor-suggestions-item", "editor-suggestions-item-disabled");
|
|
282
|
+
item.textContent = message;
|
|
283
|
+
|
|
284
|
+
this.suggestion.append(item);
|
|
285
|
+
this.positionSuggestionMenu();
|
|
286
|
+
this.suggestion.classList.remove("hidden", "hide");
|
|
287
|
+
}
|
|
288
|
+
|
|
260
289
|
positionSuggestionMenu() {
|
|
261
290
|
if (!this.suggestion || this.currentMentionStart === null) {
|
|
262
291
|
return;
|
|
@@ -26,7 +26,7 @@ describe("MentionController", () => {
|
|
|
26
26
|
|
|
27
27
|
document.body.innerHTML = `
|
|
28
28
|
<div class="mention-container">
|
|
29
|
-
<input data-
|
|
29
|
+
<input data-no_results="No users found" data-search_prompt="Type to search participants" data-controller="mention" />
|
|
30
30
|
</div>
|
|
31
31
|
`;
|
|
32
32
|
|
|
@@ -111,17 +111,20 @@ describe("MentionController", () => {
|
|
|
111
111
|
expect(suggestions.classList.contains("hidden")).toBe(false);
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
it("
|
|
114
|
+
it("shows search prompt when first mention character is entered", async () => {
|
|
115
115
|
await connectController();
|
|
116
116
|
|
|
117
117
|
mockElement.value = "Hello @d";
|
|
118
118
|
mockElement.setSelectionRange(mockElement.value.length, mockElement.value.length);
|
|
119
119
|
mockElement.dispatchEvent(new Event("input", { bubbles: true }));
|
|
120
120
|
|
|
121
|
-
await waitForDebounce();
|
|
122
|
-
|
|
123
121
|
const suggestions = document.querySelector(".editor-suggestions");
|
|
124
|
-
|
|
122
|
+
const promptItem = suggestions.querySelector(".editor-suggestions-item");
|
|
123
|
+
|
|
124
|
+
expect(promptItem).toBeInstanceOf(HTMLButtonElement);
|
|
125
|
+
expect(promptItem.textContent).toBe("Type to search participants");
|
|
126
|
+
expect(promptItem.disabled).toBe(true);
|
|
127
|
+
expect(suggestions.classList.contains("hidden")).toBe(false);
|
|
125
128
|
});
|
|
126
129
|
|
|
127
130
|
it("inserts selected mention on click", async () => {
|
|
@@ -68,7 +68,7 @@ describe("MultipleMentionsManager", () => {
|
|
|
68
68
|
spellcheck="false"
|
|
69
69
|
autocomplete="off"
|
|
70
70
|
placeholder="Search..."
|
|
71
|
-
data-
|
|
71
|
+
data-no_results="No results"
|
|
72
72
|
data-selected= "selected-users"
|
|
73
73
|
contenteditable="true"
|
|
74
74
|
data-direct-messages-disabled="Direct messages disabled">
|
|
@@ -6,11 +6,16 @@ export const adjustPickerPosition = (input, datePickerContainer, selector) => {
|
|
|
6
6
|
if (getComputedStyle(parent).position === "static") {
|
|
7
7
|
parent.style.position = "relative";
|
|
8
8
|
}
|
|
9
|
+
const stickyFooterItem = document.querySelector(".item__edit-sticky");
|
|
10
|
+
|
|
11
|
+
const availableBottom = stickyFooterItem
|
|
12
|
+
? stickyFooterItem.getBoundingClientRect().top
|
|
13
|
+
: window.innerHeight;
|
|
9
14
|
|
|
10
|
-
const rect = input.getBoundingClientRect();
|
|
11
15
|
const calendarHeight = datePickerContainer.offsetHeight;
|
|
16
|
+
const rect = input.getBoundingClientRect();
|
|
17
|
+
const spaceBelow = availableBottom - rect.bottom;
|
|
12
18
|
const spaceAbove = rect.top;
|
|
13
|
-
const spaceBelow = window.innerHeight - rect.bottom;
|
|
14
19
|
const openBelow = spaceBelow >= calendarHeight || spaceBelow >= spaceAbove;
|
|
15
20
|
|
|
16
21
|
if (openBelow) {
|
|
@@ -50,10 +55,7 @@ export const setMinute = (value) => {
|
|
|
50
55
|
};
|
|
51
56
|
|
|
52
57
|
export const formatInputDate = (date, formats) => {
|
|
53
|
-
const
|
|
54
|
-
const year = dateList[0];
|
|
55
|
-
const month = dateList[1];
|
|
56
|
-
const day = dateList[2];
|
|
58
|
+
const [year, month, day] = date.split("-");
|
|
57
59
|
|
|
58
60
|
if (formats.order === "m-d-y") {
|
|
59
61
|
return `${month}${formats.separator}${day}${formats.separator}${year}`;
|
|
@@ -63,10 +65,34 @@ export const formatInputDate = (date, formats) => {
|
|
|
63
65
|
return `${day}${formats.separator}${month}${formats.separator}${year}`;
|
|
64
66
|
};
|
|
65
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Splits a time string into two elements: hours and minutes. Ensures a returned
|
|
70
|
+
* array of size 2 for any kind of strings or `null` values.
|
|
71
|
+
*
|
|
72
|
+
* Examples:
|
|
73
|
+
* splitTime("") => ["00", "00"]
|
|
74
|
+
* splitTime(null) => ["00", "00"]
|
|
75
|
+
* splitTime("12") => ["12", "00"]
|
|
76
|
+
* splitTime("12:30") => ["12", "30"]
|
|
77
|
+
* splitTime("2:4") => ["02", "04"]
|
|
78
|
+
* splitTime("12:30:45") => ["12", "30"]
|
|
79
|
+
*
|
|
80
|
+
* @param {String} value The original time string, typically hh:ss.
|
|
81
|
+
* @returns {Array} An array with two elements where the first element is the
|
|
82
|
+
* hour part and the second element is the minute part.
|
|
83
|
+
*/
|
|
84
|
+
const splitTime = (value) => {
|
|
85
|
+
return [...(value || "").split(":"), "00"].splice(0, 2).map((part) => part.padStart(2, "0"));
|
|
86
|
+
};
|
|
87
|
+
|
|
66
88
|
export const formatInputTime = (time, format, input) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
89
|
+
if (!time) {
|
|
90
|
+
return "";
|
|
91
|
+
} else if (time.length < 1) {
|
|
92
|
+
return time;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let [hour, minute] = splitTime(time);
|
|
70
96
|
|
|
71
97
|
if (format === 12) {
|
|
72
98
|
if (Number(hour) === 12) {
|
|
@@ -80,11 +106,9 @@ export const formatInputTime = (time, format, input) => {
|
|
|
80
106
|
} else if (Number(hour) === 0) {
|
|
81
107
|
hour = "12";
|
|
82
108
|
}
|
|
83
|
-
|
|
84
|
-
return `${hour}:${minute}`;
|
|
85
109
|
};
|
|
86
110
|
|
|
87
|
-
return
|
|
111
|
+
return `${hour}:${minute}`;
|
|
88
112
|
};
|
|
89
113
|
|
|
90
114
|
export const changeHourDisplay = (change, hour, format) => {
|
|
@@ -172,16 +196,29 @@ export const updateTimeValue = (time, hour, minute) => {
|
|
|
172
196
|
};
|
|
173
197
|
|
|
174
198
|
export const formatDate = (value, formats) => {
|
|
175
|
-
|
|
176
|
-
const splitValue = value.split(formats.separator);
|
|
199
|
+
const splitValue = value.split(formats.separator).splice(0, 3).map((part) => part.replace(/[^0-9]/g, ""));
|
|
177
200
|
|
|
178
|
-
|
|
179
|
-
|
|
201
|
+
// Keep an empty date empty instead of silently defaulting to today
|
|
202
|
+
if (splitValue.every((part) => !part)) {
|
|
203
|
+
return "";
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let newValue = null;
|
|
207
|
+
if (formats.order === "m-d-y") {
|
|
208
|
+
newValue = [splitValue[0], splitValue[1], splitValue[2]];
|
|
180
209
|
} else if (formats.order === "y-m-d") {
|
|
181
|
-
newValue =
|
|
182
|
-
}
|
|
210
|
+
newValue = [splitValue[1], splitValue[2], splitValue[0]];
|
|
211
|
+
} else {
|
|
212
|
+
// Assuming d-m-y
|
|
213
|
+
newValue = [splitValue[1], splitValue[0], splitValue[2]];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Fill missing parts
|
|
217
|
+
let fallback = new Date();
|
|
218
|
+
fallback = [fallback.getMonth() + 1, fallback.getDate(), fallback.getFullYear()];
|
|
219
|
+
newValue = newValue.map((val, idx) => (val || fallback[idx]));
|
|
183
220
|
|
|
184
|
-
const date = new Date(newValue)
|
|
221
|
+
const date = new Date(newValue.join("/"))
|
|
185
222
|
|
|
186
223
|
let day = date.getDate();
|
|
187
224
|
let month = date.getMonth() + 1;
|
|
@@ -199,29 +236,21 @@ export const formatDate = (value, formats) => {
|
|
|
199
236
|
};
|
|
200
237
|
|
|
201
238
|
export const formatTime = (value, format, inputname) => {
|
|
239
|
+
let [hour, minute] = splitTime(value);
|
|
240
|
+
|
|
202
241
|
if (format === 12) {
|
|
203
|
-
const splitValue = value.split(":");
|
|
204
|
-
let hour = splitValue[0];
|
|
205
|
-
const minute = splitValue[1];
|
|
206
242
|
if (document.getElementById(`period_am_${inputname}`).checked) {
|
|
207
|
-
|
|
208
|
-
case "12":
|
|
243
|
+
if (hour === "12") {
|
|
209
244
|
hour = "00";
|
|
210
|
-
|
|
211
|
-
return `${hour}:${minute}`;
|
|
212
|
-
default:
|
|
213
|
-
return value;
|
|
214
|
-
};
|
|
245
|
+
}
|
|
215
246
|
} else if (document.getElementById(`period_pm_${inputname}`).checked) {
|
|
216
247
|
if (Number(hour) > 0 && Number(hour) < 12) {
|
|
217
248
|
hour = `${Number(hour) + 12}`;
|
|
218
249
|
};
|
|
219
|
-
|
|
220
|
-
return `${hour}:${minute}`
|
|
221
250
|
};
|
|
222
251
|
};
|
|
223
252
|
|
|
224
|
-
return
|
|
253
|
+
return `${hour}:${minute}`;
|
|
225
254
|
};
|
|
226
255
|
|
|
227
256
|
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
|
-
|
|
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();
|
|
@@ -51,7 +51,7 @@ export default function generateDatePicker(input, row, formats) {
|
|
|
51
51
|
dateColumn.appendChild(datePickerContainer);
|
|
52
52
|
|
|
53
53
|
let prevDate = null;
|
|
54
|
-
let defaultTime = input.
|
|
54
|
+
let defaultTime = input.dataset.defaultTime || "00:00"
|
|
55
55
|
|
|
56
56
|
const datePickerDisplay = (event) => {
|
|
57
57
|
if (!dateColumn.contains(event.target)) {
|
|
@@ -66,13 +66,16 @@ export default function generateDatePicker(input, row, formats) {
|
|
|
66
66
|
date.addEventListener("paste", (event) => {
|
|
67
67
|
event.preventDefault();
|
|
68
68
|
const value = event.clipboardData.getData("text/plain");
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
// Only the date part is accepted; any text after it is ignored
|
|
70
|
+
const pastedDate = value.match(/^([0-9]+[^0-9]){2}[0-9]+/);
|
|
71
|
+
|
|
72
|
+
if (pastedDate) {
|
|
73
|
+
date.value = pastedDate[0].replaceAll(/[^0-9]/g, formats.separator);
|
|
71
74
|
|
|
72
75
|
if (input.type === "date") {
|
|
73
76
|
input.value = `${formatDate(date.value, formats)}`;
|
|
74
77
|
} else if (input.type === "datetime-local") {
|
|
75
|
-
input.value = `${formatDate(date.value, formats)}T${formatTime(document.querySelector(`#${input.id}_time`).value, formats.time, input.id)
|
|
78
|
+
input.value = `${formatDate(date.value, formats)}T${formatTime(document.querySelector(`#${input.id}_time`).value || defaultTime, formats.time, input.id)}`;
|
|
76
79
|
};
|
|
77
80
|
};
|
|
78
81
|
});
|
|
@@ -81,14 +84,19 @@ export default function generateDatePicker(input, row, formats) {
|
|
|
81
84
|
datePickerContainer.style.display = "none";
|
|
82
85
|
});
|
|
83
86
|
|
|
84
|
-
date.addEventListener("
|
|
87
|
+
date.addEventListener("input", () => {
|
|
88
|
+
if (date.value.length === 0) {
|
|
89
|
+
input.value = "";
|
|
90
|
+
return;
|
|
91
|
+
};
|
|
92
|
+
|
|
85
93
|
if (date.value.length === 10) {
|
|
86
|
-
date.value = date.value.replaceAll(/[
|
|
94
|
+
date.value = date.value.replaceAll(/[^0-9]/g, formats.separator);
|
|
87
95
|
prevDate = dateToPicker(date.value, formats);
|
|
88
96
|
if (input.type === "date") {
|
|
89
97
|
input.value = `${formatDate(date.value, formats)}`;
|
|
90
98
|
} else if (input.type === "datetime-local") {
|
|
91
|
-
input.value = `${formatDate(date.value, formats)}T${formatTime(document.querySelector(`#${input.id}_time`).value, formats.time, input.id)
|
|
99
|
+
input.value = `${formatDate(date.value, formats)}T${formatTime(document.querySelector(`#${input.id}_time`).value || defaultTime, formats.time, input.id)}`;
|
|
92
100
|
};
|
|
93
101
|
};
|
|
94
102
|
});
|
|
@@ -103,7 +111,7 @@ export default function generateDatePicker(input, row, formats) {
|
|
|
103
111
|
if (input.type === "date") {
|
|
104
112
|
input.value = `${pickedDate}`;
|
|
105
113
|
} else if (input.type === "datetime-local") {
|
|
106
|
-
input.value = `${pickedDate}T${formatTime(document.querySelector(`#${input.id}_time`).value, formats.time, input.id)
|
|
114
|
+
input.value = `${pickedDate}T${formatTime(document.querySelector(`#${input.id}_time`).value || defaultTime, formats.time, input.id)}`;
|
|
107
115
|
};
|
|
108
116
|
datePickerContainer.style.display = "none";
|
|
109
117
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable require-jsdoc */
|
|
2
|
-
/* eslint max-lines: ["error",
|
|
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("
|
|
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("
|
|
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", () => {
|
data/app/packs/src/decidim/datepicker/test/datepicker_functions_adjust_picker_position.test.js
CHANGED
|
@@ -128,6 +128,37 @@ describe("adjustDatePickerPosition", () => {
|
|
|
128
128
|
|
|
129
129
|
expect(datePickerContainer.style.right).toBe("0px");
|
|
130
130
|
});
|
|
131
|
+
|
|
132
|
+
it("opens below when there is enough space above the sticky action area", () => {
|
|
133
|
+
jest.spyOn(input, "getBoundingClientRect").mockReturnValue({
|
|
134
|
+
top: 100,
|
|
135
|
+
bottom: 140
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
Reflect.defineProperty(window, "innerHeight", {
|
|
139
|
+
writable: true,
|
|
140
|
+
configurable: true,
|
|
141
|
+
value: 800
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const stickyContainer = document.createElement("div");
|
|
145
|
+
stickyContainer.className = "item__edit-sticky";
|
|
146
|
+
|
|
147
|
+
jest.spyOn(stickyContainer, "getBoundingClientRect").mockReturnValue({
|
|
148
|
+
top: 500
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
document.body.appendChild(stickyContainer);
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
adjustPickerPosition(input, datePickerContainer, ".datepicker__date-column");
|
|
155
|
+
|
|
156
|
+
expect(datePickerContainer.style.top).toBe("40px");
|
|
157
|
+
expect(datePickerContainer.style.bottom).toBe("");
|
|
158
|
+
} finally {
|
|
159
|
+
document.body.removeChild(stickyContainer);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
131
162
|
});
|
|
132
163
|
|
|
133
164
|
|
|
@@ -231,4 +262,37 @@ describe("adjustTimePickerPosition", () => {
|
|
|
231
262
|
|
|
232
263
|
expect(timePicker.style.right).toBe("0px");
|
|
233
264
|
});
|
|
265
|
+
|
|
266
|
+
it("opens above when sticky action area reduces the available space below", () => {
|
|
267
|
+
jest.spyOn(input, "getBoundingClientRect").mockReturnValue({
|
|
268
|
+
top: 300,
|
|
269
|
+
bottom: 340
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
Reflect.defineProperty(window, "innerHeight", {
|
|
273
|
+
writable: true,
|
|
274
|
+
configurable: true,
|
|
275
|
+
value: 600
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
const stickyContainer = document.createElement("div");
|
|
279
|
+
stickyContainer.className = "item__edit-sticky";
|
|
280
|
+
|
|
281
|
+
jest.spyOn(stickyContainer, "getBoundingClientRect").mockReturnValue({
|
|
282
|
+
top: 500
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
document.body.appendChild(stickyContainer);
|
|
286
|
+
|
|
287
|
+
adjustPickerPosition(
|
|
288
|
+
input,
|
|
289
|
+
timePicker,
|
|
290
|
+
".datepicker__time-column"
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
expect(timePicker.style.top).toBe("");
|
|
294
|
+
expect(timePicker.style.bottom).toBe("30px");
|
|
295
|
+
|
|
296
|
+
document.body.removeChild(stickyContainer);
|
|
297
|
+
});
|
|
234
298
|
});
|