@griddo/ax 1.65.0 → 1.65.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": "1.65.0",
4
+ "version": "1.65.3",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -220,5 +220,5 @@
220
220
  "publishConfig": {
221
221
  "access": "public"
222
222
  },
223
- "gitHead": "4550a3457d35104d6200d1008d961dece1f308a5"
223
+ "gitHead": "7c73fb8924b2d9a71dc890212293852e38348624"
224
224
  }
@@ -69,6 +69,7 @@ const SameComponentArray = (props: ISameComponentArrayProps): JSX.Element => {
69
69
  )}
70
70
  </S.ItemRow>
71
71
  {value &&
72
+ Array.isArray(value) &&
72
73
  value.map((element: any, i: number) => {
73
74
  const { editorID } = element;
74
75
  const { moduleTitle, isModuleDeactivated, componentTitle, displayName } = getComponentProps(
@@ -1,4 +1,4 @@
1
- import { dateToString, getSchema, getTemplate } from "@ax/helpers";
1
+ import { dateToString, getSchema, getTemplate, isComponentEmpty, isEmptyContainer } from "@ax/helpers";
2
2
  import { IErrorItem } from "@ax/types";
3
3
  import { ERRORS } from "./errors";
4
4
 
@@ -134,7 +134,7 @@ const getValidity = (validators: any, value: any): { isValid: boolean; errorText
134
134
  return { isValid: isValidValue, errorText };
135
135
  };
136
136
 
137
- const isEmptyField = (value: any, fieldType: string) => {
137
+ const isEmptyField = (value: any, fieldType: string, multiple: boolean) => {
138
138
  switch (fieldType) {
139
139
  case "HeadingField":
140
140
  return !value || !value.content || value.content.trim().length === 0;
@@ -145,10 +145,15 @@ const isEmptyField = (value: any, fieldType: string) => {
145
145
  case "AsyncCheckGroup":
146
146
  case "CheckGroup":
147
147
  case "ComponentArray":
148
+ return (
149
+ !value || (Array.isArray(value) && !value.length) || (value.component === "Section" && !value.modules.length)
150
+ );
148
151
  case "ArrayFieldGroup":
149
152
  return !value || !value.length;
150
153
  case "ReferenceField":
151
154
  return value.fixed && !value.fixed.length;
155
+ case "ComponentContainer":
156
+ return isEmptyContainer(value, multiple);
152
157
  default:
153
158
  return typeof value === "string" && value.trim().length === 0;
154
159
  }
@@ -165,7 +170,8 @@ const getValidationErrors = (
165
170
 
166
171
  fields.forEach((field: any) => {
167
172
  if (field.mandatory) {
168
- const isEmpty = isEmptyField(current[field.key], field.type);
173
+ const hasMultipleOptions = field.whiteList && field.whiteList.length > 1;
174
+ const isEmpty = isEmptyField(current[field.key], field.type, hasMultipleOptions);
169
175
  if (isEmpty) {
170
176
  errors.push({
171
177
  type: "Error",
@@ -219,7 +225,7 @@ const findFieldsErrors = (content: any): IErrorItem[] => {
219
225
  while (queue.length > 0) {
220
226
  const currentObj = queue.shift();
221
227
 
222
- if (currentObj.component) {
228
+ if (currentObj.component && !isComponentEmpty(currentObj)) {
223
229
  let schemaErrors: any[] = [];
224
230
  const schema: any = getSchema(currentObj.component);
225
231
  schema.configTabs.forEach((tab: any) => {