@griddo/ax 1.49.42 → 1.51.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/README.md +6 -0
- package/config/griddo-config.js +2 -2
- package/config/webpack.config.js +0 -3
- package/config/webpackSchemas.config.js +18 -0
- package/package.json +41 -24
- package/scripts/griddo-sync-schemas.js +28 -6
- package/scripts/griddo.js +0 -1
- package/src/api/sites.tsx +2 -2
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/Field/index.tsx +2 -1
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +8 -2
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldInline/index.tsx +43 -0
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldInline/style.tsx +30 -0
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/index.tsx +55 -0
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/style.tsx +48 -0
- package/src/components/Fields/ArrayFieldGroup/index.tsx +91 -0
- package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +12 -6
- package/src/components/Fields/ComponentArray/SameComponentArray/index.tsx +13 -5
- package/src/components/Fields/ComponentArray/helpers.tsx +13 -1
- package/src/components/Fields/ComponentContainer/index.tsx +5 -3
- package/src/components/Fields/FieldsDivider/index.tsx +21 -0
- package/src/components/Fields/FieldsDivider/style.tsx +19 -0
- package/src/components/Fields/RadioGroup/index.tsx +1 -1
- package/src/components/Fields/VisualUniqueSelection/ScrollableSelection/index.tsx +4 -11
- package/src/components/Fields/index.tsx +4 -0
- package/src/components/MainWrapper/AppBar/index.tsx +3 -1
- package/src/components/MainWrapper/index.tsx +1 -0
- package/src/components/index.tsx +4 -0
- package/src/containers/Navigation/Defaults/actions.tsx +32 -27
- package/src/containers/PageEditor/actions.tsx +44 -22
- package/src/containers/PageEditor/constants.tsx +1 -0
- package/src/containers/PageEditor/interfaces.tsx +6 -0
- package/src/containers/PageEditor/reducer.tsx +4 -0
- package/src/containers/Sites/actions.tsx +22 -0
- package/src/containers/Sites/constants.tsx +7 -7
- package/src/containers/Sites/interfaces.tsx +6 -0
- package/src/containers/Sites/reducer.tsx +4 -0
- package/src/forms/editor.tsx +17 -9
- package/src/forms/elements.tsx +8 -14
- package/src/forms/fields.tsx +1 -1
- package/src/forms/index.tsx +2 -0
- package/src/hooks/bulk.tsx +12 -3
- package/src/modules/Content/PageImporter/index.tsx +1 -0
- package/src/modules/Content/index.tsx +5 -1
- package/src/modules/GlobalEditor/Editor/index.tsx +6 -6
- package/src/modules/GlobalEditor/index.tsx +33 -0
- package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/index.tsx +5 -5
- package/src/modules/PageEditor/Editor/index.tsx +11 -6
- package/src/modules/PageEditor/index.tsx +1 -0
- package/src/modules/StructuredData/Form/index.tsx +1 -0
- package/src/modules/StructuredData/StructuredDataList/index.tsx +9 -2
- package/src/types/index.tsx +1 -0
|
@@ -4,7 +4,7 @@ import { IModule } from "@ax/types";
|
|
|
4
4
|
import { ComponentContainer } from "@ax/components";
|
|
5
5
|
|
|
6
6
|
import AddItemButton from "./AddItemButton";
|
|
7
|
-
import { getComponentProps } from "../helpers";
|
|
7
|
+
import { getComponentProps, getTypefromKey } from "../helpers";
|
|
8
8
|
|
|
9
9
|
import * as S from "./style";
|
|
10
10
|
|
|
@@ -21,8 +21,13 @@ const SameComponentArray = (props: ISameComponentArrayProps): JSX.Element => {
|
|
|
21
21
|
maxItems,
|
|
22
22
|
disabled,
|
|
23
23
|
activatedModules,
|
|
24
|
+
objKey,
|
|
25
|
+
field,
|
|
24
26
|
} = props;
|
|
25
27
|
|
|
28
|
+
const type = getTypefromKey(objKey);
|
|
29
|
+
const { contentType = type } = field;
|
|
30
|
+
|
|
26
31
|
let addModuleAction: any;
|
|
27
32
|
let addComponentAction: any;
|
|
28
33
|
|
|
@@ -35,14 +40,14 @@ const SameComponentArray = (props: ISameComponentArrayProps): JSX.Element => {
|
|
|
35
40
|
return value.length > 1 ? `#${index + 1} ${name}` : name;
|
|
36
41
|
};
|
|
37
42
|
|
|
38
|
-
const {
|
|
43
|
+
const { kind } = selectedContent;
|
|
39
44
|
|
|
40
|
-
const isModuleArr =
|
|
41
|
-
const isComponentModule =
|
|
45
|
+
const isModuleArr = contentType === "modules";
|
|
46
|
+
const isComponentModule = contentType === "components";
|
|
42
47
|
|
|
43
48
|
const handleAddModule = (moduleType: string) => addModuleAction(moduleType, editorID, isComponentModule);
|
|
44
49
|
|
|
45
|
-
const handleAddComponent = () => addComponentAction && addComponentAction(kind);
|
|
50
|
+
const handleAddComponent = () => addComponentAction && addComponentAction(kind, objKey);
|
|
46
51
|
|
|
47
52
|
const handleAdd = isModuleArr ? handleAddModule : handleAddComponent;
|
|
48
53
|
|
|
@@ -82,6 +87,7 @@ const SameComponentArray = (props: ISameComponentArrayProps): JSX.Element => {
|
|
|
82
87
|
selectedContent={selectedContent}
|
|
83
88
|
disabled={disabled}
|
|
84
89
|
canDuplicate={showAddItemButton && !isModuleDeactivated}
|
|
90
|
+
parentKey={objKey}
|
|
85
91
|
/>
|
|
86
92
|
);
|
|
87
93
|
})}
|
|
@@ -102,6 +108,8 @@ export interface ISameComponentArrayProps {
|
|
|
102
108
|
categories?: any;
|
|
103
109
|
disabled?: boolean;
|
|
104
110
|
activatedModules: string[];
|
|
111
|
+
objKey: string;
|
|
112
|
+
field: any;
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
export default SameComponentArray;
|
|
@@ -29,4 +29,16 @@ const getComponentProps = (element: any, activatedModules: string[], isModuleArr
|
|
|
29
29
|
const containerToComponentArray = (value: Record<string, IComponent>): IComponent[] =>
|
|
30
30
|
Object.values(value).filter((item: IComponent) => !isComponentEmpty(item));
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
const getTypefromKey = (key: string) => {
|
|
33
|
+
switch (key) {
|
|
34
|
+
case "elements":
|
|
35
|
+
case "componentModules":
|
|
36
|
+
return "components";
|
|
37
|
+
case "modules":
|
|
38
|
+
return key;
|
|
39
|
+
default:
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { getComponentTitle, getComponentProps, containerToComponentArray, getTypefromKey };
|
|
@@ -26,6 +26,7 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
|
|
|
26
26
|
arrayLength,
|
|
27
27
|
disabled,
|
|
28
28
|
canDuplicate,
|
|
29
|
+
parentKey,
|
|
29
30
|
} = props;
|
|
30
31
|
|
|
31
32
|
let deleteModuleAction: any;
|
|
@@ -65,8 +66,8 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
|
|
|
65
66
|
}
|
|
66
67
|
};
|
|
67
68
|
|
|
68
|
-
const removeItem = () => deleteModuleAction(editorID);
|
|
69
|
-
const duplicateItem = () => duplicateModuleAction(editorID);
|
|
69
|
+
const removeItem = () => deleteModuleAction(editorID, parentKey);
|
|
70
|
+
const duplicateItem = () => parentKey && duplicateModuleAction(editorID, parentKey);
|
|
70
71
|
|
|
71
72
|
const duplicateOpt = {
|
|
72
73
|
label: "duplicate",
|
|
@@ -99,7 +100,7 @@ const ComponentContainer = (props: IComponentContainerProps): JSX.Element => {
|
|
|
99
100
|
const moveModule = (e: any, isPush: boolean) => {
|
|
100
101
|
e.preventDefault();
|
|
101
102
|
e.stopPropagation();
|
|
102
|
-
moveModuleAction(editorID, selectedContent, isPush);
|
|
103
|
+
moveModuleAction(editorID, selectedContent, isPush, parentKey);
|
|
103
104
|
};
|
|
104
105
|
|
|
105
106
|
const handleOptionClick = (option: any) => actions.addComponentAction(option);
|
|
@@ -177,6 +178,7 @@ interface IComponentContainerProps {
|
|
|
177
178
|
arrayLength: number;
|
|
178
179
|
disabled?: boolean;
|
|
179
180
|
canDuplicate?: boolean;
|
|
181
|
+
parentKey?: string;
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
export default ComponentContainer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import * as S from "./style";
|
|
4
|
+
|
|
5
|
+
const FieldsDivider = (props: IProps): JSX.Element => {
|
|
6
|
+
const { data } = props;
|
|
7
|
+
const { title, text } = data;
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<S.DividerWrapper>
|
|
11
|
+
<S.DividerTitle>{title}</S.DividerTitle>
|
|
12
|
+
<S.DividerText>{text}</S.DividerText>
|
|
13
|
+
</S.DividerWrapper>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
interface IProps {
|
|
18
|
+
data: { title: string; text: string };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default FieldsDivider;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
const DividerWrapper = styled.div`
|
|
4
|
+
padding-top: ${(p) => p.theme.spacing.m};
|
|
5
|
+
border-top: 1px solid ${(p) => p.theme.color.uiLine};
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
const DividerTitle = styled.div`
|
|
9
|
+
${(p) => p.theme.textStyle.headingXS};
|
|
10
|
+
color: ${(p) => p.theme.colors.textHighEmphasis};
|
|
11
|
+
`;
|
|
12
|
+
const DividerText = styled.div`
|
|
13
|
+
${(p) => p.theme.textStyle.uiM};
|
|
14
|
+
color: ${(p) => p.theme.colors.textMediumEmphasis};
|
|
15
|
+
margin-top: ${(p) => p.theme.spacing.xs};
|
|
16
|
+
margin-bottom: ${(p) => p.theme.spacing.s};
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export { DividerWrapper, DividerTitle, DividerText };
|
|
@@ -20,7 +20,7 @@ const RadioGroup = (props: IRadioGroupProps): JSX.Element => {
|
|
|
20
20
|
|
|
21
21
|
const radiosArray = options
|
|
22
22
|
? options.map((item: IRadioFieldProps) => {
|
|
23
|
-
const checked = value.toString() === item.value.toString();
|
|
23
|
+
const checked = value ? value.toString() === item.value.toString() : false;
|
|
24
24
|
return (
|
|
25
25
|
<S.RadioFieldWrapper key={item.name}>
|
|
26
26
|
<RadioField
|
|
@@ -4,16 +4,8 @@ import { IconAction, VisualOption } from "@ax/components";
|
|
|
4
4
|
|
|
5
5
|
import * as S from "./style";
|
|
6
6
|
|
|
7
|
-
const ScrollableSelection = ({
|
|
8
|
-
value,
|
|
9
|
-
onChange,
|
|
10
|
-
actions,
|
|
11
|
-
options,
|
|
12
|
-
objKey,
|
|
13
|
-
columns,
|
|
14
|
-
disabled,
|
|
15
|
-
...props
|
|
16
|
-
}: IScrollableSelectionProps): JSX.Element => {
|
|
7
|
+
const ScrollableSelection = (props: IScrollableSelectionProps): JSX.Element => {
|
|
8
|
+
const { value, onChange, actions, options, objKey, columns, disabled, reference } = props;
|
|
17
9
|
const [carouselIndex, setCarouselIndex] = useState(0);
|
|
18
10
|
const [carouselItemWidth, setCarouselItemWidth] = useState<number>();
|
|
19
11
|
const carouselRef = useRef<HTMLDivElement>(null);
|
|
@@ -22,7 +14,7 @@ const ScrollableSelection = ({
|
|
|
22
14
|
|
|
23
15
|
const handleSelection = (newValue: string) => {
|
|
24
16
|
onChange(newValue);
|
|
25
|
-
actions.replaceElementsInCollectionAction(newValue);
|
|
17
|
+
actions.replaceElementsInCollectionAction(newValue, reference);
|
|
26
18
|
};
|
|
27
19
|
|
|
28
20
|
const handlePreviousPage = () => {
|
|
@@ -90,6 +82,7 @@ interface IScrollableSelectionProps {
|
|
|
90
82
|
disabled?: boolean;
|
|
91
83
|
actions: any;
|
|
92
84
|
selectedContent: any;
|
|
85
|
+
reference?: string;
|
|
93
86
|
}
|
|
94
87
|
|
|
95
88
|
interface IScrollableUniqueSelectionFieldOptionsProps {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ArrayFieldGroup from "./ArrayFieldGroup";
|
|
1
2
|
import AsyncCheckGroup from "./AsyncCheckGroup";
|
|
2
3
|
import AsyncSelect from "./AsyncSelect";
|
|
3
4
|
import CheckField from "./CheckField";
|
|
@@ -7,6 +8,7 @@ import ComponentContainer from "./ComponentContainer";
|
|
|
7
8
|
import ConditionalField from "./ConditionalField";
|
|
8
9
|
import DateField from "./DateField";
|
|
9
10
|
import FieldGroup from "./FieldGroup";
|
|
11
|
+
import FieldsDivider from "./FieldsDivider";
|
|
10
12
|
import HeadingField from "./HeadingField";
|
|
11
13
|
import HiddenField from "./HiddenField";
|
|
12
14
|
import ImageField from "./ImageField";
|
|
@@ -28,6 +30,7 @@ import VisualUniqueSelection from "./VisualUniqueSelection";
|
|
|
28
30
|
import Wysiwyg from "./Wysiwyg";
|
|
29
31
|
|
|
30
32
|
export {
|
|
33
|
+
ArrayFieldGroup,
|
|
31
34
|
AsyncCheckGroup,
|
|
32
35
|
AsyncSelect,
|
|
33
36
|
CheckField,
|
|
@@ -37,6 +40,7 @@ export {
|
|
|
37
40
|
ConditionalField,
|
|
38
41
|
DateField,
|
|
39
42
|
FieldGroup,
|
|
43
|
+
FieldsDivider,
|
|
40
44
|
HeadingField,
|
|
41
45
|
HiddenField,
|
|
42
46
|
ImageField,
|
|
@@ -31,6 +31,7 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
31
31
|
currentPageUrl,
|
|
32
32
|
errors,
|
|
33
33
|
errorActions,
|
|
34
|
+
isFromEditor,
|
|
34
35
|
} = props;
|
|
35
36
|
|
|
36
37
|
const publishedTooltip: any = {
|
|
@@ -43,7 +44,7 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
43
44
|
const fixedClass = fixedAppBar ? "fixed" : "";
|
|
44
45
|
|
|
45
46
|
const goToPages = () => {
|
|
46
|
-
typeof backLink === "string" ? props.history.push(backLink) : props.history.goBack();
|
|
47
|
+
typeof backLink === "string" ? props.history.push(backLink, { isFromEditor }) : props.history.goBack();
|
|
47
48
|
};
|
|
48
49
|
|
|
49
50
|
const getCurrentLanguage = (lang: string) =>
|
|
@@ -251,6 +252,7 @@ interface IAppBarProps {
|
|
|
251
252
|
errorActions?: {
|
|
252
253
|
goToError(editorID: number, tab: string, template: boolean): void;
|
|
253
254
|
};
|
|
255
|
+
isFromEditor?: boolean;
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
type IProps = IAppBarProps & RouteComponentProps;
|
|
@@ -35,6 +35,7 @@ interface IWrapperProps {
|
|
|
35
35
|
currentPageID?: number;
|
|
36
36
|
currentPageUrl?: string;
|
|
37
37
|
fullWidth?: boolean;
|
|
38
|
+
isFromEditor?: boolean;
|
|
38
39
|
languageActions?: {
|
|
39
40
|
setLanguage?(lang: { locale: string; id: number | null }): void;
|
|
40
41
|
setIsNewTranslation?(isNewTranslation: boolean): void;
|
package/src/components/index.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ArrayFieldGroup,
|
|
2
3
|
AsyncCheckGroup,
|
|
3
4
|
AsyncSelect,
|
|
4
5
|
CheckField,
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
8
9
|
ConditionalField,
|
|
9
10
|
DateField,
|
|
10
11
|
FieldGroup,
|
|
12
|
+
FieldsDivider,
|
|
11
13
|
HeadingField,
|
|
12
14
|
HiddenField,
|
|
13
15
|
ImageField,
|
|
@@ -76,6 +78,7 @@ import ElementsTooltip from "./ElementsTooltip";
|
|
|
76
78
|
|
|
77
79
|
export {
|
|
78
80
|
//Fields
|
|
81
|
+
ArrayFieldGroup,
|
|
79
82
|
AsyncCheckGroup,
|
|
80
83
|
AsyncSelect,
|
|
81
84
|
CheckField,
|
|
@@ -85,6 +88,7 @@ export {
|
|
|
85
88
|
ConditionalField,
|
|
86
89
|
DateField,
|
|
87
90
|
FieldGroup,
|
|
91
|
+
FieldsDivider,
|
|
88
92
|
HeadingField,
|
|
89
93
|
HiddenField,
|
|
90
94
|
ImageField,
|
|
@@ -4,11 +4,11 @@ import { navigation } from "@ax/api";
|
|
|
4
4
|
import { IBreadcrumbItem, ISchema } from "@ax/types";
|
|
5
5
|
import { getDefaultSchema, getSchema, handleRequest, removeEditorIds, deepClone, getNullValue } from "@ax/helpers";
|
|
6
6
|
import {
|
|
7
|
-
deleteComponent,
|
|
8
7
|
findByEditorID,
|
|
9
8
|
generateEditorIDs,
|
|
10
9
|
getLastComponentEditorID,
|
|
11
10
|
getNewBreadcrumb,
|
|
11
|
+
getParentKey,
|
|
12
12
|
moveElement,
|
|
13
13
|
replaceElements,
|
|
14
14
|
setIsSavedData,
|
|
@@ -441,7 +441,7 @@ const updateCollection = (elementType: string, prevCollection: any[]) => {
|
|
|
441
441
|
return [...prevCollection, newModule];
|
|
442
442
|
};
|
|
443
443
|
|
|
444
|
-
const getUpdatedComponents = (editorContent: any, element: any) => {
|
|
444
|
+
const getUpdatedComponents = (editorContent: any, element: any, key: string) => {
|
|
445
445
|
const { editorID, type } = element;
|
|
446
446
|
const isCollectionItem = typeof type === "string";
|
|
447
447
|
const updatedDefault = isCollectionItem ? deepClone(editorContent) : editorContent;
|
|
@@ -449,7 +449,7 @@ const getUpdatedComponents = (editorContent: any, element: any) => {
|
|
|
449
449
|
const mapValues = (item: any) => {
|
|
450
450
|
if (item.editorID !== undefined && item.editorID === editorID) {
|
|
451
451
|
if (isCollectionItem) {
|
|
452
|
-
item
|
|
452
|
+
item[key] = updateCollection(type, item[key]);
|
|
453
453
|
} else {
|
|
454
454
|
addElement(type);
|
|
455
455
|
}
|
|
@@ -468,41 +468,39 @@ const getUpdatedComponents = (editorContent: any, element: any) => {
|
|
|
468
468
|
return updatedDefault;
|
|
469
469
|
};
|
|
470
470
|
|
|
471
|
-
function addComponent(type: any): (dispatch: Dispatch, getState: any) => void {
|
|
471
|
+
function addComponent(type: any, key: string): (dispatch: Dispatch, getState: any) => void {
|
|
472
472
|
return (dispatch, getState) => {
|
|
473
473
|
const { editorContent, selectedEditorID } = getStateValues(getState);
|
|
474
474
|
const component = {
|
|
475
475
|
editorID: selectedEditorID,
|
|
476
476
|
type,
|
|
477
477
|
};
|
|
478
|
-
const updatedContent = getUpdatedComponents(editorContent, component);
|
|
478
|
+
const updatedContent = getUpdatedComponents(editorContent, component, key);
|
|
479
479
|
generateContent(updatedContent, dispatch, getState);
|
|
480
480
|
|
|
481
481
|
if (type.editorID) {
|
|
482
482
|
setSelectedContent(type.editorID)(dispatch, getState);
|
|
483
483
|
} else {
|
|
484
484
|
const { editorContent } = getStateValues(getState);
|
|
485
|
-
const lastElementEditorID = getLastComponentEditorID(editorContent, component.editorID);
|
|
485
|
+
const lastElementEditorID = getLastComponentEditorID(editorContent, component.editorID, key);
|
|
486
486
|
setSelectedContent(lastElementEditorID)(dispatch, getState);
|
|
487
487
|
}
|
|
488
488
|
};
|
|
489
489
|
}
|
|
490
490
|
|
|
491
|
-
function deleteModule(editorID: number): (dispatch: Dispatch, getState: any) => void {
|
|
491
|
+
function deleteModule(editorID: number, key: string): (dispatch: Dispatch, getState: any) => void {
|
|
492
492
|
return (dispatch, getState) => {
|
|
493
493
|
const { editorContent } = getStateValues(getState);
|
|
494
494
|
const updatedContent: any = deepClone(editorContent);
|
|
495
495
|
|
|
496
|
-
|
|
497
|
-
if (module.elements) {
|
|
498
|
-
module.elements = deleteComponent(module.elements, editorID);
|
|
499
|
-
}
|
|
500
|
-
return module.editorID !== editorID;
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
const { parent, grandParent } = findByEditorID(editorContent, editorID);
|
|
496
|
+
const { parent, grandParent } = findByEditorID(updatedContent, editorID);
|
|
504
497
|
const parentModule = Array.isArray(parent) ? grandParent : parent;
|
|
505
|
-
|
|
498
|
+
|
|
499
|
+
const parentKey = key ? key : getParentKey(parentModule, editorID);
|
|
500
|
+
const itemsArr = parentModule[parentKey];
|
|
501
|
+
|
|
502
|
+
const index = itemsArr.findIndex((module: any) => module.editorID === editorID);
|
|
503
|
+
itemsArr.splice(index, 1);
|
|
506
504
|
|
|
507
505
|
generateContent(updatedContent, dispatch, getState);
|
|
508
506
|
};
|
|
@@ -530,7 +528,7 @@ function replaceModule(module: any, parent: any, objKey: string): (dispatch: Dis
|
|
|
530
528
|
};
|
|
531
529
|
}
|
|
532
530
|
|
|
533
|
-
function duplicateModule(editorID: number): (dispatch: Dispatch, getState: any) => void {
|
|
531
|
+
function duplicateModule(editorID: number, key?: string): (dispatch: Dispatch, getState: any) => void {
|
|
534
532
|
return (dispatch, getState) => {
|
|
535
533
|
const { editorContent } = getStateValues(getState);
|
|
536
534
|
|
|
@@ -538,33 +536,39 @@ function duplicateModule(editorID: number): (dispatch: Dispatch, getState: any)
|
|
|
538
536
|
const { element: originalItem, parent, grandParent } = findByEditorID(updatedContent, editorID);
|
|
539
537
|
const parentModule = Array.isArray(parent) ? grandParent : parent;
|
|
540
538
|
|
|
541
|
-
const
|
|
539
|
+
const parentKey = key ? key : getParentKey(parentModule, editorID);
|
|
540
|
+
const itemsArr = parentModule[parentKey];
|
|
542
541
|
|
|
543
|
-
const originalItemIndex =
|
|
542
|
+
const originalItemIndex = itemsArr.findIndex((module: any) => module.editorID === editorID);
|
|
544
543
|
const duplicatedItemIndex = originalItemIndex + 1;
|
|
545
|
-
|
|
544
|
+
itemsArr.splice(duplicatedItemIndex, 0, originalItem);
|
|
546
545
|
|
|
547
546
|
generateContent(updatedContent, dispatch, getState);
|
|
548
547
|
|
|
549
548
|
const { editorContent: generatedContent } = getStateValues(getState);
|
|
550
549
|
const { parent: generatedParent, grandParent: generatedGrandParent } = findByEditorID(generatedContent, editorID);
|
|
551
550
|
const module = Array.isArray(generatedParent) ? generatedGrandParent : generatedParent;
|
|
552
|
-
const duplicatedEditorID = module
|
|
551
|
+
const duplicatedEditorID = module[parentKey][duplicatedItemIndex].editorID;
|
|
553
552
|
|
|
554
553
|
setSelectedContent(duplicatedEditorID)(dispatch, getState);
|
|
555
554
|
};
|
|
556
555
|
}
|
|
557
556
|
|
|
558
|
-
function moveModule(
|
|
557
|
+
function moveModule(
|
|
558
|
+
elementID: number,
|
|
559
|
+
content: any,
|
|
560
|
+
isPush: boolean,
|
|
561
|
+
key: string
|
|
562
|
+
): (dispatch: Dispatch, getState: any) => void {
|
|
559
563
|
return async (dispatch, getState) => {
|
|
560
564
|
try {
|
|
561
565
|
const {
|
|
562
566
|
navigation: { selectedContent, editorContent },
|
|
563
567
|
} = getState();
|
|
564
568
|
|
|
565
|
-
const contentElements = [...selectedContent
|
|
569
|
+
const contentElements = [...selectedContent[key]];
|
|
566
570
|
const { element: selectedModule } = findByEditorID(editorContent, selectedContent.editorID);
|
|
567
|
-
selectedModule
|
|
571
|
+
selectedModule[key] = moveElement(elementID, contentElements, isPush);
|
|
568
572
|
|
|
569
573
|
generateContent(editorContent, dispatch, getState);
|
|
570
574
|
} catch {
|
|
@@ -573,13 +577,14 @@ function moveModule(elementID: number, content: any, isPush: boolean): (dispatch
|
|
|
573
577
|
};
|
|
574
578
|
}
|
|
575
579
|
|
|
576
|
-
function replaceElementsInCollection(newValue: string): (dispatch: Dispatch, getState: any) => void {
|
|
580
|
+
function replaceElementsInCollection(newValue: string, reference: string): (dispatch: Dispatch, getState: any) => void {
|
|
577
581
|
return async (dispatch, getState) => {
|
|
578
582
|
const { selectedContent } = getStateValues(getState);
|
|
583
|
+
const key = reference ? reference : "elements";
|
|
579
584
|
|
|
580
|
-
const updatedContent = replaceElements(selectedContent
|
|
585
|
+
const updatedContent = replaceElements(selectedContent[key], newValue);
|
|
581
586
|
|
|
582
|
-
updateEditorContent(selectedContent.editorID,
|
|
587
|
+
updateEditorContent(selectedContent.editorID, key, updatedContent)(dispatch, getState);
|
|
583
588
|
};
|
|
584
589
|
}
|
|
585
590
|
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
getUpdatedComponents,
|
|
16
16
|
getUpdatedSections,
|
|
17
17
|
updateComponent,
|
|
18
|
-
deleteModules,
|
|
19
18
|
updateByEditorID,
|
|
20
19
|
findByEditorID,
|
|
21
20
|
generateEditorIDs,
|
|
@@ -26,6 +25,7 @@ import {
|
|
|
26
25
|
getLastComponentEditorID,
|
|
27
26
|
replaceElements,
|
|
28
27
|
findMandatoryFieldsErrors,
|
|
28
|
+
getParentKey,
|
|
29
29
|
} from "@ax/forms";
|
|
30
30
|
import { appActions } from "@ax/containers/App";
|
|
31
31
|
import { navigationActions } from "@ax/containers/Navigation";
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
SET_SELECTED_PARENT,
|
|
49
49
|
SET_ERRORS,
|
|
50
50
|
SET_VALIDATED,
|
|
51
|
+
SET_SITE_PAGE_ID,
|
|
51
52
|
} from "./constants";
|
|
52
53
|
|
|
53
54
|
import { IPage, ISavePageParams, IBreadcrumbItem, ISchema, IErrorItem } from "@ax/types";
|
|
@@ -69,6 +70,7 @@ import {
|
|
|
69
70
|
ISetSelectedParent,
|
|
70
71
|
ISetErrors,
|
|
71
72
|
ISetValidated,
|
|
73
|
+
ISetSitePageID,
|
|
72
74
|
} from "./interfaces";
|
|
73
75
|
|
|
74
76
|
const { setIsLoading, setIsSaving } = appActions;
|
|
@@ -141,6 +143,10 @@ function setValidated(validated: boolean): ISetValidated {
|
|
|
141
143
|
return { type: SET_VALIDATED, payload: { validated } };
|
|
142
144
|
}
|
|
143
145
|
|
|
146
|
+
function setSitePageID(sitePageID: number | null): ISetSitePageID {
|
|
147
|
+
return { type: SET_SITE_PAGE_ID, payload: { sitePageID } };
|
|
148
|
+
}
|
|
149
|
+
|
|
144
150
|
function createNewTranslation(isNewTranslation: boolean): (dispatch: Dispatch, getState: any) => void {
|
|
145
151
|
return async (dispatch, getState) => {
|
|
146
152
|
try {
|
|
@@ -456,7 +462,7 @@ function addTemplate(template: string): (dispatch: Dispatch) => Promise<void> {
|
|
|
456
462
|
};
|
|
457
463
|
}
|
|
458
464
|
|
|
459
|
-
function addComponent(type: any): (dispatch: Dispatch, getState: any) => void {
|
|
465
|
+
function addComponent(type: any, key: string): (dispatch: Dispatch, getState: any) => void {
|
|
460
466
|
return (dispatch, getState) => {
|
|
461
467
|
const { editorContent, sections, editorID } = getStateValues(getState);
|
|
462
468
|
const component = {
|
|
@@ -464,7 +470,7 @@ function addComponent(type: any): (dispatch: Dispatch, getState: any) => void {
|
|
|
464
470
|
type,
|
|
465
471
|
};
|
|
466
472
|
|
|
467
|
-
const updatedObj = getUpdatedComponents(sections, component);
|
|
473
|
+
const updatedObj = getUpdatedComponents(sections, component, key);
|
|
468
474
|
const updatedSections = updatedObj.updatedSections;
|
|
469
475
|
|
|
470
476
|
const updatedPageContent = {
|
|
@@ -481,7 +487,7 @@ function addComponent(type: any): (dispatch: Dispatch, getState: any) => void {
|
|
|
481
487
|
setSelectedContent(type.editorID)(dispatch, getState);
|
|
482
488
|
} else {
|
|
483
489
|
const { sections: generatedSections } = getStateValues(getState);
|
|
484
|
-
const lastElementEditorID = getLastComponentEditorID(generatedSections, component.editorID);
|
|
490
|
+
const lastElementEditorID = getLastComponentEditorID(generatedSections, component.editorID, key);
|
|
485
491
|
setSelectedContent(lastElementEditorID)(dispatch, getState);
|
|
486
492
|
}
|
|
487
493
|
};
|
|
@@ -490,6 +496,7 @@ function addComponent(type: any): (dispatch: Dispatch, getState: any) => void {
|
|
|
490
496
|
function addModule(
|
|
491
497
|
type: string,
|
|
492
498
|
selectedID: number,
|
|
499
|
+
key: string,
|
|
493
500
|
isComponentModule?: boolean
|
|
494
501
|
): (dispatch: Dispatch, getState: any) => void {
|
|
495
502
|
return (dispatch, getState) => {
|
|
@@ -503,7 +510,7 @@ function addModule(
|
|
|
503
510
|
updatedSectionIndex = 0;
|
|
504
511
|
|
|
505
512
|
if (isComponentModule) {
|
|
506
|
-
const updatedObj = getUpdatedComponents(sections, componentModule);
|
|
513
|
+
const updatedObj = getUpdatedComponents(sections, componentModule, key);
|
|
507
514
|
updatedSections = updatedObj.updatedSections;
|
|
508
515
|
updatedSectionIndex = updatedObj.selectedIndex;
|
|
509
516
|
} else {
|
|
@@ -551,33 +558,44 @@ function replaceModule(module: any, parent: any, objKey: string): (dispatch: Dis
|
|
|
551
558
|
};
|
|
552
559
|
}
|
|
553
560
|
|
|
554
|
-
function replaceElementsInCollection(newValue: string): (dispatch: Dispatch, getState: any) => void {
|
|
561
|
+
function replaceElementsInCollection(newValue: string, reference: string): (dispatch: Dispatch, getState: any) => void {
|
|
555
562
|
return async (dispatch, getState) => {
|
|
556
563
|
const { selectedContent } = getStateValues(getState);
|
|
557
564
|
|
|
558
|
-
const
|
|
565
|
+
const key = reference ? reference : "elements";
|
|
566
|
+
const updatedContent = replaceElements(selectedContent[key], newValue);
|
|
559
567
|
|
|
560
|
-
updateEditorContent(selectedContent.editorID,
|
|
568
|
+
updateEditorContent(selectedContent.editorID, key, updatedContent)(dispatch, getState);
|
|
561
569
|
|
|
562
570
|
const { editorContent } = getStateValues(getState);
|
|
563
571
|
generatePageContent(editorContent, dispatch, getState);
|
|
564
572
|
};
|
|
565
573
|
}
|
|
566
574
|
|
|
567
|
-
function deleteModule(editorID: number): (dispatch: Dispatch, getState: any) => void {
|
|
575
|
+
function deleteModule(editorID: number, key?: string): (dispatch: Dispatch, getState: any) => void {
|
|
568
576
|
return (dispatch, getState) => {
|
|
569
|
-
const {
|
|
570
|
-
|
|
577
|
+
const { sections, editorContent } = getStateValues(getState);
|
|
578
|
+
|
|
579
|
+
const updatedSections: any = [...sections];
|
|
580
|
+
const { parent, grandParent } = findByEditorID(updatedSections, editorID);
|
|
581
|
+
const parentModule = Array.isArray(parent) ? grandParent : parent;
|
|
582
|
+
|
|
583
|
+
const parentKey = key ? key : getParentKey(parentModule, editorID);
|
|
584
|
+
const itemsArr = parentModule[parentKey];
|
|
585
|
+
|
|
586
|
+
const index = itemsArr.findIndex((module: any) => module.editorID === editorID);
|
|
587
|
+
itemsArr.splice(index, 1);
|
|
571
588
|
|
|
572
589
|
const updatedPageContent = {
|
|
573
590
|
...editorContent,
|
|
591
|
+
sections: [...updatedSections],
|
|
574
592
|
};
|
|
575
593
|
|
|
576
594
|
generatePageContent(updatedPageContent, dispatch, getState);
|
|
577
595
|
};
|
|
578
596
|
}
|
|
579
597
|
|
|
580
|
-
function duplicateModule(editorID: number): (dispatch: Dispatch, getState: any) => void {
|
|
598
|
+
function duplicateModule(editorID: number, key?: string): (dispatch: Dispatch, getState: any) => void {
|
|
581
599
|
return (dispatch, getState) => {
|
|
582
600
|
const { sections, editorContent } = getStateValues(getState);
|
|
583
601
|
|
|
@@ -585,9 +603,8 @@ function duplicateModule(editorID: number): (dispatch: Dispatch, getState: any)
|
|
|
585
603
|
const { element: originalItem, parent, grandParent } = findByEditorID(updatedSections, editorID);
|
|
586
604
|
const parentModule = Array.isArray(parent) ? grandParent : parent;
|
|
587
605
|
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
const itemsArr = modules ? modules : elements ? elements : componentModules;
|
|
606
|
+
const parentKey = key ? key : getParentKey(parentModule, editorID);
|
|
607
|
+
const itemsArr = parentModule[parentKey];
|
|
591
608
|
|
|
592
609
|
const originalItemIndex = itemsArr.findIndex((module: any) => module.editorID === editorID);
|
|
593
610
|
const duplicatedItemIndex = originalItemIndex + 1;
|
|
@@ -603,11 +620,7 @@ function duplicateModule(editorID: number): (dispatch: Dispatch, getState: any)
|
|
|
603
620
|
const { sections: generatedSections } = getStateValues(getState);
|
|
604
621
|
const { parent: generatedParent, grandParent: generatedGrandParent } = findByEditorID(generatedSections, editorID);
|
|
605
622
|
const section = Array.isArray(generatedParent) ? generatedGrandParent : generatedParent;
|
|
606
|
-
const duplicatedEditorID =
|
|
607
|
-
? section.modules[duplicatedItemIndex].editorID
|
|
608
|
-
: elements
|
|
609
|
-
? section.elements[duplicatedItemIndex].editorID
|
|
610
|
-
: section.componentModules[duplicatedItemIndex].editorID;
|
|
623
|
+
const duplicatedEditorID = section[parentKey][duplicatedItemIndex].editorID;
|
|
611
624
|
|
|
612
625
|
setSelectedContent(duplicatedEditorID)(dispatch, getState);
|
|
613
626
|
};
|
|
@@ -759,6 +772,7 @@ function resetPageEditor(): (dispatch: Dispatch) => Promise<void> {
|
|
|
759
772
|
dispatch(setTemplateConfig({}));
|
|
760
773
|
dispatch(setErrors([]));
|
|
761
774
|
dispatch(setValidated(false));
|
|
775
|
+
dispatch(setSitePageID(null));
|
|
762
776
|
localStorage.removeItem("selectedID");
|
|
763
777
|
} catch (e) {
|
|
764
778
|
console.log("Error", e); //TODO
|
|
@@ -766,7 +780,12 @@ function resetPageEditor(): (dispatch: Dispatch) => Promise<void> {
|
|
|
766
780
|
};
|
|
767
781
|
}
|
|
768
782
|
|
|
769
|
-
function moveElement(
|
|
783
|
+
function moveElement(
|
|
784
|
+
elementID: number,
|
|
785
|
+
content: any,
|
|
786
|
+
isPush: boolean,
|
|
787
|
+
key: string
|
|
788
|
+
): (dispatch: Dispatch, getState: any) => void {
|
|
770
789
|
return async (dispatch, getState) => {
|
|
771
790
|
try {
|
|
772
791
|
const { selectedContent, editorContent } = getState().pageEditor;
|
|
@@ -776,6 +795,7 @@ function moveElement(elementID: number, content: any, isPush: boolean): (dispatc
|
|
|
776
795
|
selectedContent,
|
|
777
796
|
isPush,
|
|
778
797
|
page: editorContent.editorContent,
|
|
798
|
+
key,
|
|
779
799
|
});
|
|
780
800
|
|
|
781
801
|
generatePageContent(newContent, dispatch, getState);
|
|
@@ -847,11 +867,12 @@ function getGlobalFromLocalPage(): (dispatch: Dispatch, getState: any) => Promis
|
|
|
847
867
|
dispatch(setIsLoading(true));
|
|
848
868
|
|
|
849
869
|
const {
|
|
850
|
-
pageEditor: { editorContent: content },
|
|
870
|
+
pageEditor: { editorContent: content, currentPageID },
|
|
851
871
|
} = getState();
|
|
852
872
|
|
|
853
873
|
const { originalGlobalPage } = content.editorContent;
|
|
854
874
|
|
|
875
|
+
dispatch(setSitePageID(currentPageID));
|
|
855
876
|
dispatch(setCurrentPageID(originalGlobalPage));
|
|
856
877
|
} catch (e) {
|
|
857
878
|
console.log(e);
|
|
@@ -899,4 +920,5 @@ export {
|
|
|
899
920
|
deleteError,
|
|
900
921
|
restorePage,
|
|
901
922
|
getGlobalFromLocalPage,
|
|
923
|
+
setSitePageID,
|
|
902
924
|
};
|
|
@@ -16,6 +16,7 @@ export const SET_IS_NEW_TRANSLATION = `${NAME}/SET_IS_NEW_TRANSLATION`;
|
|
|
16
16
|
export const SET_TEMPLATE_CONFIG = `${NAME}/SET_TEMPLATE_CONFIG`;
|
|
17
17
|
export const SET_ERRORS = `${NAME}/SET_ERRORS`;
|
|
18
18
|
export const SET_VALIDATED = `${NAME}/SET_VALIDATED`;
|
|
19
|
+
export const SET_SITE_PAGE_ID = `${NAME}/SET_SITE_PAGE_ID`;
|
|
19
20
|
|
|
20
21
|
export const INITIAL_TEMPLATE = "BasicTemplate";
|
|
21
22
|
export const MULTIMEDIA_COMPONENTS = ["LinkableImage", "Video"];
|