@griddo/ax 11.9.5 → 11.9.7-rc.0
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 +2 -2
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +16 -8
- package/src/components/ConfigPanel/Form/index.tsx +9 -1
- package/src/components/Fields/DateField/index.tsx +8 -0
- package/src/containers/ActivityLog/actions.tsx +4 -2
- package/src/containers/PageEditor/actions.tsx +15 -4
- package/src/containers/StructuredData/actions.tsx +41 -32
- package/src/containers/StructuredData/reducer.tsx +2 -2
- package/src/forms/elements.tsx +21 -9
- package/src/modules/ActivityLog/index.tsx +5 -1
- package/src/modules/FileDrive/FileModal/DetailPanel/UsageContent/index.tsx +7 -2
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/index.tsx +12 -6
- package/src/modules/StructuredData/Form/index.tsx +1 -8
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +3 -1
- package/src/types/index.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "11.9.
|
|
4
|
+
"version": "11.9.7-rc.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -225,5 +225,5 @@
|
|
|
225
225
|
"publishConfig": {
|
|
226
226
|
"access": "public"
|
|
227
227
|
},
|
|
228
|
-
"gitHead": "
|
|
228
|
+
"gitHead": "7ad8a35489434b7eded0493be9d5e2680369a694"
|
|
229
229
|
}
|
|
@@ -50,6 +50,8 @@ const PageConnectedField = (props: any): JSX.Element => {
|
|
|
50
50
|
isReadOnly,
|
|
51
51
|
themeElements,
|
|
52
52
|
scrollEditorID,
|
|
53
|
+
oldConfig,
|
|
54
|
+
setOldConfig,
|
|
53
55
|
} = props;
|
|
54
56
|
|
|
55
57
|
const isTemplate = field.type === "template";
|
|
@@ -115,18 +117,25 @@ const PageConnectedField = (props: any): JSX.Element => {
|
|
|
115
117
|
getPageBreadcrumb(value);
|
|
116
118
|
}
|
|
117
119
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
updateEditorContent(selectedEditorID, "slug", value ? "/" : slugify(selectedContent.title));
|
|
121
|
-
}
|
|
120
|
+
const editorID = templateID ? templateID : selectedEditorID;
|
|
121
|
+
updateEditorContent(editorID, key, value);
|
|
122
122
|
|
|
123
123
|
if (slugTo) {
|
|
124
124
|
const slugValue = typeof value === "object" && value.content ? value.content : value;
|
|
125
125
|
updateEditorContent(selectedEditorID, slugTo, slugify(slugValue));
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
if (key === "isHome") {
|
|
129
|
+
if (value) {
|
|
130
|
+
setOldConfig({ slug: selectedContent.slug, parent: selectedContent.parent });
|
|
131
|
+
updateEditorContent(selectedEditorID, ["parent", "slug"], [null, "/"]);
|
|
132
|
+
} else {
|
|
133
|
+
const slugValue = oldConfig ? oldConfig.slug : slugify(selectedContent.title);
|
|
134
|
+
const parentValue = oldConfig ? oldConfig.parent : null;
|
|
135
|
+
updateEditorContent(selectedEditorID, ["parent", "slug"], [parentValue, slugValue]);
|
|
136
|
+
setOldConfig(null);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
130
139
|
|
|
131
140
|
const isPageTitle = ["Page", "GlobalPage"].includes(selectedContent.component) && key === "title";
|
|
132
141
|
if (isPageTitle) {
|
|
@@ -143,8 +152,7 @@ const PageConnectedField = (props: any): JSX.Element => {
|
|
|
143
152
|
|
|
144
153
|
const isComponentImage = ["LinkableImage", "Image"].includes(selectedContent.component) && key === "file";
|
|
145
154
|
if (isComponentImage) {
|
|
146
|
-
updateEditorContent(selectedEditorID, "title", value.title);
|
|
147
|
-
updateEditorContent(selectedEditorID, "alt", value.alt);
|
|
155
|
+
updateEditorContent(selectedEditorID, ["title", "alt"], [value.title, value.alt]);
|
|
148
156
|
}
|
|
149
157
|
};
|
|
150
158
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { ISchema, ISchemaTab, ISchemaField } from "@ax/types";
|
|
4
4
|
import { Tabs } from "@ax/components";
|
|
@@ -30,6 +30,7 @@ export const Form = (props: IFormProps): JSX.Element => {
|
|
|
30
30
|
const isAllowedToEditConfigPages = usePermission("content.editConfigPages");
|
|
31
31
|
const isAllowedToEditSiteSeo = usePermission("seoAnalytics.editSeoAnalyticsPages");
|
|
32
32
|
const isAllowedToEditGlobalSeo = usePermission("global.seoAnalytics.editSeoAnalyticsInGlobalPages");
|
|
33
|
+
const [oldConfig, setOldConfig] = useState<IOldConfig | null>(null);
|
|
33
34
|
|
|
34
35
|
const isAllowedToEditPageContent = (!isGlobal && isAllowedToEditSitePages) || (isGlobal && isAllowedToEditGlobalData);
|
|
35
36
|
const isAllowedToEditPageConfig =
|
|
@@ -60,6 +61,8 @@ export const Form = (props: IFormProps): JSX.Element => {
|
|
|
60
61
|
theme={theme}
|
|
61
62
|
setHistoryPush={setHistoryPush}
|
|
62
63
|
isReadOnly={isEditLive || isDisabled}
|
|
64
|
+
oldConfig={oldConfig}
|
|
65
|
+
setOldConfig={setOldConfig}
|
|
63
66
|
/>
|
|
64
67
|
);
|
|
65
68
|
};
|
|
@@ -136,6 +139,11 @@ export const Form = (props: IFormProps): JSX.Element => {
|
|
|
136
139
|
);
|
|
137
140
|
};
|
|
138
141
|
|
|
142
|
+
interface IOldConfig {
|
|
143
|
+
slug: string;
|
|
144
|
+
parent: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
139
147
|
export interface IFormProps {
|
|
140
148
|
selectedTab: string;
|
|
141
149
|
schema: ISchema;
|
|
@@ -61,6 +61,14 @@ const DateField = (props: IDateFieldProps): JSX.Element => {
|
|
|
61
61
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
62
|
}, [editorID]);
|
|
63
63
|
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if ((!value || value.length === 0) && mandatory) {
|
|
66
|
+
const { start, end } = initialDate;
|
|
67
|
+
handleOnChange([start, end]);
|
|
68
|
+
}
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
}, []);
|
|
71
|
+
|
|
64
72
|
registerLocale("en", en);
|
|
65
73
|
|
|
66
74
|
const handleOnChange = (dates: any) => {
|
|
@@ -244,13 +244,15 @@ function goToLogContent(
|
|
|
244
244
|
await sitesActions.getSite(site)(dispatch, getState);
|
|
245
245
|
structuredDataActions.setSelectedStructuredData(contentType.content.id, "site")(dispatch, getState);
|
|
246
246
|
dispatch(structuredDataActions.setCurrentDataID(contentType.id));
|
|
247
|
+
await structuredDataActions.getDataContent(contentType.id)(dispatch);
|
|
247
248
|
dispatch(appActions.setLanguage(language));
|
|
248
|
-
appActions.setHistoryPush(`/sites/data/${contentType.content.id}/editor
|
|
249
|
+
appActions.setHistoryPush(`/sites/data/${contentType.content.id}/editor`)(dispatch);
|
|
249
250
|
} else {
|
|
250
251
|
structuredDataActions.setSelectedStructuredData(contentType.content.id, "global")(dispatch, getState);
|
|
251
252
|
dispatch(structuredDataActions.setCurrentDataID(contentType.id));
|
|
253
|
+
await structuredDataActions.getDataContent(contentType.id)(dispatch);
|
|
252
254
|
dispatch(appActions.setLanguage(language));
|
|
253
|
-
appActions.setHistoryPush(`/data/${contentType.content.id}/editor
|
|
255
|
+
appActions.setHistoryPush(`/data/${contentType.content.id}/editor`)(dispatch);
|
|
254
256
|
}
|
|
255
257
|
}
|
|
256
258
|
break;
|
|
@@ -1084,7 +1084,7 @@ function generatePageContent(editorContent: IPage): (dispatch: Dispatch, getStat
|
|
|
1084
1084
|
|
|
1085
1085
|
function updateEditorContent(
|
|
1086
1086
|
selectedEditorID: number,
|
|
1087
|
-
key: string,
|
|
1087
|
+
key: string | string[],
|
|
1088
1088
|
value: any
|
|
1089
1089
|
): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
1090
1090
|
return (dispatch, getState) => {
|
|
@@ -1096,7 +1096,11 @@ function updateEditorContent(
|
|
|
1096
1096
|
const clonedSelected = deepClone(selectedContent);
|
|
1097
1097
|
|
|
1098
1098
|
if (clonedSelected.component === "FormPage") {
|
|
1099
|
-
|
|
1099
|
+
if (Array.isArray(key)) {
|
|
1100
|
+
key.forEach((k) => protectFormKeys(clonedContent, k));
|
|
1101
|
+
} else {
|
|
1102
|
+
protectFormKeys(clonedContent, key);
|
|
1103
|
+
}
|
|
1100
1104
|
}
|
|
1101
1105
|
|
|
1102
1106
|
const updatedSelectedContent = updateByEditorID(clonedSelected, selectedEditorID, key, value);
|
|
@@ -1116,8 +1120,15 @@ function updateEditorContent(
|
|
|
1116
1120
|
|
|
1117
1121
|
dispatch(setLastTimeout(timeoutId));
|
|
1118
1122
|
|
|
1119
|
-
const isNavigation =
|
|
1120
|
-
|
|
1123
|
+
const isNavigation = Array.isArray(key)
|
|
1124
|
+
? key.some((k) => ["header", "footer"].includes(k))
|
|
1125
|
+
: ["header", "footer"].includes(key);
|
|
1126
|
+
|
|
1127
|
+
const isObjectValue = Array.isArray(value)
|
|
1128
|
+
? value.some((v) => v !== null && typeof v === "object")
|
|
1129
|
+
: value !== null && typeof value === "object";
|
|
1130
|
+
|
|
1131
|
+
if (isNavigation || isObjectValue) {
|
|
1121
1132
|
generatePageContent(updatedEditorContent)(dispatch, getState);
|
|
1122
1133
|
}
|
|
1123
1134
|
};
|
|
@@ -97,7 +97,7 @@ function setSchema(schema: any) {
|
|
|
97
97
|
return { type: SET_SCHEMA, payload: { schema } };
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function setForm(form:
|
|
100
|
+
function setForm(form: IStructuredDataContent) {
|
|
101
101
|
return { type: CREATE_FORM, payload: { form } };
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -137,7 +137,7 @@ function setCurrentSearch(currentSearch: string): ISetCurrentSearch {
|
|
|
137
137
|
return { type: SET_CURRENT_SEARCH, payload: { currentSearch } };
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
function updateFormValue(valueObj: any): (dispatch: Dispatch, getState:
|
|
140
|
+
function updateFormValue(valueObj: any): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
141
141
|
return (dispatch, getState) => {
|
|
142
142
|
const {
|
|
143
143
|
structuredData: { form },
|
|
@@ -148,7 +148,7 @@ function updateFormValue(valueObj: any): (dispatch: Dispatch, getState: any) =>
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
function resetForm(setDefault?: boolean): (dispatch: Dispatch, getState:
|
|
151
|
+
function resetForm(setDefault?: boolean): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
152
152
|
return (dispatch, getState) => {
|
|
153
153
|
const {
|
|
154
154
|
structuredData: { currentStructuredData },
|
|
@@ -179,7 +179,7 @@ function getStructuredData(
|
|
|
179
179
|
token: string | null,
|
|
180
180
|
siteID?: number | null,
|
|
181
181
|
hasLoading = true
|
|
182
|
-
): (dispatch: Dispatch, getState:
|
|
182
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
|
|
183
183
|
return async (dispatch, getState) => {
|
|
184
184
|
try {
|
|
185
185
|
const {
|
|
@@ -215,7 +215,10 @@ function getStructuredData(
|
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
function setSelectedStructuredData(
|
|
218
|
+
function setSelectedStructuredData(
|
|
219
|
+
id: string,
|
|
220
|
+
scope: "global" | "site"
|
|
221
|
+
): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
219
222
|
return (dispatch, getState) => {
|
|
220
223
|
const {
|
|
221
224
|
structuredData: { structuredData: data },
|
|
@@ -233,7 +236,10 @@ function setSelectedStructuredData(id: string, scope: string): (dispatch: Dispat
|
|
|
233
236
|
};
|
|
234
237
|
}
|
|
235
238
|
|
|
236
|
-
function setSelectedCategory(
|
|
239
|
+
function setSelectedCategory(
|
|
240
|
+
id: string,
|
|
241
|
+
scope: "global" | "site"
|
|
242
|
+
): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
237
243
|
return (dispatch, getState) => {
|
|
238
244
|
const {
|
|
239
245
|
structuredData: { categories: data },
|
|
@@ -249,7 +255,7 @@ function getStructuredDataContents(
|
|
|
249
255
|
params: IGetStructuredDataParams,
|
|
250
256
|
siteID?: number | null,
|
|
251
257
|
hasLoading = true
|
|
252
|
-
): (dispatch: Dispatch, getState:
|
|
258
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
|
|
253
259
|
return async (dispatch, getState) => {
|
|
254
260
|
const { groupingCategories } = params;
|
|
255
261
|
|
|
@@ -308,7 +314,7 @@ function getDataContent(id: number, lang?: { locale: string; id: number }): (dis
|
|
|
308
314
|
const langID = lang ? lang.id : null;
|
|
309
315
|
|
|
310
316
|
const responseActions = {
|
|
311
|
-
handleSuccess: (response:
|
|
317
|
+
handleSuccess: (response: IStructuredDataContent) => dispatch(setForm(response)),
|
|
312
318
|
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
313
319
|
};
|
|
314
320
|
|
|
@@ -324,14 +330,14 @@ function getDataContent(id: number, lang?: { locale: string; id: number }): (dis
|
|
|
324
330
|
function createStructuredDataContent(
|
|
325
331
|
structuredDataContent: IStructuredDataContent | IStructuredDataCategory,
|
|
326
332
|
langId?: number | null
|
|
327
|
-
): (dispatch: Dispatch, getState:
|
|
333
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
328
334
|
return async (dispatch, getState) => {
|
|
329
335
|
try {
|
|
330
336
|
const {
|
|
331
337
|
app: { lang },
|
|
332
338
|
sites: { currentSiteInfo },
|
|
333
339
|
structuredData: { schema, currentStructuredData },
|
|
334
|
-
}
|
|
340
|
+
} = getState();
|
|
335
341
|
|
|
336
342
|
const isCategory = currentStructuredData?.taxonomy === true;
|
|
337
343
|
let dataContent = prepareStructuredDataContent(structuredDataContent);
|
|
@@ -363,12 +369,12 @@ function createStructuredDataContent(
|
|
|
363
369
|
|
|
364
370
|
function updateStructuredDataContent(
|
|
365
371
|
structuredDataContent: IStructuredDataContent | IStructuredDataCategory
|
|
366
|
-
): (dispatch: Dispatch, getState:
|
|
372
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
367
373
|
return async (dispatch, getState) => {
|
|
368
374
|
try {
|
|
369
375
|
const {
|
|
370
376
|
structuredData: { schema, currentStructuredData },
|
|
371
|
-
}
|
|
377
|
+
} = getState();
|
|
372
378
|
|
|
373
379
|
const isCategory = currentStructuredData?.taxonomy === true;
|
|
374
380
|
let dataContent = prepareStructuredDataContent(structuredDataContent);
|
|
@@ -394,7 +400,7 @@ function updateStructuredDataContent(
|
|
|
394
400
|
function deleteStructuredDataContent(
|
|
395
401
|
id: number | number[],
|
|
396
402
|
refresh = true
|
|
397
|
-
): (dispatch: Dispatch, getState:
|
|
403
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
398
404
|
return async (dispatch, getState) => {
|
|
399
405
|
try {
|
|
400
406
|
dispatch(setIsLoading(true));
|
|
@@ -402,7 +408,7 @@ function deleteStructuredDataContent(
|
|
|
402
408
|
const {
|
|
403
409
|
structuredData: { currentFilter, currentStructuredData },
|
|
404
410
|
sites: { currentSiteInfo, currentFilter: currentSiteFilter },
|
|
405
|
-
}
|
|
411
|
+
} = getState();
|
|
406
412
|
|
|
407
413
|
const params = {
|
|
408
414
|
...DEFAULT_PARAMS,
|
|
@@ -476,15 +482,15 @@ function restoreStructuredDataContent(
|
|
|
476
482
|
};
|
|
477
483
|
}
|
|
478
484
|
|
|
479
|
-
function getDistributorContent(data: any): (getState:
|
|
485
|
+
function getDistributorContent(data: any): (getState: () => IRootState) => Promise<any> {
|
|
480
486
|
return async (getState) => {
|
|
481
487
|
try {
|
|
482
488
|
const {
|
|
483
|
-
sites: {
|
|
484
|
-
currentSiteInfo: { id },
|
|
485
|
-
},
|
|
489
|
+
sites: { currentSiteInfo },
|
|
486
490
|
} = getState();
|
|
487
|
-
|
|
491
|
+
|
|
492
|
+
const siteID = currentSiteInfo ? currentSiteInfo.id : "global";
|
|
493
|
+
return structuredData.getDistributorContent(siteID, data);
|
|
488
494
|
} catch (e) {
|
|
489
495
|
console.log("error in get distributor");
|
|
490
496
|
}
|
|
@@ -494,7 +500,7 @@ function getDistributorContent(data: any): (getState: any) => Promise<any> {
|
|
|
494
500
|
function setStatusStructuredDataContent(
|
|
495
501
|
id: number | number[],
|
|
496
502
|
status: string
|
|
497
|
-
): (dispatch: Dispatch, getState:
|
|
503
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
498
504
|
return async (dispatch, getState) => {
|
|
499
505
|
try {
|
|
500
506
|
const {
|
|
@@ -529,17 +535,14 @@ function setStatusStructuredDataContent(
|
|
|
529
535
|
};
|
|
530
536
|
}
|
|
531
537
|
|
|
532
|
-
function validateForm(publish?: boolean): (dispatch: Dispatch, getState:
|
|
538
|
+
function validateForm(publish?: boolean): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
533
539
|
return async (dispatch, getState) => {
|
|
534
540
|
try {
|
|
535
541
|
const {
|
|
536
|
-
structuredData: {
|
|
537
|
-
form: { content },
|
|
538
|
-
schema,
|
|
539
|
-
},
|
|
542
|
+
structuredData: { form, schema },
|
|
540
543
|
} = getState();
|
|
541
544
|
|
|
542
|
-
const formContent = deepClone(content);
|
|
545
|
+
const formContent = deepClone(form?.content || {});
|
|
543
546
|
const errors = findMandatoryStructuredDataErrors(formContent, schema);
|
|
544
547
|
dispatch(setErrors(errors));
|
|
545
548
|
if (errors.length === 0) {
|
|
@@ -556,7 +559,7 @@ function validateForm(publish?: boolean): (dispatch: Dispatch, getState: any) =>
|
|
|
556
559
|
};
|
|
557
560
|
}
|
|
558
561
|
|
|
559
|
-
function deleteError(error: IErrorItem): (dispatch: Dispatch, getState:
|
|
562
|
+
function deleteError(error: IErrorItem): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
560
563
|
return async (dispatch, getState) => {
|
|
561
564
|
try {
|
|
562
565
|
const {
|
|
@@ -584,7 +587,9 @@ function resetStructuredData(): (dispatch: Dispatch) => void {
|
|
|
584
587
|
};
|
|
585
588
|
}
|
|
586
589
|
|
|
587
|
-
function getDataContentTranslation(
|
|
590
|
+
function getDataContentTranslation(
|
|
591
|
+
langID: number
|
|
592
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
588
593
|
return async (dispatch, getState) => {
|
|
589
594
|
try {
|
|
590
595
|
const {
|
|
@@ -645,7 +650,9 @@ function resetCurrentData(): (dispatch: Dispatch) => Promise<void> {
|
|
|
645
650
|
};
|
|
646
651
|
}
|
|
647
652
|
|
|
648
|
-
function createCategoryGroup(
|
|
653
|
+
function createCategoryGroup(
|
|
654
|
+
data: ICategoryGroupParams
|
|
655
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
649
656
|
return async (dispatch, getState) => {
|
|
650
657
|
try {
|
|
651
658
|
const {
|
|
@@ -696,7 +703,7 @@ function deleteCategoryGroup(
|
|
|
696
703
|
id: number | number[],
|
|
697
704
|
deleteChildren: boolean,
|
|
698
705
|
refresh = true
|
|
699
|
-
): (dispatch: Dispatch, getState:
|
|
706
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
700
707
|
return async (dispatch, getState) => {
|
|
701
708
|
try {
|
|
702
709
|
const {
|
|
@@ -737,7 +744,9 @@ function deleteCategoryGroup(
|
|
|
737
744
|
};
|
|
738
745
|
}
|
|
739
746
|
|
|
740
|
-
function orderCategory(
|
|
747
|
+
function orderCategory(
|
|
748
|
+
data: IOrderCategoryParams
|
|
749
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
741
750
|
return async (dispatch, getState) => {
|
|
742
751
|
try {
|
|
743
752
|
const {
|
|
@@ -775,7 +784,7 @@ function updateCurrentSearch(query: string): (dispatch: Dispatch) => Promise<voi
|
|
|
775
784
|
function exportDataContent(
|
|
776
785
|
structuredDataID: string,
|
|
777
786
|
data: IExportDataParams
|
|
778
|
-
): (dispatch: Dispatch, getState:
|
|
787
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
|
|
779
788
|
return async (dispatch, getState) => {
|
|
780
789
|
try {
|
|
781
790
|
const {
|
|
@@ -29,7 +29,7 @@ export interface IStructuredDataState {
|
|
|
29
29
|
currentDataContent: IStructuredDataContent[];
|
|
30
30
|
currentDataCategory: IStructuredDataCategory[];
|
|
31
31
|
schema: any;
|
|
32
|
-
form:
|
|
32
|
+
form: IStructuredDataContent | null;
|
|
33
33
|
entity: string | null;
|
|
34
34
|
currentFilter: string;
|
|
35
35
|
schemaVersion: string;
|
|
@@ -49,7 +49,7 @@ export const initialState = {
|
|
|
49
49
|
currentDataContent: [],
|
|
50
50
|
currentDataCategory: [],
|
|
51
51
|
schema: {},
|
|
52
|
-
form:
|
|
52
|
+
form: null,
|
|
53
53
|
entity: null,
|
|
54
54
|
currentFilter: "all-pages",
|
|
55
55
|
schemaVersion: "",
|
package/src/forms/elements.tsx
CHANGED
|
@@ -132,18 +132,27 @@ function deleteModules(sections: any, editorID: number) {
|
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
const
|
|
136
|
-
const
|
|
135
|
+
const setKeyValue = (obj: any, key: string, val: any) => {
|
|
136
|
+
const [parentKey, childKey] = key.split(".");
|
|
137
|
+
if (childKey) {
|
|
138
|
+
if (obj[parentKey] && typeof obj[parentKey] === "object") {
|
|
139
|
+
obj[parentKey][childKey] = val;
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
obj[parentKey] = val;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
137
145
|
|
|
138
|
-
|
|
146
|
+
const updateByEditorID = (content: any, editorID: number, contentKey: string | string[], value: any): any => {
|
|
147
|
+
if (!content || typeof content !== "object") return content;
|
|
139
148
|
|
|
140
149
|
if (content.editorID === editorID) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
content[
|
|
150
|
+
if (Array.isArray(contentKey)) {
|
|
151
|
+
const keys = contentKey;
|
|
152
|
+
const values = Array.isArray(value) ? value : [value];
|
|
153
|
+
keys.forEach((k, i) => setKeyValue(content, k, values[i]));
|
|
145
154
|
} else {
|
|
146
|
-
content
|
|
155
|
+
setKeyValue(content, contentKey, value);
|
|
147
156
|
}
|
|
148
157
|
|
|
149
158
|
return content;
|
|
@@ -151,7 +160,10 @@ const updateByEditorID = (content: any, editorID: number, contentKey: string, va
|
|
|
151
160
|
|
|
152
161
|
for (const key in content) {
|
|
153
162
|
if (Object.prototype.hasOwnProperty.call(content, key)) {
|
|
154
|
-
|
|
163
|
+
const child = content[key];
|
|
164
|
+
if (typeof child === "object") {
|
|
165
|
+
content[key] = updateByEditorID(child, editorID, contentKey, value);
|
|
166
|
+
}
|
|
155
167
|
}
|
|
156
168
|
}
|
|
157
169
|
|
|
@@ -3,7 +3,7 @@ import { connect } from "react-redux";
|
|
|
3
3
|
import { format, subDays } from "date-fns";
|
|
4
4
|
|
|
5
5
|
import { LogActivityExportRequest, LogActivityPaginationRequest } from "@griddo/api-types";
|
|
6
|
-
import { ILogItemsByDay, ILogItemsByUser, IQueryValue, IRootState } from "@ax/types";
|
|
6
|
+
import { ILogItemsByDay, ILogItemsByUser, IQueryValue, IRootState, IStructuredData } from "@ax/types";
|
|
7
7
|
import { EmptyState, ErrorToast, FilterTagsBar, MainWrapper, SearchTagsBar, Select, TableList } from "@ax/components";
|
|
8
8
|
import { activityLogActions } from "@ax/containers/ActivityLog";
|
|
9
9
|
import { structuredDataActions } from "@ax/containers/StructuredData";
|
|
@@ -26,6 +26,7 @@ const ActivityLog = (props: IActivityLogProps) => {
|
|
|
26
26
|
getActivityLogByUser,
|
|
27
27
|
downloadActivityLog,
|
|
28
28
|
getStructuredData,
|
|
29
|
+
setCurrentData,
|
|
29
30
|
} = props;
|
|
30
31
|
|
|
31
32
|
const itemsPerPage = 100;
|
|
@@ -82,6 +83,7 @@ const ActivityLog = (props: IActivityLogProps) => {
|
|
|
82
83
|
|
|
83
84
|
useEffect(() => {
|
|
84
85
|
handleUpdateStructuredDate();
|
|
86
|
+
setCurrentData(null);
|
|
85
87
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
88
|
}, []);
|
|
87
89
|
|
|
@@ -295,6 +297,7 @@ interface IActivityLogProps {
|
|
|
295
297
|
setListMode(listMode: string): void;
|
|
296
298
|
downloadActivityLog(data: LogActivityExportRequest): Promise<void>;
|
|
297
299
|
getStructuredData(token: string | null, siteID?: number | null, hasLoading?: boolean): Promise<void>;
|
|
300
|
+
setCurrentData(currentStructuredData: IStructuredData | null): void;
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
const mapStateToProps = (state: IRootState) => ({
|
|
@@ -308,6 +311,7 @@ const mapDispatchToProps = {
|
|
|
308
311
|
setListMode: activityLogActions.setListMode,
|
|
309
312
|
downloadActivityLog: activityLogActions.downloadActivityLog,
|
|
310
313
|
getStructuredData: structuredDataActions.getStructuredData,
|
|
314
|
+
setCurrentData: structuredDataActions.setCurrentData,
|
|
311
315
|
};
|
|
312
316
|
|
|
313
317
|
export default connect(mapStateToProps, mapDispatchToProps)(ActivityLog);
|
|
@@ -21,6 +21,7 @@ const UsageContent = (props: IProps) => {
|
|
|
21
21
|
getSite,
|
|
22
22
|
setCurrentDataID,
|
|
23
23
|
setSelectedStructuredData,
|
|
24
|
+
getDataContent,
|
|
24
25
|
} = props;
|
|
25
26
|
const {
|
|
26
27
|
contentInUse: { pages, simpleStructuredData, globalPages },
|
|
@@ -70,9 +71,10 @@ const UsageContent = (props: IProps) => {
|
|
|
70
71
|
}
|
|
71
72
|
if (isSiteView && selectedTab !== "global") {
|
|
72
73
|
return simpleStructuredData.map((item: IFileUseItem) => {
|
|
73
|
-
const handleClick = () => {
|
|
74
|
+
const handleClick = async () => {
|
|
74
75
|
item.structuredDataId && setSelectedStructuredData(item.structuredDataId, "site");
|
|
75
76
|
setCurrentDataID(item.id);
|
|
77
|
+
await getDataContent(item.id);
|
|
76
78
|
setHistoryPush(`data/${item.structuredDataId}/editor`, true);
|
|
77
79
|
};
|
|
78
80
|
|
|
@@ -87,9 +89,10 @@ const UsageContent = (props: IProps) => {
|
|
|
87
89
|
);
|
|
88
90
|
});
|
|
89
91
|
} else {
|
|
90
|
-
const handleClick = (item: IFileUseItem) => {
|
|
92
|
+
const handleClick = async (item: IFileUseItem) => {
|
|
91
93
|
item.structuredDataId && setSelectedStructuredData(item.structuredDataId, "global");
|
|
92
94
|
setCurrentDataID(item.id);
|
|
95
|
+
await getDataContent(item.id);
|
|
93
96
|
setHistoryPush(`/data/${item.structuredDataId}/editor`, true);
|
|
94
97
|
};
|
|
95
98
|
return <ItemGroup title="Global Simple Content" items={simpleStructuredData} onClick={handleClick} />;
|
|
@@ -120,6 +123,7 @@ interface IProps {
|
|
|
120
123
|
getSite(siteID: number): Promise<void>;
|
|
121
124
|
setCurrentDataID(id: number | null): void;
|
|
122
125
|
setSelectedStructuredData(id: string, scope: string): void;
|
|
126
|
+
getDataContent(id: number): Promise<void>;
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
const mapDispatchToProps = {
|
|
@@ -128,6 +132,7 @@ const mapDispatchToProps = {
|
|
|
128
132
|
getSite: sitesActions.getSite,
|
|
129
133
|
setCurrentDataID: structuredDataActions.setCurrentDataID,
|
|
130
134
|
setSelectedStructuredData: structuredDataActions.setSelectedStructuredData,
|
|
135
|
+
getDataContent: structuredDataActions.getDataContent,
|
|
131
136
|
};
|
|
132
137
|
|
|
133
138
|
const mapStateToProps = (state: IRootState) => ({
|
|
@@ -29,6 +29,7 @@ const UsageContent = (props: IProps) => {
|
|
|
29
29
|
setSelectedStructuredData,
|
|
30
30
|
getUserCurrentPermissions,
|
|
31
31
|
setCurrentSiteInfo,
|
|
32
|
+
getDataContent,
|
|
32
33
|
} = props;
|
|
33
34
|
|
|
34
35
|
const { id } = image;
|
|
@@ -79,11 +80,12 @@ const UsageContent = (props: IProps) => {
|
|
|
79
80
|
});
|
|
80
81
|
|
|
81
82
|
const dataItems = data.map((item: IImageUseItem) => {
|
|
82
|
-
const handleClick = () => {
|
|
83
|
+
const handleClick = async () => {
|
|
83
84
|
if (!item.structuredData) return;
|
|
84
85
|
setSelectedStructuredData(item.structuredData.id, "site");
|
|
85
86
|
setCurrentDataID(item.id);
|
|
86
|
-
|
|
87
|
+
await getDataContent(item.id);
|
|
88
|
+
setHistoryPush(`/sites/data/${item.structuredData.id}/editor`);
|
|
87
89
|
};
|
|
88
90
|
|
|
89
91
|
return (
|
|
@@ -108,7 +110,8 @@ const UsageContent = (props: IProps) => {
|
|
|
108
110
|
} else {
|
|
109
111
|
setSelectedStructuredData(page.structuredData.id, "site");
|
|
110
112
|
setCurrentDataID(page.id);
|
|
111
|
-
|
|
113
|
+
await getDataContent(page.id);
|
|
114
|
+
setHistoryPush(`/sites/data/${page.structuredData.id}/editor`);
|
|
112
115
|
}
|
|
113
116
|
};
|
|
114
117
|
return (
|
|
@@ -146,15 +149,16 @@ const UsageContent = (props: IProps) => {
|
|
|
146
149
|
return <></>;
|
|
147
150
|
}
|
|
148
151
|
const hasGlobal = currentUser?.isSuperAdmin || !!currentUser?.roles.find((rol) => rol.siteId === "global");
|
|
149
|
-
const handleClick = (item: IImageUseItem) => {
|
|
152
|
+
const handleClick = async (item: IImageUseItem) => {
|
|
150
153
|
if (!item.structuredData) return;
|
|
151
154
|
setSelectedStructuredData(item.structuredData.id, "global");
|
|
152
155
|
setCurrentDataID(item.id);
|
|
156
|
+
await getDataContent(item.id);
|
|
153
157
|
if (isSiteView) {
|
|
154
158
|
setCurrentSiteInfo(null);
|
|
155
159
|
getUserCurrentPermissions();
|
|
156
160
|
}
|
|
157
|
-
setHistoryPush(`/data/${item.structuredData.id}/editor
|
|
161
|
+
setHistoryPush(`/data/${item.structuredData.id}/editor`);
|
|
158
162
|
};
|
|
159
163
|
return (
|
|
160
164
|
<ItemGroup title="Global Simple Content" items={items.simpleData} onClick={handleClick} disabled={!hasGlobal} />
|
|
@@ -192,13 +196,14 @@ interface IProps {
|
|
|
192
196
|
currentSiteID: number | null;
|
|
193
197
|
selectedTab: "site" | "global";
|
|
194
198
|
currentUser: IUser | null;
|
|
195
|
-
setHistoryPush(page: string, isEditor
|
|
199
|
+
setHistoryPush(page: string, isEditor?: boolean): Promise<void>;
|
|
196
200
|
setCurrentPageID(currentPageID: number | null): ISetCurrentPageIDAction;
|
|
197
201
|
getSite(siteID: number): Promise<void>;
|
|
198
202
|
setCurrentDataID(id: number | null): void;
|
|
199
203
|
setSelectedStructuredData(id: string, scope: string): void;
|
|
200
204
|
getUserCurrentPermissions(): Promise<void>;
|
|
201
205
|
setCurrentSiteInfo(currentSiteInfo: ISite | null): void;
|
|
206
|
+
getDataContent(id: number): Promise<void>;
|
|
202
207
|
}
|
|
203
208
|
|
|
204
209
|
interface IInUseItems {
|
|
@@ -222,6 +227,7 @@ const mapDispatchToProps = {
|
|
|
222
227
|
setCurrentDataID: structuredDataActions.setCurrentDataID,
|
|
223
228
|
setSelectedStructuredData: structuredDataActions.setSelectedStructuredData,
|
|
224
229
|
getUserCurrentPermissions: usersActions.getUserCurrentPermissions,
|
|
230
|
+
getDataContent: structuredDataActions.getDataContent,
|
|
225
231
|
};
|
|
226
232
|
|
|
227
233
|
const mapStateToProps = (state: IRootState) => ({
|
|
@@ -111,16 +111,9 @@ const Form = (props: IProps) => {
|
|
|
111
111
|
const theme = getDefaultTheme();
|
|
112
112
|
|
|
113
113
|
useEffect(() => {
|
|
114
|
-
|
|
115
|
-
await getDataContent(dataID);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
if (currentStructuredDataId) {
|
|
119
|
-
handleGetContent(currentStructuredDataId);
|
|
120
|
-
} else {
|
|
114
|
+
if (!currentStructuredDataId) {
|
|
121
115
|
setIsDirty(true);
|
|
122
116
|
}
|
|
123
|
-
|
|
124
117
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
125
118
|
}, []);
|
|
126
119
|
|
|
@@ -50,6 +50,7 @@ const StructuredDataItem = (props: IStructuredDataItemProps): JSX.Element => {
|
|
|
50
50
|
addCategoryColors,
|
|
51
51
|
currentSiteInfo,
|
|
52
52
|
hoverCheck,
|
|
53
|
+
getDataContent,
|
|
53
54
|
} = props;
|
|
54
55
|
|
|
55
56
|
const isPrivateData = currentStructuredData?.private || false;
|
|
@@ -80,6 +81,7 @@ const StructuredDataItem = (props: IStructuredDataItemProps): JSX.Element => {
|
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
const _handleClick = () => {
|
|
84
|
+
getDataContent(structuredData.id);
|
|
83
85
|
setCurrentDataID(structuredData.id);
|
|
84
86
|
handleClick();
|
|
85
87
|
};
|
|
@@ -289,7 +291,7 @@ interface IStructuredDataItemProps {
|
|
|
289
291
|
setLanguage(lang: { locale: string; id: number | null }): void;
|
|
290
292
|
deleteStructuredDataContent(id: number): Promise<boolean>;
|
|
291
293
|
setEntity(entity: string | null): void;
|
|
292
|
-
getDataContent(id: number, lang
|
|
294
|
+
getDataContent(id: number, lang?: { locale: string; id: number }): void;
|
|
293
295
|
resetForm(): void;
|
|
294
296
|
isSelected: boolean;
|
|
295
297
|
onChange: (value: ICheck) => void;
|