@griddo/ax 1.75.239 → 1.75.241

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": "1.75.239",
4
+ "version": "1.75.241",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -230,5 +230,5 @@
230
230
  "publishConfig": {
231
231
  "access": "public"
232
232
  },
233
- "gitHead": "f551ff2a20f234d26bbe6c2b16c15f9fe3a7b1de"
233
+ "gitHead": "ed73d8fd6389ceb4f2e2dd6b95a102353b1186a4"
234
234
  }
@@ -281,12 +281,13 @@ function setItemValue(page: IMenuItem): (dispatch: Dispatch) => Promise<void> {
281
281
  };
282
282
  }
283
283
 
284
- function updateForm(valueObj: any): (dispatch: Dispatch, getState: any) => void {
284
+ function updateFormValue(valueObj: any): (dispatch: Dispatch, getState: any) => void {
285
285
  return (dispatch, getState) => {
286
286
  const {
287
287
  menu: { form },
288
288
  } = getState();
289
289
  const updatedForm = { ...form, ...valueObj };
290
+
290
291
  dispatch(setMenuFormData(updatedForm));
291
292
  };
292
293
  }
@@ -338,5 +339,5 @@ export {
338
339
  resetItemValues,
339
340
  resetMenuValues,
340
341
  reorderMenu,
341
- updateForm,
342
+ updateFormValue,
342
343
  };
@@ -33,14 +33,11 @@ const initialState = {
33
33
  type: "MainMenu",
34
34
  item: null,
35
35
  form: {
36
- itemLink: null,
37
- itemImage: null,
38
- itemLabel: "",
39
- itemAuxText: "",
36
+ url: null,
37
+ label: "",
40
38
  type: "link",
41
39
  headerStyle: "",
42
40
  footerStyle: "",
43
- itemSpecial: false,
44
41
  },
45
42
  totalItems: 0,
46
43
  };
@@ -46,6 +46,7 @@ import {
46
46
  getDisplayName,
47
47
  getTemplateType,
48
48
  getTemplateDisplayName,
49
+ getMenuItems,
49
50
  filterByCategory,
50
51
  getSchemaType,
51
52
  getModuleCategories,
@@ -133,6 +134,7 @@ export {
133
134
  getTemplateDisplayName,
134
135
  getSchemaThumbnails,
135
136
  getTemplateThumbnails,
137
+ getMenuItems,
136
138
  filterByCategory,
137
139
  getStructuredDataFromPage,
138
140
  getCurrentPageStructuredData,
@@ -74,6 +74,8 @@ const getTemplateDisplayName = (template: string) => {
74
74
  return schema ? schema.displayName : undefined;
75
75
  };
76
76
 
77
+ const getMenuItems = (type: string): ({ fields: any[] } | undefined) => schemas.menuItems[type];
78
+
77
79
  const filterByCategory = (options: any, category: string) =>
78
80
  options.filter((option: any) => allSchemas[option].category === category);
79
81
 
@@ -153,6 +155,7 @@ export {
153
155
  getSchemaType,
154
156
  getTemplateType,
155
157
  getTemplateDisplayName,
158
+ getMenuItems,
156
159
  filterByCategory,
157
160
  getModuleCategories,
158
161
  getModuleStyles,
@@ -44,18 +44,15 @@ const Item = (props: IItemProps): JSX.Element => {
44
44
  const resetValues = () => resetItemValues();
45
45
 
46
46
  const setItem = (item: IMenuItem) => {
47
- const type = item.config ? item.config.type : "link";
48
- const headerStyle = item.config ? item.config.headerStyle : "";
49
- const footerStyle = item.config ? item.config.footerStyle : "";
47
+ const { config, ...rest } = item;
48
+ const type = config ? config.type : "link";
49
+ const headerStyle = config ? config.headerStyle : "";
50
+ const footerStyle = config ? config.footerStyle : "";
50
51
  setItemValue(item);
51
- updateFormValue({ itemLink: item.url });
52
- updateFormValue({ itemLabel: item.label });
53
- updateFormValue({ itemAuxText: item.auxText });
54
- updateFormValue({ itemImage: item.image });
55
52
  updateFormValue({ type });
56
53
  updateFormValue({ headerStyle });
57
54
  updateFormValue({ footerStyle });
58
- updateFormValue({ itemSpecial: item.special || false });
55
+ updateFormValue(rest);
59
56
  };
60
57
 
61
58
  const openModal = () => {
@@ -132,7 +129,7 @@ const mapDispatchToProps = {
132
129
  deleteMenuItem: menuActions.deleteMenuItem,
133
130
  resetItemValues: menuActions.resetItemValues,
134
131
  setItemValue: menuActions.setItemValue,
135
- updateFormValue: menuActions.updateForm,
132
+ updateFormValue: menuActions.updateFormValue,
136
133
  };
137
134
 
138
135
  type IItemProps = IProps & IDispatchProps;
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+ import { connect } from "react-redux";
3
+
4
+ import { IRootState } from "@ax/types";
5
+ import { menuActions } from "@ax/containers/Navigation/Menu";
6
+ import { FieldsBehavior } from "@ax/components";
7
+
8
+ const ConnectedField = (props: IProps) => {
9
+ const { form, type, name, updateFormValue, setIsGalleryOpened } = props;
10
+
11
+ const value = form[name];
12
+
13
+ const handleChange = (newValue: any) => updateFormValue({ [name]: newValue });
14
+
15
+ const fieldProps = {
16
+ value,
17
+ onChange: handleChange,
18
+ setIsGalleryOpened: type === "ImageField" ? setIsGalleryOpened : undefined,
19
+ ...props,
20
+ };
21
+
22
+ return <FieldsBehavior fieldType={type} {...fieldProps} />;
23
+ };
24
+
25
+ interface IProps {
26
+ form: any;
27
+ type: string;
28
+ title: string;
29
+ name: string;
30
+ mandatory?: boolean;
31
+ helptext?: string;
32
+ options?: any;
33
+ updateFormValue: (value: any) => void;
34
+ setIsGalleryOpened?: (isGalleryOpened: boolean) => void;
35
+ }
36
+
37
+ const mapStateToProps = (state: IRootState) => ({
38
+ form: state.menu.form,
39
+ });
40
+
41
+ const mapDispatchToProps = {
42
+ updateFormValue: menuActions.updateFormValue,
43
+ };
44
+
45
+ export default connect(mapStateToProps, mapDispatchToProps)(ConnectedField)
@@ -1,23 +1,22 @@
1
1
  import React, { memo } from "react";
2
-
3
2
  import { connect } from "react-redux";
3
+
4
4
  import { menuActions } from "@ax/containers/Navigation";
5
5
  import { sitesActions } from "@ax/containers/Sites";
6
6
  import { FieldsBehavior } from "@ax/components";
7
+ import { IRootState, IMenuForm, ISchemaField } from "@ax/types";
8
+ import { getMenuItems } from "@ax/helpers";
7
9
 
8
- import { IRootState, IMenuForm, IImage } from "@ax/types";
10
+ import ConnectedField from "./ConnectedField";
9
11
 
10
12
  const Form = (props: IProps): JSX.Element => {
11
- const { form, updateForm, toggleSecondaryPanel, setIsGalleryOpened } = props;
13
+ const { form, updateFormValue, toggleSecondaryPanel, setIsGalleryOpened } = props;
12
14
 
13
- const { itemLink, itemLabel, itemAuxText, type, itemImage, itemSpecial } = form;
15
+ const { url, label, type } = form;
14
16
 
15
- const setLinkValue = (value: any) => updateForm({ itemLink: value });
16
- const setLabelValue = (value: string) => updateForm({ itemLabel: value });
17
- const setAuxTextValue = (value: string) => updateForm({ itemAuxText: value });
18
- const setTypeValue = (value: string) => updateForm({ type: value });
19
- const setImageValue = (value: IImage) => updateForm({ itemImage: value });
20
- const setSpecial = (value: boolean) => updateForm({ itemSpecial: value });
17
+ const setLinkValue = (value: any) => updateFormValue({ url: value });
18
+ const setLabelValue = (value: string) => updateFormValue({ label: value });
19
+ const setTypeValue = (value: string) => updateFormValue({ type: value });
21
20
 
22
21
  const typeLinkOptions = [
23
22
  {
@@ -34,6 +33,11 @@ const Form = (props: IProps): JSX.Element => {
34
33
 
35
34
  const typeLink = type ? type : "link";
36
35
 
36
+ const menuItems = getMenuItems(typeLink);
37
+ const schemaFields = menuItems && menuItems.fields ? menuItems.fields : [];
38
+
39
+ const generateFields = (fields: ISchemaField[]) => fields.map((field: ISchemaField) => <ConnectedField {...field } name={field.key} setIsGalleryOpened={setIsGalleryOpened} />);
40
+
37
41
  return (
38
42
  <>
39
43
  <FieldsBehavior
@@ -49,57 +53,22 @@ const Form = (props: IProps): JSX.Element => {
49
53
  name="navigationLabel"
50
54
  fieldType="TextField"
51
55
  autoComplete="nav-label"
52
- value={itemLabel || ""}
56
+ value={label || ""}
53
57
  onChange={setLabelValue}
54
58
  />
55
- {type !== "link" ? (
59
+ {type === "link" ? (
56
60
  <FieldsBehavior
57
- title="Image"
58
- name="image"
59
- fullWidth={true}
60
- fieldType="ImageField"
61
- value={itemImage || null}
62
- onChange={setImageValue}
63
- setIsGalleryOpened={setIsGalleryOpened}
64
- />
65
- ) : (
66
- <>
67
- <FieldsBehavior
68
61
  title="Link"
69
62
  name="link"
70
63
  fieldType="UrlField"
71
- value={itemLink || null}
64
+ value={url || null}
72
65
  onChange={setLinkValue}
73
66
  advanced={true}
74
67
  handlePanel={toggleSecondaryPanel}
75
68
  inFloatingPanel={true}
76
69
  />
77
- <FieldsBehavior
78
- title="Auxiliar Text"
79
- name="auxText"
80
- fieldType="TextArea"
81
- value={itemAuxText || ""}
82
- onChange={setAuxTextValue}
83
- />
84
- <FieldsBehavior
85
- title="Image"
86
- name="image"
87
- fullWidth={true}
88
- fieldType="ImageField"
89
- value={itemImage || null}
90
- onChange={setImageValue}
91
- setIsGalleryOpened={setIsGalleryOpened}
92
- />
93
- <FieldsBehavior
94
- name="special"
95
- fieldType="ToggleField"
96
- value={itemSpecial}
97
- onChange={setSpecial}
98
- background
99
- auxText="Check it if the link has a special behavior."
100
- />
101
- </>
102
- )}
70
+ ) : null }
71
+ {generateFields(schemaFields)}
103
72
  </>
104
73
  );
105
74
  };
@@ -109,7 +78,7 @@ const mapStateToProps = (state: IRootState) => ({
109
78
  });
110
79
 
111
80
  const mapDispatchToProps = {
112
- updateForm: menuActions.updateForm,
81
+ updateFormValue: menuActions.updateFormValue,
113
82
  getSitePages: sitesActions.getSitePages,
114
83
  };
115
84
 
@@ -122,7 +91,7 @@ interface IFormProps {
122
91
  setIsGalleryOpened?: (isGalleryOpened: boolean) => void;
123
92
  }
124
93
  interface IDispatchProps {
125
- updateForm(value: any): void;
94
+ updateFormValue(value: any): void;
126
95
  }
127
96
 
128
97
  type IProps = IDispatchProps & IStateProps & IFormProps;
@@ -14,7 +14,7 @@ const SidePanel = (props: IProps): JSX.Element => {
14
14
  const { isOpen, isOpenedSecond, toggleModal, toggleSecondaryPanel, addMenuItem, updateMenuItem, item, edit, form } =
15
15
  props;
16
16
 
17
- const { itemLabel, itemLink, itemImage, itemAuxText, type, headerStyle, footerStyle, itemSpecial } = form;
17
+ const { type, headerStyle, footerStyle } = form;
18
18
 
19
19
  const [isGalleryOpened, setIsGalleryOpened] = useState(false);
20
20
 
@@ -23,13 +23,9 @@ const SidePanel = (props: IProps): JSX.Element => {
23
23
  };
24
24
 
25
25
  let menuItem: any = {
26
- label: itemLabel,
27
- url: itemLink,
28
- image: itemImage,
29
- auxText: itemAuxText,
26
+ ...form,
30
27
  component: "Menu",
31
28
  config: { type, headerStyle, footerStyle },
32
- special: itemSpecial,
33
29
  };
34
30
 
35
31
  menuItem.children = edit && item ? item.children : [];
@@ -364,14 +364,11 @@ export interface IMenuItemConfig {
364
364
  }
365
365
 
366
366
  export interface IMenuForm {
367
- itemLink: any;
368
- itemLabel: string;
369
- itemAuxText: string;
370
- itemImage: IImage | string | null;
367
+ url: any;
368
+ label: string;
371
369
  type: string;
372
370
  headerStyle: string;
373
371
  footerStyle: string;
374
- itemSpecial: boolean;
375
372
  }
376
373
 
377
374
  export interface IHeader {