From 319d845669cc6634cb3329b2f0d0b5fad61877c2 Mon Sep 17 00:00:00 2001 From: Marthym Date: Sun, 20 Oct 2024 16:20:10 +0200 Subject: [PATCH 1/4] feat(sandside): #215 add autoread user setting --- .../baywatch/security/api/model/UserSettings.java | 3 ++- .../security/infra/mappers/UserSettingsMapper.java | 9 ++++++--- .../baywatch/security/infra/model/UserSettingsForm.java | 3 ++- .../V2_1_202410201508__users_settings_autoread.sql | 2 ++ .../src/main/resources/graphql/security/_model.graphqls | 2 ++ 5 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 sandside/src/main/resources/db/migration/V2_1_202410201508__users_settings_autoread.sql diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/api/model/UserSettings.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/api/model/UserSettings.java index ae743616..298f9e62 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/api/model/UserSettings.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/api/model/UserSettings.java @@ -3,6 +3,7 @@ import java.util.Locale; public record UserSettings( - Locale preferredLocale + Locale preferredLocale, + boolean autoread ) { } diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/mappers/UserSettingsMapper.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/mappers/UserSettingsMapper.java index 41770a90..46d1eaa9 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/mappers/UserSettingsMapper.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/mappers/UserSettingsMapper.java @@ -14,13 +14,16 @@ @Mapper(componentModel = "spring") public interface UserSettingsMapper { default Entity getUserSettingsEntity(Record r) { - return Entity.identify(new UserSettings(Locale.forLanguageTag(r.get(USERS_SETTINGS.USSE_PREFERRED_LOCALE)))) - .withId(r.get(USERS_SETTINGS.USSE_USER_ID)); + return Entity.identify(new UserSettings( + Locale.forLanguageTag(r.get(USERS_SETTINGS.USSE_PREFERRED_LOCALE)), + r.get(USERS_SETTINGS.USSE_AUTOREAD)) + ).withId(r.get(USERS_SETTINGS.USSE_USER_ID)); } default UsersSettingsRecord getUserSettingsRecord(UserSettings settings) { return USERS_SETTINGS.newRecord() - .setUssePreferredLocale(settings.preferredLocale().toLanguageTag()); + .setUssePreferredLocale(settings.preferredLocale().toLanguageTag()) + .setUsseAutoread(settings.autoread()); } UserSettings get(UserSettingsForm form); diff --git a/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/model/UserSettingsForm.java b/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/model/UserSettingsForm.java index 44a44afa..fc77f5f8 100644 --- a/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/model/UserSettingsForm.java +++ b/sandside/src/main/java/fr/ght1pc9kc/baywatch/security/infra/model/UserSettingsForm.java @@ -3,6 +3,7 @@ import java.util.Locale; public record UserSettingsForm( - Locale preferredLocale + Locale preferredLocale, + boolean autoread ) { } diff --git a/sandside/src/main/resources/db/migration/V2_1_202410201508__users_settings_autoread.sql b/sandside/src/main/resources/db/migration/V2_1_202410201508__users_settings_autoread.sql new file mode 100644 index 00000000..b9cc8164 --- /dev/null +++ b/sandside/src/main/resources/db/migration/V2_1_202410201508__users_settings_autoread.sql @@ -0,0 +1,2 @@ +alter table USERS_SETTINGS + add COLUMN USSE_AUTOREAD boolean not null default true; diff --git a/sandside/src/main/resources/graphql/security/_model.graphqls b/sandside/src/main/resources/graphql/security/_model.graphqls index fca5da8d..7b864eeb 100644 --- a/sandside/src/main/resources/graphql/security/_model.graphqls +++ b/sandside/src/main/resources/graphql/security/_model.graphqls @@ -13,10 +13,12 @@ type User { type UserSettings { _id: ID preferredLocale: String + autoread: Boolean } input UserSettingsForm { preferredLocale: String + autoread: Boolean } type Session { From d6e0bb482d5d0c4ad0b051e60d05e194e30aabe9 Mon Sep 17 00:00:00 2001 From: Marthym Date: Sun, 20 Oct 2024 16:21:05 +0200 Subject: [PATCH 2/4] feat(seaside): #215 add autoread settings to user settings tab close #215 --- seaside/src/configuration/components/SettingsTab.vue | 7 ++++++- seaside/src/locales/config-settings_en-US.ts | 3 +++ seaside/src/locales/config-settings_fr-FR.ts | 3 +++ seaside/src/security/model/UserSettings.type.ts | 1 + seaside/src/security/services/UserSettingsService.ts | 4 ++-- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/seaside/src/configuration/components/SettingsTab.vue b/seaside/src/configuration/components/SettingsTab.vue index fb28b383..41f25cc4 100644 --- a/seaside/src/configuration/components/SettingsTab.vue +++ b/seaside/src/configuration/components/SettingsTab.vue @@ -4,11 +4,16 @@
{{ t('config.settings.form.preferredLocale') }}
- + +
{{ t('config.settings.form.autoread.alt') }}
diff --git a/seaside/src/locales/config-settings_en-US.ts b/seaside/src/locales/config-settings_en-US.ts index c207bc07..4905f5ca 100644 --- a/seaside/src/locales/config-settings_en-US.ts +++ b/seaside/src/locales/config-settings_en-US.ts @@ -3,6 +3,9 @@ import { en_US as config_en_US } from '@/locales/config_en-US'; export const en_US = { ...config_en_US, 'config.settings.form.preferredLocale': 'Choose your preferred language', + 'config.settings.form.autoread.label': 'news auto read', + 'config.settings.form.autoread.alt': 'In the article list, ' + + 'autoread marks articles as read as soon as you move on to the next one.', 'config.settings.form.action.save': 'Save', 'config.settings.messages.settingsUpdateSuccessfully': 'Settings updated successfully', 'config.settings.messages.unableToUpdate': 'Unable to update settings', diff --git a/seaside/src/locales/config-settings_fr-FR.ts b/seaside/src/locales/config-settings_fr-FR.ts index f2e9ef1a..0ef2889f 100644 --- a/seaside/src/locales/config-settings_fr-FR.ts +++ b/seaside/src/locales/config-settings_fr-FR.ts @@ -3,6 +3,9 @@ import { fr_FR as config_fr_FR } from '@/locales/config_fr-FR'; export const fr_FR = { ...config_fr_FR, 'config.settings.form.preferredLocale': 'choisissez votre langue préférée :', + 'config.settings.form.autoread.label': 'lecture automatique des articles', + 'config.settings.form.autoread.alt': 'Dans la liste des articles, ' + + 'l’autoread marque les articles comme lu dés que vous passez au suivant.', 'config.settings.form.action.save': 'enregistrer', 'config.settings.messages.settingsUpdateSuccessfully': 'Paramètres enregistrés avec succès.', 'config.settings.messages.unableToUpdate': 'Erreur lors de l’enregistrement des paramètres !', diff --git a/seaside/src/security/model/UserSettings.type.ts b/seaside/src/security/model/UserSettings.type.ts index 36c4a7de..f6e5e7b6 100644 --- a/seaside/src/security/model/UserSettings.type.ts +++ b/seaside/src/security/model/UserSettings.type.ts @@ -2,4 +2,5 @@ import { Locale } from '@/common/model/Locale.type'; export type UserSettings = { preferredLocale: Locale, + autoread: boolean, } \ No newline at end of file diff --git a/seaside/src/security/services/UserSettingsService.ts b/seaside/src/security/services/UserSettingsService.ts index 1502d5f8..80ceb44d 100644 --- a/seaside/src/security/services/UserSettingsService.ts +++ b/seaside/src/security/services/UserSettingsService.ts @@ -6,7 +6,7 @@ import { UserSettings } from '@/security/model/UserSettings.type'; const USERS_SETTINGS_GET_REQUEST = `#graphql query UserSettingsGet($id: ID){ userSettingsGet(userId: $id) { - preferredLocale + preferredLocale autoread } }`; @@ -20,7 +20,7 @@ export function userSettingsGet(userId: string): Observable { const USERS_SETTINGS_UPDATE_REQUEST = `#graphql mutation UserSettingsUpdate($id: ID, $settings: UserSettingsForm){ userSettingsUpdate(userId: $id, settings: $settings) { - preferredLocale + preferredLocale autoread } }`; From 77ef5c51b782c9fa7c4bcb7858102bc4f040356a Mon Sep 17 00:00:00 2001 From: Marthym Date: Sun, 20 Oct 2024 17:07:57 +0200 Subject: [PATCH 3/4] feat(seaside): #215 use autoread user settings in news list component --- .../configuration/components/SettingsTab.vue | 6 +- seaside/src/security/router/index.ts | 2 + .../services/AuthenticationService.ts | 2 +- seaside/src/security/store/UserConstants.ts | 2 + seaside/src/security/store/user.ts | 7 + .../components/newslist/NewsList.vue | 184 +++++++++--------- 6 files changed, 112 insertions(+), 91 deletions(-) diff --git a/seaside/src/configuration/components/SettingsTab.vue b/seaside/src/configuration/components/SettingsTab.vue index 41f25cc4..5489a4d7 100644 --- a/seaside/src/configuration/components/SettingsTab.vue +++ b/seaside/src/configuration/components/SettingsTab.vue @@ -11,7 +11,7 @@
{{ t('config.settings.form.autoread.alt') }}