rimecms 0.26.5 → 0.26.6
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/collections/versions/operations.d.ts +1 -1
- package/dist/core/collections/versions/operations.js +1 -1
- package/dist/core/config/server/build-config.server.js +0 -2
- package/dist/core/dev/generate/routes/common.js +9 -6
- package/dist/core/fields/builders/select.js +0 -4
- package/dist/core/operations/blocks/extract.server.js +2 -1
- package/dist/fields/blocks/component/Block.svelte +23 -31
- package/dist/fields/blocks/component/Blocks.svelte +14 -7
- package/dist/fields/checkbox/component/Checkbox.svelte +1 -1
- package/dist/fields/combobox/component/ComboBox.svelte +1 -1
- package/dist/fields/group/component/Group.svelte +20 -12
- package/dist/fields/link/component/Link.svelte +14 -12
- package/dist/fields/link/index.d.ts +1 -1
- package/dist/fields/link/index.js +5 -5
- package/dist/fields/radio/index.d.ts +1 -0
- package/dist/fields/radio/index.js +8 -0
- package/dist/fields/relation/component/Relation.svelte +2 -1
- package/dist/fields/rich-text/component/Cell.svelte +1 -1
- package/dist/fields/rich-text/component/RichText.svelte +9 -3
- package/dist/fields/rich-text/component/bubble-menu/bubble-menu.svelte +1 -1
- package/dist/fields/rich-text/core/features/fields/fields.svelte +1 -0
- package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +4 -2
- package/dist/fields/rich-text/core/features/resource/resource.svelte +12 -3
- package/dist/fields/rich-text/core/features/upload/upload.svelte +15 -6
- package/dist/fields/select/component/Select.svelte +2 -4
- package/dist/fields/slug/component/Slug.svelte +15 -23
- package/dist/fields/tabs/component/Tabs.svelte +56 -56
- package/dist/fields/toggle/component/Toggle.svelte +1 -1
- package/dist/fields/tree/component/Tree.svelte +6 -1
- package/dist/fields/tree/component/TreeBlock.svelte +24 -20
- package/dist/panel/components/Root.svelte +3 -5
- package/dist/panel/components/sections/collection/folder/FolderEdit.svelte +5 -5
- package/dist/panel/components/sections/collection/grid/create-directory-dialog/CreateDirectoryDialog.svelte +10 -28
- package/dist/panel/components/sections/collection/grid/grid-item/GridItem.svelte +2 -3
- package/dist/panel/components/sections/collection/header/ButtonCreate.svelte +2 -3
- package/dist/panel/components/sections/collection/header/DisplayMode.svelte +9 -5
- package/dist/panel/components/sections/collection/header/Header.svelte +2 -4
- package/dist/panel/components/sections/collection/header/SearchInput.svelte +2 -3
- package/dist/panel/components/sections/collection/header/SelectUI.svelte +2 -4
- package/dist/panel/components/sections/collection/list/header/Header.svelte +12 -8
- package/dist/panel/components/sections/collection/list/row/Row.svelte +15 -10
- package/dist/panel/components/sections/document/ButtonStatus.svelte +15 -9
- package/dist/panel/components/sections/document/Document.svelte +13 -12
- package/dist/panel/components/sections/document/Header.svelte +1 -1
- package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte +2 -2
- package/dist/panel/components/sections/live/SidePanel.svelte +3 -2
- package/dist/panel/components/ui/nav/NavItem.svelte +3 -2
- package/dist/panel/context/collection.svelte.d.ts +1 -2
- package/dist/panel/context/collection.svelte.js +2 -2
- package/dist/panel/context/documentForm.svelte.d.ts +2 -3
- package/dist/panel/context/documentForm.svelte.js +19 -20
- package/dist/panel/pages/auth/sign-in/SignIn.svelte +1 -0
- package/dist/panel/pages/collection/Collection.svelte +14 -12
- package/package.json +2 -2
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { t__ } from '../../../../../core/i18n/index.js';
|
|
3
3
|
import Input from '../../../ui/input/input.svelte';
|
|
4
|
-
import
|
|
4
|
+
import { getCollectionContext } from '../../../../context/collection.svelte.js';
|
|
5
5
|
import { Search } from '@lucide/svelte';
|
|
6
|
-
import { getContext } from 'svelte';
|
|
7
6
|
|
|
8
|
-
const collection =
|
|
7
|
+
const collection = getCollectionContext('list');
|
|
9
8
|
let searchValue = $state('');
|
|
10
9
|
|
|
11
10
|
$effect(() => {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { t__ } from '../../../../../core/i18n/index.js';
|
|
3
3
|
import Button from '../../../ui/button/button.svelte';
|
|
4
|
-
import
|
|
4
|
+
import { getCollectionContext } from '../../../../context/collection.svelte.js';
|
|
5
5
|
import { ListChecks, SquareCheck, SquareMinus, Trash } from '@lucide/svelte';
|
|
6
|
-
import { getContext } from 'svelte';
|
|
7
|
-
|
|
8
|
-
const collection = getContext<CollectionContext>('rime.collectionList');
|
|
9
6
|
|
|
7
|
+
const collection = getCollectionContext('list');
|
|
10
8
|
const selectedCount = $derived(collection.selected.length);
|
|
11
9
|
const pluralSuffix = $derived(selectedCount > 1 ? 's' : '');
|
|
12
10
|
const activeListClass = $derived(collection.selectMode ? 'rz-header-select__icon--active' : '');
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { FormField } from '../../../../../../fields/types.js';
|
|
3
|
+
import { getCollectionContext } from '../../../../../context/collection.svelte.js';
|
|
2
4
|
import { capitalize } from '../../../../../../util/string.js';
|
|
3
5
|
import { ChevronDown, ChevronUp } from '@lucide/svelte';
|
|
4
|
-
import type { CollectionContext } from '../../../../../context/collection.svelte.js';
|
|
5
|
-
import type { FormField } from '../../../../../../fields/types.js';
|
|
6
|
-
import { getContext } from 'svelte';
|
|
7
6
|
|
|
8
7
|
type TableColumn = Partial<FormField> & { name: string; label?: string };
|
|
9
8
|
|
|
10
|
-
const collection =
|
|
9
|
+
const collection = getCollectionContext('list');
|
|
11
10
|
let gridTemplateColumn = $state('grid-template-columns: 2fr repeat(1, minmax(0, 1fr));');
|
|
12
11
|
|
|
13
12
|
$effect(() => {
|
|
@@ -55,8 +54,13 @@
|
|
|
55
54
|
{@render sortableColumnHeader({ name: 'updatedAt' })}
|
|
56
55
|
</div>
|
|
57
56
|
|
|
58
|
-
<style
|
|
59
|
-
|
|
57
|
+
<style>/**************************************/
|
|
58
|
+
|
|
59
|
+
/* Font */
|
|
60
|
+
|
|
61
|
+
/**************************************/
|
|
62
|
+
|
|
63
|
+
.rz-list-header {
|
|
60
64
|
display: grid;
|
|
61
65
|
height: var(--rz-size-14);
|
|
62
66
|
/* width: calc(100% - var(--rz-size-10)); */
|
|
@@ -66,14 +70,14 @@
|
|
|
66
70
|
font-size: var(--rz-text-sm);
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
.rz-list-header__column {
|
|
70
74
|
color: hsl(var(--rz-ground-2) / 1);
|
|
71
75
|
display: flex;
|
|
72
76
|
align-items: center;
|
|
73
77
|
gap: var(--rz-size-1);
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
.rz-list-header__sort-button {
|
|
77
81
|
color: hsl(var(--rz-ground-2) / 1);
|
|
78
82
|
display: flex;
|
|
79
83
|
align-items: center;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { GenericDoc } from '../../../../../../core/types/doc.js';
|
|
3
3
|
import Checkbox from '../../../../ui/checkbox/checkbox.svelte';
|
|
4
|
-
import
|
|
4
|
+
import { getCollectionContext } from '../../../../../context/collection.svelte.js';
|
|
5
5
|
import { getLocaleContext } from '../../../../../context/locale.svelte';
|
|
6
6
|
import { getValueAtPath } from '../../../../../../util/object';
|
|
7
|
-
import { getContext } from 'svelte';
|
|
8
7
|
import StatusDot from '../../StatusDot.svelte';
|
|
9
8
|
import UploadThumbCell from '../../upload-thumb-cell/UploadThumbCell.svelte';
|
|
10
9
|
|
|
@@ -14,8 +13,8 @@
|
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
const { checked, doc }: Props = $props();
|
|
17
|
-
const collection = getContext<CollectionContext>('rime.collectionList');
|
|
18
16
|
|
|
17
|
+
const collection = getCollectionContext('list');
|
|
19
18
|
const locale = getLocaleContext();
|
|
20
19
|
|
|
21
20
|
let gridTemplateColumn = $state('grid-template-columns: 2fr repeat(1, minmax(0, 1fr));');
|
|
@@ -77,8 +76,13 @@
|
|
|
77
76
|
</div>
|
|
78
77
|
</div>
|
|
79
78
|
|
|
80
|
-
<style
|
|
81
|
-
|
|
79
|
+
<style>/**************************************/
|
|
80
|
+
|
|
81
|
+
/* Font */
|
|
82
|
+
|
|
83
|
+
/**************************************/
|
|
84
|
+
|
|
85
|
+
.rz-list-row {
|
|
82
86
|
display: grid;
|
|
83
87
|
height: var(--rz-row-height);
|
|
84
88
|
align-items: center;
|
|
@@ -103,7 +107,7 @@
|
|
|
103
107
|
}
|
|
104
108
|
}
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
.rz-list-row__main {
|
|
107
111
|
display: flex;
|
|
108
112
|
align-items: center;
|
|
109
113
|
gap: var(--rz-size-3);
|
|
@@ -111,24 +115,25 @@
|
|
|
111
115
|
padding-right: var(--rz-size-5);
|
|
112
116
|
}
|
|
113
117
|
|
|
114
|
-
|
|
118
|
+
.rz-list-row__link {
|
|
115
119
|
display: flex;
|
|
116
120
|
align-items: center;
|
|
117
121
|
gap: var(--rz-size-4);
|
|
118
122
|
}
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
.rz-list-row__title {
|
|
121
125
|
display: -webkit-box;
|
|
122
126
|
-webkit-line-clamp: 1;
|
|
123
127
|
-webkit-box-orient: vertical;
|
|
124
128
|
overflow: hidden;
|
|
125
129
|
word-break: break-all;
|
|
126
130
|
}
|
|
127
|
-
|
|
131
|
+
|
|
132
|
+
label.rz-list-row__title {
|
|
128
133
|
cursor: pointer;
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
|
|
136
|
+
.rz-list-row__cell {
|
|
132
137
|
color: hsl(var(--rz-foreground) / 0.6);
|
|
133
138
|
}
|
|
134
139
|
</style>
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
{
|
|
26
26
|
method: 'PATCH',
|
|
27
27
|
body: JSON.stringify({
|
|
28
|
-
status:
|
|
28
|
+
status: status
|
|
29
29
|
})
|
|
30
30
|
}
|
|
31
31
|
)
|
|
32
32
|
.then((r) => {
|
|
33
33
|
if (r.status === 200) {
|
|
34
34
|
toast.success(t__('common.doc_updated'));
|
|
35
|
-
form.setValue('status',
|
|
35
|
+
form.setValue('status', status);
|
|
36
36
|
dialogOpen = false;
|
|
37
37
|
invalidateAll();
|
|
38
38
|
} else {
|
|
@@ -44,8 +44,7 @@
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
let
|
|
48
|
-
let internalValue = $state(initialValue);
|
|
47
|
+
let status = $derived(form.values.status);
|
|
49
48
|
</script>
|
|
50
49
|
|
|
51
50
|
<Dialog.Root bind:open={dialogOpen}>
|
|
@@ -58,7 +57,7 @@
|
|
|
58
57
|
{/snippet}
|
|
59
58
|
</Dialog.Trigger>
|
|
60
59
|
<Dialog.Content class="rz-status-dialog">
|
|
61
|
-
<Radio.Root bind:value={
|
|
60
|
+
<Radio.Root bind:value={status}>
|
|
62
61
|
{#each statusList as status, index (index)}
|
|
63
62
|
<div class="rz-radio__option">
|
|
64
63
|
<Radio.Item id="document.{status}" value={status} />
|
|
@@ -76,19 +75,26 @@
|
|
|
76
75
|
</Dialog.Content>
|
|
77
76
|
</Dialog.Root>
|
|
78
77
|
|
|
79
|
-
<style
|
|
80
|
-
|
|
78
|
+
<style>/**************************************/
|
|
79
|
+
|
|
80
|
+
/* Font */
|
|
81
|
+
|
|
82
|
+
/**************************************/
|
|
83
|
+
|
|
84
|
+
.rz-radio__option {
|
|
81
85
|
display: flex;
|
|
82
86
|
gap: var(--rz-size-3);
|
|
83
87
|
padding: var(--rz-size-3);
|
|
84
88
|
border: var(--rz-border);
|
|
85
89
|
}
|
|
86
|
-
|
|
90
|
+
|
|
91
|
+
:global {
|
|
87
92
|
.rz-dialog-footer button {
|
|
88
93
|
flex: 1;
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
|
-
|
|
96
|
+
|
|
97
|
+
p {
|
|
92
98
|
font-variation-settings: 'wght' 400;
|
|
93
99
|
font-weight: 400;
|
|
94
100
|
}
|
|
@@ -46,12 +46,14 @@
|
|
|
46
46
|
}: Props = $props();
|
|
47
47
|
|
|
48
48
|
const { getDocumentConfig } = getConfigContext();
|
|
49
|
-
const config = getDocumentConfig({
|
|
50
|
-
prototype: initial._prototype,
|
|
51
|
-
slug: initial._type
|
|
52
|
-
});
|
|
53
49
|
|
|
54
50
|
const user = getUserContext();
|
|
51
|
+
const config = $derived(
|
|
52
|
+
getDocumentConfig({
|
|
53
|
+
prototype: initial._prototype,
|
|
54
|
+
slug: initial._type
|
|
55
|
+
})
|
|
56
|
+
);
|
|
55
57
|
|
|
56
58
|
let formElement = $state<HTMLFormElement>();
|
|
57
59
|
// This is used to intercept navigation when there are unsaved changes in the form
|
|
@@ -59,6 +61,12 @@
|
|
|
59
61
|
let interceptedLeave = $state<{ url: string } | null>(null);
|
|
60
62
|
// This is used to prevent the beforeNavigate from triggering when we programmatically navigate
|
|
61
63
|
let isRedirect = $state(false);
|
|
64
|
+
// Dialog for unsaved changes confirmation
|
|
65
|
+
const isConfirmLeaveOpen = $derived(!!interceptedLeave);
|
|
66
|
+
const locale = getLocaleContext();
|
|
67
|
+
const liveEditing = $derived(!!onDataChange);
|
|
68
|
+
// This is used to show the API key after creating a document in a collection with API key auth
|
|
69
|
+
let apiKey = $state<string | null>('');
|
|
62
70
|
|
|
63
71
|
// Intercept navigation when there are unsaved changes in the form
|
|
64
72
|
beforeNavigate(async ({ cancel, to }) => {
|
|
@@ -71,8 +79,8 @@
|
|
|
71
79
|
interceptedLeave = { url: to.url.href };
|
|
72
80
|
});
|
|
73
81
|
|
|
82
|
+
// svelte-ignore state_referenced_locally
|
|
74
83
|
const form = setDocumentFormContext({
|
|
75
|
-
element: () => formElement,
|
|
76
84
|
initial,
|
|
77
85
|
config,
|
|
78
86
|
readOnly,
|
|
@@ -83,10 +91,6 @@
|
|
|
83
91
|
beforeRedirect: beforeRedirect
|
|
84
92
|
});
|
|
85
93
|
|
|
86
|
-
const isConfirmLeaveOpen = $derived(!!interceptedLeave);
|
|
87
|
-
const locale = getLocaleContext();
|
|
88
|
-
const liveEditing = !!onDataChange;
|
|
89
|
-
|
|
90
94
|
function handleKeyDown(event: KeyboardEvent) {
|
|
91
95
|
if (!formElement) throw Error('formElement is not defined');
|
|
92
96
|
if ((event.ctrlKey || event.metaKey) && event.key === 's') {
|
|
@@ -102,8 +106,6 @@
|
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
let apiKey = $state<string | null>('');
|
|
106
|
-
|
|
107
109
|
async function beforeRedirect(data?: FormSuccessData) {
|
|
108
110
|
const IS_API_AUTH = config.type === 'collection' && config.auth?.type === 'apiKey';
|
|
109
111
|
if (IS_API_AUTH) {
|
|
@@ -137,7 +139,6 @@
|
|
|
137
139
|
class="rz-document {className}"
|
|
138
140
|
bind:this={formElement}
|
|
139
141
|
use:form.enhance
|
|
140
|
-
action={form.buildPanelActionUrl()}
|
|
141
142
|
enctype="multipart/form-data"
|
|
142
143
|
method="post"
|
|
143
144
|
>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
};
|
|
21
21
|
const { form, onClose, config }: Props = $props();
|
|
22
22
|
|
|
23
|
-
const onCloseIsDefined = !!onClose;
|
|
23
|
+
const onCloseIsDefined = $derived(!!onClose);
|
|
24
24
|
const buttonLabel = $derived(form.values.id ? t__('common.save') : t__('common.create'));
|
|
25
25
|
|
|
26
26
|
function buildDocumentURL() {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
let file = $state<File | null>(null);
|
|
21
21
|
let isValidFile = $state(false);
|
|
22
22
|
|
|
23
|
-
const hasAccept = 'accept' in form.config;
|
|
24
|
-
const allowedMimeTypes = accept || [];
|
|
23
|
+
const hasAccept = $derived('accept' in form.config);
|
|
24
|
+
const allowedMimeTypes = $derived(accept || []);
|
|
25
25
|
|
|
26
26
|
const deleteFile = () => {
|
|
27
27
|
preview = null;
|
|
@@ -36,13 +36,14 @@
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
setAPIProxyContext(API_PROXY.DOCUMENT);
|
|
39
|
+
// svelte-ignore state_referenced_locally
|
|
39
40
|
setConfigContext(config);
|
|
41
|
+
// svelte-ignore state_referenced_locally
|
|
40
42
|
setUserContext(user);
|
|
41
43
|
createContext('title', '[untitled]');
|
|
42
|
-
const locale = setLocaleContext(initialeLocale);
|
|
43
44
|
|
|
44
45
|
$effect(() => {
|
|
45
|
-
|
|
46
|
+
setLocaleContext(initialeLocale);
|
|
46
47
|
});
|
|
47
48
|
</script>
|
|
48
49
|
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
const config = getConfigContext();
|
|
17
17
|
|
|
18
|
-
const RouteIcon =
|
|
19
|
-
typeof route.icon === 'function' ? route.icon : config.raw.icons[route.icon] || File
|
|
18
|
+
const RouteIcon = $derived(
|
|
19
|
+
typeof route.icon === 'function' ? route.icon : config.raw.icons[route.icon] || File
|
|
20
|
+
);
|
|
20
21
|
|
|
21
22
|
let pathname = page.url.pathname;
|
|
22
23
|
|
|
@@ -9,7 +9,7 @@ export declare const DISPLAY_MODE: {
|
|
|
9
9
|
readonly GRID: "display_grid";
|
|
10
10
|
readonly NESTED: "display_nested";
|
|
11
11
|
};
|
|
12
|
-
export declare function setCollectionContext(args: Args): {
|
|
12
|
+
export declare function setCollectionContext(key: string, args: Args): {
|
|
13
13
|
readonly stamp: number;
|
|
14
14
|
readonly title: string;
|
|
15
15
|
readonly hasDraft: boolean | undefined;
|
|
@@ -129,6 +129,5 @@ type Args<T extends GenericDoc = GenericDoc> = {
|
|
|
129
129
|
currentPath?: `root${string}`;
|
|
130
130
|
parentDirectory?: Directory;
|
|
131
131
|
};
|
|
132
|
-
key?: string;
|
|
133
132
|
};
|
|
134
133
|
export {};
|
|
@@ -434,9 +434,9 @@ function createCollectionStore(args) {
|
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
436
|
const COLLECTION_KEY = 'rime.collection';
|
|
437
|
-
export function setCollectionContext(args) {
|
|
437
|
+
export function setCollectionContext(key, args) {
|
|
438
438
|
const store = createCollectionStore(args);
|
|
439
|
-
return setContext(`${COLLECTION_KEY}.${
|
|
439
|
+
return setContext(`${COLLECTION_KEY}.${key}`, store);
|
|
440
440
|
}
|
|
441
441
|
export function getCollectionContext(key = 'root') {
|
|
442
442
|
return getContext(`${COLLECTION_KEY}.${key}`);
|
|
@@ -6,7 +6,7 @@ export declare function setDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
6
6
|
key: string;
|
|
7
7
|
setValue: (path: string, value: any) => void;
|
|
8
8
|
getRawValue: <T_1>(path: string) => NonNullable<T_1> | null;
|
|
9
|
-
enhance: (
|
|
9
|
+
enhance: (node: HTMLFormElement) => {
|
|
10
10
|
destroy(): void;
|
|
11
11
|
};
|
|
12
12
|
useField: <TValue>(path: string, config?: SimplerField<FormField>) => {
|
|
@@ -75,7 +75,7 @@ export declare function getDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
75
75
|
key: string;
|
|
76
76
|
setValue: (path: string, value: any) => void;
|
|
77
77
|
getRawValue: <T_1>(path: string) => NonNullable<T_1> | null;
|
|
78
|
-
enhance: (
|
|
78
|
+
enhance: (node: HTMLFormElement) => {
|
|
79
79
|
destroy(): void;
|
|
80
80
|
};
|
|
81
81
|
useField: <TValue>(path: string, config?: SimplerField<FormField>) => {
|
|
@@ -149,7 +149,6 @@ export type FormSuccessData = {
|
|
|
149
149
|
message?: string;
|
|
150
150
|
};
|
|
151
151
|
type Args<T> = {
|
|
152
|
-
element: () => HTMLFormElement | undefined;
|
|
153
152
|
beforeSubmit?: (data: Dic) => Promise<Dic>;
|
|
154
153
|
beforeRedirect?: (data?: FormSuccessData) => Promise<boolean>;
|
|
155
154
|
afterSuccess?: (doc?: T) => void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { applyAction, deserialize } from '$app/forms';
|
|
2
|
-
import { invalidateAll } from '$app/navigation';
|
|
3
2
|
import { page } from '$app/state';
|
|
4
3
|
import { apiUrl } from '../../core/api/index.js';
|
|
5
4
|
import { compileDocumentConfig } from '../../core/config/shared/compile.js';
|
|
@@ -24,15 +23,16 @@ import { getCollectionContext } from './collection.svelte.js';
|
|
|
24
23
|
import { setErrorsContext } from './errors.svelte.js';
|
|
25
24
|
import { getLocaleContext } from './locale.svelte.js';
|
|
26
25
|
import { getUserContext } from './user.svelte.js';
|
|
27
|
-
function createDocumentFormState({ initial,
|
|
26
|
+
function createDocumentFormState({ initial, config, readOnly, key, onNestedDocumentCreated, afterSuccess, onDataChange, beforeSubmit, beforeRedirect, onFieldFocus }) {
|
|
28
27
|
//
|
|
29
28
|
let initialDoc = $state(initial);
|
|
30
29
|
let doc = $state(initial);
|
|
30
|
+
let formElement = $state();
|
|
31
31
|
const documentConfig = compileDocumentConfig(config);
|
|
32
32
|
const changes = $derived(diff(initialDoc, doc));
|
|
33
33
|
let isDisabled = $state(readOnly);
|
|
34
34
|
let processing = $state(false);
|
|
35
|
-
const operation = doc.id ? 'update' : 'create';
|
|
35
|
+
const operation = $derived(doc.id ? 'update' : 'create');
|
|
36
36
|
const user = getUserContext();
|
|
37
37
|
const errors = setErrorsContext(key);
|
|
38
38
|
const isCollection = documentConfig.type === 'collection';
|
|
@@ -506,18 +506,14 @@ function createDocumentFormState({ initial, element, config, readOnly, key, onNe
|
|
|
506
506
|
}
|
|
507
507
|
return applyAction({ type: 'redirect', location: redirect, status: 301 });
|
|
508
508
|
}
|
|
509
|
-
// Assign
|
|
509
|
+
// Assign documents returned from the server to the form state
|
|
510
510
|
doc = (data?.document || doc);
|
|
511
|
+
initialDoc = doc;
|
|
512
|
+
// Invalidate all queries to ensure data consistency across the app
|
|
513
|
+
apiProxy.invalidateAll();
|
|
511
514
|
toast.success(message);
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
initialDoc = doc;
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
apiProxy.invalidateAll();
|
|
518
|
-
// Do not redirect on creation if it's a nested form
|
|
519
|
-
// the form will auto close and we are back to the parent
|
|
520
|
-
// Form so no need to assign the returned doc
|
|
515
|
+
// Callbacks
|
|
516
|
+
if (nestedLevel !== 0) {
|
|
521
517
|
if (onNestedDocumentCreated)
|
|
522
518
|
onNestedDocumentCreated(doc);
|
|
523
519
|
}
|
|
@@ -546,15 +542,19 @@ function createDocumentFormState({ initial, element, config, readOnly, key, onNe
|
|
|
546
542
|
}
|
|
547
543
|
processing = false;
|
|
548
544
|
};
|
|
549
|
-
const enhance = (
|
|
545
|
+
const enhance = (node) => {
|
|
546
|
+
// Assign form element
|
|
547
|
+
formElement = node;
|
|
548
|
+
// Set status field if submitter has a data-status attribute
|
|
550
549
|
const setStatus = (submitter) => {
|
|
551
550
|
const status = !!submitter?.dataset.status;
|
|
552
551
|
if (status && documentConfig.versions && documentConfig.versions.draft) {
|
|
553
552
|
setValue('status', submitter?.dataset.status);
|
|
554
553
|
}
|
|
555
554
|
};
|
|
555
|
+
// Build full action URL with query params based on submitter attributes (draft, versionId)
|
|
556
556
|
const enhanceAction = (submitter) => {
|
|
557
|
-
let action =
|
|
557
|
+
let action = buildPanelActionUrl();
|
|
558
558
|
const draft = !!submitter?.dataset.draft;
|
|
559
559
|
if (draft) {
|
|
560
560
|
action += `&draft=true`;
|
|
@@ -571,10 +571,10 @@ function createDocumentFormState({ initial, element, config, readOnly, key, onNe
|
|
|
571
571
|
setStatus(event.submitter);
|
|
572
572
|
submit(enhanceAction(event.submitter));
|
|
573
573
|
};
|
|
574
|
-
|
|
574
|
+
node.addEventListener('submit', listener);
|
|
575
575
|
return {
|
|
576
576
|
destroy() {
|
|
577
|
-
|
|
577
|
+
node.removeEventListener('submit', listener);
|
|
578
578
|
}
|
|
579
579
|
};
|
|
580
580
|
};
|
|
@@ -646,10 +646,9 @@ function createDocumentFormState({ initial, element, config, readOnly, key, onNe
|
|
|
646
646
|
isDisabled = bool;
|
|
647
647
|
},
|
|
648
648
|
get element() {
|
|
649
|
-
|
|
650
|
-
if (!htmlFormElement)
|
|
649
|
+
if (!formElement)
|
|
651
650
|
throw new Error('form element is not defined');
|
|
652
|
-
return
|
|
651
|
+
return formElement;
|
|
653
652
|
},
|
|
654
653
|
get canSubmit() {
|
|
655
654
|
return canSubmit;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { setCollectionContext } from '../../context/collection.svelte.js';
|
|
19
19
|
import { getConfigContext } from '../../context/config.svelte.js';
|
|
20
20
|
import { CopyPlus } from '@lucide/svelte';
|
|
21
|
-
import { getContext
|
|
21
|
+
import { getContext } from 'svelte';
|
|
22
22
|
|
|
23
23
|
type Props = {
|
|
24
24
|
slug: string;
|
|
@@ -36,18 +36,17 @@
|
|
|
36
36
|
|
|
37
37
|
const { data, slug }: Props = $props();
|
|
38
38
|
const config = getConfigContext();
|
|
39
|
-
const collectionConfig = config.getCollection(slug);
|
|
39
|
+
const collectionConfig = $derived(config.getCollection(slug));
|
|
40
40
|
let bulkDialogOpen = $state(false);
|
|
41
41
|
|
|
42
|
-
const collection =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
setContext('rime.collectionList', collection);
|
|
42
|
+
const collection = $derived(
|
|
43
|
+
setCollectionContext('list', {
|
|
44
|
+
initial: data.docs,
|
|
45
|
+
config: collectionConfig,
|
|
46
|
+
canCreate: data.canCreate,
|
|
47
|
+
upload: data.upload
|
|
48
|
+
})
|
|
49
|
+
);
|
|
51
50
|
|
|
52
51
|
$effect(() => {
|
|
53
52
|
collection.upload = {
|
|
@@ -62,7 +61,10 @@
|
|
|
62
61
|
});
|
|
63
62
|
|
|
64
63
|
const titleContext = getContext<{ value: string }>('title');
|
|
65
|
-
|
|
64
|
+
|
|
65
|
+
$effect(() => {
|
|
66
|
+
titleContext.value = collection.config.label.plural;
|
|
67
|
+
});
|
|
66
68
|
</script>
|
|
67
69
|
|
|
68
70
|
{#if data.status === 200}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rimecms",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.6",
|
|
4
4
|
"homepage": "https://github.com/bienbiendev/rime",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
"paneforge": "^0.0.6",
|
|
222
222
|
"polka": "^0.5.2",
|
|
223
223
|
"qs": "^6.14.0",
|
|
224
|
-
"runed": "^0.
|
|
224
|
+
"runed": "^0.37.1",
|
|
225
225
|
"sharp": "^0.34.0",
|
|
226
226
|
"sortablejs": "^1.15.6",
|
|
227
227
|
"svelte-sonner": "^1.0.5"
|