From e43e0e100be81b6e06e7af66ac28d2390898c1d5 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 2 Oct 2020 16:42:47 +0100 Subject: [PATCH] Some quick automation fixes. --- packages/server/src/automations/actions.js | 6 +++--- .../steps/{saveRecord.js => createRecord.js} | 8 ++++---- packages/server/src/automations/steps/filter.js | 10 +++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) rename packages/server/src/automations/steps/{saveRecord.js => createRecord.js} (92%) diff --git a/packages/server/src/automations/actions.js b/packages/server/src/automations/actions.js index b626919ff6..7d86250f56 100644 --- a/packages/server/src/automations/actions.js +++ b/packages/server/src/automations/actions.js @@ -1,5 +1,5 @@ const sendEmail = require("./steps/sendEmail") -const saveRecord = require("./steps/saveRecord") +const createRecord = require("./steps/createRecord") const updateRecord = require("./steps/updateRecord") const deleteRecord = require("./steps/deleteRecord") const createUser = require("./steps/createUser") @@ -17,14 +17,14 @@ const DEFAULT_DIRECTORY = ".budibase-automations" const AUTOMATION_MANIFEST = "manifest.json" const BUILTIN_ACTIONS = { SEND_EMAIL: sendEmail.run, - SAVE_RECORD: saveRecord.run, + CREATE_RECORD: createRecord.run, UPDATE_RECORD: updateRecord.run, DELETE_RECORD: deleteRecord.run, CREATE_USER: createUser.run, } const BUILTIN_DEFINITIONS = { SEND_EMAIL: sendEmail.definition, - SAVE_RECORD: saveRecord.definition, + CREATE_RECORD: createRecord.definition, UPDATE_RECORD: updateRecord.definition, DELETE_RECORD: deleteRecord.definition, CREATE_USER: createUser.definition, diff --git a/packages/server/src/automations/steps/saveRecord.js b/packages/server/src/automations/steps/createRecord.js similarity index 92% rename from packages/server/src/automations/steps/saveRecord.js rename to packages/server/src/automations/steps/createRecord.js index ae99511a7c..379aaa02b4 100644 --- a/packages/server/src/automations/steps/saveRecord.js +++ b/packages/server/src/automations/steps/createRecord.js @@ -2,12 +2,12 @@ const recordController = require("../../api/controllers/record") const automationUtils = require("../automationUtils") module.exports.definition = { - name: "Save Record", - tagline: "Save a {{inputs.enriched.model.name}} record", + name: "Create Record", + tagline: "Create a {{inputs.enriched.model.name}} record", icon: "ri-save-3-fill", - description: "Save a record to your database", + description: "Create a record to your database", type: "ACTION", - stepId: "SAVE_RECORD", + stepId: "CREATE_RECORD", inputs: {}, schema: { inputs: { diff --git a/packages/server/src/automations/steps/filter.js b/packages/server/src/automations/steps/filter.js index d6aa5eb522..4286cd44e8 100644 --- a/packages/server/src/automations/steps/filter.js +++ b/packages/server/src/automations/steps/filter.js @@ -55,7 +55,15 @@ module.exports.definition = { } 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 if (typeof field !== "object" && typeof value !== "object") { switch (condition) {