diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index 4569586762..f8087d8a39 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -3,13 +3,10 @@ import { goto, params } from "@roxi/routify" import { Table, Heading, Layout } from "@budibase/bbui" import Spinner from "components/common/Spinner.svelte" - import { - TableNames, - UNEDITABLE_USER_FIELDS, - UNSORTABLE_TYPES, - } from "constants" + import { TableNames, UNEDITABLE_USER_FIELDS } from "constants" import RoleCell from "./cells/RoleCell.svelte" import { createEventDispatcher } from "svelte" + import { canBeSortColumn } from "@budibase/shared-core" export let schema = {} export let data = [] @@ -32,12 +29,10 @@ $: isUsersTable = tableId === TableNames.USERS $: data && resetSelectedRows() $: { - UNSORTABLE_TYPES.forEach(type => { - Object.values(schema || {}).forEach(col => { - if (col.type === type) { - col.sortable = false - } - }) + Object.values(schema || {}).forEach(col => { + if (!canBeSortColumn(col.type)) { + col.sortable = false + } }) } $: { diff --git a/packages/builder/src/components/design/settings/controls/SortableFieldSelect.svelte b/packages/builder/src/components/design/settings/controls/SortableFieldSelect.svelte index 21ed68ce68..350f59f456 100644 --- a/packages/builder/src/components/design/settings/controls/SortableFieldSelect.svelte +++ b/packages/builder/src/components/design/settings/controls/SortableFieldSelect.svelte @@ -6,7 +6,7 @@ } from "builderStore/dataBinding" import { currentAsset } from "builderStore" import { createEventDispatcher } from "svelte" - import { UNSORTABLE_TYPES } from "constants" + import { canBeSortColumn } from "@budibase/shared-core" export let componentInstance = {} export let value = "" @@ -20,7 +20,7 @@ const getSortableFields = schema => { return Object.entries(schema || {}) - .filter(entry => !UNSORTABLE_TYPES.includes(entry[1].type)) + .filter(entry => canBeSortColumn(entry[1].type)) .map(entry => entry[0]) } diff --git a/packages/builder/src/constants/index.js b/packages/builder/src/constants/index.js index 66fd926a77..f556ee4b05 100644 --- a/packages/builder/src/constants/index.js +++ b/packages/builder/src/constants/index.js @@ -34,8 +34,6 @@ export const UNEDITABLE_USER_FIELDS = [ "lastName", ] -export const UNSORTABLE_TYPES = ["formula", "attachment", "array", "link"] - export const LAYOUT_NAMES = { MASTER: { PRIVATE: "layout_private_master", diff --git a/packages/client/src/components/app/table/Table.svelte b/packages/client/src/components/app/table/Table.svelte index 0ed76317db..8ef25846f8 100644 --- a/packages/client/src/components/app/table/Table.svelte +++ b/packages/client/src/components/app/table/Table.svelte @@ -2,8 +2,8 @@ import { getContext } from "svelte" import { Table } from "@budibase/bbui" import SlotRenderer from "./SlotRenderer.svelte" - import { UnsortableTypes } from "../../../constants" import { onDestroy } from "svelte" + import { canBeSortColumn } from "@budibase/shared-core" export let dataProvider export let columns @@ -102,7 +102,7 @@ return } newSchema[columnName] = schema[columnName] - if (UnsortableTypes.includes(schema[columnName].type)) { + if (!canBeSortColumn(schema[columnName].type)) { newSchema[columnName].sortable = false } diff --git a/packages/client/src/constants.js b/packages/client/src/constants.js index f0a89b9cfd..a4d7411bbd 100644 --- a/packages/client/src/constants.js +++ b/packages/client/src/constants.js @@ -1,13 +1,5 @@ -import { FieldType as FieldTypes } from "@budibase/types" export { FieldType as FieldTypes } from "@budibase/types" -export const UnsortableTypes = [ - FieldTypes.FORMULA, - FieldTypes.ATTACHMENT, - FieldTypes.ARRAY, - FieldTypes.LINK, -] - export const ActionTypes = { ValidateForm: "ValidateForm", UpdateFieldValue: "UpdateFieldValue", diff --git a/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte b/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte index 8600656520..d6cbcb582d 100644 --- a/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte @@ -1,6 +1,6 @@