From 09ac8408f2fccc37dbe1cdd6ef9f77bc3fe4d795 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 24 Jan 2022 10:44:37 +0000 Subject: [PATCH] Update all API usages in builder components directory --- .../DataTable/RelationshipDataTable.svelte | 15 +++++--- .../components/backend/DataTable/Table.svelte | 19 ++++++---- .../backend/DataTable/ViewDataTable.svelte | 31 ++++++++-------- .../backend/DataTable/modals/EditRoles.svelte | 30 +++++++++------- .../DataTable/modals/ExportModal.svelte | 19 +++++----- .../DataTable/modals/ImportModal.svelte | 20 ++++++----- .../TableIntegrationMenu/index.svelte | 17 +++++---- .../modals/CreateDatasourceModal.svelte | 30 +++++++++++----- .../TableNavigator/TableDataImport.svelte | 36 +++++++++---------- packages/frontend-core/src/api/builder.js | 9 +++++ packages/frontend-core/src/api/index.js | 9 ++++- .../frontend-core/src/api/relationships.js | 8 +++-- packages/frontend-core/src/api/rows.js | 14 ++++++++ packages/frontend-core/src/api/tables.js | 31 ++++++++++++++++ packages/frontend-core/src/api/views.js | 15 ++++++++ 15 files changed, 206 insertions(+), 97 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/RelationshipDataTable.svelte b/packages/builder/src/components/backend/DataTable/RelationshipDataTable.svelte index a0a06d1866..8ef870caca 100644 --- a/packages/builder/src/components/backend/DataTable/RelationshipDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/RelationshipDataTable.svelte @@ -1,7 +1,8 @@ diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index 3c646bde68..ab94080959 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -2,7 +2,7 @@ import { fade } from "svelte/transition" import { goto, params } from "@roxi/routify" import { Table, Modal, Heading, notifications, Layout } from "@budibase/bbui" - import api from "builderStore/api" + import { API } "api" import Spinner from "components/common/Spinner.svelte" import DeleteRowsButton from "./buttons/DeleteRowsButton.svelte" import CreateEditRow from "./modals/CreateEditRow.svelte" @@ -88,12 +88,17 @@ } const deleteRows = async () => { - await api.delete(`/api/${tableId}/rows`, { - rows: selectedRows, - }) - data = data.filter(row => !selectedRows.includes(row)) - notifications.success(`Successfully deleted ${selectedRows.length} rows`) - selectedRows = [] + try { + await API.deleteRows({ + tableId, + rows: selectedRows + }) + data = data.filter(row => !selectedRows.includes(row)) + notifications.success(`Successfully deleted ${selectedRows.length} rows`) + selectedRows = [] + } catch (error) { + notifications.error("Error deleting rows") + } } const editRow = row => { diff --git a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte index a52fbdb177..10c6703623 100644 --- a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte @@ -1,5 +1,5 @@ diff --git a/packages/builder/src/components/backend/DataTable/modals/EditRoles.svelte b/packages/builder/src/components/backend/DataTable/modals/EditRoles.svelte index 7fa9482fbe..e2ccab11af 100644 --- a/packages/builder/src/components/backend/DataTable/modals/EditRoles.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/EditRoles.svelte @@ -1,7 +1,7 @@ diff --git a/packages/builder/src/components/backend/DataTable/modals/ImportModal.svelte b/packages/builder/src/components/backend/DataTable/modals/ImportModal.svelte index 88d001a444..930842d34f 100644 --- a/packages/builder/src/components/backend/DataTable/modals/ImportModal.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/ImportModal.svelte @@ -1,7 +1,7 @@ diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte index 79ebdb1020..9277207e37 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte @@ -1,7 +1,7 @@ diff --git a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte index 44cb374092..774aac0677 100644 --- a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte +++ b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte @@ -1,7 +1,7 @@