@firecms/collection_editor 3.0.0-alpha.17 → 3.0.0-alpha.18
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/package.json +4 -3
- package/src/ConfigControllerProvider.tsx +177 -0
- package/src/components/EditorCollectionAction.tsx +95 -0
- package/src/components/HomePageEditorCollectionAction.tsx +81 -0
- package/src/components/NewCollectionCard.tsx +45 -0
- package/src/components/RootCollectionSuggestions.tsx +53 -0
- package/src/components/collection_editor/CollectionDetailsForm.tsx +312 -0
- package/src/components/collection_editor/CollectionEditorDialog.tsx +640 -0
- package/src/components/collection_editor/CollectionEditorWelcomeView.tsx +212 -0
- package/src/components/collection_editor/CollectionPropertiesEditorForm.tsx +450 -0
- package/src/components/collection_editor/CollectionYupValidation.tsx +6 -0
- package/src/components/collection_editor/EntityCustomViewsSelectDialog.tsx +29 -0
- package/src/components/collection_editor/EnumForm.tsx +354 -0
- package/src/components/collection_editor/PropertyEditView.tsx +535 -0
- package/src/components/collection_editor/PropertyFieldPreview.tsx +205 -0
- package/src/components/collection_editor/PropertySelectItem.tsx +31 -0
- package/src/components/collection_editor/PropertyTree.tsx +228 -0
- package/src/components/collection_editor/SelectIcons.tsx +72 -0
- package/src/components/collection_editor/SubcollectionsEditTab.tsx +239 -0
- package/src/components/collection_editor/UnsavedChangesDialog.tsx +47 -0
- package/src/components/collection_editor/import/CollectionEditorImportDataPreview.tsx +37 -0
- package/src/components/collection_editor/import/CollectionEditorImportMapping.tsx +236 -0
- package/src/components/collection_editor/import/clean_import_data.ts +53 -0
- package/src/components/collection_editor/properties/BlockPropertyField.tsx +131 -0
- package/src/components/collection_editor/properties/BooleanPropertyField.tsx +36 -0
- package/src/components/collection_editor/properties/CommonPropertyFields.tsx +112 -0
- package/src/components/collection_editor/properties/DateTimePropertyField.tsx +86 -0
- package/src/components/collection_editor/properties/EnumPropertyField.tsx +116 -0
- package/src/components/collection_editor/properties/FieldHelperView.tsx +13 -0
- package/src/components/collection_editor/properties/KeyValuePropertyField.tsx +20 -0
- package/src/components/collection_editor/properties/MapPropertyField.tsx +154 -0
- package/src/components/collection_editor/properties/NumberPropertyField.tsx +38 -0
- package/src/components/collection_editor/properties/ReferencePropertyField.tsx +184 -0
- package/src/components/collection_editor/properties/RepeatPropertyField.tsx +115 -0
- package/src/components/collection_editor/properties/StoragePropertyField.tsx +194 -0
- package/src/components/collection_editor/properties/StringPropertyField.tsx +85 -0
- package/src/components/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx +36 -0
- package/src/components/collection_editor/properties/validation/ArrayPropertyValidation.tsx +50 -0
- package/src/components/collection_editor/properties/validation/GeneralPropertyValidation.tsx +49 -0
- package/src/components/collection_editor/properties/validation/NumberPropertyValidation.tsx +99 -0
- package/src/components/collection_editor/properties/validation/StringPropertyValidation.tsx +131 -0
- package/src/components/collection_editor/properties/validation/ValidationPanel.tsx +28 -0
- package/src/components/collection_editor/templates/blog_template.ts +115 -0
- package/src/components/collection_editor/templates/products_template.ts +89 -0
- package/src/components/collection_editor/templates/users_template.ts +34 -0
- package/src/components/collection_editor/util.ts +21 -0
- package/src/components/collection_editor/utils/supported_fields.tsx +28 -0
- package/src/components/collection_editor/utils/update_property_for_widget.ts +258 -0
- package/src/components/collection_editor/utils/useTraceUpdate.tsx +23 -0
- package/src/index.ts +31 -0
- package/src/types/collection_editor_controller.tsx +31 -0
- package/src/types/collection_inference.ts +3 -0
- package/src/types/config_controller.tsx +30 -0
- package/src/types/config_permissions.ts +20 -0
- package/src/types/persisted_collection.ts +7 -0
- package/src/useCollectionEditorController.tsx +9 -0
- package/src/useCollectionEditorPlugin.tsx +103 -0
- package/src/useCollectionsConfigController.tsx +9 -0
- package/src/utils/arrays.ts +3 -0
- package/src/utils/entities.ts +38 -0
- package/src/utils/icons.ts +17 -0
- package/src/utils/join_collections.ts +144 -0
- package/src/utils/synonyms.ts +1952 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { getIn, useFormikContext } from "formik";
|
|
4
|
+
import { DebouncedTextField } from "@firecms/core";
|
|
5
|
+
import { GeneralPropertyValidation } from "./GeneralPropertyValidation";
|
|
6
|
+
|
|
7
|
+
export function ArrayPropertyValidation({
|
|
8
|
+
max = true,
|
|
9
|
+
min = true,
|
|
10
|
+
disabled
|
|
11
|
+
}: {
|
|
12
|
+
min?: boolean;
|
|
13
|
+
max?: boolean;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
}) {
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
values,
|
|
19
|
+
handleChange
|
|
20
|
+
} = useFormikContext();
|
|
21
|
+
|
|
22
|
+
const validationMin = "validation.min";
|
|
23
|
+
const validationMax = "validation.max";
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={"grid grid-cols-12 gap-2"}>
|
|
27
|
+
|
|
28
|
+
<GeneralPropertyValidation disabled={disabled}/>
|
|
29
|
+
|
|
30
|
+
{min && <div className={"col-span-6"}>
|
|
31
|
+
<DebouncedTextField value={getIn(values, validationMin)}
|
|
32
|
+
disabled={disabled}
|
|
33
|
+
label={"Min length"}
|
|
34
|
+
name={validationMin}
|
|
35
|
+
type="number"
|
|
36
|
+
size="small"
|
|
37
|
+
onChange={handleChange}/>
|
|
38
|
+
</div>}
|
|
39
|
+
{max && <div className={"col-span-6"}>
|
|
40
|
+
<DebouncedTextField value={getIn(values, validationMax)}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
label={"Max length"}
|
|
43
|
+
name={validationMax}
|
|
44
|
+
type="number"
|
|
45
|
+
size="small"
|
|
46
|
+
onChange={handleChange}/>
|
|
47
|
+
</div>}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { FastField, getIn, useFormikContext } from "formik";
|
|
4
|
+
import { DebouncedTextField, SwitchControl } from "@firecms/core";
|
|
5
|
+
|
|
6
|
+
export function GeneralPropertyValidation({ disabled }: {
|
|
7
|
+
required?: boolean;
|
|
8
|
+
disabled:boolean;
|
|
9
|
+
}) {
|
|
10
|
+
|
|
11
|
+
const { values, handleChange } = useFormikContext();
|
|
12
|
+
|
|
13
|
+
const validationRequired = "validation.required";
|
|
14
|
+
const validationRequiredMessage = "validation.requiredMessage";
|
|
15
|
+
const validationUnique = "validation.unique";
|
|
16
|
+
const validationUniqueInArray = "validation.uniqueInArray";
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<div className={"col-span-6"}>
|
|
21
|
+
<FastField type="checkbox"
|
|
22
|
+
disabled={disabled}
|
|
23
|
+
name={validationRequired}
|
|
24
|
+
label={"Required"}
|
|
25
|
+
tooltip={"You won't be able to save this entity if this value is not set"}
|
|
26
|
+
component={SwitchControl}/>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div className={"col-span-6"}>
|
|
30
|
+
<FastField type="checkbox"
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
name={validationUnique}
|
|
33
|
+
label={"Unique"}
|
|
34
|
+
tooltip={"There cannot be multiple entities with the same value"}
|
|
35
|
+
component={SwitchControl}/>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
{getIn(values, validationRequired) && <div className={"col-span-12"}>
|
|
39
|
+
<DebouncedTextField
|
|
40
|
+
disabled={disabled}
|
|
41
|
+
value={getIn(values, validationRequiredMessage)}
|
|
42
|
+
label={"Required message"}
|
|
43
|
+
name={validationRequiredMessage}
|
|
44
|
+
size="small"
|
|
45
|
+
onChange={handleChange}/>
|
|
46
|
+
</div>}
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { FastField, getIn, useFormikContext } from "formik";
|
|
4
|
+
import { DebouncedTextField, SwitchControl } from "@firecms/core";
|
|
5
|
+
import { GeneralPropertyValidation } from "./GeneralPropertyValidation";
|
|
6
|
+
|
|
7
|
+
export function NumberPropertyValidation({ disabled }: {
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
}) {
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
values,
|
|
13
|
+
handleChange
|
|
14
|
+
} = useFormikContext();
|
|
15
|
+
|
|
16
|
+
const validationMin = "validation.min";
|
|
17
|
+
const validationMax = "validation.max";
|
|
18
|
+
const validationLessThan = "validation.lessThan";
|
|
19
|
+
const validationMoreThan = "validation.moreThan";
|
|
20
|
+
const validationPositive = "validation.positive";
|
|
21
|
+
const validationNegative = "validation.negative";
|
|
22
|
+
const validationInteger = "validation.integer";
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
|
|
26
|
+
<div className={"grid grid-cols-12 gap-2"}>
|
|
27
|
+
<GeneralPropertyValidation disabled={disabled}/>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<div className={"col-span-6"}>
|
|
31
|
+
<DebouncedTextField value={getIn(values, validationMin)}
|
|
32
|
+
label={"Min value"}
|
|
33
|
+
name={validationMin}
|
|
34
|
+
type="number"
|
|
35
|
+
size="small"
|
|
36
|
+
disabled={disabled}
|
|
37
|
+
onChange={handleChange}/>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div className={"col-span-6"}>
|
|
41
|
+
<DebouncedTextField value={getIn(values, validationMax)}
|
|
42
|
+
label={"Max value"}
|
|
43
|
+
name={validationMax}
|
|
44
|
+
type="number"
|
|
45
|
+
size="small"
|
|
46
|
+
|
|
47
|
+
disabled={disabled}
|
|
48
|
+
onChange={handleChange}/>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
<div className={"col-span-6"}>
|
|
53
|
+
<DebouncedTextField
|
|
54
|
+
value={getIn(values, validationLessThan)}
|
|
55
|
+
label={"Less than"}
|
|
56
|
+
name={validationLessThan}
|
|
57
|
+
type="number"
|
|
58
|
+
size="small"
|
|
59
|
+
|
|
60
|
+
disabled={disabled}
|
|
61
|
+
onChange={handleChange}/>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div className={"col-span-6"}>
|
|
65
|
+
<DebouncedTextField
|
|
66
|
+
value={getIn(values, validationMoreThan)}
|
|
67
|
+
label={"More than"}
|
|
68
|
+
name={validationMoreThan}
|
|
69
|
+
type="number"
|
|
70
|
+
size="small"
|
|
71
|
+
|
|
72
|
+
disabled={disabled}
|
|
73
|
+
onChange={handleChange}/>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<div className={"col-span-4"}>
|
|
77
|
+
<FastField type="checkbox"
|
|
78
|
+
name={validationPositive}
|
|
79
|
+
label={"Positive value"}
|
|
80
|
+
disabled={disabled}
|
|
81
|
+
component={SwitchControl}/>
|
|
82
|
+
</div>
|
|
83
|
+
<div className={"col-span-4"}>
|
|
84
|
+
<FastField type="checkbox"
|
|
85
|
+
name={validationNegative}
|
|
86
|
+
label={"Negative value"}
|
|
87
|
+
disabled={disabled}
|
|
88
|
+
component={SwitchControl}/>
|
|
89
|
+
</div>
|
|
90
|
+
<div className={"col-span-4"}>
|
|
91
|
+
<FastField type="checkbox"
|
|
92
|
+
name={validationInteger}
|
|
93
|
+
label={"Integer value"}
|
|
94
|
+
disabled={disabled}
|
|
95
|
+
component={SwitchControl}/>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { FastField, getIn, useFormikContext } from "formik";
|
|
4
|
+
import { DebouncedTextField, isValidRegExp, serializeRegExp, SwitchControl } from "@firecms/core";
|
|
5
|
+
import { GeneralPropertyValidation } from "./GeneralPropertyValidation";
|
|
6
|
+
import { FieldHelperView } from "../FieldHelperView";
|
|
7
|
+
|
|
8
|
+
export function StringPropertyValidation({
|
|
9
|
+
length,
|
|
10
|
+
lowercase,
|
|
11
|
+
matches,
|
|
12
|
+
max,
|
|
13
|
+
min,
|
|
14
|
+
trim,
|
|
15
|
+
uppercase,
|
|
16
|
+
disabled,
|
|
17
|
+
showErrors
|
|
18
|
+
}: {
|
|
19
|
+
length?: boolean;
|
|
20
|
+
min?: boolean;
|
|
21
|
+
max?: boolean;
|
|
22
|
+
trim?: boolean;
|
|
23
|
+
matches?: boolean;
|
|
24
|
+
lowercase?: boolean;
|
|
25
|
+
uppercase?: boolean;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
showErrors: boolean;
|
|
28
|
+
}) {
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
values,
|
|
32
|
+
handleChange,
|
|
33
|
+
errors
|
|
34
|
+
} = useFormikContext();
|
|
35
|
+
|
|
36
|
+
const validationLength = "validation.length";
|
|
37
|
+
const validationMin = "validation.min";
|
|
38
|
+
const validationMax = "validation.max";
|
|
39
|
+
const validationTrim = "validation.trim";
|
|
40
|
+
const validationMatches = "validation.matches";
|
|
41
|
+
const validationLowercase = "validation.lowercase";
|
|
42
|
+
const validationUppercase = "validation.uppercase";
|
|
43
|
+
|
|
44
|
+
const matchesError = getIn(errors, validationMatches);
|
|
45
|
+
|
|
46
|
+
const matchesValue = getIn(values, validationMatches);
|
|
47
|
+
const matchesStringValue = typeof matchesValue === "string" ? matchesValue : serializeRegExp(matchesValue);
|
|
48
|
+
return (
|
|
49
|
+
<div className={"grid grid-cols-12 gap-2"}>
|
|
50
|
+
|
|
51
|
+
<GeneralPropertyValidation disabled={disabled}/>
|
|
52
|
+
|
|
53
|
+
<div className={"grid grid-cols-12 gap-2 col-span-12"}>
|
|
54
|
+
{lowercase && <div className={"col-span-4"}>
|
|
55
|
+
<FastField type="checkbox"
|
|
56
|
+
name={validationLowercase}
|
|
57
|
+
label={"Lowercase"}
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
component={SwitchControl}/>
|
|
60
|
+
</div>}
|
|
61
|
+
{uppercase && <div className={"col-span-4"}>
|
|
62
|
+
<FastField type="checkbox"
|
|
63
|
+
name={validationUppercase}
|
|
64
|
+
label={"Uppercase"}
|
|
65
|
+
disabled={disabled}
|
|
66
|
+
component={SwitchControl}/>
|
|
67
|
+
</div>}
|
|
68
|
+
{trim && <div className={"col-span-4"}>
|
|
69
|
+
<FastField type="checkbox"
|
|
70
|
+
name={validationTrim}
|
|
71
|
+
label={"Trim"}
|
|
72
|
+
disabled={disabled}
|
|
73
|
+
component={SwitchControl}/>
|
|
74
|
+
</div>}
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div className={"grid grid-cols-12 gap-2 col-span-12"}>
|
|
78
|
+
{length && <div className={"col-span-4"}>
|
|
79
|
+
<DebouncedTextField
|
|
80
|
+
value={getIn(values, validationLength)}
|
|
81
|
+
label={"Exact length"}
|
|
82
|
+
name={validationLength}
|
|
83
|
+
type="number"
|
|
84
|
+
size="small"
|
|
85
|
+
|
|
86
|
+
disabled={disabled}
|
|
87
|
+
onChange={handleChange}/>
|
|
88
|
+
</div>}
|
|
89
|
+
|
|
90
|
+
{min && <div className={"col-span-4"}>
|
|
91
|
+
<DebouncedTextField value={getIn(values, validationMin)}
|
|
92
|
+
label={"Min length"}
|
|
93
|
+
name={validationMin}
|
|
94
|
+
type="number"
|
|
95
|
+
size="small"
|
|
96
|
+
|
|
97
|
+
disabled={disabled}
|
|
98
|
+
onChange={handleChange}/>
|
|
99
|
+
</div>}
|
|
100
|
+
|
|
101
|
+
{max && <div className={"col-span-4"}>
|
|
102
|
+
<DebouncedTextField value={getIn(values, validationMax)}
|
|
103
|
+
label={"Max length"}
|
|
104
|
+
name={validationMax}
|
|
105
|
+
type="number"
|
|
106
|
+
size="small"
|
|
107
|
+
|
|
108
|
+
disabled={disabled}
|
|
109
|
+
onChange={handleChange}/>
|
|
110
|
+
</div>}
|
|
111
|
+
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
{matches && <div className={"col-span-12"}>
|
|
115
|
+
<FastField name={validationMatches}
|
|
116
|
+
as={DebouncedTextField}
|
|
117
|
+
validate={(value: string) => value && !isValidRegExp(value)}
|
|
118
|
+
label={"Matches regex"}
|
|
119
|
+
size="small"
|
|
120
|
+
disabled={disabled}
|
|
121
|
+
value={matchesStringValue}
|
|
122
|
+
error={Boolean(matchesError)}/>
|
|
123
|
+
<FieldHelperView error={Boolean(matchesError)}>
|
|
124
|
+
{matchesError ? "Not a valid regexp" : "e.g. /^\\d+$/ for digits only"}
|
|
125
|
+
</FieldHelperView>
|
|
126
|
+
</div>}
|
|
127
|
+
|
|
128
|
+
</div>
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
|
|
3
|
+
import { ExpandablePanel, RuleIcon, Typography } from "@firecms/core";
|
|
4
|
+
|
|
5
|
+
export function ValidationPanel({
|
|
6
|
+
children
|
|
7
|
+
}: PropsWithChildren<{}>) {
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<ExpandablePanel
|
|
11
|
+
initiallyExpanded={false}
|
|
12
|
+
asField={true}
|
|
13
|
+
className="p-4"
|
|
14
|
+
title={
|
|
15
|
+
<div className="flex flex-row text-gray-500">
|
|
16
|
+
<RuleIcon/>
|
|
17
|
+
<Typography variant={"subtitle2"}
|
|
18
|
+
className="ml-2">
|
|
19
|
+
Validation
|
|
20
|
+
</Typography>
|
|
21
|
+
</div>
|
|
22
|
+
}>
|
|
23
|
+
|
|
24
|
+
{children}
|
|
25
|
+
|
|
26
|
+
</ExpandablePanel>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { buildCollection, buildProperty } from "@firecms/core";
|
|
2
|
+
|
|
3
|
+
export const blogCollectionTemplate = buildCollection({
|
|
4
|
+
path: "blog",
|
|
5
|
+
name: "Blog",
|
|
6
|
+
singularName: "Blog entry",
|
|
7
|
+
group: "Content",
|
|
8
|
+
icon: "article",
|
|
9
|
+
description: "A collection of blog entries",
|
|
10
|
+
defaultSize: "l",
|
|
11
|
+
properties: {
|
|
12
|
+
name: buildProperty({
|
|
13
|
+
name: "Name",
|
|
14
|
+
validation: { required: true },
|
|
15
|
+
dataType: "string"
|
|
16
|
+
}),
|
|
17
|
+
header_image: buildProperty({
|
|
18
|
+
name: "Header image",
|
|
19
|
+
dataType: "string",
|
|
20
|
+
storage: {
|
|
21
|
+
storagePath: "images",
|
|
22
|
+
acceptedFiles: ["image/*"],
|
|
23
|
+
metadata: {
|
|
24
|
+
cacheControl: "max-age=1000000"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
content: buildProperty({
|
|
29
|
+
name: "Content",
|
|
30
|
+
description: "Content blocks for the blog entry",
|
|
31
|
+
validation: { required: true },
|
|
32
|
+
dataType: "array",
|
|
33
|
+
oneOf: {
|
|
34
|
+
typeField: "type",
|
|
35
|
+
valueField: "value",
|
|
36
|
+
properties: {
|
|
37
|
+
text: {
|
|
38
|
+
dataType: "string",
|
|
39
|
+
name: "Text",
|
|
40
|
+
markdown: true
|
|
41
|
+
},
|
|
42
|
+
quote: {
|
|
43
|
+
dataType: "string",
|
|
44
|
+
name: "Quote",
|
|
45
|
+
multiline: true
|
|
46
|
+
},
|
|
47
|
+
images: {
|
|
48
|
+
name: "Images",
|
|
49
|
+
dataType: "array",
|
|
50
|
+
of: {
|
|
51
|
+
dataType: "string",
|
|
52
|
+
storage: {
|
|
53
|
+
storagePath: "images",
|
|
54
|
+
acceptedFiles: ["image/*"],
|
|
55
|
+
metadata: {
|
|
56
|
+
cacheControl: "max-age=1000000"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
description: "This fields allows uploading multiple images at once and reordering"
|
|
61
|
+
},
|
|
62
|
+
products: {
|
|
63
|
+
name: "Products",
|
|
64
|
+
dataType: "array",
|
|
65
|
+
of: {
|
|
66
|
+
dataType: "reference",
|
|
67
|
+
path: "products",
|
|
68
|
+
previewProperties: ["name", "main_image"]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
propertiesOrder: ["text", "quote", "images", "products"]
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
created_on: {
|
|
76
|
+
name: "Created on",
|
|
77
|
+
dataType: "date",
|
|
78
|
+
autoValue: "on_create"
|
|
79
|
+
},
|
|
80
|
+
status: {
|
|
81
|
+
name: "Status",
|
|
82
|
+
validation: { required: true },
|
|
83
|
+
dataType: "string",
|
|
84
|
+
enumValues: {
|
|
85
|
+
published: {
|
|
86
|
+
id: "published",
|
|
87
|
+
label: "Published",
|
|
88
|
+
},
|
|
89
|
+
draft: "Draft"
|
|
90
|
+
},
|
|
91
|
+
defaultValue: "draft"
|
|
92
|
+
},
|
|
93
|
+
publish_date: {
|
|
94
|
+
name: "Publish date",
|
|
95
|
+
dataType: "date",
|
|
96
|
+
clearable: true
|
|
97
|
+
},
|
|
98
|
+
reviewed: {
|
|
99
|
+
name: "Reviewed",
|
|
100
|
+
dataType: "boolean"
|
|
101
|
+
},
|
|
102
|
+
tags: {
|
|
103
|
+
name: "Tags",
|
|
104
|
+
description: "Example of generic array",
|
|
105
|
+
dataType: "array",
|
|
106
|
+
of: {
|
|
107
|
+
dataType: "string",
|
|
108
|
+
previewAsTag: true
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
initialFilter: {
|
|
113
|
+
status: ["==", "published"]
|
|
114
|
+
}
|
|
115
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { buildCollection } from "@firecms/core";
|
|
2
|
+
|
|
3
|
+
export const productsCollectionTemplate = buildCollection({
|
|
4
|
+
path: "products",
|
|
5
|
+
name: "Products",
|
|
6
|
+
singularName: "Product",
|
|
7
|
+
group: "Main",
|
|
8
|
+
icon: "shopping_cart",
|
|
9
|
+
description: "List of the products currently sold in your shop",
|
|
10
|
+
properties: {
|
|
11
|
+
name: {
|
|
12
|
+
dataType: "string",
|
|
13
|
+
name: "Name",
|
|
14
|
+
description: "Name of this product",
|
|
15
|
+
validation: {
|
|
16
|
+
required: true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
brand: {
|
|
20
|
+
dataType: "string",
|
|
21
|
+
name: "Brand",
|
|
22
|
+
validation: {
|
|
23
|
+
required: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
description: {
|
|
27
|
+
dataType: "string",
|
|
28
|
+
name: "Description",
|
|
29
|
+
description: "Description of this product, supports markdown",
|
|
30
|
+
markdown: true
|
|
31
|
+
},
|
|
32
|
+
main_image: {
|
|
33
|
+
dataType: "string",
|
|
34
|
+
name: "Image",
|
|
35
|
+
storage: {
|
|
36
|
+
storagePath: "images",
|
|
37
|
+
acceptedFiles: ["image/*"],
|
|
38
|
+
},
|
|
39
|
+
description: "Upload field for images"
|
|
40
|
+
},
|
|
41
|
+
available: {
|
|
42
|
+
dataType: "boolean",
|
|
43
|
+
name: "Available",
|
|
44
|
+
columnWidth: 100,
|
|
45
|
+
description: "Is this product available in the website"
|
|
46
|
+
},
|
|
47
|
+
price: {
|
|
48
|
+
dataType: "number",
|
|
49
|
+
name: "Price",
|
|
50
|
+
validation: {
|
|
51
|
+
requiredMessage: "You must set a positive price",
|
|
52
|
+
min: 0
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
images: {
|
|
56
|
+
dataType: "array",
|
|
57
|
+
name: "Images",
|
|
58
|
+
hideFromCollection: true,
|
|
59
|
+
of: {
|
|
60
|
+
dataType: "string",
|
|
61
|
+
storage: {
|
|
62
|
+
storagePath: "images",
|
|
63
|
+
acceptedFiles: ["image/*"]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
related_products: {
|
|
68
|
+
dataType: "array",
|
|
69
|
+
name: "Related products",
|
|
70
|
+
description: "Products related to this one",
|
|
71
|
+
of: {
|
|
72
|
+
dataType: "reference",
|
|
73
|
+
path: "products"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
metadata: {
|
|
77
|
+
name: "Metadata",
|
|
78
|
+
description: "This is an example of a map property",
|
|
79
|
+
dataType: "map",
|
|
80
|
+
keyValue: true
|
|
81
|
+
},
|
|
82
|
+
added_on: {
|
|
83
|
+
dataType: "date",
|
|
84
|
+
name: "Added on",
|
|
85
|
+
autoValue: "on_create"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { buildCollection } from "@firecms/core";
|
|
2
|
+
|
|
3
|
+
export const usersCollectionTemplate = buildCollection({
|
|
4
|
+
path: "users",
|
|
5
|
+
name: "Users",
|
|
6
|
+
singularName: "User",
|
|
7
|
+
group: "Main",
|
|
8
|
+
description: "Registered users in the app/web",
|
|
9
|
+
icon: "person",
|
|
10
|
+
properties: {
|
|
11
|
+
displayName: {
|
|
12
|
+
name: "Display name",
|
|
13
|
+
dataType: "string"
|
|
14
|
+
},
|
|
15
|
+
email: {
|
|
16
|
+
name: "Email",
|
|
17
|
+
dataType: "string",
|
|
18
|
+
email: true
|
|
19
|
+
},
|
|
20
|
+
emailVerified: {
|
|
21
|
+
name: "Email verified",
|
|
22
|
+
dataType: "boolean"
|
|
23
|
+
},
|
|
24
|
+
phone: {
|
|
25
|
+
name: "Phone",
|
|
26
|
+
dataType: "string"
|
|
27
|
+
},
|
|
28
|
+
photoURL: {
|
|
29
|
+
name: "Photo URL",
|
|
30
|
+
dataType: "string",
|
|
31
|
+
url: "image"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function idToPropertiesPath(id: string): string {
|
|
2
|
+
return "properties." + id.replaceAll(".", ".properties.");
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function namespaceToPropertiesPath(namespace?: string): string {
|
|
6
|
+
return namespace
|
|
7
|
+
? "properties." + namespace.replaceAll(".", ".properties.") + ".properties"
|
|
8
|
+
: "properties";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function namespaceToPropertiesOrderPath(namespace?: string): string {
|
|
12
|
+
return namespace
|
|
13
|
+
? "properties." + namespace.replaceAll(".", ".properties.") + ".propertiesOrder"
|
|
14
|
+
: "propertiesOrder";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getFullId(propertyKey: string, propertyNamespace?: string): string {
|
|
18
|
+
return propertyNamespace
|
|
19
|
+
? `${propertyNamespace}.${propertyKey}`
|
|
20
|
+
: propertyKey;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DEFAULT_FIELD_CONFIGS, FieldConfigId } from "@firecms/core";
|
|
2
|
+
|
|
3
|
+
export const supportedFieldsIds: FieldConfigId[] = [
|
|
4
|
+
"text_field",
|
|
5
|
+
"multiline",
|
|
6
|
+
"markdown",
|
|
7
|
+
"url",
|
|
8
|
+
"email",
|
|
9
|
+
"select",
|
|
10
|
+
"multi_select",
|
|
11
|
+
"number_input",
|
|
12
|
+
"number_select",
|
|
13
|
+
"multi_number_select",
|
|
14
|
+
"file_upload",
|
|
15
|
+
"multi_file_upload",
|
|
16
|
+
"group",
|
|
17
|
+
"key_value",
|
|
18
|
+
"reference",
|
|
19
|
+
"multi_references",
|
|
20
|
+
"switch",
|
|
21
|
+
"date_time",
|
|
22
|
+
"repeat",
|
|
23
|
+
"block"
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export const supportedFields = Object.entries(DEFAULT_FIELD_CONFIGS).filter(([id]) =>
|
|
27
|
+
supportedFieldsIds.includes(id as FieldConfigId)
|
|
28
|
+
);
|