From 5d49d529e3a163278eac5bdaa10e911e919fa541 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 9 Oct 2020 19:10:28 +0100 Subject: [PATCH] Changing record -> row in this update, completing the update of renaming in the builder, this release needs further testing. --- CONTRIBUTING.md | 2 +- .../integration/createAutomation.spec.js | 10 +- .../integration/createComponents.spec.js | 2 +- .../cypress/integration/createTable.spec.js | 8 +- .../cypress/integration/createView.spec.js | 14 +- packages/builder/cypress/support/commands.js | 2 +- .../store/automation/tests/testAutomation.js | 10 +- .../builder/src/builderStore/store/backend.js | 6 +- .../flowchart/AutomationBlockTagline.svelte | 2 +- .../SetupPanel/AutomationBlockSetup.svelte | 6 +- ...cordSelector.svelte => RowSelector.svelte} | 0 .../backend/DataTable/DataTable.svelte | 6 +- .../DataTable/RelationshipDataTable.svelte | 22 +- ...dControl.svelte => RowFieldControl.svelte} | 4 +- .../components/backend/DataTable/Table.svelte | 8 +- .../backend/DataTable/ViewDataTable.svelte | 2 +- .../src/components/backend/DataTable/api.js | 16 +- .../DataTable/buttons/CreateRowButton.svelte | 4 +- ...Modal.svelte => CreateEditRowModal.svelte} | 30 +-- .../popovers/CreateEditColumnPopover.svelte | 2 +- .../DataTable/popovers/RowPopover.svelte | 10 +- ...lector.svelte => LinkedRowSelector.svelte} | 26 +-- .../{CreateRecord.svelte => CreateRow.svelte} | 0 .../{UpdateRecord.svelte => UpdateRow.svelte} | 30 +-- .../EventsEditor/actions/index.js | 12 +- .../userInterface/IconSelect/icons.js | 4 +- .../userInterface/temporaryPanelStructure.js | 8 +- .../[selectedField]/index.svelte | 2 +- .../index.svelte | 0 packages/builder/tests/testData.js | 4 +- packages/client/src/api/index.js | 22 +- packages/client/src/state/eventHandlers.js | 4 +- .../server/scripts/createApiKeyAndAppId.js | 8 +- .../server/src/api/controllers/instance.js | 4 +- .../src/api/controllers/{record.js => row.js} | 172 +++++++-------- packages/server/src/api/controllers/table.js | 40 ++-- .../server/src/api/controllers/view/index.js | 4 +- packages/server/src/api/index.js | 6 +- packages/server/src/api/routes/index.js | 4 +- .../src/api/routes/{record.js => row.js} | 32 +-- .../src/api/routes/tests/automation.spec.js | 10 +- .../src/api/routes/tests/couchTestUtils.js | 2 +- .../tests/{record.spec.js => row.spec.js} | 104 ++++----- .../server/src/api/routes/tests/table.spec.js | 8 +- .../server/src/api/routes/tests/view.spec.js | 20 +- packages/server/src/api/routes/view.js | 4 +- packages/server/src/automations/actions.js | 18 +- .../server/src/automations/automationUtils.js | 28 +-- .../steps/{createRecord.js => createRow.js} | 34 +-- .../steps/{deleteRecord.js => deleteRow.js} | 18 +- .../steps/{updateRecord.js => updateRow.js} | 48 ++--- packages/server/src/automations/triggers.js | 56 ++--- .../LinkController.js | 74 +++---- .../db/{linkedRecords => linkedRows}/index.js | 72 +++---- .../linkUtils.js | 20 +- packages/server/src/db/utils.js | 40 ++-- packages/server/src/events/index.js | 12 +- packages/server/src/middleware/usageQuota.js | 2 +- .../{linkedRecords.js => linkedRows.js} | 0 packages/server/src/utilities/usageQuota.js | 6 +- packages/standard-components/components.json | 10 +- packages/standard-components/public/bundle.js | 200 +++++++++--------- .../standard-components/public/bundle.js.map | 42 ++-- .../public/clientAppDefinition.js | 16 +- .../src/Chart/Brush.svelte | 6 +- .../src/Chart/Bullet.svelte | 6 +- .../src/Chart/Donut.svelte | 14 +- .../src/Chart/Heatmap.svelte | 6 +- .../src/Chart/ScatterPlot.svelte | 6 +- .../src/Chart/Sparkline.svelte | 6 +- .../src/Chart/StackedArea.svelte | 6 +- .../src/Chart/StackedBar.svelte | 6 +- .../standard-components/src/Chart/Step.svelte | 6 +- .../src/Chart/tests/line.html | 18 +- .../standard-components/src/Chart/utils.js | 14 +- .../standard-components/src/DataChart.svelte | 6 +- .../standard-components/src/DataList.svelte | 6 +- .../standard-components/src/DataTable.svelte | 2 +- packages/standard-components/src/Form.svelte | 48 ++--- ...lector.svelte => LinkedRowSelector.svelte} | 22 +- .../{RecordDetail.svelte => RowDetail.svelte} | 32 +-- .../{saveRecordButton.js => saveRowButton.js} | 12 +- packages/standard-components/src/fetchData.js | 14 +- packages/standard-components/src/index.js | 4 +- 84 files changed, 816 insertions(+), 816 deletions(-) rename packages/builder/src/components/automation/SetupPanel/ParamInputs/{RecordSelector.svelte => RowSelector.svelte} (100%) rename packages/builder/src/components/backend/DataTable/{RecordFieldControl.svelte => RowFieldControl.svelte} (87%) rename packages/builder/src/components/backend/DataTable/modals/{CreateEditRecordModal.svelte => CreateEditRowModal.svelte} (50%) rename packages/builder/src/components/common/{LinkedRecordSelector.svelte => LinkedRowSelector.svelte} (61%) rename packages/builder/src/components/userInterface/EventsEditor/actions/{CreateRecord.svelte => CreateRow.svelte} (100%) rename packages/builder/src/components/userInterface/EventsEditor/actions/{UpdateRecord.svelte => UpdateRow.svelte} (81%) rename packages/builder/src/pages/[application]/backend/table/[selectedTable]/relationship/{[selectedRecord] => [selectedRow]}/[selectedField]/index.svelte (88%) rename packages/builder/src/pages/[application]/backend/table/[selectedTable]/relationship/{[selectedRecord] => [selectedRow]}/index.svelte (100%) rename packages/server/src/api/controllers/{record.js => row.js} (58%) rename packages/server/src/api/routes/{record.js => row.js} (57%) rename packages/server/src/api/routes/tests/{record.spec.js => row.spec.js} (74%) rename packages/server/src/automations/steps/{createRecord.js => createRow.js} (74%) rename packages/server/src/automations/steps/{deleteRecord.js => deleteRow.js} (83%) rename packages/server/src/automations/steps/{updateRecord.js => updateRow.js} (59%) rename packages/server/src/db/{linkedRecords => linkedRows}/LinkController.js (83%) rename packages/server/src/db/{linkedRecords => linkedRows}/index.js (57%) rename packages/server/src/db/{linkedRecords => linkedRows}/linkUtils.js (87%) rename packages/server/src/utilities/{linkedRecords.js => linkedRows.js} (100%) rename packages/standard-components/src/{LinkedRecordSelector.svelte => LinkedRowSelector.svelte} (69%) rename packages/standard-components/src/{RecordDetail.svelte => RowDetail.svelte} (56%) rename packages/standard-components/src/Templates/{saveRecordButton.js => saveRowButton.js} (57%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 544c24c003..eb9e9a0b73 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -145,7 +145,7 @@ The HTML and CSS for your apps runtime pages, as well as the budibase client lib #### Backend -The backend schema, tables and records are stored using PouchDB when developing locally, and in [CouchDB](https://pouchdb.com/) when running in production. +/he backend schema, tables and rows are stored using PouchDB when developing locally, and in [CouchDB](https://pouchdb.com/) when running in production. ### Publishing Budibase to NPM diff --git a/packages/builder/cypress/integration/createAutomation.spec.js b/packages/builder/cypress/integration/createAutomation.spec.js index 26af4fac71..67132c736b 100644 --- a/packages/builder/cypress/integration/createAutomation.spec.js +++ b/packages/builder/cypress/integration/createAutomation.spec.js @@ -16,7 +16,7 @@ context("Create a automation", () => { cy.contains("automate").click() cy.contains("Create New Automation").click() cy.get(".modal").within(() => { - cy.get("input").type("Add Record") + cy.get("input").type("Add Row") cy.get(".buttons") .contains("Create") .click() @@ -24,7 +24,7 @@ context("Create a automation", () => { // Add trigger cy.get("[data-cy=add-automation-component]").click() - cy.get("[data-cy=RECORD_SAVED]").click() + cy.get("[data-cy=ROW_SAVED]").click() cy.get("[data-cy=automation-block-setup]").within(() => { cy.get("select") .first() @@ -32,7 +32,7 @@ context("Create a automation", () => { }) // Create action - cy.get("[data-cy=CREATE_RECORD]").click() + cy.get("[data-cy=CREATE_ROW]").click() cy.get("[data-cy=automation-block-setup]").within(() => { cy.get("select") .first() @@ -53,9 +53,9 @@ context("Create a automation", () => { cy.get(".stop-button.highlighted").should("be.visible") }) - it("should add record when a new record is added", () => { + it("should add row when a new row is added", () => { cy.contains("backend").click() - cy.addRecord(["Rover", 15]) + cy.addRow(["Rover", 15]) cy.reload() cy.contains("goodboy").should("have.text", "goodboy") }) diff --git a/packages/builder/cypress/integration/createComponents.spec.js b/packages/builder/cypress/integration/createComponents.spec.js index 2e247f7110..f2035bf16b 100644 --- a/packages/builder/cypress/integration/createComponents.spec.js +++ b/packages/builder/cypress/integration/createComponents.spec.js @@ -6,7 +6,7 @@ xcontext('Create Components', () => { // https://on.cypress.io/type cy.createApp('Model App', 'Model App Description') cy.createTable('dog', 'name', 'age') - cy.addRecord('bob', '15') + cy.addRow('bob', '15') }) // https://on.cypress.io/interacting-with-elements diff --git a/packages/builder/cypress/integration/createTable.spec.js b/packages/builder/cypress/integration/createTable.spec.js index d7ae805b27..36aed6e058 100644 --- a/packages/builder/cypress/integration/createTable.spec.js +++ b/packages/builder/cypress/integration/createTable.spec.js @@ -16,8 +16,8 @@ context("Create a Table", () => { cy.contains("name").should("be.visible") }) - it("creates a record in the table", () => { - cy.addRecord(["Rover"]) + it("creates a row in the table", () => { + cy.addRow(["Rover"]) cy.contains("Rover").should("be.visible") }) @@ -32,7 +32,7 @@ context("Create a Table", () => { cy.contains("nameupdated").should("have.text", "nameupdated") }) - it("edits a record", () => { + it("edits a row", () => { cy.get("tbody .ri-more-line").click() cy.get("[data-cy=edit-row]").click() cy.get(".modal input").type("Updated") @@ -40,7 +40,7 @@ context("Create a Table", () => { cy.contains("RoverUpdated").should("have.text", "RoverUpdated") }) - it("deletes a record", () => { + it("deletes a row", () => { cy.get("tbody .ri-more-line").click() cy.get("[data-cy=delete-row]").click() cy.contains("Delete Row").click() diff --git a/packages/builder/cypress/integration/createView.spec.js b/packages/builder/cypress/integration/createView.spec.js index c224b8af42..e35688c813 100644 --- a/packages/builder/cypress/integration/createView.spec.js +++ b/packages/builder/cypress/integration/createView.spec.js @@ -7,13 +7,13 @@ context("Create a View", () => { cy.addColumn("data", "age", "Number") cy.addColumn("data", "rating", "Number") - // 6 Records - cy.addRecord(["Students", 25, 1]) - cy.addRecord(["Students", 20, 3]) - cy.addRecord(["Students", 18, 6]) - cy.addRecord(["Students", 25, 2]) - cy.addRecord(["Teachers", 49, 5]) - cy.addRecord(["Teachers", 36, 3]) + // 6 Rows + cy.addRow(["Students", 25, 1]) + cy.addRow(["Students", 20, 3]) + cy.addRow(["Students", 18, 6]) + cy.addRow(["Students", 25, 2]) + cy.addRow(["Teachers", 49, 5]) + cy.addRow(["Teachers", 36, 3]) }) it("creates a view", () => { diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index bcc82a0396..cf47051d38 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -92,7 +92,7 @@ Cypress.Commands.add("addColumn", (tableName, columnName, type) => { }) }) -Cypress.Commands.add("addRecord", values => { +Cypress.Commands.add("addRow", values => { cy.contains("Create New Row").click() cy.get(".modal").within(() => { diff --git a/packages/builder/src/builderStore/store/automation/tests/testAutomation.js b/packages/builder/src/builderStore/store/automation/tests/testAutomation.js index 8f714bdead..3fafbaf1d0 100644 --- a/packages/builder/src/builderStore/store/automation/tests/testAutomation.js +++ b/packages/builder/src/builderStore/store/automation/tests/testAutomation.js @@ -26,11 +26,11 @@ export default { ], trigger: { id: "iRzYMOqND", - name: "Record Saved", - event: "record:save", + name: "Row Saved", + event: "row:save", icon: "ri-save-line", - tagline: "Record is added to {{table.name}}", - description: "Fired when a record is saved to your database.", + tagline: "Row is added to {{table.name}}", + description: "Fired when a row is saved to your database.", params: { table: "table" }, type: "TRIGGER", args: { @@ -65,7 +65,7 @@ export default { _rev: "7-b8aa1ce0b53e88928bb88fc11bdc0aff", }, }, - stepId: "RECORD_SAVED", + stepId: "ROW_SAVED", }, }, type: "automation", diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index a5d7afcbb5..d89796f9cc 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -27,7 +27,7 @@ export const getBackendUiStore = () => { }) }, }, - records: { + rows: { save: () => store.update(state => { state.selectedView = state.selectedView @@ -38,9 +38,9 @@ export const getBackendUiStore = () => { state.selectedView = state.selectedView return state }), - select: record => + select: row => store.update(state => { - state.selectedRecord = record + state.selectedRow = row return state }), }, diff --git a/packages/builder/src/components/automation/AutomationBuilder/flowchart/AutomationBlockTagline.svelte b/packages/builder/src/components/automation/AutomationBuilder/flowchart/AutomationBlockTagline.svelte index b0a588314f..aca1e7f90d 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/flowchart/AutomationBlockTagline.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/flowchart/AutomationBlockTagline.svelte @@ -13,7 +13,7 @@ function enrichInputs(inputs) { let enrichedInputs = { ...inputs, enriched: {} } - const tableId = inputs.tableId || inputs.record?.tableId + const tableId = inputs.tableId || inputs.row?.tableId if (tableId) { enrichedInputs.enriched.table = $backendUiStore.tables.find( table => table._id === tableId diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index a43126afbb..896652dbb7 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -1,6 +1,6 @@ -{#if record && record._id === recordId} +{#if row && row._id === rowId} {/if} diff --git a/packages/builder/src/components/backend/DataTable/RecordFieldControl.svelte b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte similarity index 87% rename from packages/builder/src/components/backend/DataTable/RecordFieldControl.svelte rename to packages/builder/src/components/backend/DataTable/RowFieldControl.svelte index 50d13557fd..f974e521c4 100644 --- a/packages/builder/src/components/backend/DataTable/RecordFieldControl.svelte +++ b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte @@ -2,7 +2,7 @@ import { Input, Select, Label, DatePicker, Toggle } from "@budibase/bbui" import Dropzone from "components/common/Dropzone.svelte" import { capitalise } from "../../../helpers" - import LinkedRecordSelector from "components/common/LinkedRecordSelector.svelte" + import LinkedRowSelector from "components/common/LinkedRowSelector.svelte" export let meta export let value = meta.type === "boolean" ? false : "" @@ -28,7 +28,7 @@ {:else if type === 'boolean'} {:else if type === 'link'} - + {:else} {/if} diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index 9c387ca6b2..dde114a76c 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -10,7 +10,7 @@ import ActionButton from "components/common/ActionButton.svelte" import AttachmentList from "./AttachmentList.svelte" import TablePagination from "./TablePagination.svelte" - import CreateEditRecordModal from "./modals/CreateEditRecordModal.svelte" + import CreateEditRowModal from "./modals/CreateEditRowModal.svelte" import RowPopover from "./buttons/CreateRowButton.svelte" import ColumnPopover from "./buttons/CreateColumnButton.svelte" import ViewPopover from "./buttons/CreateViewButton.svelte" @@ -41,12 +41,12 @@ : [] $: tableId = data?.length ? data[0].tableId : null - function selectRelationship(record, fieldName) { - if (!record?.[fieldName]?.length) { + function selectRelationship(row, fieldName) { + if (!row?.[fieldName]?.length) { return } $goto( - `/${$params.application}/backend/table/${tableId}/relationship/${record._id}/${fieldName}` + `/${$params.application}/backend/table/${tableId}/relationship/${row._id}/${fieldName}` ) } diff --git a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte index ec94ae2aa6..d3c82e4f7c 100644 --- a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte @@ -12,7 +12,7 @@ $: name = view.name - // Fetch records for specified view + // Fetch rows for specified view $: { if (!name.startsWith("all_")) { fetchViewData(name, view.field, view.groupBy) diff --git a/packages/builder/src/components/backend/DataTable/api.js b/packages/builder/src/components/backend/DataTable/api.js index b14a7fc613..496db35b3f 100644 --- a/packages/builder/src/components/backend/DataTable/api.js +++ b/packages/builder/src/components/backend/DataTable/api.js @@ -6,22 +6,22 @@ export async function createUser(user) { return await response.json() } -export async function saveRecord(record, tableId) { - const SAVE_RECORDS_URL = `/api/${tableId}/records` - const response = await api.post(SAVE_RECORDS_URL, record) +export async function saveRow(row, tableId) { + const SAVE_ROWS_URL = `/api/${tableId}/rows` + const response = await api.post(SAVE_ROWS_URL, row) return await response.json() } -export async function deleteRecord(record) { - const DELETE_RECORDS_URL = `/api/${record.tableId}/records/${record._id}/${record._rev}` - const response = await api.delete(DELETE_RECORDS_URL) +export async function deleteRow(row) { + const DELETE_ROWS_URL = `/api/${row.tableId}/rows/${row._id}/${row._rev}` + const response = await api.delete(DELETE_ROWS_URL) return response } export async function fetchDataForView(view) { - const FETCH_RECORDS_URL = `/api/views/${view.name}` + const FETCH_ROWS_URL = `/api/views/${view.name}` - const response = await api.get(FETCH_RECORDS_URL) + const response = await api.get(FETCH_ROWS_URL) return await response.json() } diff --git a/packages/builder/src/components/backend/DataTable/buttons/CreateRowButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/CreateRowButton.svelte index 1ef0333398..3c0444881f 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/CreateRowButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/CreateRowButton.svelte @@ -1,6 +1,6 @@ @@ -12,5 +12,5 @@ - + diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditRecordModal.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditRowModal.svelte similarity index 50% rename from packages/builder/src/components/backend/DataTable/modals/CreateEditRecordModal.svelte rename to packages/builder/src/components/backend/DataTable/modals/CreateEditRowModal.svelte index 08aaae1880..2cc0113f55 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditRecordModal.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditRowModal.svelte @@ -1,46 +1,46 @@ + onConfirm={saveRow}> {#each tableSchema as [key, meta]}
- +
{/each}
diff --git a/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte b/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte index 4caa3e3d40..a03c3def9b 100644 --- a/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte +++ b/packages/builder/src/components/backend/DataTable/popovers/CreateEditColumnPopover.svelte @@ -19,7 +19,7 @@ import Checkbox from "components/common/Checkbox.svelte" import ActionButton from "components/common/ActionButton.svelte" import DatePicker from "components/common/DatePicker.svelte" - import LinkedRecordSelector from "components/common/LinkedRecordSelector.svelte" + import LinkedRowSelector from "components/common/LinkedRowSelector.svelte" import * as api from "../api" let fieldDefinitions = cloneDeep(FIELDS) diff --git a/packages/builder/src/components/backend/DataTable/popovers/RowPopover.svelte b/packages/builder/src/components/backend/DataTable/popovers/RowPopover.svelte index 040fc34fab..786c062245 100644 --- a/packages/builder/src/components/backend/DataTable/popovers/RowPopover.svelte +++ b/packages/builder/src/components/backend/DataTable/popovers/RowPopover.svelte @@ -1,7 +1,7 @@ @@ -52,7 +52,7 @@ onOk={deleteRow} title="Confirm Delete" /> - +