rimecms 1.5.0 → 1.5.1
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/dist/core/auth/better-auth/config.server.d.ts +1 -1
- package/dist/core/auth/better-auth/instance.server.d.ts +2 -2
- package/dist/core/boot.server.d.ts +2 -2
- package/dist/core/i18n/en/common.d.ts +10 -4
- package/dist/core/i18n/en/common.js +12 -6
- package/dist/core/i18n/fr/common.d.ts +10 -4
- package/dist/core/i18n/fr/common.js +12 -7
- package/dist/core/prototype/shared/title/find-title.d.ts +9 -0
- package/dist/core/prototype/shared/title/find-title.js +20 -4
- package/dist/fields/group/component/Group.svelte +4 -3
- package/dist/fields/text/index.d.ts +11 -3
- package/dist/fields/text/index.js +11 -3
- package/dist/panel/components/fields/RenderFields.svelte +3 -2
- package/dist/panel/components/sections/collection/DropHint.svelte +41 -0
- package/dist/panel/components/sections/collection/DropHint.svelte.d.ts +7 -0
- package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte +23 -3
- package/dist/panel/components/sections/collection/header/ButtonCreate.svelte +3 -3
- package/dist/panel/components/sections/collection/header/ButtonCreate.svelte.d.ts +1 -1
- package/dist/panel/components/sections/collection/list/CollectionList.svelte +8 -0
- package/dist/panel/components/sections/document/ButtonPublish.svelte +39 -0
- package/dist/panel/components/sections/document/ButtonPublish.svelte.d.ts +7 -0
- package/dist/panel/components/sections/document/ButtonSave.svelte +6 -3
- package/dist/panel/components/sections/document/ButtonSave.svelte.d.ts +3 -1
- package/dist/panel/components/sections/document/Header.svelte +116 -65
- package/dist/panel/components/sections/document/Settings.svelte +42 -125
- package/dist/panel/components/sections/document/VersionMenu.svelte +383 -0
- package/dist/panel/components/sections/document/VersionMenu.svelte.d.ts +8 -0
- package/dist/panel/components/sections/document/Versions.svelte +1 -1
- package/dist/panel/components/sections/document/Versions.svelte.d.ts +1 -1
- package/dist/panel/components/sections/document/version-status.d.ts +12 -0
- package/dist/panel/components/sections/document/version-status.js +33 -0
- package/dist/panel/components/sections/document/versions-list.d.ts +1 -1
- package/dist/panel/components/sections/document/versions-list.js +1 -1
- package/dist/panel/components/ui/calendar/calendar.svelte.d.ts +1 -1
- package/dist/panel/components/ui/checkbox/checkbox.svelte.d.ts +1 -1
- package/dist/panel/components/ui/page-header/PageHeader.svelte +36 -4
- package/dist/panel/components/ui/page-header/PageHeader.svelte.d.ts +4 -0
- package/dist/panel/components/ui/switch/switch.svelte.d.ts +1 -1
- package/dist/panel/context/collection.svelte.d.ts +2 -2
- package/dist/panel/context/documentForm.svelte.d.ts +2 -0
- package/dist/panel/context/documentForm.svelte.js +12 -0
- package/dist/panel/context/versions.svelte.js +1 -1
- package/dist/panel/pages/collection/CollectionPage.svelte +37 -27
- package/dist/panel/pages/collection/CollectionPage.svelte.d.ts +1 -1
- package/package.json +1 -1
- package/dist/panel/components/sections/document/ButtonStatus.svelte +0 -158
- package/dist/panel/components/sections/document/ButtonStatus.svelte.d.ts +0 -7
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { goto } from '$app/navigation';
|
|
3
|
+
import { resolve } from '$app/paths';
|
|
4
|
+
import { PARAMS } from '../../../../core/constants.js';
|
|
5
|
+
import { t__ } from '../../../../core/i18n/index.js';
|
|
6
|
+
import { VERSIONS_STATUS } from '../../../../core/prototype/shared/versions/constant.js';
|
|
7
|
+
import { apiUrl, panelPath } from '../../../../core/routes/util.js';
|
|
8
|
+
import * as Dialog from '../../ui/dialog/index.js';
|
|
9
|
+
import * as DropdownMenu from '../../ui/dropdown-menu/index.js';
|
|
10
|
+
import { getAPIProxyContext } from '../../../context/api-proxy.svelte.js';
|
|
11
|
+
import { useCommands } from '../../../context/commands.svelte.js';
|
|
12
|
+
import type { DocumentFormContext } from '../../../context/documentForm.svelte.js';
|
|
13
|
+
import { getLocaleContext } from '../../../context/locale.svelte.js';
|
|
14
|
+
import { getUserContext } from '../../../context/user.svelte.js';
|
|
15
|
+
import { getVersionsContext } from '../../../context/versions.svelte.js';
|
|
16
|
+
import type { DocVersion } from '../../../index.js';
|
|
17
|
+
import { documentSegments } from '../../../util/url.js';
|
|
18
|
+
import type { GenericDoc } from '../../../../types.js';
|
|
19
|
+
import ChevronDown from '@lucide/svelte/icons/chevron-down';
|
|
20
|
+
import Eye from '@lucide/svelte/icons/eye';
|
|
21
|
+
import EyeOff from '@lucide/svelte/icons/eye-off';
|
|
22
|
+
import ExternalLink from '@lucide/svelte/icons/external-link';
|
|
23
|
+
import FilePlus from '@lucide/svelte/icons/file-plus';
|
|
24
|
+
import History from '@lucide/svelte/icons/history';
|
|
25
|
+
import Trash2 from '@lucide/svelte/icons/trash-2';
|
|
26
|
+
import { toast } from 'svelte-sonner';
|
|
27
|
+
import Button from '../../ui/button/button.svelte';
|
|
28
|
+
import StatusDot from '../collection/StatusDot.svelte';
|
|
29
|
+
import { setVersionStatus } from './version-status.js';
|
|
30
|
+
import { versionsApiUrl, versionsListUrl } from './versions-list.js';
|
|
31
|
+
|
|
32
|
+
type Props = { form: DocumentFormContext<GenericDoc> };
|
|
33
|
+
const { form }: Props = $props();
|
|
34
|
+
|
|
35
|
+
const APIProxy = getAPIProxyContext();
|
|
36
|
+
const locale = getLocaleContext();
|
|
37
|
+
const user = getUserContext();
|
|
38
|
+
/** The history lives on the document page; `undefined` where a document is shown without one. */
|
|
39
|
+
const history = getVersionsContext();
|
|
40
|
+
|
|
41
|
+
const drafts = $derived(!!form.config.versions?.draft);
|
|
42
|
+
const published = $derived(form.values.status === VERSIONS_STATUS.PUBLISHED);
|
|
43
|
+
|
|
44
|
+
const resource = $derived(
|
|
45
|
+
APIProxy.getRessource<{ docs: DocVersion[] }>(versionsListUrl(form.values))
|
|
46
|
+
);
|
|
47
|
+
const list = $derived(resource.data?.docs ?? []);
|
|
48
|
+
/** The newest rows; "All versions" opens the whole history. */
|
|
49
|
+
const recent = $derived(list.slice(0, 3));
|
|
50
|
+
/** A document keeps at least one version, so its last one cannot be deleted. */
|
|
51
|
+
const canDeleteVersion = $derived(list.length > 1);
|
|
52
|
+
|
|
53
|
+
/** The row the site shows: the newest published one with drafts, else the newest. */
|
|
54
|
+
const live = $derived(
|
|
55
|
+
list.find(
|
|
56
|
+
(version) => !version.isAutoSave && (!drafts || version.status === VERSIONS_STATUS.PUBLISHED)
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The row on screen at its url, when the site shows another one:
|
|
62
|
+
* `https://site.com/news/hello?versionId=v2`.
|
|
63
|
+
*/
|
|
64
|
+
const preview = $derived.by(() => {
|
|
65
|
+
const url = form.values.url;
|
|
66
|
+
if (!url || !form.values.versionId || live?.id === form.values.versionId) return null;
|
|
67
|
+
const href = new URL(url);
|
|
68
|
+
href.searchParams.set(PARAMS.VERSION_ID, String(form.values.versionId));
|
|
69
|
+
return href.href;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const documentPath = $derived(panelPath(...documentSegments(form.config.kebab, form.values)));
|
|
73
|
+
const versionPath = (versionId: string) => `${documentPath}?${PARAMS.VERSION_ID}=${versionId}`;
|
|
74
|
+
|
|
75
|
+
const who = (version: DocVersion) =>
|
|
76
|
+
version.updatedBy?.name || version.updatedBy?.email || t__('common.someone');
|
|
77
|
+
const when = (version: DocVersion) =>
|
|
78
|
+
locale.dateFormat(version.updatedAt, { short: true, withTime: true });
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A row's two sides: an auto-save by whose typing it is, a version by its status with drafts,
|
|
82
|
+
* else by its date.
|
|
83
|
+
*
|
|
84
|
+
* ```
|
|
85
|
+
* Your auto-save 19 Nov 14:02
|
|
86
|
+
* Draft Admin · 19 Nov 14:02
|
|
87
|
+
* 19 Nov 14:02 Admin
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
function describe(version: DocVersion) {
|
|
91
|
+
if (version.isAutoSave) {
|
|
92
|
+
const label =
|
|
93
|
+
version.updatedBy?.id === user.attributes.id
|
|
94
|
+
? t__('common.your_auto_save')
|
|
95
|
+
: t__('common.auto_save_by', who(version));
|
|
96
|
+
return { label, meta: when(version) };
|
|
97
|
+
}
|
|
98
|
+
if (drafts) {
|
|
99
|
+
return { label: t__(`common.${version.status}`), meta: `${who(version)} · ${when(version)}` };
|
|
100
|
+
}
|
|
101
|
+
return { label: when(version), meta: who(version) };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let deleteConfirmOpen = $state(false);
|
|
105
|
+
|
|
106
|
+
/** One version goes; the document and its other versions stay. */
|
|
107
|
+
async function deleteVersion() {
|
|
108
|
+
const response = await fetch(`${versionsApiUrl(form.config.slug)}/${form.values.versionId}`, {
|
|
109
|
+
method: 'DELETE'
|
|
110
|
+
});
|
|
111
|
+
deleteConfirmOpen = false;
|
|
112
|
+
if (!response.ok) {
|
|
113
|
+
toast.error(t__('common.generic_error'));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
toast.success(t__('common.version_deleted'));
|
|
117
|
+
// The version history drops the deleted row. `apiUrl(kebab)` reaches `/api/<kebab>--versions`
|
|
118
|
+
// because `invalidate` matches by substring (api-proxy.svelte.ts).
|
|
119
|
+
APIProxy.invalidate(apiUrl(form.config.kebab));
|
|
120
|
+
// The plain address may be the one loaded: the loads rerun so the page lands on the newest row,
|
|
121
|
+
// and the form, which was on the deleted row, is rebuilt on it.
|
|
122
|
+
await goto(documentPath, { refreshAll: true });
|
|
123
|
+
history?.rebuildForm();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Sets a `data-*` attribute, or removes it when the value is `undefined`. */
|
|
127
|
+
function setData(element: HTMLElement, key: string, value: string | undefined) {
|
|
128
|
+
if (value === undefined) {
|
|
129
|
+
delete element.dataset[key];
|
|
130
|
+
} else {
|
|
131
|
+
element.dataset[key] = value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Submits through the Save button as a new draft, then gives the button its own attributes back.
|
|
137
|
+
* The submit listener reads them before its first `await`, so they are back once it has.
|
|
138
|
+
*/
|
|
139
|
+
function saveAsNewDraft() {
|
|
140
|
+
if (form.readOnly || !form.element) return;
|
|
141
|
+
const saveButton = form.element.querySelector<HTMLButtonElement>('button[data-submit]');
|
|
142
|
+
if (!saveButton) return;
|
|
143
|
+
|
|
144
|
+
const { fork, status } = saveButton.dataset;
|
|
145
|
+
setData(saveButton, 'fork', 'true');
|
|
146
|
+
setData(saveButton, 'status', VERSIONS_STATUS.DRAFT);
|
|
147
|
+
form.element.requestSubmit(saveButton);
|
|
148
|
+
setData(saveButton, 'fork', fork);
|
|
149
|
+
setData(saveButton, 'status', status);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const openHistory = () => {
|
|
153
|
+
if (history) history.open = true;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/** The version actions in the palette: the history, a new draft, the other status, a deletion. */
|
|
157
|
+
useCommands(() => [
|
|
158
|
+
...(history
|
|
159
|
+
? [
|
|
160
|
+
{
|
|
161
|
+
id: 'document.versions',
|
|
162
|
+
label: t__('common.versions_history'),
|
|
163
|
+
icon: History,
|
|
164
|
+
group: t__('common.document'),
|
|
165
|
+
run: openHistory
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
: []),
|
|
169
|
+
...(drafts && published
|
|
170
|
+
? [
|
|
171
|
+
{
|
|
172
|
+
id: 'document.new_draft',
|
|
173
|
+
label: t__('common.save_new_draft'),
|
|
174
|
+
icon: FilePlus,
|
|
175
|
+
group: t__('common.document'),
|
|
176
|
+
run: saveAsNewDraft
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
: []),
|
|
180
|
+
...(drafts
|
|
181
|
+
? Object.values(VERSIONS_STATUS)
|
|
182
|
+
.filter((status) => status !== form.values.status)
|
|
183
|
+
.map((status) => ({
|
|
184
|
+
id: `document.status.${status}`,
|
|
185
|
+
label: t__('common.mark_as', t__(`common.${status}`)),
|
|
186
|
+
group: t__('common.document'),
|
|
187
|
+
run: () => setVersionStatus(form, APIProxy, status)
|
|
188
|
+
}))
|
|
189
|
+
: []),
|
|
190
|
+
...(form.values.versionId && canDeleteVersion
|
|
191
|
+
? [
|
|
192
|
+
{
|
|
193
|
+
id: 'document.delete_version',
|
|
194
|
+
label: t__('common.delete_version'),
|
|
195
|
+
icon: Trash2,
|
|
196
|
+
group: t__('common.document'),
|
|
197
|
+
run: () => (deleteConfirmOpen = true)
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
: [])
|
|
201
|
+
]);
|
|
202
|
+
</script>
|
|
203
|
+
|
|
204
|
+
<!--
|
|
205
|
+
The row on screen and its history: with drafts its status, else "History". Opens on a preview of
|
|
206
|
+
the row when the site shows another, the newest versions, then what can be done with the row.
|
|
207
|
+
-->
|
|
208
|
+
<DropdownMenu.Root>
|
|
209
|
+
<DropdownMenu.Trigger>
|
|
210
|
+
{#snippet child({ props })}
|
|
211
|
+
<Button size="sm" variant="ghost" {...props} class="{props.class} rz-version-menu__trigger">
|
|
212
|
+
{#if drafts}
|
|
213
|
+
<StatusDot status={form.values.status} />
|
|
214
|
+
<span class="rz-version-menu__status">{t__(`common.${form.values.status}`)}</span>
|
|
215
|
+
{:else}
|
|
216
|
+
<History size="14" />
|
|
217
|
+
{t__('common.history')}
|
|
218
|
+
{/if}
|
|
219
|
+
<ChevronDown size="14" />
|
|
220
|
+
</Button>
|
|
221
|
+
{/snippet}
|
|
222
|
+
</DropdownMenu.Trigger>
|
|
223
|
+
|
|
224
|
+
<DropdownMenu.Portal>
|
|
225
|
+
<DropdownMenu.Content align="end" sideOffset={6} class="rz-document-menu rz-version-menu">
|
|
226
|
+
{#if preview}
|
|
227
|
+
<DropdownMenu.Item>
|
|
228
|
+
{#snippet child({ props })}
|
|
229
|
+
<a {...props} href={preview} target="_blank" rel="noreferrer">
|
|
230
|
+
<Eye size="14" />
|
|
231
|
+
<span class="rz-version-menu__grow">
|
|
232
|
+
{published ? t__('common.preview_version') : t__('common.preview_draft')}
|
|
233
|
+
</span>
|
|
234
|
+
<ExternalLink size="14" />
|
|
235
|
+
</a>
|
|
236
|
+
{/snippet}
|
|
237
|
+
</DropdownMenu.Item>
|
|
238
|
+
<DropdownMenu.Separator />
|
|
239
|
+
{/if}
|
|
240
|
+
|
|
241
|
+
<div class="rz-version-menu__heading">
|
|
242
|
+
<span>{t__('common.versions')}</span>
|
|
243
|
+
{#if history}
|
|
244
|
+
<DropdownMenu.Item class="rz-version-menu__all" onclick={openHistory}>
|
|
245
|
+
{t__('common.all_versions')}
|
|
246
|
+
</DropdownMenu.Item>
|
|
247
|
+
{/if}
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
{#each recent as version (version.id)}
|
|
251
|
+
{@const { label, meta } = describe(version)}
|
|
252
|
+
<DropdownMenu.Item>
|
|
253
|
+
{#snippet child({ props })}
|
|
254
|
+
<a
|
|
255
|
+
{...props}
|
|
256
|
+
href={resolve(versionPath(version.id))}
|
|
257
|
+
class="{props.class} rz-version-menu__row"
|
|
258
|
+
aria-current={version.id === form.values.versionId ? 'true' : undefined}
|
|
259
|
+
>
|
|
260
|
+
{#if drafts && !version.isAutoSave}
|
|
261
|
+
<StatusDot status={version.status} />
|
|
262
|
+
{/if}
|
|
263
|
+
<span class="rz-version-menu__grow">{label}</span>
|
|
264
|
+
{#if version.id === live?.id}
|
|
265
|
+
<span class="rz-version-menu__live">{t__('common.live')}</span>
|
|
266
|
+
{/if}
|
|
267
|
+
<span class="rz-version-menu__meta">{meta}</span>
|
|
268
|
+
</a>
|
|
269
|
+
{/snippet}
|
|
270
|
+
</DropdownMenu.Item>
|
|
271
|
+
{/each}
|
|
272
|
+
|
|
273
|
+
{#if drafts && !published && live}
|
|
274
|
+
<p class="rz-version-menu__note">
|
|
275
|
+
{t__('common.publish_replaces', locale.dateFormat(live.updatedAt, { short: true }))}
|
|
276
|
+
</p>
|
|
277
|
+
{/if}
|
|
278
|
+
|
|
279
|
+
{#if drafts && published}
|
|
280
|
+
<DropdownMenu.Separator />
|
|
281
|
+
<DropdownMenu.Item disabled={form.readOnly} onclick={saveAsNewDraft}>
|
|
282
|
+
<FilePlus size="14" />
|
|
283
|
+
{t__('common.save_new_draft')}
|
|
284
|
+
</DropdownMenu.Item>
|
|
285
|
+
<DropdownMenu.Item
|
|
286
|
+
disabled={form.readOnly}
|
|
287
|
+
onclick={() => setVersionStatus(form, APIProxy, VERSIONS_STATUS.DRAFT)}
|
|
288
|
+
>
|
|
289
|
+
<EyeOff size="14" />
|
|
290
|
+
{t__('common.unpublish')}
|
|
291
|
+
</DropdownMenu.Item>
|
|
292
|
+
{/if}
|
|
293
|
+
|
|
294
|
+
{#if form.values.versionId}
|
|
295
|
+
<DropdownMenu.Separator />
|
|
296
|
+
<DropdownMenu.Item
|
|
297
|
+
class="rz-document-menu__danger"
|
|
298
|
+
disabled={!canDeleteVersion || form.readOnly}
|
|
299
|
+
onclick={() => (deleteConfirmOpen = true)}
|
|
300
|
+
>
|
|
301
|
+
<Trash2 size="14" />
|
|
302
|
+
{drafts && !published ? t__('common.delete_draft') : t__('common.delete_version')}
|
|
303
|
+
</DropdownMenu.Item>
|
|
304
|
+
{/if}
|
|
305
|
+
</DropdownMenu.Content>
|
|
306
|
+
</DropdownMenu.Portal>
|
|
307
|
+
</DropdownMenu.Root>
|
|
308
|
+
|
|
309
|
+
<Dialog.Root bind:open={deleteConfirmOpen}>
|
|
310
|
+
<Dialog.Content>
|
|
311
|
+
<Dialog.Header>
|
|
312
|
+
{t__('common.delete_version_dialog_title')}
|
|
313
|
+
</Dialog.Header>
|
|
314
|
+
<p>{t__('common.delete_version_dialog_text')}</p>
|
|
315
|
+
<Dialog.Footer>
|
|
316
|
+
<Button onclick={deleteVersion} kbd="enter">{t__('common.delete_confirm')}</Button>
|
|
317
|
+
<Button onclick={() => (deleteConfirmOpen = false)} variant="secondary" kbd="escape">
|
|
318
|
+
{t__('common.cancel')}
|
|
319
|
+
</Button>
|
|
320
|
+
</Dialog.Footer>
|
|
321
|
+
</Dialog.Content>
|
|
322
|
+
</Dialog.Root>
|
|
323
|
+
|
|
324
|
+
<style>
|
|
325
|
+
/* The status as a ghost button: a small dot, its name, then a chevron. */
|
|
326
|
+
:global(.rz-version-menu__trigger) {
|
|
327
|
+
--rz-dot-size: var(--rz-size-1-5);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/* The document menu's card, wider: a row holds a name, a "Live" mark and who saved it, when. */
|
|
331
|
+
:global(.rz-version-menu.rz-dropdown-content) {
|
|
332
|
+
--rz-dot-size: var(--rz-size-1-5);
|
|
333
|
+
width: var(--rz-size-80);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
:global(.rz-version-menu .rz-version-menu__grow) {
|
|
337
|
+
flex: 1;
|
|
338
|
+
min-width: 0;
|
|
339
|
+
overflow: hidden;
|
|
340
|
+
text-overflow: ellipsis;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/* "Versions", then "All versions" as a link at the end of the line. */
|
|
344
|
+
.rz-version-menu__heading {
|
|
345
|
+
display: flex;
|
|
346
|
+
align-items: center;
|
|
347
|
+
justify-content: space-between;
|
|
348
|
+
padding: var(--rz-size-1) var(--rz-size-1) var(--rz-size-1) var(--rz-size-2);
|
|
349
|
+
color: var(--rz-fg-muted);
|
|
350
|
+
font-size: var(--rz-text-xs);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
:global(.rz-version-menu .rz-dropdown-item.rz-version-menu__all) {
|
|
354
|
+
height: var(--rz-size-6);
|
|
355
|
+
padding-inline: var(--rz-size-1-5);
|
|
356
|
+
color: var(--rz-accent-text);
|
|
357
|
+
font-size: var(--rz-text-xs);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
:global(.rz-version-menu .rz-version-menu__row[aria-current='true']) {
|
|
361
|
+
background-color: var(--rz-bg-active);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.rz-version-menu__live {
|
|
365
|
+
padding: 0 var(--rz-size-1-5);
|
|
366
|
+
border-radius: var(--rz-radius-sm);
|
|
367
|
+
background-color: color-mix(in oklch, var(--rz-success) 14%, transparent);
|
|
368
|
+
color: var(--rz-success);
|
|
369
|
+
font-size: var(--rz-text-xs);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.rz-version-menu__meta {
|
|
373
|
+
color: var(--rz-fg-subtle);
|
|
374
|
+
font-size: var(--rz-text-xs);
|
|
375
|
+
font-variant-numeric: tabular-nums;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.rz-version-menu__note {
|
|
379
|
+
padding: var(--rz-size-1) var(--rz-size-2);
|
|
380
|
+
color: var(--rz-fg-subtle);
|
|
381
|
+
font-size: var(--rz-text-xs);
|
|
382
|
+
}
|
|
383
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DocumentFormContext } from '../../../context/documentForm.svelte.js';
|
|
2
|
+
import type { GenericDoc } from '../../../../types.js';
|
|
3
|
+
type Props = {
|
|
4
|
+
form: DocumentFormContext<GenericDoc>;
|
|
5
|
+
};
|
|
6
|
+
declare const VersionMenu: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type VersionMenu = ReturnType<typeof VersionMenu>;
|
|
8
|
+
export default VersionMenu;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import { versionsApiUrl, versionsListUrl } from './versions-list.js';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* The document's version history, opened from the
|
|
25
|
+
* The document's version history, opened from the version menu.
|
|
26
26
|
*
|
|
27
27
|
* `doc` is the row on screen: its `versionId` marks the active entry, and picking another entry
|
|
28
28
|
* loads that row into the same page by `?versionId=`. The list comes from the API proxy, so an
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GenericDoc } from '../../../../core/prototype/types.js';
|
|
2
2
|
/**
|
|
3
|
-
* The document's version history, opened from the
|
|
3
|
+
* The document's version history, opened from the version menu.
|
|
4
4
|
*
|
|
5
5
|
* `doc` is the row on screen: its `versionId` marks the active entry, and picking another entry
|
|
6
6
|
* loads that row into the same page by `?versionId=`. The list comes from the API proxy, so an
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VersionsStatus } from '../../../../core/prototype/shared/versions/constant.js';
|
|
2
|
+
import type { getAPIProxyContext } from '../../../context/api-proxy.svelte.js';
|
|
3
|
+
import type { DocumentFormContext } from '../../../context/documentForm.svelte.js';
|
|
4
|
+
/**
|
|
5
|
+
* Sets the status of the row on screen, without a save, then takes it into the form without
|
|
6
|
+
* dirtying it and reloads the page data and the version history.
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* PATCH /api/news/n1?versionId=v2 { status: 'published' }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function setVersionStatus(form: DocumentFormContext, APIProxy: ReturnType<typeof getAPIProxyContext>, next: VersionsStatus): Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { invalidateAll } from '$app/navigation';
|
|
2
|
+
import { PARAMS } from '../../../../core/constants.js';
|
|
3
|
+
import { t__ } from '../../../../core/i18n/index.js';
|
|
4
|
+
import { apiUrl } from '../../../../core/routes/util.js';
|
|
5
|
+
import { documentSegments } from '../../../util/url.js';
|
|
6
|
+
import { toast } from 'svelte-sonner';
|
|
7
|
+
/**
|
|
8
|
+
* Sets the status of the row on screen, without a save, then takes it into the form without
|
|
9
|
+
* dirtying it and reloads the page data and the version history.
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* PATCH /api/news/n1?versionId=v2 { status: 'published' }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export async function setVersionStatus(form, APIProxy, next) {
|
|
16
|
+
const url = apiUrl(...documentSegments(form.config.kebab, form.values));
|
|
17
|
+
const response = await fetch(`${url}?${PARAMS.VERSION_ID}=${form.values.versionId}`, {
|
|
18
|
+
method: 'PATCH',
|
|
19
|
+
body: JSON.stringify({ status: next })
|
|
20
|
+
}).catch(() => null);
|
|
21
|
+
if (response?.status !== 200) {
|
|
22
|
+
toast.error(t__('common.generic_error'));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
toast.success(t__('common.doc_updated'));
|
|
26
|
+
// The server holds the new status already: the form takes it without getting dirty, so no
|
|
27
|
+
// auto-save follows a publish.
|
|
28
|
+
form.sync('status', next);
|
|
29
|
+
invalidateAll();
|
|
30
|
+
// The write went around the form: the version history re-reads its statuses. `apiUrl(kebab)`
|
|
31
|
+
// reaches `/api/<kebab>--versions` because `invalidate` matches by substring (api-proxy.svelte.ts).
|
|
32
|
+
APIProxy.invalidate(apiUrl(form.config.kebab));
|
|
33
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** The versions collection's endpoint behind a document type: `/api/news--versions`. */
|
|
2
2
|
export declare const versionsApiUrl: (type: string) => string;
|
|
3
3
|
/**
|
|
4
|
-
* One document's history, as the version history (Versions.svelte) and the
|
|
4
|
+
* One document's history, as the version history (Versions.svelte) and the version menu read
|
|
5
5
|
* it. One URL, so the API proxy serves both from the same cache and one invalidation refreshes
|
|
6
6
|
* both.
|
|
7
7
|
*/
|
|
@@ -4,7 +4,7 @@ import { apiUrl } from '../../../../core/routes/util.js';
|
|
|
4
4
|
/** The versions collection's endpoint behind a document type: `/api/news--versions`. */
|
|
5
5
|
export const versionsApiUrl = (type) => apiUrl(prototypeKebab(withVersionsSuffix(type)));
|
|
6
6
|
/**
|
|
7
|
-
* One document's history, as the version history (Versions.svelte) and the
|
|
7
|
+
* One document's history, as the version history (Versions.svelte) and the version menu read
|
|
8
8
|
* it. One URL, so the API proxy serves both from the same cache and one invalidation refreshes
|
|
9
9
|
* both.
|
|
10
10
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Calendar as CalendarPrimitive, type WithoutChildrenOrChild } from 'bits-ui';
|
|
2
2
|
import * as Calendar from './index.js';
|
|
3
3
|
import './calendar.css';
|
|
4
|
-
declare const Calendar: import("svelte").Component<WithoutChildrenOrChild<CalendarPrimitive.RootProps>, {}, "value" | "
|
|
4
|
+
declare const Calendar: import("svelte").Component<WithoutChildrenOrChild<CalendarPrimitive.RootProps>, {}, "value" | "ref" | "placeholder">;
|
|
5
5
|
type Calendar = ReturnType<typeof Calendar>;
|
|
6
6
|
export default Calendar;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Checkbox as CheckboxPrimitive } from 'bits-ui';
|
|
2
2
|
import './checkbox.css';
|
|
3
|
-
declare const Checkbox: import("svelte").Component<Omit<Omit<CheckboxPrimitive.RootProps, "child">, "children">, {}, "
|
|
3
|
+
declare const Checkbox: import("svelte").Component<Omit<Omit<CheckboxPrimitive.RootProps, "child">, "children">, {}, "ref" | "checked">;
|
|
4
4
|
type Checkbox = ReturnType<typeof Checkbox>;
|
|
5
5
|
export default Checkbox;
|
|
@@ -4,17 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
title?: Snippet;
|
|
7
|
+
/** Right after the title, on its line: a collection's create buttons. */
|
|
8
|
+
titleEnd?: Snippet;
|
|
7
9
|
/** A line under the title: a count, a date. */
|
|
8
10
|
meta?: Snippet;
|
|
9
11
|
/** Under the meta line: a document's url. */
|
|
10
12
|
aside?: Snippet;
|
|
11
13
|
/** The toolbar under the title, its left side. */
|
|
12
14
|
bottomLeft?: Snippet;
|
|
15
|
+
/** The toolbar's right end: a collection's count. */
|
|
16
|
+
bottomRight?: Snippet;
|
|
13
17
|
/** Replaces the breadcrumb, top left: a nested document's Close. */
|
|
14
18
|
topLeft?: Snippet;
|
|
15
19
|
topRight?: Snippet;
|
|
16
20
|
};
|
|
17
|
-
const { bottomLeft, topRight, topLeft, title, meta, aside }: Props =
|
|
21
|
+
const { bottomLeft, bottomRight, topRight, topLeft, title, titleEnd, meta, aside }: Props =
|
|
22
|
+
$props();
|
|
18
23
|
</script>
|
|
19
24
|
|
|
20
25
|
<div class="rz-page-header__row rz-page-header__row-top">
|
|
@@ -33,7 +38,12 @@
|
|
|
33
38
|
|
|
34
39
|
{#if title || meta || aside}
|
|
35
40
|
<div class="rz-page-header__head">
|
|
36
|
-
{#if title}
|
|
41
|
+
{#if title && titleEnd}
|
|
42
|
+
<div class="rz-page-header__title-row">
|
|
43
|
+
<h1 class="rz-page-header__title">{@render title()}</h1>
|
|
44
|
+
<div class="rz-page-header__title-end">{@render titleEnd()}</div>
|
|
45
|
+
</div>
|
|
46
|
+
{:else if title}
|
|
37
47
|
<h1 class="rz-page-header__title">{@render title()}</h1>
|
|
38
48
|
{/if}
|
|
39
49
|
{#if meta}
|
|
@@ -43,11 +53,16 @@
|
|
|
43
53
|
</div>
|
|
44
54
|
{/if}
|
|
45
55
|
|
|
46
|
-
{#if bottomLeft}
|
|
56
|
+
{#if bottomLeft || bottomRight}
|
|
47
57
|
<div class="rz-page-header__toolbar">
|
|
48
58
|
<div class="rz-page-header__bottom-left">
|
|
49
59
|
{@render bottomLeft?.()}
|
|
50
60
|
</div>
|
|
61
|
+
{#if bottomRight}
|
|
62
|
+
<div class="rz-page-header__bottom-right">
|
|
63
|
+
{@render bottomRight()}
|
|
64
|
+
</div>
|
|
65
|
+
{/if}
|
|
51
66
|
</div>
|
|
52
67
|
{/if}
|
|
53
68
|
|
|
@@ -92,7 +107,8 @@
|
|
|
92
107
|
}
|
|
93
108
|
|
|
94
109
|
.rz-page-header__row-top > div,
|
|
95
|
-
.rz-page-header__bottom-left
|
|
110
|
+
.rz-page-header__bottom-left,
|
|
111
|
+
.rz-page-header__bottom-right {
|
|
96
112
|
display: flex;
|
|
97
113
|
align-items: center;
|
|
98
114
|
gap: var(--rz-size-2);
|
|
@@ -115,11 +131,27 @@
|
|
|
115
131
|
gap: var(--rz-size-1-5);
|
|
116
132
|
}
|
|
117
133
|
|
|
134
|
+
/* The title takes the room it needs, the buttons follow it. */
|
|
135
|
+
.rz-page-header__title-row {
|
|
136
|
+
display: flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
gap: var(--rz-size-4);
|
|
139
|
+
min-width: 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.rz-page-header__title-end {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-shrink: 0;
|
|
145
|
+
align-items: center;
|
|
146
|
+
gap: var(--rz-size-1);
|
|
147
|
+
}
|
|
148
|
+
|
|
118
149
|
.rz-page-header__title {
|
|
119
150
|
overflow: hidden;
|
|
120
151
|
display: -webkit-box;
|
|
121
152
|
-webkit-box-orient: vertical;
|
|
122
153
|
-webkit-line-clamp: 1;
|
|
154
|
+
min-width: 0;
|
|
123
155
|
font-variation-settings: 'wght' 600;
|
|
124
156
|
font-weight: 600;
|
|
125
157
|
font-size: var(--rz-text-4xl);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
2
|
type Props = {
|
|
3
3
|
title?: Snippet;
|
|
4
|
+
/** Right after the title, on its line: a collection's create buttons. */
|
|
5
|
+
titleEnd?: Snippet;
|
|
4
6
|
/** A line under the title: a count, a date. */
|
|
5
7
|
meta?: Snippet;
|
|
6
8
|
/** Under the meta line: a document's url. */
|
|
7
9
|
aside?: Snippet;
|
|
8
10
|
/** The toolbar under the title, its left side. */
|
|
9
11
|
bottomLeft?: Snippet;
|
|
12
|
+
/** The toolbar's right end: a collection's count. */
|
|
13
|
+
bottomRight?: Snippet;
|
|
10
14
|
/** Replaces the breadcrumb, top left: a nested document's Close. */
|
|
11
15
|
topLeft?: Snippet;
|
|
12
16
|
topRight?: Snippet;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Switch as SwitchPrimitive } from 'bits-ui';
|
|
2
2
|
import './switch.css';
|
|
3
|
-
declare const Switch: import("svelte").Component<Omit<Omit<SwitchPrimitive.RootProps, "child">, "children">, {}, "
|
|
3
|
+
declare const Switch: import("svelte").Component<Omit<Omit<SwitchPrimitive.RootProps, "child">, "children">, {}, "ref" | "checked">;
|
|
4
4
|
type Switch = ReturnType<typeof Switch>;
|
|
5
5
|
export default Switch;
|
|
@@ -45,7 +45,7 @@ export declare function setCollectionContext(args: Args): {
|
|
|
45
45
|
/** A filter change drops the selection, so no hidden document stays picked. */
|
|
46
46
|
statusFilter: StatusFilter;
|
|
47
47
|
kindFilter: KindFilter;
|
|
48
|
-
readonly kinds: ("
|
|
48
|
+
readonly kinds: ("audio" | "video" | "image" | "document" | "other")[];
|
|
49
49
|
readonly draftsCount: number;
|
|
50
50
|
readonly totalSize: number;
|
|
51
51
|
/** Every document of the collection, whatever the search. */
|
|
@@ -95,7 +95,7 @@ export declare function getCollectionContext(): {
|
|
|
95
95
|
/** A filter change drops the selection, so no hidden document stays picked. */
|
|
96
96
|
statusFilter: StatusFilter;
|
|
97
97
|
kindFilter: KindFilter;
|
|
98
|
-
readonly kinds: ("
|
|
98
|
+
readonly kinds: ("audio" | "video" | "image" | "document" | "other")[];
|
|
99
99
|
readonly draftsCount: number;
|
|
100
100
|
readonly totalSize: number;
|
|
101
101
|
/** Every document of the collection, whatever the search. */
|
|
@@ -89,6 +89,8 @@ export declare function setDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
89
89
|
readonly config: import("../../types.js").BuiltCollection;
|
|
90
90
|
readonly title: string | import("../../core/prototype/collection/types.js").CollectionLabel;
|
|
91
91
|
readonly isLive: boolean;
|
|
92
|
+
/** The path of the title the page's heading edits, or `null`: the form leaves that field out. */
|
|
93
|
+
readonly inlineTitle: string | null;
|
|
92
94
|
/** Puts the document back as it was loaded or last saved. The errors stay. */
|
|
93
95
|
reset(): void;
|
|
94
96
|
};
|