@jskit-ai/users-web 0.2.105 → 0.2.107
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 +6 -1
- package/fixtures/account-settings/main.js +4 -1
- package/locales/en.json +12 -1
- package/package.json +5 -5
- package/patterns/account-settings/PATTERN.md +62 -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 +248 -30
- package/src/client/composables/useAccountSettingsRuntime.js +30 -5
- package/test/accountSettings.browser.test.js +462 -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,107 @@ 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 is filled primary on its row's secondary-container pill: primary-container
|
|
178
|
+
shares the pill's tone and would vanish into it for some seeds, primary stands out for any. -->
|
|
179
|
+
<template #prepend>
|
|
180
|
+
<v-avatar :color="isShown(section) ? 'primary' : 'primary-container'" rounded="lg" size="40">
|
|
181
|
+
<v-icon
|
|
182
|
+
:icon="section.icon"
|
|
183
|
+
:color="isShown(section) ? 'on-primary' : 'on-primary-container'"
|
|
184
|
+
size="24"
|
|
185
|
+
/>
|
|
186
|
+
</v-avatar>
|
|
187
|
+
</template>
|
|
188
|
+
<template #title>
|
|
189
|
+
<span :id="`settings-section-${section.value}-title`">{{ text(section.title) }}</span>
|
|
190
|
+
</template>
|
|
191
|
+
<template v-if="section.summary" #subtitle>
|
|
192
|
+
<span :id="`settings-section-${section.value}-summary`">{{ text(section.summary) }}</span>
|
|
193
|
+
</template>
|
|
194
|
+
<!-- A row that opens its section's page ends in a chevron; beside the open section it selects in place. -->
|
|
195
|
+
<template v-if="!twoPane" #append>
|
|
196
|
+
<v-icon icon="$chevronRight" color="on-surface-variant" />
|
|
197
|
+
</template>
|
|
198
|
+
</v-list-item>
|
|
106
199
|
</v-list>
|
|
107
200
|
</template>
|
|
108
201
|
<template #detail>
|
|
109
202
|
<div v-if="shownSection" :key="shownSection.value" class="settings-section-detail">
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
203
|
+
<!-- Beside the list, the open section is headed by its tile and its title, as its row in the list is.
|
|
204
|
+
Alone, the app bar's title names it. -->
|
|
205
|
+
<div v-if="twoPane" class="settings-section-heading" data-testid="account-settings-section-heading">
|
|
206
|
+
<v-avatar color="primary-container" rounded="lg" size="40">
|
|
207
|
+
<v-icon :icon="shownSection.icon" color="on-primary-container" size="24" />
|
|
208
|
+
</v-avatar>
|
|
209
|
+
<h2 class="settings-section-heading__title text-title-large">{{ text(shownSection.title) }}</h2>
|
|
210
|
+
</div>
|
|
211
|
+
<div class="settings-section-detail__body">
|
|
212
|
+
<component
|
|
213
|
+
:is="shownSection.component"
|
|
214
|
+
v-bind="shownSection.usesSharedRuntime ? { runtime } : undefined"
|
|
215
|
+
/>
|
|
216
|
+
</div>
|
|
114
217
|
</div>
|
|
115
218
|
</template>
|
|
116
219
|
</ShellListDetail>
|
|
117
220
|
</template>
|
|
118
221
|
</div>
|
|
119
222
|
</div>
|
|
223
|
+
<v-dialog
|
|
224
|
+
:model-value="Boolean(leaving)"
|
|
225
|
+
max-width="560"
|
|
226
|
+
role="alertdialog"
|
|
227
|
+
aria-modal="true"
|
|
228
|
+
:aria-labelledby="discardTitleId"
|
|
229
|
+
:aria-describedby="discardTextId"
|
|
230
|
+
@update:model-value="(open) => open || answerLeaving(false)"
|
|
231
|
+
>
|
|
232
|
+
<v-card>
|
|
233
|
+
<v-card-title :id="discardTitleId" class="settings-discard__headline">
|
|
234
|
+
{{ t("jskit.users.accountSettings.discard.title") }}
|
|
235
|
+
</v-card-title>
|
|
236
|
+
<v-card-text class="settings-discard__text">
|
|
237
|
+
<p :id="discardTextId" class="my-0">
|
|
238
|
+
{{ t("jskit.users.accountSettings.discard.text", { section: shownSection ? text(shownSection.title) : "" }) }}
|
|
239
|
+
</p>
|
|
240
|
+
</v-card-text>
|
|
241
|
+
<v-card-actions>
|
|
242
|
+
<v-spacer />
|
|
243
|
+
<v-btn autofocus variant="text" @click="answerLeaving(false)">
|
|
244
|
+
{{ t("jskit.users.accountSettings.discard.keepEditing") }}
|
|
245
|
+
</v-btn>
|
|
246
|
+
<v-btn variant="text" @click="answerLeaving(true)">
|
|
247
|
+
{{ t("jskit.users.accountSettings.discard.confirm") }}
|
|
248
|
+
</v-btn>
|
|
249
|
+
</v-card-actions>
|
|
250
|
+
</v-card>
|
|
251
|
+
</v-dialog>
|
|
120
252
|
</section>
|
|
121
253
|
</template>
|
|
122
254
|
|
|
@@ -125,17 +257,63 @@ function sectionTarget(value) {
|
|
|
125
257
|
overflow: hidden;
|
|
126
258
|
}
|
|
127
259
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
260
|
+
/* A dialog's headline is headline-small, its supporting text 16dp under it: the headline's own padding, with no top
|
|
261
|
+
padding on the text, whose paragraph has no top margin either (my-0: Vuetify 4 leaves the browser's 1em). */
|
|
262
|
+
.settings-discard__headline {
|
|
263
|
+
font-size: 1.5rem;
|
|
264
|
+
font-weight: 400;
|
|
265
|
+
line-height: 2rem;
|
|
266
|
+
padding: 24px 24px 16px;
|
|
267
|
+
white-space: normal;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.settings-discard__text {
|
|
271
|
+
padding-top: 0;
|
|
131
272
|
}
|
|
132
273
|
|
|
274
|
+
/* The list starts at the page's margin, under the bar's Up arrow: no padding of its own. */
|
|
133
275
|
.settings-panel__body {
|
|
134
|
-
padding:
|
|
276
|
+
padding: 0;
|
|
135
277
|
}
|
|
136
278
|
|
|
137
|
-
|
|
138
|
-
|
|
279
|
+
.settings-section-list.v-list {
|
|
280
|
+
padding-inline: 0;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* Alone, a row starts at the page's margin; beside the open section, its pill leaves room around the tile. */
|
|
284
|
+
.settings-section-list .settings-section-list__item {
|
|
285
|
+
--settings-item-inset: 0px;
|
|
286
|
+
padding-inline: var(--settings-item-inset);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.settings-view--two-pane .settings-section-list .settings-section-list__item,
|
|
290
|
+
.settings-view--two-pane .settings-account {
|
|
291
|
+
--settings-item-inset: 12px;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/* Beside the list, the open section's heading is the account row's height at its top, so the two panes' tiles line
|
|
295
|
+
up; it starts at the pane's edge, as the section's fields do. */
|
|
296
|
+
.settings-section-heading {
|
|
297
|
+
display: flex;
|
|
298
|
+
align-items: center;
|
|
299
|
+
gap: 16px;
|
|
300
|
+
box-sizing: content-box;
|
|
301
|
+
min-height: 56px;
|
|
302
|
+
padding: 8px 0 0;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/* A form beside the list keeps a readable width. */
|
|
306
|
+
.settings-view--two-pane .settings-section-detail__body {
|
|
307
|
+
max-width: 600px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.settings-section-heading__title {
|
|
311
|
+
margin: 0;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* The selected section's row carries Material 3's active indicator, a pill in secondary-container behind its primary
|
|
315
|
+
tile and its label in on-secondary-container, as the shell's navigation draws it; its hover and pressed state layers
|
|
316
|
+
take the same pill. */
|
|
139
317
|
.settings-section-list__item {
|
|
140
318
|
--v-activated-opacity: 0;
|
|
141
319
|
border-radius: 9999px;
|
|
@@ -143,16 +321,56 @@ function sectionTarget(value) {
|
|
|
143
321
|
color: rgb(var(--v-theme-on-surface-variant));
|
|
144
322
|
}
|
|
145
323
|
|
|
324
|
+
/* Material 3's two-line list item is 72dp. */
|
|
325
|
+
.settings-section-list__item--two-line {
|
|
326
|
+
min-height: 72px;
|
|
327
|
+
}
|
|
328
|
+
|
|
146
329
|
.settings-section-list__item.v-list-item--active {
|
|
147
330
|
background: rgb(var(--v-theme-secondary-container));
|
|
148
331
|
color: rgb(var(--v-theme-on-secondary-container));
|
|
149
332
|
}
|
|
150
333
|
|
|
151
|
-
/*
|
|
334
|
+
/* The open section's label is bold as well as on its pill, so the pill's colour is not its only mark. */
|
|
335
|
+
.settings-section-list__item.v-list-item--active :deep(.v-list-item-title) {
|
|
336
|
+
font-weight: 700;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/* The account, above the list: its avatar lined up with the items' tiles and its name with their titles, in a row the
|
|
340
|
+
open section's heading matches beside it. */
|
|
341
|
+
.settings-account {
|
|
342
|
+
--settings-item-inset: 0px;
|
|
343
|
+
display: flex;
|
|
344
|
+
align-items: center;
|
|
345
|
+
gap: 16px;
|
|
346
|
+
box-sizing: content-box;
|
|
347
|
+
min-height: 56px;
|
|
348
|
+
padding: 8px var(--settings-item-inset) 16px;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.settings-account__names {
|
|
352
|
+
min-width: 0;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.settings-account__name,
|
|
356
|
+
.settings-account__email {
|
|
357
|
+
margin: 0;
|
|
358
|
+
overflow: hidden;
|
|
359
|
+
text-overflow: ellipsis;
|
|
360
|
+
white-space: nowrap;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* Material 3's list item: its title in body-large and its summary in body-medium, not Vuetify's 13px nav list type. */
|
|
152
364
|
.settings-section-list__item :deep(.v-list-item-title) {
|
|
365
|
+
font-size: 1rem;
|
|
366
|
+
font-weight: 400;
|
|
367
|
+
letter-spacing: 0.03125rem;
|
|
368
|
+
line-height: 1.5rem;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.settings-section-list__item :deep(.v-list-item-subtitle) {
|
|
153
372
|
font-size: 0.875rem;
|
|
154
|
-
|
|
155
|
-
letter-spacing: 0.00625rem;
|
|
373
|
+
letter-spacing: 0.015625rem;
|
|
156
374
|
line-height: 1.25rem;
|
|
157
375
|
}
|
|
158
376
|
|
|
@@ -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,
|