diff --git a/packages/frontend-core/src/api/viewsV2.js b/packages/frontend-core/src/api/viewsV2.js index 9e92bde1db..c31d3dcdee 100644 --- a/packages/frontend-core/src/api/viewsV2.js +++ b/packages/frontend-core/src/api/viewsV2.js @@ -58,15 +58,6 @@ export const buildViewV2Endpoints = API => ({ return await API.delete({ url: `/api/v2/views/${viewId}` }) }, - - - - - - - - - /** * Creates a row from a view * @param row the row to create diff --git a/packages/frontend-core/src/components/grid/stores/viewV2.js b/packages/frontend-core/src/components/grid/stores/viewV2.js index 2f0166cad6..c14ce8cf0d 100644 --- a/packages/frontend-core/src/components/grid/stores/viewV2.js +++ b/packages/frontend-core/src/components/grid/stores/viewV2.js @@ -27,15 +27,15 @@ export const createActions = context => { row.tableId = $datasource?.tableId row._viewId = $datasource?.id return { - ...await API.saveRow(row, SuppressErrors), - _viewId: row._viewId + ...(await API.saveRow(row, SuppressErrors)), + _viewId: row._viewId, } } const updateRow = async row => { const $datasource = get(datasource) return { - ...await API.patchRow(row, SuppressErrors), + ...(await API.patchRow(row, SuppressErrors)), _viewId: $datasource.id, } } diff --git a/packages/server/src/api/controllers/row/internal.ts b/packages/server/src/api/controllers/row/internal.ts index a18390e2b6..4a412c42eb 100644 --- a/packages/server/src/api/controllers/row/internal.ts +++ b/packages/server/src/api/controllers/row/internal.ts @@ -1,13 +1,28 @@ import * as linkRows from "../../../db/linkedRows" -import {generateRowID, getTableIDFromRowID, InternalTables,} from "../../../db/utils" +import { + generateRowID, + getTableIDFromRowID, + InternalTables, +} from "../../../db/utils" import * as userController from "../user" -import {cleanupAttachments, inputProcessing, outputProcessing,} from "../../../utilities/rowProcessor" -import {FieldTypes} from "../../../constants" +import { + cleanupAttachments, + inputProcessing, + outputProcessing, +} from "../../../utilities/rowProcessor" +import { FieldTypes } from "../../../constants" import * as utils from "./utils" -import {cloneDeep} from "lodash/fp" -import {context} from "@budibase/backend-core" -import {finaliseRow, updateRelatedFormula} from "./staticFormula" -import {LinkDocumentValue, PatchRowRequest, PatchRowResponse, Row, Table, UserCtx,} from "@budibase/types" +import { cloneDeep } from "lodash/fp" +import { context } from "@budibase/backend-core" +import { finaliseRow, updateRelatedFormula } from "./staticFormula" +import { + LinkDocumentValue, + PatchRowRequest, + PatchRowResponse, + Row, + Table, + UserCtx, +} from "@budibase/types" import sdk from "../../../sdk" export async function patch(ctx: UserCtx) { diff --git a/packages/server/src/api/controllers/table/index.ts b/packages/server/src/api/controllers/table/index.ts index 62aa4c33e9..5e09a5237a 100644 --- a/packages/server/src/api/controllers/table/index.ts +++ b/packages/server/src/api/controllers/table/index.ts @@ -1,12 +1,23 @@ import * as internal from "./internal" import * as external from "./external" -import {isRows, isSchema, validate as validateSchema,} from "../../../utilities/schema" -import {isExternalTable, isSQL} from "../../../integrations/utils" -import {events} from "@budibase/backend-core" -import {FetchTablesResponse, SaveTableRequest, SaveTableResponse, Table, TableResponse, UserCtx,} from "@budibase/types" +import { + isRows, + isSchema, + validate as validateSchema, +} from "../../../utilities/schema" +import { isExternalTable, isSQL } from "../../../integrations/utils" +import { events } from "@budibase/backend-core" +import { + FetchTablesResponse, + SaveTableRequest, + SaveTableResponse, + Table, + TableResponse, + UserCtx, +} from "@budibase/types" import sdk from "../../../sdk" -import {jsonFromCsvString} from "../../../utilities/csv" -import {builderSocket} from "../../../websockets" +import { jsonFromCsvString } from "../../../utilities/csv" +import { builderSocket } from "../../../websockets" function pickApi({ tableId, table }: { tableId?: string; table?: Table }) { if (table && !tableId) { diff --git a/packages/server/src/api/controllers/view/viewsV2.ts b/packages/server/src/api/controllers/view/viewsV2.ts index 404f018886..c6898c4600 100644 --- a/packages/server/src/api/controllers/view/viewsV2.ts +++ b/packages/server/src/api/controllers/view/viewsV2.ts @@ -45,7 +45,8 @@ async function parseSchemaUI(ctx: Ctx, view: CreateViewRequest) { } } - const finalViewSchema = view.schema && + const finalViewSchema = + view.schema && Object.entries(view.schema).reduce((p, [fieldName, schemaValue]) => { const fieldSchema: RequiredKeys = { order: schemaValue.order, diff --git a/packages/server/src/sdk/app/tables/index.ts b/packages/server/src/sdk/app/tables/index.ts index 30fc3aba42..1bf9117837 100644 --- a/packages/server/src/sdk/app/tables/index.ts +++ b/packages/server/src/sdk/app/tables/index.ts @@ -1,9 +1,18 @@ -import {context} from "@budibase/backend-core" -import {BudibaseInternalDB, getTableParams} from "../../../db/utils" -import {breakExternalTableId, isExternalTable, isSQL,} from "../../../integrations/utils" -import {Database, Table, TableResponse, TableViewsResponse,} from "@budibase/types" +import { context } from "@budibase/backend-core" +import { BudibaseInternalDB, getTableParams } from "../../../db/utils" +import { + breakExternalTableId, + isExternalTable, + isSQL, +} from "../../../integrations/utils" +import { + Database, + Table, + TableResponse, + TableViewsResponse, +} from "@budibase/types" import datasources from "../datasources" -import {isEditableColumn, populateExternalTableSchemas} from "./validation" +import { isEditableColumn, populateExternalTableSchemas } from "./validation" import sdk from "../../../sdk" async function getAllInternalTables(db?: Database): Promise { diff --git a/packages/server/src/sdk/app/views/index.ts b/packages/server/src/sdk/app/views/index.ts index 5acf5f0a5a..d4f94adffa 100644 --- a/packages/server/src/sdk/app/views/index.ts +++ b/packages/server/src/sdk/app/views/index.ts @@ -79,16 +79,16 @@ export function enrichSchema(view: View | ViewV2, tableSchema: TableSchema) { } let schema = { ...tableSchema } - const anyViewOrder = Object.values(view.schemaUI || {}).some(ui => ui.order != null) + const anyViewOrder = Object.values(view.schemaUI || {}).some( + ui => ui.order != null + ) for (const key of Object.keys(schema)) { // if nothing specified in view, then it is not visible const ui = view.schemaUI?.[key] || { visible: false } schema[key] = { ...schema[key], ...ui, - order: anyViewOrder - ? ui?.order ?? undefined - : schema[key].order, + order: anyViewOrder ? ui?.order ?? undefined : schema[key].order, } } delete view.schemaUI