@jskit-ai/users-web 0.2.105 → 0.2.106
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.
- package/CHANGELOG.md +5 -1
- package/locales/en.json +12 -1
- package/package.json +5 -5
- package/patterns/account-settings/PATTERN.md +59 -10
- package/patterns/account-settings/example/src/components/account/settings/AccountSettingsNotificationsSection.vue +25 -12
- package/patterns/account-settings/example/src/components/account/settings/AccountSettingsPreferencesSection.vue +25 -19
- package/patterns/account-settings/example/src/components/account/settings/AccountSettingsProfileSection.vue +74 -54
- package/patterns/account-settings/example/src/components/account/settings/AccountSettingsSignInMethodsSection.vue +7 -2
- package/src/client/account-settings/sections.js +39 -0
- package/src/client/components/AccountSettingsClientElement.vue +254 -28
- package/src/client/composables/useAccountSettingsRuntime.js +30 -5
- package/test/accountSettings.browser.test.js +371 -28
- package/test/accountSettingsSections.test.js +57 -0
- package/test/settingsPlacementContract.test.js +4 -2
|
@@ -12,6 +12,23 @@ import {
|
|
|
12
12
|
|
|
13
13
|
const ACCOUNT_SETTINGS_SECTION_TARGET = "account-settings:sections";
|
|
14
14
|
const EMPTY_ACCOUNT_SETTINGS_SECTIONS = Object.freeze([]);
|
|
15
|
+
// The icon of each section the account-settings pattern places, for a placement that names none. Any other section
|
|
16
|
+
// without one takes the settings icon, so every entry of the list has its tile.
|
|
17
|
+
const ACCOUNT_SETTINGS_SECTION_ICONS = Object.freeze({
|
|
18
|
+
profile: "$person",
|
|
19
|
+
preferences: "$tune",
|
|
20
|
+
notifications: "$notifications",
|
|
21
|
+
"sign-in-methods": "$key"
|
|
22
|
+
});
|
|
23
|
+
const ACCOUNT_SETTINGS_SECTION_ICON = "$settings";
|
|
24
|
+
// The line under the title of each section the account-settings pattern places, for a placement that names none, as a
|
|
25
|
+
// message key. Any other section without one shows its title alone.
|
|
26
|
+
const ACCOUNT_SETTINGS_SECTION_SUMMARIES = Object.freeze({
|
|
27
|
+
profile: "jskit.users.accountSettings.summary.profile",
|
|
28
|
+
preferences: "jskit.users.accountSettings.summary.preferences",
|
|
29
|
+
notifications: "jskit.users.accountSettings.summary.notifications",
|
|
30
|
+
"sign-in-methods": "jskit.users.accountSettings.summary.signInMethods"
|
|
31
|
+
});
|
|
15
32
|
|
|
16
33
|
// A section title is plain text, a message key or { key, fallback, params };
|
|
17
34
|
// the settings host renders it with useJskitText().text().
|
|
@@ -22,6 +39,26 @@ function normalizeSectionTitle(value) {
|
|
|
22
39
|
return String(value || "").trim();
|
|
23
40
|
}
|
|
24
41
|
|
|
42
|
+
// A section's icon: its placement's (an icon alias such as "$person"), else users-web's for its own sections, else the
|
|
43
|
+
// settings icon.
|
|
44
|
+
function resolveSectionIcon(value, icon) {
|
|
45
|
+
const named = String(icon || "").trim();
|
|
46
|
+
if (named) {
|
|
47
|
+
return named;
|
|
48
|
+
}
|
|
49
|
+
return Object.hasOwn(ACCOUNT_SETTINGS_SECTION_ICONS, value) ? ACCOUNT_SETTINGS_SECTION_ICONS[value] : ACCOUNT_SETTINGS_SECTION_ICON;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// A section's summary: its placement's (plain text, a message key or { key, fallback, params }), else users-web's for its
|
|
53
|
+
// own sections, else "".
|
|
54
|
+
function resolveSectionSummary(value, summary) {
|
|
55
|
+
const named = normalizeSectionTitle(summary);
|
|
56
|
+
if (named) {
|
|
57
|
+
return named;
|
|
58
|
+
}
|
|
59
|
+
return Object.hasOwn(ACCOUNT_SETTINGS_SECTION_SUMMARIES, value) ? ACCOUNT_SETTINGS_SECTION_SUMMARIES[value] : "";
|
|
60
|
+
}
|
|
61
|
+
|
|
25
62
|
function normalizeAccountSettingsSectionEntry(entry = null) {
|
|
26
63
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
27
64
|
return null;
|
|
@@ -40,6 +77,8 @@ function normalizeAccountSettingsSectionEntry(entry = null) {
|
|
|
40
77
|
return Object.freeze({
|
|
41
78
|
value,
|
|
42
79
|
title,
|
|
80
|
+
icon: resolveSectionIcon(value, props.icon || entry.icon),
|
|
81
|
+
summary: resolveSectionSummary(value, props.summary || entry.summary),
|
|
43
82
|
component,
|
|
44
83
|
order: Number.isFinite(Number(entry.order)) ? Number(entry.order) : 500,
|
|
45
84
|
usesSharedRuntime: props.usesSharedRuntime === true || entry.usesSharedRuntime === true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed } from "vue";
|
|
3
|
-
import { useRoute } from "vue-router";
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, shallowRef, useId } from "vue";
|
|
3
|
+
import { onBeforeRouteLeave, onBeforeRouteUpdate, useRoute } from "vue-router";
|
|
4
4
|
import ShellListDetail from "@jskit-ai/shell-web/client/components/ShellListDetail";
|
|
5
5
|
import ShellPageAction from "@jskit-ai/shell-web/client/components/ShellPageAction";
|
|
6
6
|
import ShellPageActions from "@jskit-ai/shell-web/client/components/ShellPageActions";
|
|
@@ -17,11 +17,9 @@ const runtime = useAccountSettingsRuntime();
|
|
|
17
17
|
const route = useRoute();
|
|
18
18
|
const paths = usePaths();
|
|
19
19
|
const sections = useAccountSettingsSections();
|
|
20
|
-
// The app bar
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
// on another of the app's origins.
|
|
24
|
-
useShellPageTitle(() => t("jskit.users.accountSettings.title"));
|
|
20
|
+
// The app bar's Up arrow, on a page that declares a parent, is the way out; a Done action beside it would be a second
|
|
21
|
+
// back control. Done shows only where Up can't take the person back: a page without a parent, an open section beside
|
|
22
|
+
// the list on a wide window (the list is the parent, already in view), or a returnTo on another of the app's origins.
|
|
25
23
|
const { canGoUp } = useShellNavigation();
|
|
26
24
|
const doneTarget = computed(() => runtime.backNavigationTarget.value);
|
|
27
25
|
const showsDone = computed(() => !canGoUp.value || !doneTarget.value.sameOrigin);
|
|
@@ -44,20 +42,82 @@ const openSection = computed(() => {
|
|
|
44
42
|
return sectionValues.value.includes(section) ? section : "";
|
|
45
43
|
});
|
|
46
44
|
const { isExpanded, isLarge } = useShellWindowSizeClass();
|
|
45
|
+
// The list beside the open section (expanded and large windows), or alone, each row opening its section's page.
|
|
46
|
+
const twoPane = computed(() => isExpanded.value || isLarge.value);
|
|
47
47
|
const shownSection = computed(() => {
|
|
48
|
-
const value = openSection.value || (
|
|
48
|
+
const value = openSection.value || (twoPane.value ? defaultSection.value : "");
|
|
49
49
|
return sections.value.find((section) => section.value === value) || null;
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
// The app bar's title says where the person is: a section open alone (a phone or a tablet) is the section's page,
|
|
53
|
+
// under Up to the list; the list, alone or beside the open section, is Account settings.
|
|
54
|
+
useShellPageTitle(() =>
|
|
55
|
+
!twoPane.value && shownSection.value ? text(shownSection.value.title) : t("jskit.users.accountSettings.title")
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// The detail pane is open on a section's page, and on a wide window on the list's own page too, where the first section
|
|
59
|
+
// shows beside the list: both draw the same bar, with no Up to the list beside them (Done is the way out).
|
|
60
|
+
const detailOpen = computed(() => Boolean(openSection.value || (twoPane.value && shownSection.value)));
|
|
61
|
+
|
|
62
|
+
function isShown(section) {
|
|
63
|
+
return shownSection.value?.value === section.value;
|
|
64
|
+
}
|
|
65
|
+
|
|
52
66
|
// A section's page keeps the address's returnTo, where Done leads.
|
|
53
67
|
function sectionTarget(value) {
|
|
54
68
|
const returnTo = route.query?.returnTo;
|
|
55
69
|
return { path: paths.page(`/${value}`), query: returnTo ? { returnTo } : {} };
|
|
56
70
|
}
|
|
71
|
+
|
|
72
|
+
// Leaving a section's form with edits the person has not saved asks first: its close, Done, another section, the
|
|
73
|
+
// browser's Back, and closing or reloading the tab (the browser's own question). Keep editing stays; Discard gives the
|
|
74
|
+
// form back its saved values and goes on.
|
|
75
|
+
const leaving = shallowRef(null);
|
|
76
|
+
const discardTitleId = `${useId()}-discard-title`;
|
|
77
|
+
const discardTextId = `${discardTitleId}-text`;
|
|
78
|
+
|
|
79
|
+
// The open question's answer; with none open, nothing to answer.
|
|
80
|
+
function answerLeaving(discard) {
|
|
81
|
+
const resolve = leaving.value;
|
|
82
|
+
if (!resolve) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
leaving.value = null;
|
|
86
|
+
if (discard) {
|
|
87
|
+
runtime.discardEdits();
|
|
88
|
+
}
|
|
89
|
+
resolve(discard);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// A navigation started while the question is open (a second Back) ends the first one where it is.
|
|
93
|
+
function askBeforeLeaving() {
|
|
94
|
+
if (!runtime.hasUnsavedEdits.value) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
answerLeaving(false);
|
|
98
|
+
return new Promise((resolve) => {
|
|
99
|
+
leaving.value = resolve;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
onBeforeRouteLeave(askBeforeLeaving);
|
|
104
|
+
onBeforeRouteUpdate((to, from) => (to.path === from.path ? true : askBeforeLeaving()));
|
|
105
|
+
|
|
106
|
+
// The browser asks before the tab closes or reloads; returnValue is for browsers that ask only when it is set (Chrome
|
|
107
|
+
// and Edge before 119), as MDN shows.
|
|
108
|
+
function warnBeforeUnload(event) {
|
|
109
|
+
if (runtime.hasUnsavedEdits.value) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
event.returnValue = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
onMounted(() => window.addEventListener("beforeunload", warnBeforeUnload));
|
|
116
|
+
onBeforeUnmount(() => window.removeEventListener("beforeunload", warnBeforeUnload));
|
|
57
117
|
</script>
|
|
58
118
|
|
|
59
119
|
<template>
|
|
60
|
-
<section class="settings-view py-2 py-md-4">
|
|
120
|
+
<section class="settings-view py-2 py-md-4" :class="{ 'settings-view--two-pane': twoPane }">
|
|
61
121
|
<ShellPageActions v-if="showsDone">
|
|
62
122
|
<ShellPageAction
|
|
63
123
|
:label="t('jskit.users.accountSettings.done')"
|
|
@@ -66,10 +126,6 @@ function sectionTarget(value) {
|
|
|
66
126
|
/>
|
|
67
127
|
</ShellPageActions>
|
|
68
128
|
<div class="settings-panel">
|
|
69
|
-
<p class="settings-panel__intro text-body-medium on-surface-variant">
|
|
70
|
-
{{ t("jskit.users.accountSettings.subtitle") }}
|
|
71
|
-
</p>
|
|
72
|
-
|
|
73
129
|
<div class="settings-panel__body">
|
|
74
130
|
<template v-if="runtime.loadingSettings.value">
|
|
75
131
|
<v-skeleton-loader type="text@2, list-item-two-line@4" class="mb-4" />
|
|
@@ -92,31 +148,111 @@ function sectionTarget(value) {
|
|
|
92
148
|
</template>
|
|
93
149
|
<template v-else>
|
|
94
150
|
<v-progress-linear v-if="runtime.refreshingSettings.value" indeterminate class="mb-4" />
|
|
95
|
-
<ShellListDetail :detail-open="
|
|
151
|
+
<ShellListDetail :detail-open="detailOpen">
|
|
96
152
|
<template #list>
|
|
153
|
+
<!-- Whose account this is: its avatar in a container colour, its name and its email. -->
|
|
154
|
+
<div class="settings-account" data-testid="account-settings-account">
|
|
155
|
+
<v-avatar color="primary-container" size="40">
|
|
156
|
+
<v-img v-if="runtime.profile.avatar.effectiveUrl" :src="runtime.profile.avatar.effectiveUrl" cover />
|
|
157
|
+
<span v-else class="text-title-medium">{{ runtime.account.initials.value }}</span>
|
|
158
|
+
</v-avatar>
|
|
159
|
+
<div class="settings-account__names">
|
|
160
|
+
<p class="settings-account__name text-headline-small">{{ runtime.account.saved.displayName }}</p>
|
|
161
|
+
<p class="settings-account__email text-body-medium on-surface-variant">{{ runtime.account.saved.email }}</p>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
97
164
|
<v-list nav class="settings-section-list">
|
|
165
|
+
<!-- A row's name is its section's title; its summary, the line under it, is the row's description. -->
|
|
98
166
|
<v-list-item
|
|
99
167
|
v-for="section in sections"
|
|
100
168
|
:key="section.value"
|
|
101
169
|
class="settings-section-list__item"
|
|
102
|
-
:
|
|
170
|
+
:class="{ 'settings-section-list__item--two-line': section.summary }"
|
|
103
171
|
:to="sectionTarget(section.value)"
|
|
104
|
-
:active="
|
|
105
|
-
|
|
172
|
+
:active="isShown(section)"
|
|
173
|
+
:aria-labelledby="`settings-section-${section.value}-title`"
|
|
174
|
+
:aria-describedby="section.summary ? `settings-section-${section.value}-summary` : undefined"
|
|
175
|
+
>
|
|
176
|
+
<!-- Each section is headed by its tonal icon tile, as Material 3's finished screen heads a section; the
|
|
177
|
+
open section's tile joins its pill, the selected item's indicator, its icon in on-secondary-container. -->
|
|
178
|
+
<template #prepend>
|
|
179
|
+
<v-avatar
|
|
180
|
+
:color="isShown(section) ? undefined : 'primary-container'"
|
|
181
|
+
:class="{ 'settings-section-list__tile--open': isShown(section) }"
|
|
182
|
+
rounded="lg"
|
|
183
|
+
size="40"
|
|
184
|
+
>
|
|
185
|
+
<v-icon
|
|
186
|
+
:icon="section.icon"
|
|
187
|
+
:color="isShown(section) ? 'on-secondary-container' : 'on-primary-container'"
|
|
188
|
+
size="24"
|
|
189
|
+
/>
|
|
190
|
+
</v-avatar>
|
|
191
|
+
</template>
|
|
192
|
+
<template #title>
|
|
193
|
+
<span :id="`settings-section-${section.value}-title`">{{ text(section.title) }}</span>
|
|
194
|
+
</template>
|
|
195
|
+
<template v-if="section.summary" #subtitle>
|
|
196
|
+
<span :id="`settings-section-${section.value}-summary`">{{ text(section.summary) }}</span>
|
|
197
|
+
</template>
|
|
198
|
+
<!-- A row that opens its section's page ends in a chevron; beside the open section it selects in place. -->
|
|
199
|
+
<template v-if="!twoPane" #append>
|
|
200
|
+
<v-icon icon="$chevronRight" color="on-surface-variant" />
|
|
201
|
+
</template>
|
|
202
|
+
</v-list-item>
|
|
106
203
|
</v-list>
|
|
107
204
|
</template>
|
|
108
205
|
<template #detail>
|
|
109
206
|
<div v-if="shownSection" :key="shownSection.value" class="settings-section-detail">
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
207
|
+
<!-- Beside the list, the open section is headed by its tile and its title, as its row in the list is.
|
|
208
|
+
Alone, the app bar's title names it. -->
|
|
209
|
+
<div v-if="twoPane" class="settings-section-heading" data-testid="account-settings-section-heading">
|
|
210
|
+
<v-avatar color="primary-container" rounded="lg" size="40">
|
|
211
|
+
<v-icon :icon="shownSection.icon" color="on-primary-container" size="24" />
|
|
212
|
+
</v-avatar>
|
|
213
|
+
<h2 class="settings-section-heading__title text-title-large">{{ text(shownSection.title) }}</h2>
|
|
214
|
+
</div>
|
|
215
|
+
<div class="settings-section-detail__body">
|
|
216
|
+
<component
|
|
217
|
+
:is="shownSection.component"
|
|
218
|
+
v-bind="shownSection.usesSharedRuntime ? { runtime } : undefined"
|
|
219
|
+
/>
|
|
220
|
+
</div>
|
|
114
221
|
</div>
|
|
115
222
|
</template>
|
|
116
223
|
</ShellListDetail>
|
|
117
224
|
</template>
|
|
118
225
|
</div>
|
|
119
226
|
</div>
|
|
227
|
+
<v-dialog
|
|
228
|
+
:model-value="Boolean(leaving)"
|
|
229
|
+
max-width="560"
|
|
230
|
+
role="alertdialog"
|
|
231
|
+
aria-modal="true"
|
|
232
|
+
:aria-labelledby="discardTitleId"
|
|
233
|
+
:aria-describedby="discardTextId"
|
|
234
|
+
@update:model-value="(open) => open || answerLeaving(false)"
|
|
235
|
+
>
|
|
236
|
+
<v-card>
|
|
237
|
+
<v-card-title :id="discardTitleId" class="settings-discard__headline">
|
|
238
|
+
{{ t("jskit.users.accountSettings.discard.title") }}
|
|
239
|
+
</v-card-title>
|
|
240
|
+
<v-card-text class="settings-discard__text">
|
|
241
|
+
<p :id="discardTextId" class="my-0">
|
|
242
|
+
{{ t("jskit.users.accountSettings.discard.text", { section: shownSection ? text(shownSection.title) : "" }) }}
|
|
243
|
+
</p>
|
|
244
|
+
</v-card-text>
|
|
245
|
+
<v-card-actions>
|
|
246
|
+
<v-spacer />
|
|
247
|
+
<v-btn autofocus variant="text" @click="answerLeaving(false)">
|
|
248
|
+
{{ t("jskit.users.accountSettings.discard.keepEditing") }}
|
|
249
|
+
</v-btn>
|
|
250
|
+
<v-btn variant="text" @click="answerLeaving(true)">
|
|
251
|
+
{{ t("jskit.users.accountSettings.discard.confirm") }}
|
|
252
|
+
</v-btn>
|
|
253
|
+
</v-card-actions>
|
|
254
|
+
</v-card>
|
|
255
|
+
</v-dialog>
|
|
120
256
|
</section>
|
|
121
257
|
</template>
|
|
122
258
|
|
|
@@ -125,13 +261,63 @@ function sectionTarget(value) {
|
|
|
125
261
|
overflow: hidden;
|
|
126
262
|
}
|
|
127
263
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
264
|
+
/* A dialog's headline is headline-small, its supporting text 16dp under it: the headline's own padding, with no top
|
|
265
|
+
padding on the text, whose paragraph has no top margin either (my-0: Vuetify 4 leaves the browser's 1em). */
|
|
266
|
+
.settings-discard__headline {
|
|
267
|
+
font-size: 1.5rem;
|
|
268
|
+
font-weight: 400;
|
|
269
|
+
line-height: 2rem;
|
|
270
|
+
padding: 24px 24px 16px;
|
|
271
|
+
white-space: normal;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.settings-discard__text {
|
|
275
|
+
padding-top: 0;
|
|
131
276
|
}
|
|
132
277
|
|
|
278
|
+
/* The list starts at the page's margin, under the bar's Up arrow: no padding of its own. */
|
|
133
279
|
.settings-panel__body {
|
|
134
|
-
padding:
|
|
280
|
+
padding: 0;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.settings-section-list.v-list {
|
|
284
|
+
padding-inline: 0;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* Alone, a row starts at the page's margin; beside the open section, its pill leaves room around the tile. */
|
|
288
|
+
.settings-section-list .settings-section-list__item {
|
|
289
|
+
--settings-item-inset: 0px;
|
|
290
|
+
padding-inline: var(--settings-item-inset);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.settings-view--two-pane .settings-section-list .settings-section-list__item,
|
|
294
|
+
.settings-view--two-pane .settings-account {
|
|
295
|
+
--settings-item-inset: 12px;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* The open section's tile is its pill's: no fill of its own. */
|
|
299
|
+
.settings-section-list__tile--open {
|
|
300
|
+
background: transparent;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/* Beside the list, the open section's heading is the account row's height at its top, so the two panes' tiles line
|
|
304
|
+
up; it starts at the pane's edge, as the section's fields do. */
|
|
305
|
+
.settings-section-heading {
|
|
306
|
+
display: flex;
|
|
307
|
+
align-items: center;
|
|
308
|
+
gap: 16px;
|
|
309
|
+
box-sizing: content-box;
|
|
310
|
+
min-height: 56px;
|
|
311
|
+
padding: 8px 0 0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* A form beside the list keeps a readable width. */
|
|
315
|
+
.settings-view--two-pane .settings-section-detail__body {
|
|
316
|
+
max-width: 600px;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.settings-section-heading__title {
|
|
320
|
+
margin: 0;
|
|
135
321
|
}
|
|
136
322
|
|
|
137
323
|
/* The selected section is Material 3's pill indicator in secondary-container, as the shell's navigation draws it, and
|
|
@@ -143,16 +329,56 @@ function sectionTarget(value) {
|
|
|
143
329
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
144
330
|
}
|
|
145
331
|
|
|
332
|
+
/* Material 3's two-line list item is 72dp. */
|
|
333
|
+
.settings-section-list__item--two-line {
|
|
334
|
+
min-height: 72px;
|
|
335
|
+
}
|
|
336
|
+
|
|
146
337
|
.settings-section-list__item.v-list-item--active {
|
|
147
338
|
background: rgb(var(--v-theme-secondary-container));
|
|
148
339
|
color: rgb(var(--v-theme-on-secondary-container));
|
|
149
340
|
}
|
|
150
341
|
|
|
151
|
-
/*
|
|
342
|
+
/* The open section's label is bold as well as on its pill, so the pill's colour is not its only mark. */
|
|
343
|
+
.settings-section-list__item.v-list-item--active :deep(.v-list-item-title) {
|
|
344
|
+
font-weight: 700;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/* The account, above the list: its avatar lined up with the items' tiles and its name with their titles, in a row the
|
|
348
|
+
open section's heading matches beside it. */
|
|
349
|
+
.settings-account {
|
|
350
|
+
--settings-item-inset: 0px;
|
|
351
|
+
display: flex;
|
|
352
|
+
align-items: center;
|
|
353
|
+
gap: 16px;
|
|
354
|
+
box-sizing: content-box;
|
|
355
|
+
min-height: 56px;
|
|
356
|
+
padding: 8px var(--settings-item-inset) 16px;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.settings-account__names {
|
|
360
|
+
min-width: 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.settings-account__name,
|
|
364
|
+
.settings-account__email {
|
|
365
|
+
margin: 0;
|
|
366
|
+
overflow: hidden;
|
|
367
|
+
text-overflow: ellipsis;
|
|
368
|
+
white-space: nowrap;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/* Material 3's list item: its title in body-large and its summary in body-medium, not Vuetify's 13px nav list type. */
|
|
152
372
|
.settings-section-list__item :deep(.v-list-item-title) {
|
|
373
|
+
font-size: 1rem;
|
|
374
|
+
font-weight: 400;
|
|
375
|
+
letter-spacing: 0.03125rem;
|
|
376
|
+
line-height: 1.5rem;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.settings-section-list__item :deep(.v-list-item-subtitle) {
|
|
153
380
|
font-size: 0.875rem;
|
|
154
|
-
|
|
155
|
-
letter-spacing: 0.00625rem;
|
|
381
|
+
letter-spacing: 0.015625rem;
|
|
156
382
|
line-height: 1.25rem;
|
|
157
383
|
}
|
|
158
384
|
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
resolveSurfacePathFromPlacementContext
|
|
10
10
|
} from "@jskit-ai/shell-web/client/placement";
|
|
11
11
|
import { useShellWebErrorRuntime } from "@jskit-ai/shell-web/client/error";
|
|
12
|
+
import { personInitials } from "@jskit-ai/auth-web/client/lib/personInitials";
|
|
12
13
|
import { ROUTE_VISIBILITY_PUBLIC } from "@jskit-ai/kernel/shared/support/visibility";
|
|
13
14
|
import { userProfileContract } from "@jskit-ai/users-core/shared/resources/userProfileResource";
|
|
14
15
|
import { userSettingsContract } from "@jskit-ai/users-core/shared/resources/userSettingsResource";
|
|
@@ -132,11 +133,16 @@ function useAccountSettingsRuntime() {
|
|
|
132
133
|
});
|
|
133
134
|
const savedLocale = ref("");
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
// The account control's initials for the same person (auth-web's rule).
|
|
137
|
+
const profileInitials = computed(
|
|
138
|
+
() => personInitials(profileForm.displayName || profileForm.email) || t("jskit.users.accountSettings.profile.initialsFallback")
|
|
139
|
+
);
|
|
140
|
+
// The account as the server has it, which the settings page's header shows; the profile form holds what the person
|
|
141
|
+
// types and has not saved.
|
|
142
|
+
const savedAccount = reactive({ displayName: "", email: "" });
|
|
143
|
+
const savedAccountInitials = computed(
|
|
144
|
+
() => personInitials(savedAccount.displayName || savedAccount.email) || t("jskit.users.accountSettings.profile.initialsFallback")
|
|
145
|
+
);
|
|
140
146
|
|
|
141
147
|
const themeOptions = computed(() => translateOptions(THEME_OPTIONS));
|
|
142
148
|
const localeOptions = computed(() => resolveLocaleOptions(savedLocale.value));
|
|
@@ -343,6 +349,8 @@ function useAccountSettingsRuntime() {
|
|
|
343
349
|
// what the person changed and has not saved, and the rest of the page shows what the server holds.
|
|
344
350
|
function applySettingsData(payload) {
|
|
345
351
|
const data = normalizeSettingsPayload(payload);
|
|
352
|
+
savedAccount.displayName = String(data.profile?.displayName || "");
|
|
353
|
+
savedAccount.email = String(data.profile?.email || "");
|
|
346
354
|
profileAddEdit.applyLoaded(data);
|
|
347
355
|
preferencesAddEdit.applyLoaded(data);
|
|
348
356
|
notificationsAddEdit.applyLoaded(data);
|
|
@@ -458,6 +466,8 @@ function useAccountSettingsRuntime() {
|
|
|
458
466
|
conflicts: computed(() => profileAddEdit.conflicts),
|
|
459
467
|
acceptServerValue: profileAddEdit.acceptServerValue,
|
|
460
468
|
keepOwnValue: profileAddEdit.keepOwnValue,
|
|
469
|
+
// A field the person changed and has not saved: Save waits for one.
|
|
470
|
+
hasUnsavedEdits: computed(() => profileAddEdit.hasUnsavedEdits),
|
|
461
471
|
isSaving: savingProfile,
|
|
462
472
|
isDeletingAvatar: deletingAvatar,
|
|
463
473
|
isRefreshing: refreshingSettings,
|
|
@@ -472,6 +482,7 @@ function useAccountSettingsRuntime() {
|
|
|
472
482
|
conflicts: computed(() => preferencesAddEdit.conflicts),
|
|
473
483
|
acceptServerValue: preferencesAddEdit.acceptServerValue,
|
|
474
484
|
keepOwnValue: preferencesAddEdit.keepOwnValue,
|
|
485
|
+
hasUnsavedEdits: computed(() => preferencesAddEdit.hasUnsavedEdits),
|
|
475
486
|
isSaving: savingPreferences,
|
|
476
487
|
isRefreshing: refreshingSettings,
|
|
477
488
|
// Plain arrays for v-select items; the getters follow the active language.
|
|
@@ -500,6 +511,7 @@ function useAccountSettingsRuntime() {
|
|
|
500
511
|
conflicts: computed(() => notificationsAddEdit.conflicts),
|
|
501
512
|
acceptServerValue: notificationsAddEdit.acceptServerValue,
|
|
502
513
|
keepOwnValue: notificationsAddEdit.keepOwnValue,
|
|
514
|
+
hasUnsavedEdits: computed(() => notificationsAddEdit.hasUnsavedEdits),
|
|
503
515
|
isSaving: savingNotifications,
|
|
504
516
|
isRefreshing: refreshingSettings,
|
|
505
517
|
submit: submitNotifications
|
|
@@ -513,9 +525,22 @@ function useAccountSettingsRuntime() {
|
|
|
513
525
|
unlink: unlinkSignInMethod
|
|
514
526
|
};
|
|
515
527
|
|
|
528
|
+
// The forms' unsaved edits, which only the open section's form can hold: leaving the settings asks first, and
|
|
529
|
+
// discarding gives every form back what it last took from the server.
|
|
530
|
+
const forms = [profileAddEdit, preferencesAddEdit, notificationsAddEdit];
|
|
531
|
+
const hasUnsavedEdits = computed(() => forms.some((form) => form.hasUnsavedEdits));
|
|
532
|
+
function discardEdits() {
|
|
533
|
+
for (const form of forms) {
|
|
534
|
+
form.discardEdits();
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
516
538
|
return {
|
|
517
539
|
backTarget,
|
|
518
540
|
backNavigationTarget,
|
|
541
|
+
hasUnsavedEdits,
|
|
542
|
+
discardEdits,
|
|
543
|
+
account: { saved: savedAccount, initials: savedAccountInitials },
|
|
519
544
|
loadingSettings,
|
|
520
545
|
refreshingSettings,
|
|
521
546
|
settingsLoadError,
|