@griddo/ax 11.1.9 → 11.1.10

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.1.9",
4
+ "version": "11.1.10",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -62,7 +62,6 @@
62
62
  "@types/react-draft-wysiwyg": "^1.13.1",
63
63
  "@types/react-redux": "^7.1.23",
64
64
  "@types/react-router-dom": "5.3.3",
65
- "@types/react-select": "^3.0.8",
66
65
  "@types/react-slick": "^0.23.10",
67
66
  "@types/react-test-renderer": "17.0.1",
68
67
  "@types/react-textarea-autosize": "^4.3.5",
@@ -134,7 +133,7 @@
134
133
  "react-redux": "^7.2.8",
135
134
  "react-refresh": "^0.10.0",
136
135
  "react-router-dom": "5.1.2",
137
- "react-select": "^3.0.8",
136
+ "react-select": "5.10.0",
138
137
  "react-slick": "^0.29.0",
139
138
  "react-textarea-autosize": "^7.1.2",
140
139
  "redux": "4.0.4",
@@ -225,5 +224,5 @@
225
224
  "publishConfig": {
226
225
  "access": "public"
227
226
  },
228
- "gitHead": "6d0f91ca783b025364513319976c3e9873e76953"
227
+ "gitHead": "68794c64ceac7a98aef51c9fca387b9066cc6ff3"
229
228
  }
@@ -1,8 +1,9 @@
1
1
  import React, { useEffect, useState } from "react";
2
+ import { InputActionMeta } from "react-select";
2
3
 
3
4
  import { isReqOk } from "@ax/helpers";
4
5
  import { selects, checkgroups } from "@ax/api";
5
- import { ISite } from "@ax/types";
6
+ import { IPage, ISite } from "@ax/types";
6
7
 
7
8
  import * as S from "./style";
8
9
 
@@ -27,10 +28,12 @@ const AsyncSelect = (props: IAsyncSelectProps): JSX.Element => {
27
28
  maxWidth,
28
29
  } = props;
29
30
 
30
- const initialState: { items: IOption[]; hasEmptyOption: boolean } = {
31
+ const initialState: IState = {
31
32
  items: [],
32
33
  hasEmptyOption: true,
34
+ inputText: "",
33
35
  };
36
+
34
37
  const [state, setState] = useState(initialState);
35
38
 
36
39
  const isPage = entity === "pages";
@@ -65,6 +68,7 @@ const AsyncSelect = (props: IAsyncSelectProps): JSX.Element => {
65
68
  }
66
69
  }
67
70
  } catch (e) {
71
+ // eslint-disable-next-line no-console
68
72
  console.log(e);
69
73
  }
70
74
  return data;
@@ -81,6 +85,7 @@ const AsyncSelect = (props: IAsyncSelectProps): JSX.Element => {
81
85
  : optionValues;
82
86
  if (isMounted) setState((state) => ({ ...state, items: filteredOptions }));
83
87
  })
88
+ // eslint-disable-next-line no-console
84
89
  .catch((apiError) => console.log(apiError));
85
90
  return () => {
86
91
  isMounted = false;
@@ -97,11 +102,12 @@ const AsyncSelect = (props: IAsyncSelectProps): JSX.Element => {
97
102
  return state.items.filter((i: IOption) => i.label.toLowerCase().includes(inputValue.toLowerCase()));
98
103
  };
99
104
 
100
- const handleInputChange = (newValue: string) => {
101
- const inputValue = newValue.replace(/\W/g, "");
102
- const hasEmptyOption = inputValue.length === 0;
103
- setState((state) => ({ ...state, hasEmptyOption }));
104
- return inputValue;
105
+ const handleInputChange = (inputText: string, meta: InputActionMeta) => {
106
+ if (meta.action !== "input-blur" && meta.action !== "menu-close") {
107
+ const inputValue = inputText.replace(/\W/g, "");
108
+ const hasEmptyOption = inputValue.length === 0;
109
+ setState((state) => ({ ...state, hasEmptyOption, inputText }));
110
+ }
105
111
  };
106
112
 
107
113
  const loadOptions = (inputValue: string, callback: any) => {
@@ -110,7 +116,6 @@ const AsyncSelect = (props: IAsyncSelectProps): JSX.Element => {
110
116
  }, 0);
111
117
  };
112
118
 
113
- // tslint:disable-next-line: no-shadowed-variable
114
119
  const getObjectValue = (val: any, options: IOption[]) => {
115
120
  const fixedVal = Array.isArray(val) ? val[0] : val;
116
121
  const selectedValue = fixedVal && typeof fixedVal === "object" ? fixedVal.id : fixedVal;
@@ -139,11 +144,18 @@ const AsyncSelect = (props: IAsyncSelectProps): JSX.Element => {
139
144
  hasEmptyOption={state.hasEmptyOption}
140
145
  isSearchable={searchable}
141
146
  maxWidth={maxWidth}
147
+ inputValue={state.inputText}
142
148
  />
143
149
  </div>
144
150
  );
145
151
  };
146
152
 
153
+ interface IState {
154
+ items: IOption[];
155
+ hasEmptyOption: boolean;
156
+ inputText: string;
157
+ }
158
+
147
159
  interface IOption {
148
160
  value: number | string | null;
149
161
  label: string;
@@ -164,11 +176,11 @@ export interface IAsyncSelectProps {
164
176
  onChange: (value: string | number | null) => void;
165
177
  site?: ISite | null;
166
178
  lang?: string;
167
- selectedContent?: any;
179
+ selectedContent?: IPage;
168
180
  mandatory?: boolean;
169
181
  placeholder?: string;
170
- filter?: any[];
171
- options?: any[];
182
+ filter?: (string | number | null)[];
183
+ options?: IOption[];
172
184
  source?: string;
173
185
  type?: string;
174
186
  maxWidth?: number;
@@ -1,4 +1,5 @@
1
1
  import React, { useState } from "react";
2
+ import { InputActionMeta } from "react-select";
2
3
 
3
4
  import * as S from "./style";
4
5
 
@@ -22,20 +23,20 @@ const Select = (props: ISelectProps): JSX.Element => {
22
23
  const emptyOption = { value: "", label: placeholder || "Empty" };
23
24
 
24
25
  const [hasEmptyOption, setHasEmptyOption] = useState(!mandatory);
26
+ const [inputText, setInputText] = useState<string>("");
25
27
 
26
28
  const optionValues: IOptionProps[] = hasEmptyOption ? [emptyOption, ...options] : options;
27
29
 
28
- const handleChange = (selectedValue: IOptionProps) => {
29
- onChange(selectedValue.value);
30
- };
30
+ const handleChange = (selectedValue: IOptionProps) => onChange(selectedValue.value);
31
31
 
32
- const handleInputChange = (newValue: string) => {
33
- const inputValue = newValue.replace(/\W/g, "");
34
- setHasEmptyOption(!mandatory && inputValue.length === 0);
35
- return inputValue;
32
+ const handleInputChange = (inputText: string, meta: InputActionMeta) => {
33
+ if (meta.action !== "input-blur" && meta.action !== "menu-close") {
34
+ const inputValue = inputText.replace(/\W/g, "");
35
+ setInputText(inputText);
36
+ setHasEmptyOption(!mandatory && inputValue.length === 0);
37
+ }
36
38
  };
37
39
 
38
- // tslint:disable-next-line: no-shadowed-variable
39
40
  const getObjectValue = (value: string | undefined, options: IOptionProps[]) =>
40
41
  options.find((option) => option.value === value);
41
42
 
@@ -61,6 +62,7 @@ const Select = (props: ISelectProps): JSX.Element => {
61
62
  alignRight={alignRight}
62
63
  aria-label={name}
63
64
  maxWidth={maxWidth}
65
+ inputValue={inputText}
64
66
  />
65
67
  </div>
66
68
  );
@@ -24,7 +24,6 @@ const ContentFilters = (props: IProps): JSX.Element => {
24
24
  addTemplate,
25
25
  setSelectedStructuredData,
26
26
  resetFilter,
27
- setStructuredDataFilter,
28
27
  setFilter,
29
28
  addNew,
30
29
  } = props;
@@ -46,7 +45,6 @@ const ContentFilters = (props: IProps): JSX.Element => {
46
45
  resetFilter();
47
46
  setContentFilter(value);
48
47
  setSelectedStructuredData(value, "site");
49
- current && setStructuredDataFilter(value);
50
48
  if (hasTemplate) {
51
49
  addTemplate(firstTemplate);
52
50
  } else {
@@ -65,7 +63,6 @@ const ContentFilters = (props: IProps): JSX.Element => {
65
63
 
66
64
  setContentFilter(filter);
67
65
  setSelectedStructuredData(filter, "site");
68
- current && setStructuredDataFilter(filter);
69
66
  };
70
67
 
71
68
  return (
@@ -110,7 +107,6 @@ interface IProps {
110
107
  addTemplate(template: string): void;
111
108
  setSelectedStructuredData(id: string, scope: string): void;
112
109
  resetFilter(): void;
113
- setStructuredDataFilter: (filter: string) => void;
114
110
  setFilter: (pointer: string, filter: IQueryValue[]) => void;
115
111
  addNew: () => void;
116
112
  }
@@ -119,7 +115,6 @@ const mapDispatchToProps = {
119
115
  setContentFilter: sitesActions.setFilter,
120
116
  addTemplate: pageEditorActions.addTemplate,
121
117
  setSelectedStructuredData: structuredDataActions.setSelectedStructuredData,
122
- setStructuredDataFilter: structuredDataActions.setFilter,
123
118
  };
124
119
 
125
120
  export default connect(null, mapDispatchToProps)(ContentFilters);
@@ -25,6 +25,7 @@ const FormEditor = (props: IProps) => {
25
25
  globalLangs,
26
26
  formContent,
27
27
  isNewTranslation,
28
+ currentSiteInfo,
28
29
  setHistoryPush,
29
30
  setLanguage,
30
31
  deleteForm,
@@ -36,6 +37,7 @@ const FormEditor = (props: IProps) => {
36
37
  const { id, title, state, dataLanguages } = formContent || { dataLanguages: [] };
37
38
  const formStatus = state === "active" ? "active" : "offline";
38
39
  const isTranslated = dataLanguages.length > 1;
40
+ const isSiteView = !!currentSiteInfo;
39
41
 
40
42
  const formLanguages: ILanguage[] = [];
41
43
  dataLanguages?.forEach((dataLang) => {
@@ -52,7 +54,7 @@ const FormEditor = (props: IProps) => {
52
54
  const { isDirty, setIsDirty, resetDirty } = useIsDirty(formContent);
53
55
  const browserRef = useRef<HTMLDivElement>(null);
54
56
 
55
- const backLinkRoute = "/forms";
57
+ const backLinkRoute = isSiteView ? "/sites/forms" : "/forms";
56
58
  const theme = getDefaultTheme();
57
59
 
58
60
  useEffect(() => {
@@ -204,7 +206,7 @@ const FormEditor = (props: IProps) => {
204
206
  currentLanguages={formLanguages}
205
207
  currentPageID={0}
206
208
  fullWidth={true}
207
- inversed={true}
209
+ inversed={!isSiteView}
208
210
  isFromEditor={true}
209
211
  isDirty={isDirty}
210
212
  >
@@ -9,23 +9,25 @@ import { getSchemaFormCategories } from "@ax/helpers";
9
9
  import MenuGroup from "./MenuGroup";
10
10
 
11
11
  import * as S from "./style";
12
+ import { IRootState, ISite } from "@ax/types";
12
13
 
13
14
  const FormsMenu = (props: IProps): JSX.Element => {
14
- const { selected, setHistoryPush } = props;
15
+ const { selected, currentSiteInfo, setHistoryPush } = props;
15
16
 
17
+ const basePath = currentSiteInfo ? "/sites" : "";
16
18
  const formCategories = getSchemaFormCategories();
17
19
 
18
20
  const navItems: INavItem[] = [
19
21
  {
20
22
  label: "All Forms",
21
- path: "/forms",
23
+ path: `${basePath}/forms`,
22
24
  },
23
25
  ];
24
26
 
25
27
  if (formCategories.length) {
26
28
  navItems.push({
27
29
  label: "Forms Categories",
28
- path: "/forms/categories/",
30
+ path: `${basePath}/forms/categories/`,
29
31
  items: formCategories,
30
32
  });
31
33
  }
@@ -77,11 +79,16 @@ interface INavItem {
77
79
 
78
80
  interface IProps {
79
81
  selected?: string;
82
+ currentSiteInfo: ISite | null;
80
83
  setHistoryPush(path: string, isEditor?: boolean): Promise<void>;
81
84
  }
82
85
 
86
+ const mapStateToProps = (state: IRootState) => ({
87
+ currentSiteInfo: state.sites.currentSiteInfo,
88
+ });
89
+
83
90
  const mapDispatchToProps = {
84
91
  setHistoryPush: appActions.setHistoryPush,
85
92
  };
86
93
 
87
- export default connect(null, mapDispatchToProps)(FormsMenu);
94
+ export default connect(mapStateToProps, mapDispatchToProps)(FormsMenu);
@@ -61,7 +61,7 @@ const FramePreview = (props: IProps) => {
61
61
 
62
62
  const selectHoverEditorID = (editorID: number, parentEditorID: number) => {
63
63
  const { parent } = findByEditorID(content, parentEditorID);
64
- if (parent && parent.parentEditorID === 0) {
64
+ if (parent && (parent.parentEditorID === null || parent.parentEditorID === 0)) {
65
65
  window.parent.postMessage({ type: "module-scroll", message: editorID }, "*");
66
66
  }
67
67
  };
@@ -23,6 +23,7 @@ const Sites = (props: ISitesProps): JSX.Element => {
23
23
  globalLangs,
24
24
  getRoles,
25
25
  updateCurrentSearch,
26
+ resetCurrentData,
26
27
  setIsLoading,
27
28
  } = props;
28
29
 
@@ -31,6 +32,7 @@ const Sites = (props: ISitesProps): JSX.Element => {
31
32
  setIsLoading(true);
32
33
  setCurrentSiteInfo(null);
33
34
  updateCurrentSearch("");
35
+ resetCurrentData();
34
36
  await getRoles({ siteId: "global" }, token, false);
35
37
  await getUser("me", token, false);
36
38
  await getStructuredData(token, null, false);
@@ -74,6 +76,7 @@ interface IDispatchProps {
74
76
  getUser: (id: string, token?: string, hasLoading?: boolean) => Promise<void>;
75
77
  getRoles: (params: IGetRoles, token?: string, hasLoading?: boolean) => Promise<void>;
76
78
  updateCurrentSearch(query: string): Promise<void>;
79
+ resetCurrentData(): Promise<void>;
77
80
  setIsLoading(isLoading: boolean): void;
78
81
  }
79
82
 
@@ -87,6 +90,7 @@ const mapDispatchToProps = {
87
90
  getUser: usersActions.getUser,
88
91
  getRoles: usersActions.getRoles,
89
92
  updateCurrentSearch: structuredDataActions.updateCurrentSearch,
93
+ resetCurrentData: structuredDataActions.resetCurrentData,
90
94
  setIsLoading: appActions.setIsLoading,
91
95
  };
92
96
 
@@ -16,6 +16,9 @@ import Profile from "./../modules/Users/Profile";
16
16
  import Integrations from "./../modules/Settings/Integrations";
17
17
  import IntegrationForm from "./../modules/Settings/Integrations/IntegrationForm";
18
18
  import FileDrive from "./../modules/FileDrive";
19
+ import FormList from "../modules/Forms/FormList";
20
+ import FormEditor from "../modules/Forms/FormEditor";
21
+ import FormCategoriesList from "../modules/Forms/FormCategoriesList";
19
22
 
20
23
  const BASE_PATH = "/sites";
21
24
 
@@ -89,6 +92,39 @@ export default [
89
92
  },
90
93
  ],
91
94
  },
95
+ {
96
+ path: `${BASE_PATH}/forms`,
97
+ component: FormList,
98
+ name: "Forms",
99
+ showInNav: true,
100
+ icon: "Form",
101
+ },
102
+ {
103
+ path: `${BASE_PATH}/forms/categories`,
104
+ component: FormCategoriesList,
105
+ name: "Form Categories",
106
+ showInNav: false,
107
+ },
108
+ {
109
+ path: `${BASE_PATH}/forms/categories/:cat`,
110
+ component: FormCategoriesList,
111
+ name: "Form Categories",
112
+ showInNav: false,
113
+ },
114
+ {
115
+ path: `${BASE_PATH}/forms/editor`,
116
+ component: FormEditor,
117
+ name: "Form Editor",
118
+ showInNav: false,
119
+ hideNav: true,
120
+ },
121
+ {
122
+ path: `${BASE_PATH}/forms/editor/new`,
123
+ component: FormEditor,
124
+ name: "New Form Editor",
125
+ showInNav: false,
126
+ hideNav: true,
127
+ },
92
128
  {
93
129
  path: `${BASE_PATH}/files`,
94
130
  component: FileDrive,