From 86726706c3faea6ed3b1cead1a6e2a35768ca471 Mon Sep 17 00:00:00 2001 From: Hugo LE DALL Date: Sun, 19 Jul 2020 18:21:52 +0200 Subject: [PATCH] Fixing required checkbox --- .../nav/ModelSetupNav/ModelFieldEditor.svelte | 7 +++- .../builder/src/constants/backend/index.js | 38 +++++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/packages/builder/src/components/nav/ModelSetupNav/ModelFieldEditor.svelte b/packages/builder/src/components/nav/ModelSetupNav/ModelFieldEditor.svelte index e5e7528333..d57fc0784e 100644 --- a/packages/builder/src/components/nav/ModelSetupNav/ModelFieldEditor.svelte +++ b/packages/builder/src/components/nav/ModelSetupNav/ModelFieldEditor.svelte @@ -21,7 +21,7 @@ $: required = field.constraints && field.constraints.presence && - !constraints.presence.allowEmpty + !field.constraints.presence.allowEmpty
@@ -41,7 +41,10 @@
- + (field.constraints.presence.allowEmpty = required)} />
{#if field.type === 'string'} diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 0747439cfa..1a82702273 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -6,7 +6,7 @@ export const FIELDS = { constraints: { type: "string", length: {}, - presence: false, + presence: { allowEmpty: true }, }, }, NUMBER: { @@ -15,7 +15,7 @@ export const FIELDS = { type: "number", constraints: { type: "number", - presence: false, + presence: { allowEmpty: true }, numericality: {}, }, }, @@ -25,7 +25,7 @@ export const FIELDS = { type: "boolean", constraints: { type: "boolean", - presence: false, + presence: { allowEmpty: true }, }, }, // OPTIONS: { @@ -34,7 +34,7 @@ export const FIELDS = { // type: "options", // constraints: { // type: "string", - // presence: false, + // presence: { allowEmpty: true }, // }, // }, DATETIME: { @@ -44,7 +44,7 @@ export const FIELDS = { constraints: { type: "string", length: {}, - presence: false, + presence: { allowEmpty: true }, }, }, // IMAGE: { @@ -53,7 +53,7 @@ export const FIELDS = { // type: "file", // constraints: { // type: "string", - // presence: false, + // presence: { allowEmpty: true }, // }, // }, // FILE: { @@ -62,7 +62,7 @@ export const FIELDS = { // type: "file", // constraints: { // type: "string", - // presence: false, + // presence: { allowEmpty: true }, // }, // }, LINKED_FIELDS: { @@ -84,7 +84,7 @@ export const BLOCKS = { constraints: { type: "string", length: {}, - presence: false, + presence: { allowEmpty: true }, }, }, COMPANY: { @@ -94,7 +94,7 @@ export const BLOCKS = { constraints: { type: "string", length: {}, - presence: false, + presence: { allowEmpty: true }, }, }, EMAIL: { @@ -104,7 +104,7 @@ export const BLOCKS = { constraints: { type: "string", length: {}, - presence: false, + presence: { allowEmpty: true }, }, }, PHONE_NUMBER: { @@ -113,7 +113,7 @@ export const BLOCKS = { type: "number", constraints: { type: "number", - presence: false, + presence: { allowEmpty: true }, numericality: {}, }, }, @@ -123,7 +123,7 @@ export const BLOCKS = { type: "number", constraints: { type: "number", - presence: false, + presence: { allowEmpty: true }, numericality: {}, }, }, @@ -133,7 +133,7 @@ export const BLOCKS = { type: "boolean", constraints: { type: "boolean", - presence: false, + presence: { allowEmpty: true }, }, }, URL: { @@ -143,7 +143,7 @@ export const BLOCKS = { constraints: { type: "string", length: {}, - presence: false, + presence: { allowEmpty: true }, }, }, IMAGE: { @@ -153,7 +153,7 @@ export const BLOCKS = { constraints: { type: "string", length: {}, - presence: false, + presence: { allowEmpty: true }, }, }, // PRIORITY: { @@ -162,7 +162,7 @@ export const BLOCKS = { // type: "options", // constraints: { // type: "string", - // presence: false, + // presence: { allowEmpty: true }, // inclusion: ["low", "medium", "high"], // }, // }, @@ -173,7 +173,7 @@ export const BLOCKS = { constraints: { type: "string", length: {}, - presence: false, + presence: { allowEmpty: true }, }, }, // AVATAR: { @@ -182,7 +182,7 @@ export const BLOCKS = { // type: "image", // constraints: { // type: "string", - // presence: false, + // presence: { allowEmpty: true }, // }, // }, // PDF: { @@ -191,7 +191,7 @@ export const BLOCKS = { // type: "file", // constraints: { // type: "string", - // presence: false, + // presence: { allowEmpty: true }, // }, // }, }