rimecms 0.25.1 → 0.25.2
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/config/shared/upload-directories.d.ts +0 -4
- package/dist/core/config/shared/upload-directories.js +0 -72
- package/dist/fields/relation/component/Relation.svelte +0 -2
- package/dist/fields/relation/component/default/Default.svelte +3 -3
- package/dist/fields/relation/component/types.d.ts +0 -1
- package/dist/fields/relation/index.js +2 -1
- package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle-plugin.js +1 -2
- package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.js +0 -1
- package/dist/panel/components/sections/collection/grid/grid-item/Folder.svelte +6 -1
- package/dist/panel/components/sections/collection/grid/grid-item/FolderEdit.svelte +3 -15
- package/dist/panel/components/sections/collection/list/row/Row.svelte +1 -1
- package/dist/panel/components/sections/collection/tree/CollectionTree.svelte +0 -1
- package/dist/panel/context/documentForm.svelte.d.ts +1 -0
- package/dist/panel/context/documentForm.svelte.js +3 -3
- package/package.json +1 -1
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { WithUpload } from '../../collections/upload/util/config.js';
|
|
2
2
|
import type { BuiltCollection } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Creates an upload directories collection for collections with upload enabled
|
|
5
|
-
* Eg. for medias this will create a collection medias_directories
|
|
6
|
-
*/
|
|
7
3
|
/**
|
|
8
4
|
* Creates an upload directories collection for collections with upload enabled
|
|
9
5
|
* Eg. for medias this will create a collection medias_directories
|
|
@@ -2,76 +2,6 @@ import { validatePath } from '../../collections/upload/util/path.js';
|
|
|
2
2
|
import { withDirectoriesSuffix } from '../../naming.js';
|
|
3
3
|
import { date } from '../../../fields/date/index.js';
|
|
4
4
|
import { text } from '../../../fields/text/index.js';
|
|
5
|
-
/**
|
|
6
|
-
* Creates an upload directories collection for collections with upload enabled
|
|
7
|
-
* Eg. for medias this will create a collection medias_directories
|
|
8
|
-
*/
|
|
9
|
-
// export function makeUploadDirectoriesCollections<C extends Config>(config: C) {
|
|
10
|
-
// for (const collection of config.collections || []) {
|
|
11
|
-
// if (collection.upload) {
|
|
12
|
-
// const slug = withDirectoriesSuffix(collection.slug);
|
|
13
|
-
// // If already created skip to the next colleciton
|
|
14
|
-
// // for exemple a versions collections of an upload
|
|
15
|
-
// // collection should not have a directories related table
|
|
16
|
-
// if ((config.collections || []).filter((c) => c.slug === slug).length) continue;
|
|
17
|
-
// const directoriesConfig = collection.upload.directories;
|
|
18
|
-
// // else create the directory collection
|
|
19
|
-
// let directoriesCollection: BuiltCollection = {
|
|
20
|
-
// slug: slug as CollectionSlug,
|
|
21
|
-
// kebab: withDirectoriesSuffix(toKebabCase(collection.slug)),
|
|
22
|
-
// versions: undefined,
|
|
23
|
-
// access: {
|
|
24
|
-
// read: directoriesConfig?.access?.read || collection.access.read,
|
|
25
|
-
// create: directoriesConfig?.access?.create || collection.access.create,
|
|
26
|
-
// update: directoriesConfig?.access?.update || collection.access.update,
|
|
27
|
-
// delete: directoriesConfig?.access?.delete || collection.access.delete
|
|
28
|
-
// },
|
|
29
|
-
// fields: [
|
|
30
|
-
// text('id').validate(validatePath).unique().required().hidden(),
|
|
31
|
-
// text('name').validate((value) => {
|
|
32
|
-
// const pattern = /^[a-zA-Z0-9-_ ]+$/;
|
|
33
|
-
// if (typeof value !== 'string' || !pattern.test(value)) {
|
|
34
|
-
// return 'Incorrect folder name';
|
|
35
|
-
// }
|
|
36
|
-
// return true;
|
|
37
|
-
// }),
|
|
38
|
-
// text('parent').hidden(),
|
|
39
|
-
// ...(directoriesConfig?.fields || []),
|
|
40
|
-
// date('createdAt').hidden(),
|
|
41
|
-
// date('updatedAt').hidden()
|
|
42
|
-
// ],
|
|
43
|
-
// type: 'collection',
|
|
44
|
-
// label: {
|
|
45
|
-
// singular: `${collection.slug} directory`,
|
|
46
|
-
// plural: `${collection.slug} directories`
|
|
47
|
-
// },
|
|
48
|
-
// icon: collection.icon,
|
|
49
|
-
// $hooks: {
|
|
50
|
-
// beforeOperation: directoriesConfig?.$hooks?.beforeOperation || [],
|
|
51
|
-
// beforeCreate: [exctractPath, ...(directoriesConfig?.$hooks?.beforeCreate || [])],
|
|
52
|
-
// beforeRead: directoriesConfig?.$hooks?.beforeRead || [],
|
|
53
|
-
// beforeUpdate: [
|
|
54
|
-
// exctractPath,
|
|
55
|
-
// prepareDirectoryChildren,
|
|
56
|
-
// ...(directoriesConfig?.$hooks?.beforeUpdate || [])
|
|
57
|
-
// ],
|
|
58
|
-
// beforeDelete: directoriesConfig?.$hooks?.beforeDelete || [],
|
|
59
|
-
// afterCreate: directoriesConfig?.$hooks?.afterCreate || [],
|
|
60
|
-
// afterUpdate: [updateDirectoryChildren, ...(directoriesConfig?.$hooks?.afterUpdate || [])],
|
|
61
|
-
// afterDelete: directoriesConfig?.$hooks?.afterDelete || []
|
|
62
|
-
// },
|
|
63
|
-
// asTitle: 'path',
|
|
64
|
-
// asThumbnail: collection.asThumbnail,
|
|
65
|
-
// panel: false
|
|
66
|
-
// // _generateTypes: false,
|
|
67
|
-
// // _generateSchema: false
|
|
68
|
-
// };
|
|
69
|
-
// directoriesCollection = augmentHooks(directoriesCollection);
|
|
70
|
-
// config.collections = [...(config.collections || []), directoriesCollection];
|
|
71
|
-
// }
|
|
72
|
-
// }
|
|
73
|
-
// return config;
|
|
74
|
-
// }
|
|
75
5
|
/**
|
|
76
6
|
* Creates an upload directories collection for collections with upload enabled
|
|
77
7
|
* Eg. for medias this will create a collection medias_directories
|
|
@@ -79,8 +9,6 @@ import { text } from '../../../fields/text/index.js';
|
|
|
79
9
|
export function makeUploadDirectoriesCollectionClient(collection) {
|
|
80
10
|
const slug = withDirectoriesSuffix(collection.slug);
|
|
81
11
|
const directoriesConfig = collection.upload.directories;
|
|
82
|
-
console.log(collection.upload);
|
|
83
|
-
console.log(directoriesConfig?.fields);
|
|
84
12
|
// else create the directory collection
|
|
85
13
|
let directoriesCollection = {
|
|
86
14
|
slug: slug,
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import { getLocaleContext } from '../../../panel/context/locale.svelte';
|
|
11
11
|
import { panelUrl } from '../../../panel/util/url.js';
|
|
12
12
|
import { moveItem } from '../../../util/array.js';
|
|
13
|
-
import { getValueAtPath } from '../../../util/object.js';
|
|
14
13
|
import { snapshot } from '../../../util/state.js';
|
|
15
14
|
import { API_PROXY, getAPIProxyContext } from '../../../panel/context/api-proxy.svelte.js';
|
|
16
15
|
import type { Relation, RelationField } from '../index.js';
|
|
@@ -58,7 +57,6 @@
|
|
|
58
57
|
function documentToRelationFieldItem(doc: GenericDoc) {
|
|
59
58
|
const itemInFieldValue = retreiveRelation(doc.id);
|
|
60
59
|
const item: RelationFieldItem = {
|
|
61
|
-
label: getValueAtPath(relationConfig.asTitle, doc) || '[untitled]',
|
|
62
60
|
documentId: doc.id,
|
|
63
61
|
title: doc.title,
|
|
64
62
|
editUrl: panelUrl(relationConfig.kebab, doc.id),
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
>
|
|
84
84
|
{#each selectedItems as item (item.documentId)}
|
|
85
85
|
<Tag onRemove={() => removeValue(item.documentId)} {readOnly}>
|
|
86
|
-
<a href={item.editUrl}>{item.
|
|
86
|
+
<a href={item.editUrl}>{item.title}</a>
|
|
87
87
|
</Tag>
|
|
88
88
|
{/each}
|
|
89
89
|
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
{#if inputFocused}
|
|
108
108
|
<Command.List>
|
|
109
109
|
{#each availableItems as item (item.documentId)}
|
|
110
|
-
<Command.Item value={item.
|
|
111
|
-
<span>{item.
|
|
110
|
+
<Command.Item value={item.title} onSelect={() => onSelect(item)}>
|
|
111
|
+
<span>{item.title}</span>
|
|
112
112
|
</Command.Item>
|
|
113
113
|
{/each}
|
|
114
114
|
<Command.Empty>Nothing to select</Command.Empty>
|
|
@@ -4,6 +4,7 @@ import { PARAMS } from '../../core/constant';
|
|
|
4
4
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
5
5
|
import { trycatchFetch } from '../../util/function';
|
|
6
6
|
import { hasProps, isObjectLiteral } from '../../util/object.js';
|
|
7
|
+
import { toKebabCase } from '../../util/string.js';
|
|
7
8
|
import Cell from './component/Cell.svelte';
|
|
8
9
|
import RelationComponent from './component/Relation.svelte';
|
|
9
10
|
export const ensureRelationExists = async (value, { config }) => {
|
|
@@ -13,7 +14,7 @@ export const ensureRelationExists = async (value, { config }) => {
|
|
|
13
14
|
const getRequsetEvent = await import('$app/server').then((m) => m.getRequestEvent);
|
|
14
15
|
const output = [];
|
|
15
16
|
const retrieveRelation = async (id) => {
|
|
16
|
-
const [err, response] = await trycatchFetch(`${env.PUBLIC_RIME_URL}/api/${config.relationTo}/${id}?${PARAMS.SELECT}=id`, {
|
|
17
|
+
const [err, response] = await trycatchFetch(`${env.PUBLIC_RIME_URL}/api/${toKebabCase(config.relationTo)}/${id}?${PARAMS.SELECT}=id`, {
|
|
17
18
|
method: 'GET',
|
|
18
19
|
headers: getRequsetEvent().request.headers
|
|
19
20
|
});
|
|
@@ -21,7 +21,7 @@ const getAbsolutePos = (state, relativePos) => {
|
|
|
21
21
|
if (!ystate) {
|
|
22
22
|
return -1;
|
|
23
23
|
}
|
|
24
|
-
return relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0;
|
|
24
|
+
return (relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0);
|
|
25
25
|
};
|
|
26
26
|
const getOuterDomNode = (view, domNode) => {
|
|
27
27
|
let tmpDomNode = domNode;
|
|
@@ -144,7 +144,6 @@ export const DragHandlePlugin = ({ pluginKey = dragHandlePluginDefaultKey, eleme
|
|
|
144
144
|
const newPos = tr.mapping.map(currentNodePos);
|
|
145
145
|
if (newPos !== currentNodePos) {
|
|
146
146
|
// TODO: Remove
|
|
147
|
-
// console.log('Position has changed …', { old: currentNodePos, new: newPos }, tr);
|
|
148
147
|
// Set the new position for our current node.
|
|
149
148
|
currentNodePos = newPos;
|
|
150
149
|
// Memorize relative position to retrieve absolute position in case of collaboration
|
|
@@ -42,7 +42,6 @@ class SvelteNodeView extends NodeView {
|
|
|
42
42
|
context.set(key, ctx);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
console.log(context);
|
|
46
45
|
const as = this.options.as ?? (this.node.isInline ? 'span' : 'div');
|
|
47
46
|
const target = document.createElement(as);
|
|
48
47
|
target.classList.add(`node-${this.node.type.name}`);
|
|
@@ -38,8 +38,13 @@
|
|
|
38
38
|
h3 {
|
|
39
39
|
font-variation-settings: 'wght' 600;
|
|
40
40
|
font-weight: 600;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
display: -webkit-box;
|
|
43
|
+
-webkit-box-orient: vertical;
|
|
44
|
+
-webkit-line-clamp: 1;
|
|
45
|
+
font-size: var(--rz-text-sm);
|
|
41
46
|
text-align: center;
|
|
42
|
-
|
|
47
|
+
margin-block: var(--rz-size-3);
|
|
43
48
|
}
|
|
44
49
|
.rz-folder-svg {
|
|
45
50
|
aspect-ratio: 5 / 4;
|
|
@@ -8,10 +8,7 @@
|
|
|
8
8
|
import * as Dialog from '../../../../ui/dialog/index.js';
|
|
9
9
|
import { API_PROXY, setAPIProxyContext } from '../../../../../context/api-proxy.svelte.js';
|
|
10
10
|
import { getConfigContext } from '../../../../../context/config.svelte.js';
|
|
11
|
-
import {
|
|
12
|
-
setDocumentFormContext,
|
|
13
|
-
type FormSuccessData
|
|
14
|
-
} from '../../../../../context/documentForm.svelte.js';
|
|
11
|
+
import { setDocumentFormContext } from '../../../../../context/documentForm.svelte.js';
|
|
15
12
|
import { getUserContext } from '../../../../../context/user.svelte.js';
|
|
16
13
|
|
|
17
14
|
type Props = {
|
|
@@ -24,13 +21,8 @@
|
|
|
24
21
|
const user = getUserContext();
|
|
25
22
|
const configCtx = getConfigContext();
|
|
26
23
|
const config = configCtx.getCollection(withDirectoriesSuffix(collection.slug));
|
|
27
|
-
setAPIProxyContext(API_PROXY.DOCUMENT);
|
|
28
24
|
let formElement = $state<HTMLFormElement>();
|
|
29
|
-
|
|
30
|
-
async function beforeRedirect(data?: FormSuccessData) {
|
|
31
|
-
open = false;
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
25
|
+
setAPIProxyContext(API_PROXY.DOCUMENT);
|
|
34
26
|
|
|
35
27
|
const form = setDocumentFormContext({
|
|
36
28
|
element: () => formElement,
|
|
@@ -38,7 +30,7 @@
|
|
|
38
30
|
config,
|
|
39
31
|
readOnly: !config.access.update(user.attributes, { id: folder.id }),
|
|
40
32
|
key: folder._type,
|
|
41
|
-
|
|
33
|
+
afterSuccess: () => (open = false)
|
|
42
34
|
});
|
|
43
35
|
|
|
44
36
|
function handleKeyDown(event: KeyboardEvent) {
|
|
@@ -64,11 +56,7 @@
|
|
|
64
56
|
<Dialog.Content>
|
|
65
57
|
{#snippet child({ props })}
|
|
66
58
|
<form use:form.enhance action={form.buildPanelActionUrl()} bind:this={formElement} {...props}>
|
|
67
|
-
<Dialog.Header>
|
|
68
|
-
{t__('common.rename_dialog_title', folder.name)}
|
|
69
|
-
</Dialog.Header>
|
|
70
59
|
<RenderFields {form} fields={config.fields} />
|
|
71
|
-
|
|
72
60
|
<Dialog.Footer --rz-justify-content="space-between">
|
|
73
61
|
<Button data-submit disabled={!form.canSubmit} type="submit">{t__('common.save')}</Button>
|
|
74
62
|
<Button onclick={() => (open = false)} variant="secondary">{t__('common.cancel')}</Button>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
{/if}
|
|
46
46
|
<label for="checkbox-{doc.id}" class="rz-list-row__title">{doc.title || '[untitled]'}</label>
|
|
47
47
|
{:else}
|
|
48
|
-
<a class="rz-list-row__link" href="/panel/{collection.config.
|
|
48
|
+
<a class="rz-list-row__link" href="/panel/{collection.config.kebab}/{doc.id}">
|
|
49
49
|
{#if doc._thumbnail}
|
|
50
50
|
<UploadThumbCell url={doc._thumbnail} mimeType={doc.mimeType} />
|
|
51
51
|
{:else}
|
|
@@ -152,6 +152,7 @@ type Args<T> = {
|
|
|
152
152
|
element: () => HTMLFormElement | undefined;
|
|
153
153
|
beforeSubmit?: (data: Dic) => Promise<Dic>;
|
|
154
154
|
beforeRedirect?: (data?: FormSuccessData) => Promise<boolean>;
|
|
155
|
+
afterSuccess?: (doc?: T) => void;
|
|
155
156
|
initial: T;
|
|
156
157
|
config: (AreaSlug extends never ? never : BuiltAreaClient) | BuiltCollectionClient;
|
|
157
158
|
readOnly: boolean;
|
|
@@ -24,7 +24,7 @@ import { getCollectionContext } from './collection.svelte.js';
|
|
|
24
24
|
import { setErrorsContext } from './errors.svelte.js';
|
|
25
25
|
import { getLocaleContext } from './locale.svelte.js';
|
|
26
26
|
import { getUserContext } from './user.svelte.js';
|
|
27
|
-
function createDocumentFormState({ initial, element, config, readOnly, key, onNestedDocumentCreated, onDataChange, beforeSubmit, beforeRedirect, onFieldFocus }) {
|
|
27
|
+
function createDocumentFormState({ initial, element, config, readOnly, key, onNestedDocumentCreated, afterSuccess, onDataChange, beforeSubmit, beforeRedirect, onFieldFocus }) {
|
|
28
28
|
//
|
|
29
29
|
let initialDoc = $state(initial);
|
|
30
30
|
let doc = $state(initial);
|
|
@@ -522,6 +522,8 @@ function createDocumentFormState({ initial, element, config, readOnly, key, onNe
|
|
|
522
522
|
if (onNestedDocumentCreated)
|
|
523
523
|
onNestedDocumentCreated(doc);
|
|
524
524
|
}
|
|
525
|
+
if (afterSuccess)
|
|
526
|
+
afterSuccess(doc);
|
|
525
527
|
}
|
|
526
528
|
async function handleError(data) {
|
|
527
529
|
// Handle error
|
|
@@ -578,8 +580,6 @@ function createDocumentFormState({ initial, element, config, readOnly, key, onNe
|
|
|
578
580
|
};
|
|
579
581
|
};
|
|
580
582
|
const buildPanelActionUrl = () => {
|
|
581
|
-
console.log('@buildPanelActionUrl----');
|
|
582
|
-
console.log(operation);
|
|
583
583
|
// Start with the base URI for the panel
|
|
584
584
|
let panelUri = `/panel/${config.kebab}`;
|
|
585
585
|
// Add the item ID to the URI if we're updating a collection doc
|