Some quick automation fixes.
This commit is contained in:
parent
7594b17ec7
commit
e43e0e100b
|
@ -1,5 +1,5 @@
|
||||||
const sendEmail = require("./steps/sendEmail")
|
const sendEmail = require("./steps/sendEmail")
|
||||||
const saveRecord = require("./steps/saveRecord")
|
const createRecord = require("./steps/createRecord")
|
||||||
const updateRecord = require("./steps/updateRecord")
|
const updateRecord = require("./steps/updateRecord")
|
||||||
const deleteRecord = require("./steps/deleteRecord")
|
const deleteRecord = require("./steps/deleteRecord")
|
||||||
const createUser = require("./steps/createUser")
|
const createUser = require("./steps/createUser")
|
||||||
|
@ -17,14 +17,14 @@ const DEFAULT_DIRECTORY = ".budibase-automations"
|
||||||
const AUTOMATION_MANIFEST = "manifest.json"
|
const AUTOMATION_MANIFEST = "manifest.json"
|
||||||
const BUILTIN_ACTIONS = {
|
const BUILTIN_ACTIONS = {
|
||||||
SEND_EMAIL: sendEmail.run,
|
SEND_EMAIL: sendEmail.run,
|
||||||
SAVE_RECORD: saveRecord.run,
|
CREATE_RECORD: createRecord.run,
|
||||||
UPDATE_RECORD: updateRecord.run,
|
UPDATE_RECORD: updateRecord.run,
|
||||||
DELETE_RECORD: deleteRecord.run,
|
DELETE_RECORD: deleteRecord.run,
|
||||||
CREATE_USER: createUser.run,
|
CREATE_USER: createUser.run,
|
||||||
}
|
}
|
||||||
const BUILTIN_DEFINITIONS = {
|
const BUILTIN_DEFINITIONS = {
|
||||||
SEND_EMAIL: sendEmail.definition,
|
SEND_EMAIL: sendEmail.definition,
|
||||||
SAVE_RECORD: saveRecord.definition,
|
CREATE_RECORD: createRecord.definition,
|
||||||
UPDATE_RECORD: updateRecord.definition,
|
UPDATE_RECORD: updateRecord.definition,
|
||||||
DELETE_RECORD: deleteRecord.definition,
|
DELETE_RECORD: deleteRecord.definition,
|
||||||
CREATE_USER: createUser.definition,
|
CREATE_USER: createUser.definition,
|
||||||
|
|
|
@ -2,12 +2,12 @@ const recordController = require("../../api/controllers/record")
|
||||||
const automationUtils = require("../automationUtils")
|
const automationUtils = require("../automationUtils")
|
||||||
|
|
||||||
module.exports.definition = {
|
module.exports.definition = {
|
||||||
name: "Save Record",
|
name: "Create Record",
|
||||||
tagline: "Save a {{inputs.enriched.model.name}} record",
|
tagline: "Create a {{inputs.enriched.model.name}} record",
|
||||||
icon: "ri-save-3-fill",
|
icon: "ri-save-3-fill",
|
||||||
description: "Save a record to your database",
|
description: "Create a record to your database",
|
||||||
type: "ACTION",
|
type: "ACTION",
|
||||||
stepId: "SAVE_RECORD",
|
stepId: "CREATE_RECORD",
|
||||||
inputs: {},
|
inputs: {},
|
||||||
schema: {
|
schema: {
|
||||||
inputs: {
|
inputs: {
|
|
@ -55,7 +55,15 @@ module.exports.definition = {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.run = async function filter({ inputs }) {
|
module.exports.run = async function filter({ inputs }) {
|
||||||
const { field, condition, value } = inputs
|
let { field, condition, value } = inputs
|
||||||
|
// coerce types so that we can use them
|
||||||
|
if (!isNaN(value) && !isNaN(field)) {
|
||||||
|
value = parseFloat(value)
|
||||||
|
field = parseFloat(field)
|
||||||
|
} else if (!isNaN(Date.parse(value)) && !isNaN(Date.parse(field))) {
|
||||||
|
value = Date.parse(value)
|
||||||
|
field = Date.parse(field)
|
||||||
|
}
|
||||||
let success
|
let success
|
||||||
if (typeof field !== "object" && typeof value !== "object") {
|
if (typeof field !== "object" && typeof value !== "object") {
|
||||||
switch (condition) {
|
switch (condition) {
|
||||||
|
|
Loading…
Reference in New Issue