@griddo/ax 1.65.13 → 1.65.14
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/api/structuredData.tsx +13 -2
- package/src/components/Fields/AsyncCheckGroup/index.tsx +2 -3
- package/src/containers/StructuredData/actions.tsx +7 -0
- package/src/containers/StructuredData/constants.tsx +2 -0
- package/src/containers/StructuredData/interfaces.tsx +7 -0
- package/src/containers/StructuredData/reducer.tsx +4 -0
- package/src/modules/StructuredData/Form/index.tsx +12 -1
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +4 -2
- package/src/modules/StructuredData/StructuredDataList/index.tsx +1 -0
- 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": "1.65.
|
|
4
|
+
"version": "1.65.14",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -221,5 +221,5 @@
|
|
|
221
221
|
"publishConfig": {
|
|
222
222
|
"access": "public"
|
|
223
223
|
},
|
|
224
|
-
"gitHead": "
|
|
224
|
+
"gitHead": "2e1445241e1bd82891250dcabcd2cba13ecf5e7a"
|
|
225
225
|
}
|
|
@@ -104,11 +104,22 @@ const getDataContent = (dataContentId: number, langID: number | null) => {
|
|
|
104
104
|
|
|
105
105
|
const getDataContents = (params: IGetStructuredDataParams, siteID?: number | null) => {
|
|
106
106
|
const { host, endpoint } = SERVICES.GET_DATA_CONTENTS;
|
|
107
|
-
const {
|
|
107
|
+
const {
|
|
108
|
+
dataID,
|
|
109
|
+
page,
|
|
110
|
+
itemsPerPage,
|
|
111
|
+
pagination,
|
|
112
|
+
deleted,
|
|
113
|
+
include_draft,
|
|
114
|
+
query,
|
|
115
|
+
filterQuery,
|
|
116
|
+
relatedFields = false,
|
|
117
|
+
} = params;
|
|
108
118
|
|
|
109
119
|
const url = siteID ? `${host}/site/${siteID}${endpoint}` : `${host}${endpoint}`;
|
|
110
120
|
|
|
111
|
-
SERVICES.GET_DATA_CONTENTS.dynamicUrl = `${url}${dataID}?page=${page}&itemsPerPage=${itemsPerPage}&pagination=${pagination}&deleted=${deleted}&includeDraft=${include_draft}
|
|
121
|
+
SERVICES.GET_DATA_CONTENTS.dynamicUrl = `${url}${dataID}?page=${page}&itemsPerPage=${itemsPerPage}&pagination=${pagination}&deleted=${deleted}&includeDraft=${include_draft}`;
|
|
122
|
+
if (relatedFields) SERVICES.GET_DATA_CONTENTS.dynamicUrl += `&relatedFields=true`;
|
|
112
123
|
if (query && query.trim() !== "") SERVICES.GET_DATA_CONTENTS.dynamicUrl += `&query=${query}`;
|
|
113
124
|
if (filterQuery) SERVICES.GET_DATA_CONTENTS.dynamicUrl += filterQuery;
|
|
114
125
|
|
|
@@ -10,7 +10,7 @@ import * as S from "./style";
|
|
|
10
10
|
const AsyncCheckGroup = (props: IAsyncCheckGroup): JSX.Element => {
|
|
11
11
|
const { onChange, value, site, source, disabled, error, handleValidation, fullHeight } = props;
|
|
12
12
|
|
|
13
|
-
const [options, setOptions] = useState([]);
|
|
13
|
+
const [options, setOptions] = useState<ICheck[]>([]);
|
|
14
14
|
|
|
15
15
|
const safeValue = value ? value : [];
|
|
16
16
|
|
|
@@ -58,8 +58,7 @@ const AsyncCheckGroup = (props: IAsyncCheckGroup): JSX.Element => {
|
|
|
58
58
|
error && handleValidation && handleValidation(newArrayObject);
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
const isChecked = (id: number) =>
|
|
62
|
-
safeValue.find((e: any) => (typeof e === "number" ? e === id : (e.value || e.id) === id));
|
|
61
|
+
const isChecked = (id: number) => safeValue.find((e: any) => (typeof e === "number" ? e === id : e.value === id));
|
|
63
62
|
|
|
64
63
|
const checks =
|
|
65
64
|
options &&
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
SET_CATEGORIES,
|
|
4
4
|
SET_STRUCTURED_DATA,
|
|
5
5
|
SET_CURRENT_STRUCTURED_DATA,
|
|
6
|
+
SET_CURRENT_STRUCTURED_DATA_ID,
|
|
6
7
|
SET_CURRENT_STRUCTURED_DATA_CONTENTS,
|
|
7
8
|
SET_CATEGORY,
|
|
8
9
|
SET_SCHEMA,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
ISetCategories,
|
|
22
23
|
ISetStructuredData,
|
|
23
24
|
ISetCurrentData,
|
|
25
|
+
ISetCurrentDataID,
|
|
24
26
|
ISetCurrentDataContent,
|
|
25
27
|
ISetIsActive,
|
|
26
28
|
ISetCategory,
|
|
@@ -56,6 +58,10 @@ function setCurrentData(currentStructuredData: any): ISetCurrentData {
|
|
|
56
58
|
return { type: SET_CURRENT_STRUCTURED_DATA, payload: { currentStructuredData } };
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
function setCurrentDataID(currentStructuredDataId: any): ISetCurrentDataID {
|
|
62
|
+
return { type: SET_CURRENT_STRUCTURED_DATA_ID, payload: { currentStructuredDataId } };
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
function setCurrentDataContent(currentDataContent: any): ISetCurrentDataContent {
|
|
60
66
|
return { type: SET_CURRENT_STRUCTURED_DATA_CONTENTS, payload: { currentDataContent } };
|
|
61
67
|
}
|
|
@@ -530,6 +536,7 @@ export {
|
|
|
530
536
|
setCategories,
|
|
531
537
|
setStructuredData,
|
|
532
538
|
setCurrentData,
|
|
539
|
+
setCurrentDataID,
|
|
533
540
|
setCategory,
|
|
534
541
|
setSchema,
|
|
535
542
|
setForm,
|
|
@@ -4,6 +4,7 @@ const SET_IS_ACTIVE = `${NAME}/SET_IS_ACTIVE`;
|
|
|
4
4
|
const SET_CATEGORIES = `${NAME}/SET_CATEGORIES`;
|
|
5
5
|
const SET_STRUCTURED_DATA = `${NAME}/SET_STRUCTURED_DATA`;
|
|
6
6
|
const SET_CURRENT_STRUCTURED_DATA = `${NAME}/SET_CURRENT_STRUCTURED_DATA`;
|
|
7
|
+
const SET_CURRENT_STRUCTURED_DATA_ID = `${NAME}/SET_CURRENT_STRUCTURED_DATA_ID`;
|
|
7
8
|
const SET_CURRENT_STRUCTURED_DATA_CONTENTS = `${NAME}/SET_CURRENT_STRUCTURED_DATA_CONTENTS`;
|
|
8
9
|
const SET_CATEGORY = `${NAME}/SET_CATEGORY`;
|
|
9
10
|
const SET_SCHEMA = `${NAME}/SET_SCHEMA`;
|
|
@@ -30,6 +31,7 @@ export {
|
|
|
30
31
|
SET_CATEGORIES,
|
|
31
32
|
SET_STRUCTURED_DATA,
|
|
32
33
|
SET_CURRENT_STRUCTURED_DATA,
|
|
34
|
+
SET_CURRENT_STRUCTURED_DATA_ID,
|
|
33
35
|
SET_CURRENT_STRUCTURED_DATA_CONTENTS,
|
|
34
36
|
SET_CATEGORY,
|
|
35
37
|
SET_SCHEMA,
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
SET_CATEGORIES,
|
|
3
3
|
SET_STRUCTURED_DATA,
|
|
4
4
|
SET_CURRENT_STRUCTURED_DATA,
|
|
5
|
+
SET_CURRENT_STRUCTURED_DATA_ID,
|
|
5
6
|
SET_CURRENT_STRUCTURED_DATA_CONTENTS,
|
|
6
7
|
SET_SCHEMA,
|
|
7
8
|
UPDATE_FORM,
|
|
@@ -30,6 +31,11 @@ export interface ISetCurrentData {
|
|
|
30
31
|
payload: { currentStructuredData: any };
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
export interface ISetCurrentDataID {
|
|
35
|
+
type: typeof SET_CURRENT_STRUCTURED_DATA_ID;
|
|
36
|
+
payload: { currentStructuredDataId: number };
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
export interface ISetCategory {
|
|
34
40
|
type: typeof SET_CATEGORY;
|
|
35
41
|
payload: { category: ICategory };
|
|
@@ -79,4 +85,5 @@ export type CategoryActionsCreators = ISetCategories & ISetCurrentData;
|
|
|
79
85
|
export type StructuredDataActionsCreators = CategoryActionsCreators &
|
|
80
86
|
ISetStructuredData &
|
|
81
87
|
ISetCurrentData &
|
|
88
|
+
ISetCurrentDataID &
|
|
82
89
|
ISetCurrentDataContent;
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
SET_CATEGORIES,
|
|
4
4
|
SET_STRUCTURED_DATA,
|
|
5
5
|
SET_CURRENT_STRUCTURED_DATA,
|
|
6
|
+
SET_CURRENT_STRUCTURED_DATA_ID,
|
|
6
7
|
SET_CURRENT_STRUCTURED_DATA_CONTENTS,
|
|
7
8
|
SET_CATEGORY,
|
|
8
9
|
SET_SCHEMA,
|
|
@@ -23,6 +24,7 @@ export interface IStructuredDataState {
|
|
|
23
24
|
categories: { global: IStructuredData[]; site: IStructuredData[] };
|
|
24
25
|
structuredData: { global: IStructuredData[]; site: IStructuredData[] };
|
|
25
26
|
currentStructuredData: IStructuredData | null;
|
|
27
|
+
currentStructuredDataId: number | null;
|
|
26
28
|
currentDataContent: IStructuredDataContent[];
|
|
27
29
|
category: ICategory;
|
|
28
30
|
schema: any;
|
|
@@ -39,6 +41,7 @@ export const initialState = {
|
|
|
39
41
|
categories: { global: [], site: [] },
|
|
40
42
|
structuredData: { global: [], site: [] },
|
|
41
43
|
currentStructuredData: null,
|
|
44
|
+
currentStructuredDataId: null,
|
|
42
45
|
currentDataContent: [],
|
|
43
46
|
category: { name: "", code: "", lang: null, isTranslation: false, isNew: true },
|
|
44
47
|
schema: {},
|
|
@@ -55,6 +58,7 @@ export function reducer(state = initialState, action: StructuredDataActionsCreat
|
|
|
55
58
|
case SET_CATEGORIES:
|
|
56
59
|
case SET_STRUCTURED_DATA:
|
|
57
60
|
case SET_CURRENT_STRUCTURED_DATA:
|
|
61
|
+
case SET_CURRENT_STRUCTURED_DATA_ID:
|
|
58
62
|
case SET_CURRENT_STRUCTURED_DATA_CONTENTS:
|
|
59
63
|
case SET_CATEGORY:
|
|
60
64
|
case SET_SCHEMA:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
|
|
4
4
|
import { IDataPack, IErrorItem, IRootState, ISite } from "@ax/types";
|
|
@@ -39,6 +39,8 @@ const Form = (props: IProps) => {
|
|
|
39
39
|
errors,
|
|
40
40
|
validated,
|
|
41
41
|
validateForm,
|
|
42
|
+
currentStructuredDataId,
|
|
43
|
+
resetForm,
|
|
42
44
|
} = props;
|
|
43
45
|
|
|
44
46
|
const [isNewStructuredData, setIsNewStructuredData] = useState(!form.id);
|
|
@@ -56,6 +58,11 @@ const Form = (props: IProps) => {
|
|
|
56
58
|
|
|
57
59
|
const theme = getDefaultTheme();
|
|
58
60
|
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
resetForm();
|
|
63
|
+
currentStructuredDataId && getDataContent(currentStructuredDataId);
|
|
64
|
+
}, [currentStructuredDataId]);
|
|
65
|
+
|
|
59
66
|
const Fields =
|
|
60
67
|
fields &&
|
|
61
68
|
fields.map((field: any, i: number) => {
|
|
@@ -315,6 +322,8 @@ interface IProps {
|
|
|
315
322
|
setDataStatus(id: number, status: string): Promise<boolean>;
|
|
316
323
|
deleteStructuredDataContent(id: number): Promise<boolean>;
|
|
317
324
|
validateForm(publish?: boolean): Promise<boolean>;
|
|
325
|
+
currentStructuredDataId: number | null;
|
|
326
|
+
resetForm(): void;
|
|
318
327
|
}
|
|
319
328
|
|
|
320
329
|
const mapStateToProps = (state: IRootState) => ({
|
|
@@ -322,6 +331,7 @@ const mapStateToProps = (state: IRootState) => ({
|
|
|
322
331
|
form: state.structuredData.form,
|
|
323
332
|
site: state.sites.currentSiteInfo,
|
|
324
333
|
currentStructuredData: state.structuredData.currentStructuredData,
|
|
334
|
+
currentStructuredDataId: state.structuredData.currentStructuredDataId,
|
|
325
335
|
isSaving: state.app.isSaving,
|
|
326
336
|
isLoading: state.app.isLoading,
|
|
327
337
|
lang: state.app.lang,
|
|
@@ -343,6 +353,7 @@ const mapDispatchToProps = {
|
|
|
343
353
|
setDataStatus: structuredDataActions.setStatusStructuredDataContent,
|
|
344
354
|
deleteStructuredDataContent: structuredDataActions.deleteStructuredDataContent,
|
|
345
355
|
validateForm: structuredDataActions.validateForm,
|
|
356
|
+
resetForm: structuredDataActions.resetForm,
|
|
346
357
|
};
|
|
347
358
|
|
|
348
359
|
export default connect(mapStateToProps, mapDispatchToProps)(Form);
|
|
@@ -21,6 +21,7 @@ const StructuredDataItem = (props: IStructuredDataItemProps): JSX.Element => {
|
|
|
21
21
|
setLanguage,
|
|
22
22
|
setEntity,
|
|
23
23
|
currentStructuredData,
|
|
24
|
+
setCurrentDataID,
|
|
24
25
|
resetForm,
|
|
25
26
|
isSelected,
|
|
26
27
|
onChange,
|
|
@@ -52,8 +53,7 @@ const StructuredDataItem = (props: IStructuredDataItemProps): JSX.Element => {
|
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
const _handleClick = () => {
|
|
55
|
-
|
|
56
|
-
updateForm(structuredData);
|
|
56
|
+
setCurrentDataID(structuredData.id);
|
|
57
57
|
handleClick();
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -244,6 +244,7 @@ interface IStructuredDataItemProps {
|
|
|
244
244
|
columns: Record<string, IColumn>;
|
|
245
245
|
categoryColors: any;
|
|
246
246
|
addCategoryColors(cats: string[]): void;
|
|
247
|
+
setCurrentDataID(id: number | null): void;
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
const mapStateToProps = (state: IRootState) => ({
|
|
@@ -258,6 +259,7 @@ const mapDispatchToProps = {
|
|
|
258
259
|
resetForm: structuredDataActions.resetForm,
|
|
259
260
|
setLanguage: appActions.setLanguage,
|
|
260
261
|
setDataStatus: structuredDataActions.setStatusStructuredDataContent,
|
|
262
|
+
setCurrentDataID: structuredDataActions.setCurrentDataID,
|
|
261
263
|
};
|
|
262
264
|
|
|
263
265
|
const memoizedComponent = memo(StructuredDataItem);
|