diff --git a/packages/builder/cypress/integration/createView.spec.js b/packages/builder/cypress/integration/createView.spec.js
index b605135ad4..3c13405914 100644
--- a/packages/builder/cypress/integration/createView.spec.js
+++ b/packages/builder/cypress/integration/createView.spec.js
@@ -1,3 +1,4 @@
+
context('Create a View', () => {
before(() => {
cy.visit('localhost:4001/_builder')
@@ -7,6 +8,7 @@ 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])
@@ -15,11 +17,39 @@ context('Create a View', () => {
cy.addRecord(["Teachers", 36, 3])
})
-
- it('creates a stats view based on age', () => {
+ it('creates a view', () => {
cy.contains("Create New View").click()
cy.get("[placeholder='View Name']").type("Test View")
cy.contains("Save View").click()
+ cy.get(".title").contains("Test View")
+ cy.get("thead th").should(($headers) => {
+ expect($headers).to.have.length(3)
+ const headers = $headers.map((i, header) => Cypress.$(header).text())
+ expect(headers.get()).to.deep.eq([
+ "group",
+ "age",
+ "rating"
+ ])
+ })
+ });
+
+ it('filters the view by age over 10', () => {
+ cy.contains("Filter").click()
+ cy.contains("Add Filter").click()
+ cy.get(".menu-container").find("select").first().select("age")
+ cy.get(".menu-container").find("select").eq(1).select("More Than")
+ cy.get("input[placeholder='age']").type(18)
+ cy.contains("Save").click()
+ cy.get("tbody tr").should(($values) => {
+ expect($values).to.have.length(5)
+ })
+ });
+
+ it('creates a stats calculation view based on age', () => {
+ cy.contains("Calculate").click()
+ cy.get(".menu-container").find("select").first().select("Statistics")
+ cy.get(".menu-container").find("select").eq(1).select("age")
+ cy.contains("Save").click()
cy.get("thead th").should(($headers) => {
expect($headers).to.have.length(7)
const headers = $headers.map((i, header) => Cypress.$(header).text())
@@ -28,8 +58,8 @@ context('Create a View', () => {
"sum",
"min",
"max",
- "sumsqr",
"count",
+ "sumsqr",
"avg",
])
})
@@ -37,17 +67,17 @@ context('Create a View', () => {
const values = $values.map((i, value) => Cypress.$(value).text())
expect(values.get()).to.deep.eq([
"null",
- "173",
- "18",
+ "155",
+ "20",
"49",
- "5671",
- "6",
- "28.833333333333332"
+ "5",
+ "5347",
+ "31"
])
})
})
- it('groups the stats view by group', () => {
+ it('groups the view by group', () => {
cy.contains("Group By").click()
cy.get("select").select("group")
cy.contains("Save").click()
@@ -58,12 +88,12 @@ context('Create a View', () => {
const values = $values.map((i, value) => Cypress.$(value).text())
expect(values.get()).to.deep.eq([
"Students",
- "88",
- "18",
+ "70",
+ "20",
"25",
- "1974",
- "4",
- "22"
+ "3",
+ "1650",
+ "23.333333333333332"
])
})
})
@@ -77,6 +107,7 @@ context('Create a View', () => {
})
it('deletes a view', () => {
+ cy.contains("[data-cy=model-nav-item]", "Test View Updated").click()
cy.contains("[data-cy=model-nav-item]", "Test View Updated").find(".ri-more-line").click()
cy.contains("Delete").click()
cy.get(".content").contains("button", "Delete").click()
diff --git a/packages/builder/src/budibase.css b/packages/builder/src/budibase.css
index 8de82530b1..0db3e2fec7 100644
--- a/packages/builder/src/budibase.css
+++ b/packages/builder/src/budibase.css
@@ -127,4 +127,30 @@
align-items: center;
justify-content: center;
font-size: 20px;
-}
\ No newline at end of file
+}
+
+/* Table styles */
+.bb-table {
+ border-collapse: collapse;
+ border-spacing: 0;
+ width: 100%;
+ margin-bottom: var(--spacing-xl);
+}
+
+* + .bb-table {
+ margin-top: var(--spacing-xl)
+}
+
+.bb-table th {
+ padding: var(--spacing-l) var(--spacing-m);
+ text-align: left;
+ vertical-align: bottom;
+}
+
+.bb-table td {
+ padding: var(--spacing-l) var(--spacing-m);
+ vertical-align: top;
+}
+
+.bb-table td > :last-child { margin-bottom: 0; }
+
diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js
index 6e75323b6d..fec21a467e 100644
--- a/packages/builder/src/builderStore/store/backend.js
+++ b/packages/builder/src/builderStore/store/backend.js
@@ -9,10 +9,6 @@ const INITIAL_BACKEND_UI_STATE = {
selectedDatabase: {},
selectedModel: {},
draftModel: {},
- tabs: {
- SETUP_PANEL: "SETUP",
- NAVIGATION_PANEL: "NAVIGATE",
- },
}
export const getBackendUiStore = () => {
@@ -127,19 +123,24 @@ export const getBackendUiStore = () => {
await store.actions.models.fetch()
},
save: async view => {
- await api.post(`/api/views`, view)
+ const response = await api.post(`/api/views`, view)
+ const json = await response.json()
+
+ const viewMeta = {
+ name: view.name,
+ ...json,
+ }
store.update(state => {
const viewModel = state.models.find(
model => model._id === view.modelId
)
- // TODO: Cleaner?
- if (!viewModel.views) viewModel.views = {}
+
if (view.originalName) delete viewModel.views[view.originalName]
- viewModel.views[view.name] = view
+ viewModel.views[view.name] = viewMeta
state.models = state.models
- state.selectedView = view
+ state.selectedView = viewMeta
return state
})
},
@@ -156,11 +157,3 @@ export const getBackendUiStore = () => {
return store
}
-
-// Store Actions
-export const createDatabaseForApp = store => appInstance => {
- store.update(state => {
- state.appInstances.push(appInstance)
- return state
- })
-}
diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js
index 3c1ef7ad05..ac13c90dbe 100644
--- a/packages/builder/src/builderStore/store/index.js
+++ b/packages/builder/src/builderStore/store/index.js
@@ -1,7 +1,6 @@
import { values, cloneDeep } from "lodash/fp"
import getNewComponentName from "../getNewComponentName"
import { backendUiStore } from "builderStore"
-import * as backendStoreActions from "./backend"
import { writable, get } from "svelte/store"
import api from "../api"
import { DEFAULT_PAGES_OBJECT } from "../../constants"
@@ -25,6 +24,7 @@ import {
saveScreenApi as _saveScreenApi,
regenerateCssForCurrentScreen,
generateNewIdsForComponent,
+ getComponentDefinition,
} from "../storeUtils"
export const getStore = () => {
const initial = {
@@ -50,8 +50,6 @@ export const getStore = () => {
store.setPackage = setPackage(store, initial)
- store.createDatabaseForApp = backendStoreActions.createDatabaseForApp(store)
-
store.saveScreen = saveScreen(store)
store.setCurrentScreen = setCurrentScreen(store)
store.setCurrentPage = setCurrentPage(store)
@@ -77,9 +75,6 @@ export const getStore = () => {
export default getStore
-export const getComponentDefinition = (state, name) =>
- name.startsWith("##") ? getBuiltin(name) : state.components[name]
-
const setPackage = (store, initial) => async pkg => {
const [main_screens, unauth_screens] = await Promise.all([
api
diff --git a/packages/builder/src/builderStore/storeUtils.js b/packages/builder/src/builderStore/storeUtils.js
index b88bda17b2..2efffc9d4c 100644
--- a/packages/builder/src/builderStore/storeUtils.js
+++ b/packages/builder/src/builderStore/storeUtils.js
@@ -1,4 +1,7 @@
-import { makePropsSafe } from "components/userInterface/pagesParsing/createProps"
+import {
+ makePropsSafe,
+ getBuiltin,
+} from "components/userInterface/pagesParsing/createProps"
import api from "./api"
import { generate_screen_css } from "./generate_css"
import { uuid } from "./uuid"
@@ -87,3 +90,6 @@ export const generateNewIdsForComponent = (c, state) =>
p._id = uuid()
p._instanceName = getNewComponentName(p._component, state)
})
+
+export const getComponentDefinition = (state, name) =>
+ name.startsWith("##") ? getBuiltin(name) : state.components[name]
diff --git a/packages/builder/src/components/database/DataTable/ModelDataTable.svelte b/packages/builder/src/components/database/DataTable/ModelDataTable.svelte
index 25f9c1e78e..af99b2bada 100644
--- a/packages/builder/src/components/database/DataTable/ModelDataTable.svelte
+++ b/packages/builder/src/components/database/DataTable/ModelDataTable.svelte
@@ -63,7 +63,7 @@
{/if}
-