@griddo/ax 10.6.1 → 10.6.3

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": "10.6.1",
4
+ "version": "10.6.3",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -232,5 +232,5 @@
232
232
  "publishConfig": {
233
233
  "access": "public"
234
234
  },
235
- "gitHead": "7c09ff5f84d88f828072c1e328345173f2cdf992"
235
+ "gitHead": "d921dd845629fd4f41cb067d6b2159d0110ca4a1"
236
236
  }
@@ -24,7 +24,7 @@ const SideModalOption = (props: IProps) => {
24
24
  const label = isNavigationDefault ? option.title : getDisplayName(optionParam);
25
25
 
26
26
  const setOption = () => {
27
- if(handleClick) {
27
+ if (handleClick) {
28
28
  handleClick(option);
29
29
  toggleModal();
30
30
  }
@@ -92,8 +92,8 @@ const SideModal = (props: ISideModalProps): JSX.Element | null => {
92
92
  const selectedClass = isSelected ? "selected" : "";
93
93
 
94
94
  return (
95
- <MenuItem key={`${value}${i}`} className={selectedClass}>
96
- <S.NavLink onClick={filterOptions} data-testid="side-modal-nav-link">
95
+ <MenuItem key={`${value}${i}`} className={selectedClass} onClick={filterOptions}>
96
+ <S.NavLink data-testid="side-modal-nav-link">
97
97
  <S.Link data-testid="side-modal-link" active={isSelected}>
98
98
  {label}
99
99
  </S.Link>
@@ -40,7 +40,11 @@ const OptionTable = (props: IOptionTableProps): JSX.Element => {
40
40
  });
41
41
  };
42
42
 
43
- const currentType = currentStructuredData ? currentStructuredData.dataPacks[0] : "basics";
43
+ const currentType = currentStructuredData
44
+ ? currentStructuredData.dataPacks[0]
45
+ : filters.length
46
+ ? filters[0].value
47
+ : "";
44
48
 
45
49
  const initialState: IOptionTableStore = {
46
50
  columnValues: filterOptions(currentType, "type"),
@@ -125,10 +129,17 @@ const OptionTable = (props: IOptionTableProps): JSX.Element => {
125
129
  });
126
130
 
127
131
  setValues(filteredOptionsByDataPack);
128
- const selectedTemplate =
132
+
133
+ const currentStructuredDataTemplate: string | undefined =
129
134
  currentStructuredData && currentStructuredData.schema.templates
130
135
  ? currentStructuredData.schema.templates[0]
131
- : selectedValue;
136
+ : undefined;
137
+
138
+ const selectedTemplate =
139
+ filteredOptionsByDataPack.find((opt) => opt.value === currentStructuredDataTemplate)?.value ||
140
+ filteredOptionsByDataPack[0]?.value ||
141
+ "";
142
+
132
143
  selectOption(selectedTemplate, filteredOptionsByDataPack);
133
144
  };
134
145
 
@@ -4,34 +4,38 @@ import { pageStatus } from "@ax/containers/PageEditor/interfaces";
4
4
  import { IDataPack, IPage, IStructuredData } from "@ax/types";
5
5
 
6
6
  const getTemplatesFilters = (activatedDataPacks: IDataPack[]) => {
7
- const filters: { label: string; value: string; mode: string }[] = [];
8
7
  const activatedDataPacksIds = getActivatedDataPacksIds(activatedDataPacks);
9
8
  const { templates } = schemas;
10
9
 
11
- Object.keys(templates).forEach((schema: any) => {
12
- const { type, dataPacks } = templates[schema];
13
- const isActivated = !dataPacks || activatedDataPacksIds.some((id: string) => dataPacks.indexOf(id) >= 0);
14
-
15
- if (isActivated) {
16
- !dataPacks
17
- ? filters.push({ ...type })
18
- : dataPacks.forEach((dataPack: string) => {
19
- const currentDataPack = activatedDataPacks.find(
20
- (activatedDataPack: IDataPack) => dataPack === activatedDataPack.id
21
- );
22
-
23
- if (currentDataPack) {
24
- filters.push({
25
- label: currentDataPack?.title,
26
- value: currentDataPack?.id,
27
- mode: type.mode,
28
- });
29
- }
30
- });
31
- }
32
- });
10
+ const filters: { label: string; value: string; mode?: string }[] = Object.keys(templates)
11
+ .filter((templateName: string) => !templates[templateName].dataPacks)
12
+ .map((templateName: string) => templates[templateName].type);
13
+
14
+ Object.keys(templates)
15
+ .filter((templateName: string) => Array.isArray(templates[templateName].dataPacks))
16
+ .forEach((templateName: string) => {
17
+ const { type, dataPacks } = templates[templateName];
18
+ const isActivated = activatedDataPacksIds.some((id: string) => dataPacks.indexOf(id) >= 0);
19
+
20
+ if (isActivated) {
21
+ dataPacks.forEach((dataPack: string) => {
22
+ const currentDataPack = activatedDataPacks.find(
23
+ (activatedDataPack: IDataPack) => dataPack === activatedDataPack.id
24
+ );
25
+
26
+ if (currentDataPack) {
27
+ filters.push({
28
+ label: currentDataPack?.title,
29
+ value: currentDataPack?.id,
30
+ mode: type.mode,
31
+ });
32
+ }
33
+ });
34
+ }
35
+ });
33
36
 
34
37
  const uniqueFilters: { label: string; value: string; mode: string }[] = filterDuplicatedValues(filters);
38
+
35
39
  return uniqueFilters;
36
40
  };
37
41
 
@@ -103,9 +107,6 @@ const getOptionFilters = (options: IStructuredData[], activatedDataPacks: IDataP
103
107
  const filters = [...templateFilters, ...mappedOptions];
104
108
  const uniqueFilters = [...new Map(filters.map((item: any) => [item.value, item])).values()];
105
109
  const sortedUniqueFilters = uniqueFilters.sort((a, b) => a.label.localeCompare(b.label));
106
- const staticFilterIdx = sortedUniqueFilters.findIndex((filter) => filter.value === "static");
107
- const staticFilter = sortedUniqueFilters.splice(staticFilterIdx, 1);
108
- sortedUniqueFilters.unshift(...staticFilter);
109
110
  return sortedUniqueFilters;
110
111
  };
111
112