From bb7f0cd3a5adb0729a6b979ad0a4562f1ca52761 Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Thu, 7 Nov 2024 10:18:11 +0100 Subject: [PATCH 01/17] 119602: Improve profile page link accessibility --- src/app/profile-page/profile-page.component.html | 2 +- src/assets/i18n/en.json5 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/profile-page/profile-page.component.html b/src/app/profile-page/profile-page.component.html index d8394ac5d4c..d2809a04b64 100644 --- a/src/app/profile-page/profile-page.component.html +++ b/src/app/profile-page/profile-page.component.html @@ -35,7 +35,7 @@

{{'profile.head' | translate}}

{{'profile.card.accessibility.header' | translate}}
-
{{'profile.card.accessibility.content' | translate}}
+ {{'profile.card.accessibility.content' | translate}} {{'profile.card.accessibility.link' | translate}}
diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index fc749377a98..dc69f0fbe86 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3278,7 +3278,7 @@ "profile.card.accessibility.header": "Accessibility", - "profile.card.accessibility.link": "Accessibility Settings Page", + "profile.card.accessibility.link": "Go to Accessibility Settings Page", "profile.card.identify": "Identify", From fe90d39943f62d025b0e3ab64d57bcc017ed46b2 Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Mon, 18 Nov 2024 11:36:10 +0100 Subject: [PATCH 02/17] 119602: Add placeholder in form --- .../accessibility/accessibility-settings.service.ts | 11 +++++++++++ .../accessibility-settings.component.html | 1 + .../accessibility-settings.component.ts | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/src/app/accessibility/accessibility-settings.service.ts b/src/app/accessibility/accessibility-settings.service.ts index 4089fd03b17..77b6c91bea8 100644 --- a/src/app/accessibility/accessibility-settings.service.ts +++ b/src/app/accessibility/accessibility-settings.service.ts @@ -224,4 +224,15 @@ export class AccessibilitySettingsService { } } + getPlaceholder(setting: AccessibilitySetting): string { + switch (setting) { + case AccessibilitySetting.NotificationTimeOut: + return environment.notifications.timeOut.toString(); + case AccessibilitySetting.LiveRegionTimeOut: + return environment.liveRegion.messageTimeOutDurationMs.toString(); + default: + return ''; + } + } + } diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.html b/src/app/info/accessibility-settings/accessibility-settings.component.html index 6550c6a2880..8a76917462c 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.html +++ b/src/app/info/accessibility-settings/accessibility-settings.component.html @@ -9,6 +9,7 @@

{{ 'info.accessibility-settings.title' | translate }}

diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.ts b/src/app/info/accessibility-settings/accessibility-settings.component.ts index 97e3ddb321f..ed1d481be61 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.ts +++ b/src/app/info/accessibility-settings/accessibility-settings.component.ts @@ -38,6 +38,10 @@ export class AccessibilitySettingsComponent implements OnInit { return this.settingsService.getInputType(setting); } + getPlaceholder(setting: AccessibilitySetting): string { + return this.settingsService.getPlaceholder(setting); + } + saveSettings() { this.settingsService.setSettings(this.formValues).pipe(take(1)).subscribe(location => { this.notificationsService.success(null, this.translateService.instant('info.accessibility-settings.save-notification.' + location)); From ecb00a95a07424bafa1976e871086585c3374b7a Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Mon, 18 Nov 2024 13:50:46 +0100 Subject: [PATCH 03/17] 119602: Implement converting of accessibility settings values --- .../accessibility-settings.service.ts | 105 +++++++++++++++++- .../accessibility-settings.component.ts | 22 +++- 2 files changed, 122 insertions(+), 5 deletions(-) diff --git a/src/app/accessibility/accessibility-settings.service.ts b/src/app/accessibility/accessibility-settings.service.ts index 77b6c91bea8..bdf1d296797 100644 --- a/src/app/accessibility/accessibility-settings.service.ts +++ b/src/app/accessibility/accessibility-settings.service.ts @@ -30,7 +30,7 @@ export enum AccessibilitySetting { LiveRegionTimeOut = 'liveRegionTimeOut', } -export type AccessibilitySettings = { [key in AccessibilitySetting]?: any }; +export type AccessibilitySettings = { [key in AccessibilitySetting]?: string }; /** * Service handling the retrieval and configuration of accessibility settings. @@ -235,4 +235,107 @@ export class AccessibilitySettingsService { } } + /** + * Returns the converter method for the provided setting. + * The converter methods are used to convert the value entered by the user in the form to the format that is used + * to store the setting value. + */ + getFormValueToStoredValueConverterMethod(setting: AccessibilitySetting): (value: string) => string { + switch (setting) { + case AccessibilitySetting.NotificationTimeOut: + return secondsToMilliseconds; + case AccessibilitySetting.LiveRegionTimeOut: + return secondsToMilliseconds; + default: + return null; + } + } + + /** + * Convert the user-configured value to the format used to store the setting value. + * Returns the provided value without conversion if no converter is configured for the provided setting. + */ + convertFormValueToStoredValue(setting: AccessibilitySetting, value: string): string { + const converterMethod = this.getFormValueToStoredValueConverterMethod(setting); + + if (hasValue(converterMethod)) { + return converterMethod(value); + } else { + return value; + } + } + + /** + * Convert all values in the provided accessibility settings object to values ready to be stored. + */ + convertAllFormValuesToStoredValues(settings: AccessibilitySettings): AccessibilitySettings { + const convertedSettings = {}; + + this.getAllAccessibilitySettingKeys().filter(setting => setting in settings).forEach(setting => + convertedSettings[setting] = this.convertFormValueToStoredValue(setting, settings[setting]) + ); + + return convertedSettings; + } + + /** + * Returns the converter method for the provided setting. + * The converter methods are used to convert the value as it is stored to the format visible by the user in the form. + */ + getStoredValueToFormValueConverterMethod(setting: AccessibilitySetting): (value: string) => string { + switch (setting) { + case AccessibilitySetting.NotificationTimeOut: + return millisecondsToSeconds; + case AccessibilitySetting.LiveRegionTimeOut: + return millisecondsToSeconds; + default: + return null; + } + } + + /** + * Convert the stored value to the format used in the form. + * Returns the provided value without conversion if no converter is configured for the provided setting. + */ + convertStoredValueToFormValue(setting: AccessibilitySetting, value: string): string { + const converterMethod = this.getStoredValueToFormValueConverterMethod(setting); + + if (hasValue(converterMethod)) { + return converterMethod(value); + } else { + return value; + } + } + + /** + * Convert all values in the provided accessibility settings object to values ready to show in the form. + */ + convertAllStoredValuesToFormValues(settings: AccessibilitySettings): AccessibilitySettings { + const convertedSettings = {}; + + this.getAllAccessibilitySettingKeys().filter(setting => setting in settings).forEach(setting => + convertedSettings[setting] = this.convertStoredValueToFormValue(setting, settings[setting]) + ); + + return convertedSettings; + } + +} + +function secondsToMilliseconds(secondsStr: string): string { + const seconds = parseFloat(secondsStr); + if (isNaN(seconds)) { + return null; + } else { + return (seconds * 1000).toString(); + } +} + +function millisecondsToSeconds(millisecondsStr: string): string { + const milliseconds = parseFloat(millisecondsStr); + if (isNaN(milliseconds)) { + return null; + } else { + return (milliseconds / 1000).toString(); + } } diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.ts b/src/app/info/accessibility-settings/accessibility-settings.component.ts index ed1d481be61..6d325e8f0cf 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.ts +++ b/src/app/info/accessibility-settings/accessibility-settings.component.ts @@ -29,9 +29,7 @@ export class AccessibilitySettingsComponent implements OnInit { ngOnInit() { this.accessibilitySettingsOptions = this.settingsService.getAllAccessibilitySettingKeys(); - this.settingsService.getAll().pipe(take(1)).subscribe(currentSettings => { - this.formValues = currentSettings; - }); + this.updateFormValues(); } getInputType(setting: AccessibilitySetting): string { @@ -42,10 +40,26 @@ export class AccessibilitySettingsComponent implements OnInit { return this.settingsService.getPlaceholder(setting); } + /** + * Saves the user-configured settings + */ saveSettings() { - this.settingsService.setSettings(this.formValues).pipe(take(1)).subscribe(location => { + const formValues = this.formValues; + const convertedValues = this.settingsService.convertAllFormValuesToStoredValues(formValues); + this.settingsService.setSettings(convertedValues).pipe(take(1)).subscribe(location => { this.notificationsService.success(null, this.translateService.instant('info.accessibility-settings.save-notification.' + location)); }); + + this.updateFormValues(); + } + + /** + * Updates the form values with the currently stored accessibility settings + */ + updateFormValues() { + this.settingsService.getAll().pipe(take(1)).subscribe(storedSettings => { + this.formValues = this.settingsService.convertAllStoredValuesToFormValues(storedSettings); + }); } } From fdfa6e2c06042a22b6055760818406ea6b83ff9f Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Mon, 18 Nov 2024 14:26:48 +0100 Subject: [PATCH 04/17] 119602: Update values after converters implementation --- src/app/accessibility/accessibility-settings.service.ts | 4 ++-- src/assets/i18n/en.json5 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/accessibility/accessibility-settings.service.ts b/src/app/accessibility/accessibility-settings.service.ts index bdf1d296797..8434614434f 100644 --- a/src/app/accessibility/accessibility-settings.service.ts +++ b/src/app/accessibility/accessibility-settings.service.ts @@ -227,9 +227,9 @@ export class AccessibilitySettingsService { getPlaceholder(setting: AccessibilitySetting): string { switch (setting) { case AccessibilitySetting.NotificationTimeOut: - return environment.notifications.timeOut.toString(); + return millisecondsToSeconds(environment.notifications.timeOut.toString()); case AccessibilitySetting.LiveRegionTimeOut: - return environment.liveRegion.messageTimeOutDurationMs.toString(); + return millisecondsToSeconds(environment.liveRegion.messageTimeOutDurationMs.toString()); default: return ''; } diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index dc69f0fbe86..6cf15ed8448 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -1846,11 +1846,11 @@ "info.accessibility-settings.liveRegionTimeOut.label": "Live region time-out", - "info.accessibility-settings.liveRegionTimeOut.hint": "The duration in milliseconds after which a message in the live region disappears.", + "info.accessibility-settings.liveRegionTimeOut.hint": "The duration in seconds after which a message in the live region disappears.", "info.accessibility-settings.notificationTimeOut.label": "Notification time-out", - "info.accessibility-settings.notificationTimeOut.hint": "The duration in milliseconds after which a notification disappears. Set to 0 for notifications to remain indefinitely.", + "info.accessibility-settings.notificationTimeOut.hint": "The duration in seconds after which a notification disappears. Set to 0 for notifications to remain indefinitely.", "info.accessibility-settings.save-notification.cookie": "Successfully saved settings locally.", From dc8a699e94be3069b1eed53a3f9927d2aa151bec Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Fri, 22 Nov 2024 11:55:05 +0100 Subject: [PATCH 05/17] 119602: Rework convertion & form format --- .../accessibility-settings.service.ts | 108 +++--------------- .../accessibility-settings.component.html | 35 ++++-- .../accessibility-settings.component.ts | 16 +-- 3 files changed, 49 insertions(+), 110 deletions(-) diff --git a/src/app/accessibility/accessibility-settings.service.ts b/src/app/accessibility/accessibility-settings.service.ts index 8434614434f..48e2c8f5de9 100644 --- a/src/app/accessibility/accessibility-settings.service.ts +++ b/src/app/accessibility/accessibility-settings.service.ts @@ -32,6 +32,11 @@ export enum AccessibilitySetting { export type AccessibilitySettings = { [key in AccessibilitySetting]?: string }; +export interface AccessibilitySettingsFormValues { + notificationTimeOut: string, + liveRegionTimeOut: string, +} + /** * Service handling the retrieval and configuration of accessibility settings. * @@ -210,20 +215,6 @@ export class AccessibilitySettingsService { } } - /** - * Returns the input type that a form should use for the provided {@link AccessibilitySetting} - */ - getInputType(setting: AccessibilitySetting): string { - switch (setting) { - case AccessibilitySetting.NotificationTimeOut: - return 'number'; - case AccessibilitySetting.LiveRegionTimeOut: - return 'number'; - default: - return 'text'; - } - } - getPlaceholder(setting: AccessibilitySetting): string { switch (setting) { case AccessibilitySetting.NotificationTimeOut: @@ -236,88 +227,23 @@ export class AccessibilitySettingsService { } /** - * Returns the converter method for the provided setting. - * The converter methods are used to convert the value entered by the user in the form to the format that is used - * to store the setting value. + * Convert values in the provided accessibility settings object to values ready to be stored. */ - getFormValueToStoredValueConverterMethod(setting: AccessibilitySetting): (value: string) => string { - switch (setting) { - case AccessibilitySetting.NotificationTimeOut: - return secondsToMilliseconds; - case AccessibilitySetting.LiveRegionTimeOut: - return secondsToMilliseconds; - default: - return null; - } - } - - /** - * Convert the user-configured value to the format used to store the setting value. - * Returns the provided value without conversion if no converter is configured for the provided setting. - */ - convertFormValueToStoredValue(setting: AccessibilitySetting, value: string): string { - const converterMethod = this.getFormValueToStoredValueConverterMethod(setting); - - if (hasValue(converterMethod)) { - return converterMethod(value); - } else { - return value; - } + convertFormValuesToStoredValues(settings: AccessibilitySettingsFormValues): AccessibilitySettings { + return { + 'notificationTimeOut': secondsToMilliseconds(settings.notificationTimeOut), + 'liveRegionTimeOut': secondsToMilliseconds(settings.liveRegionTimeOut), + }; } /** - * Convert all values in the provided accessibility settings object to values ready to be stored. + * Convert values in the provided accessibility settings object to values ready to show in the form. */ - convertAllFormValuesToStoredValues(settings: AccessibilitySettings): AccessibilitySettings { - const convertedSettings = {}; - - this.getAllAccessibilitySettingKeys().filter(setting => setting in settings).forEach(setting => - convertedSettings[setting] = this.convertFormValueToStoredValue(setting, settings[setting]) - ); - - return convertedSettings; - } - - /** - * Returns the converter method for the provided setting. - * The converter methods are used to convert the value as it is stored to the format visible by the user in the form. - */ - getStoredValueToFormValueConverterMethod(setting: AccessibilitySetting): (value: string) => string { - switch (setting) { - case AccessibilitySetting.NotificationTimeOut: - return millisecondsToSeconds; - case AccessibilitySetting.LiveRegionTimeOut: - return millisecondsToSeconds; - default: - return null; - } - } - - /** - * Convert the stored value to the format used in the form. - * Returns the provided value without conversion if no converter is configured for the provided setting. - */ - convertStoredValueToFormValue(setting: AccessibilitySetting, value: string): string { - const converterMethod = this.getStoredValueToFormValueConverterMethod(setting); - - if (hasValue(converterMethod)) { - return converterMethod(value); - } else { - return value; - } - } - - /** - * Convert all values in the provided accessibility settings object to values ready to show in the form. - */ - convertAllStoredValuesToFormValues(settings: AccessibilitySettings): AccessibilitySettings { - const convertedSettings = {}; - - this.getAllAccessibilitySettingKeys().filter(setting => setting in settings).forEach(setting => - convertedSettings[setting] = this.convertStoredValueToFormValue(setting, settings[setting]) - ); - - return convertedSettings; + convertStoredValuesToFormValues(settings: AccessibilitySettings): AccessibilitySettingsFormValues { + return { + notificationTimeOut: millisecondsToSeconds(settings.notificationTimeOut), + liveRegionTimeOut: millisecondsToSeconds(settings.liveRegionTimeOut), + }; } } diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.html b/src/app/info/accessibility-settings/accessibility-settings.component.html index 8a76917462c..947bff495a1 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.html +++ b/src/app/info/accessibility-settings/accessibility-settings.component.html @@ -2,19 +2,36 @@

{{ 'info.accessibility-settings.title' | translate }}

-
-
diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.ts b/src/app/info/accessibility-settings/accessibility-settings.component.ts index ea7c853a972..0de18152eef 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.ts +++ b/src/app/info/accessibility-settings/accessibility-settings.component.ts @@ -57,4 +57,14 @@ export class AccessibilitySettingsComponent implements OnInit { }); } + /** + * Resets accessibility settings + */ + resetSettings() { + this.settingsService.clearSettings().pipe(take(1)).subscribe(() => { + this.notificationsService.success(null, this.translateService.instant('info.accessibility-settings.reset-notification')); + this.updateFormValues(); + }); + } + } diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index d9533da9c7f..69127375cf4 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -1860,6 +1860,10 @@ "info.accessibility-settings.save-notification.metadata": "Successfully saved settings on the user profile.", + "info.accessibility-settings.reset-notification": "Successfully reset settings.", + + "info.accessibility-settings.reset": "Reset accessibility settings", + "info.accessibility-settings.submit": "Save accessibility settings", "info.accessibility-settings.title": "Accessibility settings", From 287d0283313beae07b7e8d0fcd47b71c349730c1 Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Fri, 22 Nov 2024 16:03:52 +0100 Subject: [PATCH 08/17] 119602: Make input boxes smaller --- .../accessibility-settings.component.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.html b/src/app/info/accessibility-settings/accessibility-settings.component.html index 43371d33366..076cfdf9648 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.html +++ b/src/app/info/accessibility-settings/accessibility-settings.component.html @@ -7,7 +7,7 @@

{{ 'info.accessibility-settings.title' | translate }}

{{ 'info.accessibility-settings.disableNotificationTimeOut.label' | translate }} -
+
{{ 'info.accessibility-settings.title' | translate }} {{ 'info.accessibility-settings.notificationTimeOut.label' | translate }} -
+
{{ 'info.accessibility-settings.title' | translate }} {{ 'info.accessibility-settings.liveRegionTimeOut.label' | translate }} -
+
Date: Fri, 22 Nov 2024 16:09:12 +0100 Subject: [PATCH 09/17] 119602: Add unit after input fields --- .../accessibility-settings.component.html | 8 ++++++++ src/assets/i18n/en.json5 | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.html b/src/app/info/accessibility-settings/accessibility-settings.component.html index 076cfdf9648..d3c03f556b6 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.html +++ b/src/app/info/accessibility-settings/accessibility-settings.component.html @@ -35,6 +35,10 @@

{{ 'info.accessibility-settings.title' | translate }}

{{ 'info.accessibility-settings.notificationTimeOut.hint' | translate }}
+ +
+ {{ 'info.accessibility-settings.notificationTimeOut.unit' | translate }} +
@@ -52,6 +56,10 @@

{{ 'info.accessibility-settings.title' | translate }}

{{ 'info.accessibility-settings.liveRegionTimeOut.hint' | translate }}
+ +
+ {{ 'info.accessibility-settings.liveRegionTimeOut.unit' | translate }} +
diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 69127375cf4..54286d60744 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -1850,11 +1850,15 @@ "info.accessibility-settings.liveRegionTimeOut.label": "Live region time-out", - "info.accessibility-settings.liveRegionTimeOut.hint": "The duration in seconds after which a message in the live region disappears.", + "info.accessibility-settings.liveRegionTimeOut.hint": "The duration after which a message in the live region disappears.", + + "info.accessibility-settings.liveRegionTimeOut.unit": "Seconds", "info.accessibility-settings.notificationTimeOut.label": "Notification time-out", - "info.accessibility-settings.notificationTimeOut.hint": "The duration in seconds after which a notification disappears.", + "info.accessibility-settings.notificationTimeOut.hint": "The duration after which a notification disappears.", + + "info.accessibility-settings.notificationTimeOut.unit": "Seconds", "info.accessibility-settings.save-notification.cookie": "Successfully saved settings locally.", From 5a28e66b2f6b6c8335821eb5526f7f347810115d Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Mon, 25 Nov 2024 09:44:27 +0100 Subject: [PATCH 10/17] 119602: Move hints to contextHelp --- .../accessibility-settings.component.html | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.html b/src/app/info/accessibility-settings/accessibility-settings.component.html index d3c03f556b6..d247b12f949 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.html +++ b/src/app/info/accessibility-settings/accessibility-settings.component.html @@ -7,15 +7,19 @@

{{ 'info.accessibility-settings.title' | translate }}

{{ 'info.accessibility-settings.disableNotificationTimeOut.label' | translate }} -
+
+
- - {{ 'info.accessibility-settings.disableNotificationTimeOut.hint' | translate }} - +
@@ -30,15 +34,19 @@

{{ 'info.accessibility-settings.title' | translate }}

[readOnly]="formValues.disableNotificationTimeOut" [(ngModel)]="formValues.notificationTimeOut" [ngModelOptions]="{ standalone: true }" [attr.aria-describedby]="'notificationTimeOutHint'"> - - - {{ 'info.accessibility-settings.notificationTimeOut.hint' | translate }} -
-
+
{{ 'info.accessibility-settings.notificationTimeOut.unit' | translate }}
+ +
+
@@ -51,15 +59,19 @@

{{ 'info.accessibility-settings.title' | translate }}

[placeholder]="getPlaceholder(AccessibilitySetting.LiveRegionTimeOut)" [(ngModel)]="formValues.liveRegionTimeOut" [ngModelOptions]="{ standalone: true }" [attr.aria-describedby]="'liveRegionTimeOutHint'"> - - - {{ 'info.accessibility-settings.liveRegionTimeOut.hint' | translate }} -
-
+
{{ 'info.accessibility-settings.liveRegionTimeOut.unit' | translate }}
+ +
+
From ced163a25f40dabd446c9141f10aa6e69b1460a8 Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Mon, 25 Nov 2024 09:49:09 +0100 Subject: [PATCH 11/17] 119602: Remove obsolete tests --- .../accessibility-settings.service.spec.ts | 8 -------- .../accessibility-settings.component.spec.ts | 13 +------------ 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/app/accessibility/accessibility-settings.service.spec.ts b/src/app/accessibility/accessibility-settings.service.spec.ts index d6f61840575..5344c31d452 100644 --- a/src/app/accessibility/accessibility-settings.service.spec.ts +++ b/src/app/accessibility/accessibility-settings.service.spec.ts @@ -368,12 +368,4 @@ describe('accessibilitySettingsService', () => { }); }); - describe('getInputType', () => { - it('should correctly return the input type', () => { - expect(service.getInputType(AccessibilitySetting.NotificationTimeOut)).toEqual('number'); - expect(service.getInputType(AccessibilitySetting.LiveRegionTimeOut)).toEqual('number'); - expect(service.getInputType('unknownValue' as AccessibilitySetting)).toEqual('text'); - }); - }); - }); diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.spec.ts b/src/app/info/accessibility-settings/accessibility-settings.component.spec.ts index f6d3252a384..3ba0e1ab967 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.spec.ts +++ b/src/app/info/accessibility-settings/accessibility-settings.component.spec.ts @@ -4,7 +4,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { AuthServiceStub } from '../../shared/testing/auth-service.stub'; import { getAccessibilitySettingsServiceStub } from '../../accessibility/accessibility-settings.service.stub'; -import { AccessibilitySettingsService, AccessibilitySetting } from '../../accessibility/accessibility-settings.service'; +import { AccessibilitySettingsService } from '../../accessibility/accessibility-settings.service'; import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub'; import { AuthService } from '../../core/auth/auth.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; @@ -47,22 +47,11 @@ describe('AccessibilitySettingsComponent', () => { }); describe('On Init', () => { - it('should retrieve all accessibility settings options', () => { - expect(settingsService.getAllAccessibilitySettingKeys).toHaveBeenCalled(); - }); - it('should retrieve the current settings', () => { expect(settingsService.getAll).toHaveBeenCalled(); }); }); - describe('getInputType', () => { - it('should retrieve the input type for the setting from the service', () => { - component.getInputType(AccessibilitySetting.LiveRegionTimeOut); - expect(settingsService.getInputType).toHaveBeenCalledWith(AccessibilitySetting.LiveRegionTimeOut); - }); - }); - describe('saveSettings', () => { it('should save the settings in the service', () => { settingsService.setSettings = jasmine.createSpy('setSettings').and.returnValue(of('cookie')); From ec016e80fb931f8f9ea25a64e0cbeab8d8c4dc16 Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Mon, 25 Nov 2024 10:00:04 +0100 Subject: [PATCH 12/17] 119602: Update AccessibilitySettingsService stub --- .../accessibility/accessibility-settings.service.stub.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/accessibility/accessibility-settings.service.stub.ts b/src/app/accessibility/accessibility-settings.service.stub.ts index b619a337de9..4ac965059e6 100644 --- a/src/app/accessibility/accessibility-settings.service.stub.ts +++ b/src/app/accessibility/accessibility-settings.service.stub.ts @@ -31,4 +31,10 @@ export class AccessibilitySettingsServiceStub { setSettingsInCookie = jasmine.createSpy('setSettingsInCookie'); getInputType = jasmine.createSpy('getInputType').and.returnValue('text'); + + convertFormValuesToStoredValues = jasmine.createSpy('convertFormValuesToStoredValues').and.returnValue({}); + + convertStoredValuesToFormValues = jasmine.createSpy('convertStoredValuesToFormValues').and.returnValue({}); + + getPlaceholder = jasmine.createSpy('getPlaceholder').and.returnValue('placeholder'); } From deb4a63c88dce3b9dd906911cfc2cd83a6ffc8e5 Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Mon, 25 Nov 2024 10:12:39 +0100 Subject: [PATCH 13/17] 119602: Add additional accessibilitySettingsComponent tests --- .../accessibility-settings.component.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.spec.ts b/src/app/info/accessibility-settings/accessibility-settings.component.spec.ts index 3ba0e1ab967..bcd4ff94c86 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.spec.ts +++ b/src/app/info/accessibility-settings/accessibility-settings.component.spec.ts @@ -50,6 +50,10 @@ describe('AccessibilitySettingsComponent', () => { it('should retrieve the current settings', () => { expect(settingsService.getAll).toHaveBeenCalled(); }); + + it('should convert retrieved settings to form format', () => { + expect(settingsService.convertStoredValuesToFormValues).toHaveBeenCalled(); + }); }); describe('saveSettings', () => { @@ -59,6 +63,12 @@ describe('AccessibilitySettingsComponent', () => { expect(settingsService.setSettings).toHaveBeenCalled(); }); + it('should convert form settings to stored format', () => { + settingsService.setSettings = jasmine.createSpy('setSettings').and.returnValue(of('cookie')); + component.saveSettings(); + expect(settingsService.convertFormValuesToStoredValues).toHaveBeenCalled(); + }); + it('should give the user a notification mentioning where the settings were saved', () => { settingsService.setSettings = jasmine.createSpy('setSettings').and.returnValue(of('cookie')); component.saveSettings(); From c38352ed22072921469b7c8b7f00ef6bc18a0019 Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Mon, 25 Nov 2024 10:29:16 +0100 Subject: [PATCH 14/17] 119602: Update doc comments --- .../accessibility-settings.service.ts | 14 ++++++++++++-- .../accessibility-settings.component.ts | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/accessibility/accessibility-settings.service.ts b/src/app/accessibility/accessibility-settings.service.ts index e86742d76de..f2151675391 100644 --- a/src/app/accessibility/accessibility-settings.service.ts +++ b/src/app/accessibility/accessibility-settings.service.ts @@ -23,16 +23,22 @@ export const ACCESSIBILITY_SETTINGS_METADATA_KEY = 'dspace.accessibility.setting /** * Enum containing all possible accessibility settings. - * When adding new settings, the {@link AccessibilitySettingsService#getInputType} method and the i18n keys for the - * accessibility settings page should be updated. + * When adding new settings, make sure to add the new setting to the accessibility-settings component. + * The converter methods to convert from stored format to form format (and vice-versa) need to be updated as well. */ export enum AccessibilitySetting { NotificationTimeOut = 'notificationTimeOut', LiveRegionTimeOut = 'liveRegionTimeOut', } +/** + * Type representing an object that contains accessibility settings values. + */ export type AccessibilitySettings = { [key in AccessibilitySetting]?: string }; +/** + * The accessibility settings object format used by the accessibility-settings component form. + */ export interface AccessibilitySettingsFormValues { disableNotificationTimeOut: boolean, notificationTimeOut: string, @@ -226,6 +232,10 @@ export class AccessibilitySettingsService { return this.setSettingsInAuthenticatedUserMetadata({}); } + /** + * Retrieve the placeholder to be used for the provided AccessibilitySetting. + * Returns an empty string when no placeholder is specified for the provided setting. + */ getPlaceholder(setting: AccessibilitySetting): string { switch (setting) { case AccessibilitySetting.NotificationTimeOut: diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.ts b/src/app/info/accessibility-settings/accessibility-settings.component.ts index 0de18152eef..cd417393d44 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.ts +++ b/src/app/info/accessibility-settings/accessibility-settings.component.ts @@ -9,6 +9,9 @@ import { take } from 'rxjs'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { TranslateService } from '@ngx-translate/core'; +/** + * Component providing the form where users can update accessibility settings. + */ @Component({ selector: 'ds-accessibility-settings', templateUrl: './accessibility-settings.component.html' From cdec4880d2e62c32b7fc40173b936124762163ed Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Fri, 29 Nov 2024 10:44:44 +0100 Subject: [PATCH 15/17] 119602: Compare notifications by id to correctly update store --- .../notifications-board/notifications-board.component.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/shared/notifications/notifications-board/notifications-board.component.ts b/src/app/shared/notifications/notifications-board/notifications-board.component.ts index 20bf7175f6f..8439a1af16d 100644 --- a/src/app/shared/notifications/notifications-board/notifications-board.component.ts +++ b/src/app/shared/notifications/notifications-board/notifications-board.component.ts @@ -10,7 +10,6 @@ import { import { select, Store } from '@ngrx/store'; import { BehaviorSubject, Subscription, take } from 'rxjs'; -import difference from 'lodash/difference'; import { NotificationsService } from '../notifications.service'; import { AppState } from '../../../app.reducer'; @@ -23,6 +22,7 @@ import { AccessibilitySetting } from '../../../accessibility/accessibility-settings.service'; import cloneDeep from 'lodash/cloneDeep'; +import differenceWith from 'lodash/differenceWith'; @Component({ selector: 'ds-notifications-board', @@ -69,13 +69,13 @@ export class NotificationsBoardComponent implements OnInit, OnDestroy { this.notifications = []; } else if (state.length > this.notifications.length) { // Add - const newElem = difference(state, this.notifications); + const newElem = differenceWith(state, this.notifications, this.byId); newElem.forEach((notification) => { this.add(notification); }); } else { // Remove - const delElem = difference(this.notifications, state); + const delElem = differenceWith(this.notifications, state, this.byId); delElem.forEach((notification) => { this.notifications = this.notifications.filter((item: INotification) => item.id !== notification.id); @@ -85,6 +85,9 @@ export class NotificationsBoardComponent implements OnInit, OnDestroy { }); } + private byId = (notificationA: INotification, notificationB: INotification) => + notificationA.id === notificationB.id; + // Add the new notification to the notification array add(item: INotification): void { const toBlock: boolean = this.block(item); From 010b2f9693da1e6905951118f35aefc2a7f6a3fa Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Wed, 11 Dec 2024 09:35:01 +0100 Subject: [PATCH 16/17] 119602: Improve types & docs --- .../accessibility-settings.service.spec.ts | 36 ++++++----------- .../accessibility-settings.service.ts | 40 +++++++++++-------- .../accessibility-settings.component.html | 4 +- .../accessibility-settings.component.ts | 3 -- .../shared/live-region/live-region.service.ts | 4 +- .../notifications-board.component.ts | 5 +-- 6 files changed, 41 insertions(+), 51 deletions(-) diff --git a/src/app/accessibility/accessibility-settings.service.spec.ts b/src/app/accessibility/accessibility-settings.service.spec.ts index 5344c31d452..3d58c02d109 100644 --- a/src/app/accessibility/accessibility-settings.service.spec.ts +++ b/src/app/accessibility/accessibility-settings.service.spec.ts @@ -1,6 +1,5 @@ import { AccessibilitySettingsService, - AccessibilitySetting, AccessibilitySettings, ACCESSIBILITY_SETTINGS_METADATA_KEY, ACCESSIBILITY_COOKIE @@ -41,17 +40,6 @@ describe('accessibilitySettingsService', () => { ); }); - describe('getALlAccessibilitySettingsKeys', () => { - it('should return an array containing all accessibility setting names', () => { - const settingNames: AccessibilitySetting[] = [ - AccessibilitySetting.NotificationTimeOut, - AccessibilitySetting.LiveRegionTimeOut, - ]; - - expect(service.getAllAccessibilitySettingKeys()).toEqual(settingNames); - }); - }); - describe('get', () => { it('should return the setting if it is set', () => { const settings: AccessibilitySettings = { @@ -60,7 +48,7 @@ describe('accessibilitySettingsService', () => { service.getAll = jasmine.createSpy('getAll').and.returnValue(of(settings)); - service.get(AccessibilitySetting.NotificationTimeOut, 'default').subscribe(value => + service.get('notificationTimeOut', 'default').subscribe(value => expect(value).toEqual('1000') ); }); @@ -72,7 +60,7 @@ describe('accessibilitySettingsService', () => { service.getAll = jasmine.createSpy('getAll').and.returnValue(of(settings)); - service.get(AccessibilitySetting.LiveRegionTimeOut, 'default').subscribe(value => + service.get('liveRegionTimeOut', 'default').subscribe(value => expect(value).toEqual('default') ); }); @@ -82,7 +70,7 @@ describe('accessibilitySettingsService', () => { it('should return the setting as number if the value for the setting can be parsed to a number', () => { service.get = jasmine.createSpy('get').and.returnValue(of('1000')); - service.getAsNumber(AccessibilitySetting.NotificationTimeOut).subscribe(value => + service.getAsNumber('notificationTimeOut').subscribe(value => expect(value).toEqual(1000) ); }); @@ -90,7 +78,7 @@ describe('accessibilitySettingsService', () => { it('should return the default value if no value is set for the setting', () => { service.get = jasmine.createSpy('get').and.returnValue(of(null)); - service.getAsNumber(AccessibilitySetting.NotificationTimeOut, 123).subscribe(value => + service.getAsNumber('notificationTimeOut', 123).subscribe(value => expect(value).toEqual(123) ); }); @@ -98,7 +86,7 @@ describe('accessibilitySettingsService', () => { it('should return the default value if the value for the setting can not be parsed to a number', () => { service.get = jasmine.createSpy('get').and.returnValue(of('text')); - service.getAsNumber(AccessibilitySetting.NotificationTimeOut, 123).subscribe(value => + service.getAsNumber('notificationTimeOut', 123).subscribe(value => expect(value).toEqual(123) ); }); @@ -176,7 +164,7 @@ describe('accessibilitySettingsService', () => { it('should correctly update the chosen setting', () => { service.updateSettings = jasmine.createSpy('updateSettings'); - service.set(AccessibilitySetting.LiveRegionTimeOut, '500'); + service.set('liveRegionTimeOut', '500'); expect(service.updateSettings).toHaveBeenCalledWith({ liveRegionTimeOut: '500' }); }); }); @@ -307,7 +295,7 @@ describe('accessibilitySettingsService', () => { }); it('should set the settings in metadata', () => { - service.setSettingsInMetadata(ePerson, { [AccessibilitySetting.LiveRegionTimeOut]: '500' }).subscribe(); + service.setSettingsInMetadata(ePerson, { ['liveRegionTimeOut']: '500' }).subscribe(); expect(ePerson.setMetadata).toHaveBeenCalled(); }); @@ -318,19 +306,19 @@ describe('accessibilitySettingsService', () => { }); it('should create a patch with the metadata changes', () => { - service.setSettingsInMetadata(ePerson, { [AccessibilitySetting.LiveRegionTimeOut]: '500' }).subscribe(); + service.setSettingsInMetadata(ePerson, { ['liveRegionTimeOut']: '500' }).subscribe(); expect(ePersonService.createPatchFromCache).toHaveBeenCalled(); }); it('should send the patch request', () => { - service.setSettingsInMetadata(ePerson, { [AccessibilitySetting.LiveRegionTimeOut]: '500' }).subscribe(); + service.setSettingsInMetadata(ePerson, { ['liveRegionTimeOut']: '500' }).subscribe(); expect(ePersonService.patch).toHaveBeenCalled(); }); it('should emit true when the update succeeded', fakeAsync(() => { ePersonService.patch = jasmine.createSpy().and.returnValue(createSuccessfulRemoteDataObject$({})); - service.setSettingsInMetadata(ePerson, { [AccessibilitySetting.LiveRegionTimeOut]: '500' }) + service.setSettingsInMetadata(ePerson, { ['liveRegionTimeOut']: '500' }) .subscribe(value => { expect(value).toBeTrue(); }); @@ -341,7 +329,7 @@ describe('accessibilitySettingsService', () => { it('should emit false when the update failed', fakeAsync(() => { ePersonService.patch = jasmine.createSpy().and.returnValue(createFailedRemoteDataObject$()); - service.setSettingsInMetadata(ePerson, { [AccessibilitySetting.LiveRegionTimeOut]: '500' }) + service.setSettingsInMetadata(ePerson, { ['liveRegionTimeOut']: '500' }) .subscribe(value => { expect(value).toBeFalse(); }); @@ -357,7 +345,7 @@ describe('accessibilitySettingsService', () => { }); it('should store the settings in a cookie', () => { - service.setSettingsInCookie({ [AccessibilitySetting.LiveRegionTimeOut]: '500' }); + service.setSettingsInCookie({ ['liveRegionTimeOut']: '500' }); expect(cookieService.set).toHaveBeenCalled(); }); diff --git a/src/app/accessibility/accessibility-settings.service.ts b/src/app/accessibility/accessibility-settings.service.ts index f2151675391..e9e41954c7c 100644 --- a/src/app/accessibility/accessibility-settings.service.ts +++ b/src/app/accessibility/accessibility-settings.service.ts @@ -22,19 +22,21 @@ export const ACCESSIBILITY_COOKIE = 'dsAccessibilityCookie'; export const ACCESSIBILITY_SETTINGS_METADATA_KEY = 'dspace.accessibility.settings'; /** - * Enum containing all possible accessibility settings. - * When adding new settings, make sure to add the new setting to the accessibility-settings component. + * Type containing all possible accessibility settings. + * When adding new settings, make sure to add the new setting to the accessibility-settings component form. * The converter methods to convert from stored format to form format (and vice-versa) need to be updated as well. */ -export enum AccessibilitySetting { - NotificationTimeOut = 'notificationTimeOut', - LiveRegionTimeOut = 'liveRegionTimeOut', -} +export type AccessibilitySetting = 'notificationTimeOut' | 'liveRegionTimeOut'; /** - * Type representing an object that contains accessibility settings values. + * Type representing an object that contains accessibility settings values for all accessibility settings. */ -export type AccessibilitySettings = { [key in AccessibilitySetting]?: string }; +export type FullAccessibilitySettings = { [key in AccessibilitySetting]: string }; + +/** + * Type representing an object that contains accessibility settings values for some accessibility settings. + */ +export type AccessibilitySettings = Partial; /** * The accessibility settings object format used by the accessibility-settings component form. @@ -63,10 +65,6 @@ export class AccessibilitySettingsService { ) { } - getAllAccessibilitySettingKeys(): AccessibilitySetting[] { - return Object.entries(AccessibilitySetting).map(([_, val]) => val); - } - /** * Get the stored value for the provided {@link AccessibilitySetting}. If the value does not exist or if it is empty, * the provided defaultValue is emitted instead. @@ -238,9 +236,9 @@ export class AccessibilitySettingsService { */ getPlaceholder(setting: AccessibilitySetting): string { switch (setting) { - case AccessibilitySetting.NotificationTimeOut: + case 'notificationTimeOut': return millisecondsToSeconds(environment.notifications.timeOut.toString()); - case AccessibilitySetting.LiveRegionTimeOut: + case 'liveRegionTimeOut': return millisecondsToSeconds(environment.liveRegion.messageTimeOutDurationMs.toString()); default: return ''; @@ -250,11 +248,11 @@ export class AccessibilitySettingsService { /** * Convert values in the provided accessibility settings object to values ready to be stored. */ - convertFormValuesToStoredValues(settings: AccessibilitySettingsFormValues): AccessibilitySettings { + convertFormValuesToStoredValues(settings: AccessibilitySettingsFormValues): FullAccessibilitySettings { return { - 'notificationTimeOut': settings.disableNotificationTimeOut ? '0' + notificationTimeOut: settings.disableNotificationTimeOut ? '0' : secondsToMilliseconds(settings.notificationTimeOut), - 'liveRegionTimeOut': secondsToMilliseconds(settings.liveRegionTimeOut), + liveRegionTimeOut: secondsToMilliseconds(settings.liveRegionTimeOut), }; } @@ -271,6 +269,10 @@ export class AccessibilitySettingsService { } +/** + * Converts a string representing seconds to a string representing milliseconds + * Returns null if the input could not be parsed to a float + */ function secondsToMilliseconds(secondsStr: string): string { const seconds = parseFloat(secondsStr); if (isNaN(seconds)) { @@ -280,6 +282,10 @@ function secondsToMilliseconds(secondsStr: string): string { } } +/** + * Converts a string representing milliseconds to a string representing seconds + * Returns null if the input could not be parsed to a float + */ function millisecondsToSeconds(millisecondsStr: string): string { const milliseconds = parseFloat(millisecondsStr); if (isNaN(milliseconds)) { diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.html b/src/app/info/accessibility-settings/accessibility-settings.component.html index d247b12f949..5a5493f0bea 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.html +++ b/src/app/info/accessibility-settings/accessibility-settings.component.html @@ -30,7 +30,7 @@

{{ 'info.accessibility-settings.title' | translate }}

@@ -56,7 +56,7 @@

{{ 'info.accessibility-settings.title' | translate }}

diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.ts b/src/app/info/accessibility-settings/accessibility-settings.component.ts index cd417393d44..d537c363c3f 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.ts +++ b/src/app/info/accessibility-settings/accessibility-settings.component.ts @@ -18,9 +18,6 @@ import { TranslateService } from '@ngx-translate/core'; }) export class AccessibilitySettingsComponent implements OnInit { - // Re-export for use in template - protected readonly AccessibilitySetting = AccessibilitySetting; - protected formValues: AccessibilitySettingsFormValues; constructor( diff --git a/src/app/shared/live-region/live-region.service.ts b/src/app/shared/live-region/live-region.service.ts index 7a7b99fa6e7..37f58a2795d 100644 --- a/src/app/shared/live-region/live-region.service.ts +++ b/src/app/shared/live-region/live-region.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { BehaviorSubject, map, Observable, switchMap, take, timer } from 'rxjs'; import { environment } from '../../../environments/environment'; import { UUIDService } from '../../core/shared/uuid.service'; -import { AccessibilitySettingsService, AccessibilitySetting } from '../../accessibility/accessibility-settings.service'; +import { AccessibilitySettingsService } from '../../accessibility/accessibility-settings.service'; export const MIN_MESSAGE_DURATION = 200; @@ -130,7 +130,7 @@ export class LiveRegionService { */ getConfiguredMessageTimeOutMs(): Observable { return this.accessibilitySettingsService.getAsNumber( - AccessibilitySetting.LiveRegionTimeOut, + 'liveRegionTimeOut', this.getMessageTimeOutMs(), ).pipe(map(timeOut => Math.max(timeOut, MIN_MESSAGE_DURATION))); } diff --git a/src/app/shared/notifications/notifications-board/notifications-board.component.ts b/src/app/shared/notifications/notifications-board/notifications-board.component.ts index 8439a1af16d..96319416268 100644 --- a/src/app/shared/notifications/notifications-board/notifications-board.component.ts +++ b/src/app/shared/notifications/notifications-board/notifications-board.component.ts @@ -18,8 +18,7 @@ import { INotification } from '../models/notification.model'; import { NotificationsState } from '../notifications.reducers'; import { INotificationBoardOptions } from '../../../../config/notifications-config.interfaces'; import { - AccessibilitySettingsService, - AccessibilitySetting + AccessibilitySettingsService } from '../../../accessibility/accessibility-settings.service'; import cloneDeep from 'lodash/cloneDeep'; import differenceWith from 'lodash/differenceWith'; @@ -98,7 +97,7 @@ export class NotificationsBoardComponent implements OnInit, OnDestroy { // It would be a bit better to handle the retrieval of configured settings in the NotificationsService. // Due to circular dependencies this is difficult to implement. - this.accessibilitySettingsService.getAsNumber(AccessibilitySetting.NotificationTimeOut, item.options.timeOut) + this.accessibilitySettingsService.getAsNumber('notificationTimeOut', item.options.timeOut) .pipe(take(1)).subscribe(timeOut => { if (timeOut < 0) { timeOut = 0; From c71c6667e03cae24b718803363e71b91e83b0c8c Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Wed, 11 Dec 2024 10:10:16 +0100 Subject: [PATCH 17/17] 119602: Improve notification hiding toggle useability --- src/app/accessibility/accessibility-settings.service.ts | 8 ++++---- .../accessibility-settings.component.html | 4 ++-- src/assets/i18n/en.json5 | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/accessibility/accessibility-settings.service.ts b/src/app/accessibility/accessibility-settings.service.ts index e9e41954c7c..813bccd4706 100644 --- a/src/app/accessibility/accessibility-settings.service.ts +++ b/src/app/accessibility/accessibility-settings.service.ts @@ -42,7 +42,7 @@ export type AccessibilitySettings = Partial; * The accessibility settings object format used by the accessibility-settings component form. */ export interface AccessibilitySettingsFormValues { - disableNotificationTimeOut: boolean, + notificationTimeOutEnabled: boolean, notificationTimeOut: string, liveRegionTimeOut: string, } @@ -250,8 +250,8 @@ export class AccessibilitySettingsService { */ convertFormValuesToStoredValues(settings: AccessibilitySettingsFormValues): FullAccessibilitySettings { return { - notificationTimeOut: settings.disableNotificationTimeOut ? '0' - : secondsToMilliseconds(settings.notificationTimeOut), + notificationTimeOut: settings.notificationTimeOutEnabled ? + secondsToMilliseconds(settings.notificationTimeOut) : '0', liveRegionTimeOut: secondsToMilliseconds(settings.liveRegionTimeOut), }; } @@ -261,7 +261,7 @@ export class AccessibilitySettingsService { */ convertStoredValuesToFormValues(settings: AccessibilitySettings): AccessibilitySettingsFormValues { return { - disableNotificationTimeOut: parseFloat(settings.notificationTimeOut) === 0, + notificationTimeOutEnabled: parseFloat(settings.notificationTimeOut) !== 0, notificationTimeOut: millisecondsToSeconds(settings.notificationTimeOut), liveRegionTimeOut: millisecondsToSeconds(settings.liveRegionTimeOut), }; diff --git a/src/app/info/accessibility-settings/accessibility-settings.component.html b/src/app/info/accessibility-settings/accessibility-settings.component.html index 5a5493f0bea..cacfae61fce 100644 --- a/src/app/info/accessibility-settings/accessibility-settings.component.html +++ b/src/app/info/accessibility-settings/accessibility-settings.component.html @@ -9,7 +9,7 @@

{{ 'info.accessibility-settings.title' | translate }}

@@ -31,7 +31,7 @@

{{ 'info.accessibility-settings.title' | translate }}

diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 54286d60744..94126bbc168 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -1844,7 +1844,7 @@ "info.accessibility-settings.breadcrumbs": "Accessibility settings", - "info.accessibility-settings.disableNotificationTimeOut.label": "Disable automatic notification hiding", + "info.accessibility-settings.disableNotificationTimeOut.label": "Hide notifications automatically", "info.accessibility-settings.disableNotificationTimeOut.hint": "When this toggle is activated, notifications will remain until manually closed.",