Browse Source

Allowing formula fields to be display columns.

master
mike12345567 5 years ago
parent
commit
c531a02725
  1. 5
      packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte
  2. 1011
      packages/builder/yarn.lock
  3. 5
      packages/server/src/db/linkedRows/index.js
  4. 7
      packages/server/src/utilities/rowProcessor.js

5
packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte

@ -72,10 +72,7 @@
field.subtype !== AUTO_COLUMN_SUB_TYPES.CREATED_BY &&
field.subtype !== AUTO_COLUMN_SUB_TYPES.UPDATED_BY &&
field.type !== FORMULA_TYPE
$: canBeDisplay =
field.type !== LINK_TYPE &&
field.type !== AUTO_TYPE &&
field.type !== FORMULA_TYPE
$: canBeDisplay = field.type !== LINK_TYPE && field.type !== AUTO_TYPE
$: canBeRequired =
field.type !== LINK_TYPE && !uneditable && field.type !== AUTO_TYPE
$: relationshipOptions = getRelationshipOptions(field)

1011
packages/builder/yarn.lock

File diff suppressed because it is too large

5
packages/server/src/db/linkedRows/index.js

@ -14,6 +14,7 @@ const { FieldTypes } = require("../../constants")
const { getMultiIDParams, USER_METDATA_PREFIX } = require("../../db/utils")
const { partition } = require("lodash")
const { getGlobalUsers } = require("../../utilities/global")
const processor = require("../../utilities/rowProcessor")
/**
* This functionality makes sure that when rows with links are created, updated or deleted they are processed
@ -201,7 +202,9 @@ exports.attachFullLinkedDocs = async (appId, table, rows) => {
if (!linkedRow || !linkedTable) {
continue
}
row[link.fieldName].push(linkedRow)
row[link.fieldName].push(
processor.processFormulas(linkedTable, linkedRow)
)
}
}
return rows

7
packages/server/src/utilities/rowProcessor.js

@ -127,6 +127,10 @@ function processAutoColumn(user, table, row) {
* Looks through the rows provided and finds formulas - which it then processes.
*/
function processFormulas(table, rows) {
const single = !Array.isArray(rows)
if (single) {
rows = [rows]
}
for (let [column, schema] of Object.entries(table.schema)) {
if (schema.type !== FieldTypes.FORMULA) {
continue
@ -137,8 +141,9 @@ function processFormulas(table, rows) {
[column]: processStringSync(schema.formula, row),
}))
}
return rows
return single ? rows[0] : rows
}
exports.processFormulas = processFormulas
/**
* This will coerce a value to the correct types based on the type transform map

Loading…
Cancel
Save