@griddo/ax 11.7.2 → 11.7.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": "11.7.2",
4
+ "version": "11.7.3",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -223,5 +223,5 @@
223
223
  "publishConfig": {
224
224
  "access": "public"
225
225
  },
226
- "gitHead": "3fa6c7e418ad83f45aace6ee880e3b7cf49fed53"
226
+ "gitHead": "35cccad9fe3f0eaf9e2331184ac382d5312c60fb"
227
227
  }
@@ -1,7 +1,6 @@
1
1
  import { Dispatch } from "redux";
2
2
 
3
3
  import { handleRequest } from "@ax/helpers";
4
- import { generateEditorIDs } from "@ax/forms";
5
4
  import { menus } from "@ax/api";
6
5
  import { appActions } from "@ax/containers/App";
7
6
  import { IMenuItem, IMenu, IRootState, IMenuForm } from "@ax/types";
@@ -129,8 +128,7 @@ function addMenuItem(item: IMenuItem): (dispatch: Dispatch, getState: () => IRoo
129
128
  const elements = editorMenu.elements || [];
130
129
  const itemWithTemporaryId = { ...item, id: new Date().getTime() };
131
130
  const menuElements = [...elements, itemWithTemporaryId];
132
- const updatedElementsWithInternalIds = generateEditorIDs(menuElements).pageContent;
133
- const updatedMenu = { ...editorMenu, elements: updatedElementsWithInternalIds };
131
+ const updatedMenu = { ...editorMenu, elements: menuElements };
134
132
 
135
133
  dispatch(setEditorMenu(updatedMenu));
136
134
  updateTotalItems(dispatch, getState);
@@ -143,10 +141,10 @@ function updateMenuItem(updatedItem: IMenuItem): (dispatch: Dispatch, getState:
143
141
  if (!editorMenu) return;
144
142
 
145
143
  const updateElements = (elements: IMenuItem[]): any => {
146
- const hasUpdatedChild = elements.some((element) => element.editorID === updatedItem.editorID);
144
+ const hasUpdatedChild = elements.some((element) => element.id === updatedItem.id);
147
145
  if (hasUpdatedChild) {
148
146
  const elementsWithUpdate = elements.map((item: IMenuItem) => {
149
- return item.editorID === updatedItem.editorID ? updatedItem : item;
147
+ return item.id === updatedItem.id ? updatedItem : item;
150
148
  });
151
149
  return elementsWithUpdate;
152
150
  }
@@ -158,6 +156,7 @@ function updateMenuItem(updatedItem: IMenuItem): (dispatch: Dispatch, getState:
158
156
  }
159
157
  }
160
158
  };
159
+
161
160
  const updatedElements = updateElements([...editorMenu.elements]);
162
161
 
163
162
  const updatedMenu = {
@@ -177,7 +176,7 @@ function deleteMenuItem(
177
176
  const { editorMenu } = getStateValues(getState);
178
177
  if (!editorMenu) return;
179
178
 
180
- const updateElements = (elements: IMenuItem[]): IMenuItem[] => {
179
+ const updateElements = (elements: IMenuItem[]): IMenuItem[] | undefined => {
181
180
  const deletedItem = elements.find((element) => element.id === deletedItemId);
182
181
  if (deletedItem) {
183
182
  if (deleteChildren) {
@@ -199,10 +198,9 @@ function deleteMenuItem(
199
198
  }
200
199
  }
201
200
  }
202
- return [];
203
201
  };
204
202
 
205
- const updatedElements = updateElements([...editorMenu.elements]);
203
+ const updatedElements = updateElements([...editorMenu.elements]) || [];
206
204
 
207
205
  const updatedMenu = {
208
206
  ...editorMenu,