budibase/packages/builder/src/constants/backend/index.js

183 lines
3.1 KiB
JavaScript
Raw Normal View History

2020-06-15 17:41:31 +02:00
const FIELD_TYPES = ["string", "number", "boolean"]
export const FIELDS = {
PLAIN_TEXT: {
name: "Plain Text",
icon: "ri-text",
2020-06-16 21:29:18 +02:00
type: "string",
constraints: {
2020-06-15 17:41:31 +02:00
type: "string",
2020-06-16 21:29:18 +02:00
length: {},
presence: false,
2020-06-15 17:41:31 +02:00
},
},
NUMBER: {
name: "Number",
icon: "ri-number-1",
2020-06-16 21:29:18 +02:00
type: "number",
constraints: {
2020-06-15 17:41:31 +02:00
type: "number",
2020-06-16 21:29:18 +02:00
presence: false,
numericality: {},
2020-06-15 17:41:31 +02:00
},
},
BOOLEAN: {
name: "True/False",
icon: "ri-toggle-line",
2020-06-16 21:29:18 +02:00
type: "boolean",
constraints: {
2020-06-15 17:41:31 +02:00
type: "boolean",
2020-06-16 21:29:18 +02:00
presence: false,
2020-06-15 17:41:31 +02:00
},
},
OPTIONS: {
name: "Options",
icon: "ri-list-check-2",
2020-06-16 21:29:18 +02:00
type: "options",
constraints: {
type: "string",
presence: false,
2020-06-15 17:41:31 +02:00
},
},
DATETIME: {
name: "Date/Time",
icon: "ri-calendar-event-fill",
2020-06-16 21:29:18 +02:00
type: "datetime",
constraints: {
2020-06-15 17:41:31 +02:00
type: "date",
2020-06-16 21:29:18 +02:00
datetime: {},
presence: false,
2020-06-15 17:41:31 +02:00
},
},
IMAGE: {
2020-06-18 18:17:18 +02:00
name: "File",
2020-06-15 17:41:31 +02:00
icon: "ri-image-line",
2020-06-18 18:17:18 +02:00
type: "file",
2020-06-16 21:29:18 +02:00
constraints: {
type: "string",
presence: false,
2020-06-15 17:41:31 +02:00
},
},
FILE: {
name: "Image",
icon: "ri-file-line",
2020-06-16 21:29:18 +02:00
type: "file",
constraints: {
type: "string",
presence: false,
2020-06-15 17:41:31 +02:00
},
},
DATA_LINK: {
name: "Data Links",
icon: "ri-link",
2020-06-16 21:29:18 +02:00
type: "link",
modelId: null,
constraints: {
type: "array",
}
2020-06-15 17:41:31 +02:00
},
}
export const BLOCKS = {
NAME: {
name: "Name",
icon: "ri-text",
type: "string",
constraints: {
type: "string",
length: {},
presence: false,
},
},
PHONE_NUMBER: {
name: "Phone Number",
icon: "ri-number-1",
type: "number",
constraints: {
type: "number",
presence: false,
numericality: {},
},
},
ACTIVE: {
name: "Active",
icon: "ri-toggle-line",
type: "boolean",
constraints: {
type: "boolean",
presence: false,
},
},
PRIORITY: {
name: "Options",
icon: "ri-list-check-2",
type: "options",
constraints: {
type: "string",
presence: false,
inclusion: [
"low",
"medium",
"high"
]
},
},
END_DATE: {
name: "End Date",
icon: "ri-calendar-event-fill",
type: "datetime",
constraints: {
type: "date",
datetime: {},
presence: false,
},
},
AVATAR: {
name: "Avatar",
icon: "ri-image-line",
type: "image",
constraints: {
type: "string",
presence: false,
},
},
PDF: {
name: "PDF",
icon: "ri-file-line",
type: "file",
constraints: {
type: "string",
presence: false,
},
},
DATA_LINK: {
name: "Data Links",
icon: "ri-link",
type: "link",
modelId: null,
constraints: {
type: "array",
}
},
2020-06-15 17:41:31 +02:00
}
// TODO: Needs more thought, need to come up with the constraints etc for each one
export const MODELS = {
CONTACTS: {
icon: "ri-link",
name: "Contacts",
schema: {
Name: BLOCKS.NAME,
"Phone Number": BLOCKS.PHONE_NUMBER
}
},
RECIPES: {
icon: "ri-link",
name: "Recipes",
schema: {
Name: BLOCKS.NAME,
"Phone Number": BLOCKS.PHONE_NUMBER
}
}
}