Browse Source

Fix #2209 - views, calculations and group by can't support formula or link fields, making sure these aren't options in the UI. Also fixing an issue where formula values were being saved to DB.

gh-pages
mike12345567 5 years ago
parent
commit
56cf236ebf
  1. 15
      packages/builder/src/components/backend/DataTable/modals/CalculateModal.svelte
  2. 2
      packages/builder/src/components/backend/DataTable/modals/GroupByModal.svelte
  3. 8
      packages/server/src/utilities/rowProcessor.js

15
packages/builder/src/components/backend/DataTable/modals/CalculateModal.svelte

@ -2,6 +2,7 @@
import { Select, Label, notifications, ModalContent } from "@budibase/bbui" import { Select, Label, notifications, ModalContent } from "@budibase/bbui"
import { tables, views } from "stores/backend" import { tables, views } from "stores/backend"
import analytics from "analytics" import analytics from "analytics"
import { FIELDS } from "constants/backend"
const CALCULATIONS = [ const CALCULATIONS = [
{ {
@ -26,11 +27,15 @@
$: fields = $: fields =
viewTable && viewTable &&
Object.keys(viewTable.schema).filter( Object.keys(viewTable.schema).filter(
field => fieldName => {
view.calculation === "count" || const field = viewTable.schema[fieldName]
// don't want to perform calculations based on auto ID return field.type !== FIELDS.FORMULA.type && field.type !== FIELDS.LINK.type &&
(viewTable.schema[field].type === "number" && (view.calculation === "count" ||
!viewTable.schema[field].autocolumn) // don't want to perform calculations based on auto ID
(field.type === "number" &&
!field.autocolumn))
}
) )
function saveView() { function saveView() {

2
packages/builder/src/components/backend/DataTable/modals/GroupByModal.svelte

@ -11,7 +11,7 @@
$: fields = $: fields =
viewTable && viewTable &&
Object.entries(viewTable.schema) Object.entries(viewTable.schema)
.filter(entry => entry[1].type !== FIELDS.LINK.type) .filter(entry => entry[1].type !== FIELDS.LINK.type && entry[1].type !== FIELDS.FORMULA.type)
.map(([key]) => key) .map(([key]) => key)
function saveView() { function saveView() {

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

@ -184,7 +184,13 @@ exports.inputProcessing = (user = {}, table, row) => {
} }
continue continue
} }
clonedRow[key] = exports.coerce(value, field.type) // specific case to delete formula values if they get saved
// type coercion cannot completely remove the field, so have to do it here
if (field.type === FieldTypes.FORMULA) {
delete clonedRow[key]
} else {
clonedRow[key] = exports.coerce(value, field.type)
}
} }
// handle auto columns - this returns an object like {table, row} // handle auto columns - this returns an object like {table, row}
return processAutoColumn(user, copiedTable, clonedRow) return processAutoColumn(user, copiedTable, clonedRow)

Loading…
Cancel
Save