@firecms/collection_editor 3.0.0-alpha.72 → 3.0.0-alpha.74

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.
@@ -0,0 +1,2 @@
1
+ import { EntityCollection } from "@firecms/core";
2
+ export declare const pagesCollectionTemplate: EntityCollection;
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@firecms/collection_editor",
3
3
  "type": "module",
4
- "version": "3.0.0-alpha.72",
4
+ "version": "3.0.0-alpha.74",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "source": "src/index.ts",
9
9
  "dependencies": {
10
- "@firecms/data_import_export": "^3.0.0-alpha.72",
11
- "@firecms/schema_inference": "^3.0.0-alpha.72",
12
- "@firecms/ui": "^3.0.0-alpha.72",
10
+ "@firecms/data_import_export": "^3.0.0-alpha.74",
11
+ "@firecms/schema_inference": "^3.0.0-alpha.74",
12
+ "@firecms/ui": "^3.0.0-alpha.74",
13
13
  "json5": "^2.2.3",
14
14
  "prism-react-renderer": "^2.3.0"
15
15
  },
@@ -72,5 +72,5 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "7f6599121c226abbb4fb4dccbe109b2c8ba6e23e"
75
+ "gitHead": "52ebcaf1e5c019f0f5e03cc63a3ea7663c356d23"
76
76
  }
@@ -7,7 +7,7 @@ import {
7
7
  useNavigationController,
8
8
  useSnackbarController
9
9
  } from "@firecms/core";
10
- import { Button, IconButton, SaveIcon, SettingsIcon, Tooltip, } from "@firecms/ui";
10
+ import { Button, IconButton, SaveIcon, SettingsIcon, Tooltip, UndoIcon, } from "@firecms/ui";
11
11
 
12
12
  import { useCollectionEditorController } from "../useCollectionEditorController";
13
13
  import { useCollectionsConfigController } from "../useCollectionsConfigController";
@@ -52,7 +52,7 @@ export function EditorCollectionAction({
52
52
  if (collection?.initialSort)
53
53
  tableController.setSortBy?.(collection?.initialSort);
54
54
  }}>
55
- <SaveIcon/>
55
+ <UndoIcon/>
56
56
  </Button>
57
57
  </Tooltip>}
58
58
 
@@ -25,7 +25,7 @@ export function PropertyAddColumnComponent({
25
25
  return (
26
26
  <Tooltip title={canEditCollection ? "Add new property" : "You don't have permission to add new properties"}>
27
27
  <div
28
- className={"p-0.5 w-20 h-full flex items-center justify-center cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-950"}
28
+ className={"p-0.5 w-20 h-full flex items-center justify-center cursor-pointer bg-gray-100 bg-opacity-40 hover:bg-gray-100 dark:bg-gray-950 dark:bg-opacity-40 dark:hover:bg-gray-950"}
29
29
  // className={onHover ? "bg-white dark:bg-gray-950" : undefined}
30
30
  onClick={() => {
31
31
  collectionEditorController.editProperty({
@@ -19,6 +19,7 @@ import { productsCollectionTemplate } from "./templates/products_template";
19
19
  import { blogCollectionTemplate } from "./templates/blog_template";
20
20
  import { usersCollectionTemplate } from "./templates/users_template";
21
21
  import { ImportFileUpload } from "@firecms/data_import_export";
22
+ import { pagesCollectionTemplate } from "./templates/pages_template";
22
23
 
23
24
  export function CollectionEditorWelcomeView({
24
25
  path,
@@ -125,6 +126,13 @@ export function CollectionEditorWelcomeView({
125
126
  setValues(productsCollectionTemplate);
126
127
  onContinue();
127
128
  }}/>
129
+ <TemplateButton title={"Users"}
130
+ subtitle={"A collection of users with emails, names and roles"}
131
+ icon={<Icon size={"small"} iconKey={usersCollectionTemplate.icon!}/>}
132
+ onClick={() => {
133
+ setValues(usersCollectionTemplate);
134
+ onContinue();
135
+ }}/>
128
136
  <TemplateButton title={"Blog posts"}
129
137
  subtitle={"A collection of blog posts with images, authors and complex content"}
130
138
  icon={<Icon size={"small"} iconKey={blogCollectionTemplate.icon!}/>}
@@ -132,11 +140,11 @@ export function CollectionEditorWelcomeView({
132
140
  setValues(blogCollectionTemplate);
133
141
  onContinue();
134
142
  }}/>
135
- <TemplateButton title={"Users"}
136
- subtitle={"A collection of users with emails, names and roles"}
137
- icon={<Icon size={"small"} iconKey={usersCollectionTemplate.icon!}/>}
143
+ <TemplateButton title={"Pages"}
144
+ subtitle={"A collection of pages with images, authors and complex content"}
145
+ icon={<Icon size={"small"} iconKey={pagesCollectionTemplate.icon!}/>}
138
146
  onClick={() => {
139
- setValues(usersCollectionTemplate);
147
+ setValues(pagesCollectionTemplate);
140
148
  onContinue();
141
149
  }}/>
142
150
  </div>
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useMemo, useState } from "react";
1
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
2
2
 
3
3
  import { Field, FormikErrors, getIn, useFormikContext } from "formik";
4
4
  import {
@@ -248,6 +248,14 @@ export function CollectionPropertiesEditorForm({
248
248
  setFieldTouched(previousPropertyPath, false, false);
249
249
  }
250
250
 
251
+ console.debug("onPropertyChanged", {
252
+ id,
253
+ property,
254
+ previousId,
255
+ namespace,
256
+ propertyPath
257
+ })
258
+
251
259
  if (propertyPath) {
252
260
  setFieldValue(propertyPath, property, false);
253
261
  setFieldTouched(propertyPath, true, false);
@@ -255,7 +263,7 @@ export function CollectionPropertiesEditorForm({
255
263
 
256
264
  };
257
265
 
258
- const onPropertyErrorInternal = (id: string, namespace?: string, error?: FormikErrors<any>) => {
266
+ const onPropertyErrorInternal = useCallback((id: string, namespace?: string, error?: FormikErrors<any>) => {
259
267
  const propertyPath = id ? getFullId(id, namespace) : undefined;
260
268
  console.warn("onPropertyErrorInternal", {
261
269
  id,
@@ -268,7 +276,7 @@ export function CollectionPropertiesEditorForm({
268
276
  onPropertyError(id, namespace, hasError ? error : undefined);
269
277
  setFieldError(idToPropertiesPath(propertyPath), hasError ? "Property error" : undefined);
270
278
  }
271
- };
279
+ }, [])
272
280
 
273
281
  const closePropertyDialog = () => {
274
282
  setSelectedPropertyIndex(undefined);
@@ -137,7 +137,7 @@ export const PropertyForm = React.memo(
137
137
  ? { id: propertyKey, ...property } as PropertyWithId
138
138
  : initialValue}
139
139
  onSubmit={(newPropertyWithId: PropertyWithId, helpers) => {
140
- console.log("onSubmit", newPropertyWithId);
140
+ console.debug("onSubmit", newPropertyWithId);
141
141
  const {
142
142
  id,
143
143
  ...property
@@ -0,0 +1,188 @@
1
+ import { EntityCollection } from "@firecms/core";
2
+
3
+ export const pagesCollectionTemplate: EntityCollection = {
4
+ id: "pages",
5
+ path: "pages",
6
+ name: "Pages",
7
+ singularName: "Page",
8
+ icon: "insert_drive_file",
9
+ description: "List of website pages that can be edited here",
10
+ properties: {
11
+ title: {
12
+ dataType: "string",
13
+ name: "Page Title",
14
+ validation: { required: true }
15
+ },
16
+ slug: {
17
+ dataType: "string",
18
+ name: "URL Slug",
19
+ validation: {
20
+ required: true,
21
+ unique: true,
22
+ matches: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,
23
+ matchesMessage: "Must be lowercase, alphanumeric, and hyphenated"
24
+ }
25
+ },
26
+ hero_section: {
27
+ dataType: "map",
28
+ name: "Hero Section",
29
+ properties: {
30
+ headline: {
31
+ dataType: "string",
32
+ name: "Headline",
33
+ validation: { required: true }
34
+ },
35
+ subhead: {
36
+ dataType: "string",
37
+ name: "Subheadline"
38
+ },
39
+ background_image: {
40
+ dataType: "string",
41
+ name: "Background Image",
42
+ storage: {
43
+ storagePath: "page_hero/images",
44
+ acceptedFiles: ["image/*"],
45
+ }
46
+ },
47
+ call_to_action: {
48
+ dataType: "string",
49
+ name: "Call to Action"
50
+ },
51
+ call_to_action_link: {
52
+ dataType: "string",
53
+ name: "CTA Link",
54
+ url: true
55
+ }
56
+ }
57
+ },
58
+ content: {
59
+ dataType: "array",
60
+ name: "Content",
61
+ oneOf: {
62
+ properties: {
63
+ section: {
64
+ dataType: "map",
65
+ name: "Section",
66
+ properties: {
67
+ title: {
68
+ dataType: "string",
69
+ name: "Section Title",
70
+ validation: { required: true }
71
+ },
72
+ content: {
73
+ dataType: "string",
74
+ name: "Section Content",
75
+ markdown: true
76
+ },
77
+ image: {
78
+ dataType: "string",
79
+ name: "Section Image",
80
+ storage: {
81
+ storagePath: "page_sections/images",
82
+ acceptedFiles: ["image/*"]
83
+ }
84
+ },
85
+ link: {
86
+ dataType: "string",
87
+ name: "Section Link",
88
+ url: true
89
+ }
90
+ }
91
+ },
92
+ image: {
93
+ dataType: "string",
94
+ name: "Image",
95
+ storage: {
96
+ storagePath: "page_sections/images",
97
+ acceptedFiles: ["image/*"]
98
+ }
99
+ },
100
+ slider: {
101
+ dataType: "array",
102
+ name: "Slider",
103
+ of: {
104
+ dataType: "map",
105
+ properties: {
106
+ title: {
107
+ dataType: "string",
108
+ name: "Title",
109
+ validation: { required: true }
110
+ },
111
+ image: {
112
+ dataType: "string",
113
+ storage: {
114
+ storagePath: "page_sections/images",
115
+ acceptedFiles: ["image/*"]
116
+ }
117
+ }
118
+ }
119
+ }
120
+ },
121
+ }
122
+ }
123
+ },
124
+ sidebar: {
125
+ dataType: "map",
126
+ name: "Sidebar",
127
+ properties: {
128
+ title: {
129
+ dataType: "string",
130
+ name: "Sidebar Title",
131
+ validation: { required: false }
132
+ },
133
+ content: {
134
+ dataType: "string",
135
+ name: "Sidebar Content",
136
+ markdown: true
137
+ }
138
+ }
139
+ },
140
+ seo_metadata: {
141
+ dataType: "map",
142
+ name: "SEO Metadata",
143
+ properties: {
144
+ meta_title: {
145
+ dataType: "string",
146
+ name: "Meta Title"
147
+ },
148
+ meta_description: {
149
+ dataType: "string",
150
+ name: "Meta Description"
151
+ },
152
+ focus_keywords: {
153
+ dataType: "array",
154
+ name: "Focus Keywords",
155
+ of: {
156
+ dataType: "string"
157
+ }
158
+ }
159
+ }
160
+ },
161
+ footer_override: {
162
+ dataType: "string",
163
+ name: "Footer Override",
164
+ markdown: true
165
+ },
166
+ publish_date: {
167
+ dataType: "date",
168
+ name: "Publish Date",
169
+ validation: { required: true }
170
+ },
171
+ last_updated: {
172
+ dataType: "date",
173
+ name: "Last Updated",
174
+ autoValue: "on_update"
175
+ },
176
+ is_published: {
177
+ dataType: "boolean",
178
+ name: "Is Published",
179
+ columnWidth: 100,
180
+ description: "Should this page be live on the site?"
181
+ },
182
+ author_uid: {
183
+ dataType: "reference",
184
+ name: "Author",
185
+ path: "users"
186
+ }
187
+ }
188
+ };
@@ -25,6 +25,14 @@ export const usersCollectionTemplate: EntityCollection = {
25
25
  name: "Phone",
26
26
  dataType: "string"
27
27
  },
28
+ favourite_products: {
29
+ name: "Favourite products",
30
+ dataType: "array",
31
+ of: {
32
+ dataType: "reference",
33
+ path: "products"
34
+ }
35
+ },
28
36
  photoURL: {
29
37
  name: "Photo URL",
30
38
  dataType: "string",