@griddo/ax 11.9.7-rc.0 → 11.9.7-rc.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "11.9.7-rc.0",
4
+ "version": "11.9.7-rc.1",
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": "7ad8a35489434b7eded0493be9d5e2680369a694"
228
+ "gitHead": "e2ee7aff8a992dc64b94c9aaf22734bae96140aa"
229
229
  }
@@ -31,13 +31,14 @@ const NavConnectedField = (props: any): JSX.Element => {
31
31
  tab,
32
32
  } = props;
33
33
 
34
- const updateValue = (key: string, value: any) => {
34
+ const updateValue = (key: string, value: any, templateID?: number) => {
35
35
  const isMenu = field.entity && field.entity === "menu_containers";
36
+ const editorID = templateID ? templateID : selectedEditorID;
36
37
  if (isMenu) {
37
38
  const menu = menus.find((menu: any) => menu.id === value);
38
39
  updateEditorContent(selectedEditorID, key, menu);
39
40
  } else {
40
- updateEditorContent(selectedEditorID, key, value);
41
+ updateEditorContent(editorID, key, value);
41
42
  }
42
43
  };
43
44
 
@@ -85,6 +86,9 @@ const NavConnectedField = (props: any): JSX.Element => {
85
86
  return !isHidden;
86
87
  });
87
88
 
89
+ const templateContent = selectedContent.template;
90
+ const handleUpdate = (fieldKey: string, value: any) => updateValue(fieldKey, value, templateContent.editorID);
91
+
88
92
  return (
89
93
  <>
90
94
  {templateFields.map((formField) => {
@@ -95,9 +99,9 @@ const NavConnectedField = (props: any): JSX.Element => {
95
99
  key={key}
96
100
  objKey={key}
97
101
  field={formField}
98
- selectedContent={selectedContent}
102
+ selectedContent={templateContent}
99
103
  goTo={goTo}
100
- updateValue={updateValue}
104
+ updateValue={handleUpdate}
101
105
  pages={pages}
102
106
  actions={actions}
103
107
  site={site}
@@ -20,6 +20,7 @@ import {
20
20
  getNullValue,
21
21
  getDefaultNavigationModules,
22
22
  getImageFromHtml,
23
+ protectFormKeys,
23
24
  } from "@ax/helpers";
24
25
  import {
25
26
  findByEditorID,
@@ -800,15 +801,24 @@ function updateEditorContent(
800
801
  navigation: { selectedContent, editorContent },
801
802
  } = getState();
802
803
 
804
+ const isFormPage = selectedContent.component === "FormPage";
803
805
  const clonedSelected = deepClone(selectedContent);
804
806
  const clonedEditor = deepClone(editorContent);
805
807
 
808
+ if (isFormPage) {
809
+ protectFormKeys(clonedEditor, key, selectedEditorID);
810
+ }
811
+
806
812
  const updatedSelectedContent = updateByEditorID(clonedSelected, selectedEditorID, key, value);
807
813
  const updatedEditorContent = updateByEditorID(clonedEditor, selectedEditorID, key, value);
808
814
  dispatch(setSelectedDefaultContent(updatedSelectedContent));
809
815
  dispatch(setEditorContent(updatedEditorContent));
810
816
 
811
- generateContent(updatedEditorContent)(dispatch, getState);
817
+ const isObjectValue = value !== null && typeof value === "object";
818
+
819
+ if (isObjectValue) {
820
+ generateContent(updatedEditorContent)(dispatch, getState);
821
+ }
812
822
  };
813
823
  }
814
824
 
@@ -10,6 +10,7 @@ import {
10
10
  getCurrentPageStructuredData,
11
11
  getNullValue,
12
12
  handleRequest,
13
+ protectFormKeys,
13
14
  } from "@ax/helpers";
14
15
  import {
15
16
  getUpdatedComponents,
@@ -44,7 +45,6 @@ import {
44
45
  getPageData,
45
46
  getPageNavigation,
46
47
  getStateValues,
47
- protectFormKeys,
48
48
  addElementToCollection,
49
49
  } from "./utils";
50
50
  import {
@@ -1095,12 +1095,8 @@ function updateEditorContent(
1095
1095
  const clonedContent = deepClone(editorContent);
1096
1096
  const clonedSelected = deepClone(selectedContent);
1097
1097
 
1098
- if (clonedSelected.component === "FormPage") {
1099
- if (Array.isArray(key)) {
1100
- key.forEach((k) => protectFormKeys(clonedContent, k));
1101
- } else {
1102
- protectFormKeys(clonedContent, key);
1103
- }
1098
+ if (clonedSelected.component === "FormPage" && !Array.isArray(key)) {
1099
+ protectFormKeys(clonedContent, key, selectedEditorID);
1104
1100
  }
1105
1101
 
1106
1102
  const updatedSelectedContent = updateByEditorID(clonedSelected, selectedEditorID, key, value);
@@ -1,5 +1,5 @@
1
1
  import { IIntegration, IRootState, ISavePageParams } from "@ax/types";
2
- import { cleanContent, findByComponent, updateElementCollection } from "@ax/forms";
2
+ import { cleanContent, updateElementCollection } from "@ax/forms";
3
3
  import { Dispatch } from "redux";
4
4
  import { generatePageContent } from "./actions";
5
5
 
@@ -125,18 +125,6 @@ const getDefaultPageNavigation = (defaultsContent: any, type: string) => {
125
125
  return navitagion;
126
126
  };
127
127
 
128
- const protectFormKeys = (content: any, key: string) => {
129
- const formComponent = findByComponent(content, "FormPage");
130
- if (!formComponent) return;
131
-
132
- const protectedKeys = formComponent.protectedKeys || [];
133
- if (!protectedKeys.includes(key)) {
134
- formComponent.protectedKeys = [...protectedKeys, key];
135
- }
136
-
137
- return content;
138
- };
139
-
140
128
  const addElementToCollection = (type: string, key: string, dispatch: Dispatch, getState: () => IRootState) => {
141
129
  const { editorContent } = getStateValues(getState);
142
130
  const updatedComponent = updateElementCollection(type, editorContent.template[key]);
@@ -156,6 +144,5 @@ export {
156
144
  getPageNavigation,
157
145
  getDefaultIntegrations,
158
146
  getDefaultPageNavigation,
159
- protectFormKeys,
160
147
  addElementToCollection,
161
148
  };
@@ -0,0 +1,18 @@
1
+ import { findByEditorID } from "@ax/forms";
2
+
3
+ const protectFormKeys = (content: any, key: string, editorID: number) => {
4
+ const { parent: formComponent } = findByEditorID(content, editorID);
5
+ if (!formComponent) return;
6
+
7
+ if (!Array.isArray(formComponent.protectedKeys)) {
8
+ formComponent.protectedKeys = [];
9
+ }
10
+
11
+ if (!formComponent.protectedKeys.includes(key)) {
12
+ formComponent.protectedKeys.push(key);
13
+ }
14
+
15
+ return formComponent;
16
+ };
17
+
18
+ export { protectFormKeys };
@@ -124,6 +124,8 @@ import { getFileIcon, getNewBreadcrumb, updatePropertyById } from "./files";
124
124
 
125
125
  import { getMaxColumns, updateColumns } from "./customColumns";
126
126
 
127
+ import { protectFormKeys } from "./forms";
128
+
127
129
  export {
128
130
  isComponentEmpty,
129
131
  setAsContainedComponent,
@@ -233,4 +235,5 @@ export {
233
235
  findObjectValue,
234
236
  removeDuplicatesByProperty,
235
237
  delay,
238
+ protectFormKeys,
236
239
  };