fixes views store

This commit is contained in:
Keviin Åberg Kultalahti 2021-04-01 11:53:22 +02:00
parent 3a8e753eae
commit 50da4159e1
3 changed files with 11 additions and 13 deletions

View File

@ -21,6 +21,7 @@ context("Create a View", () => {
cy.get("input").type("Test View")
cy.contains("Save View").click()
})
cy.wait(1000)
cy.get(".table-title h1").contains("Test View")
cy.get("[data-cy=table-header]").then($headers => {
expect($headers).to.have.length(3)

View File

@ -44,7 +44,7 @@
<EditTablePopover {table} />
{/if}
</NavItem>
{#each Object.keys(table.views || {}) as viewName}
{#each Object.keys(table.views || {}) as viewName, idx (idx)}
<NavItem
indentLevel={1}
icon="ri-eye-line"

View File

@ -10,7 +10,7 @@ export function createViewsStore() {
return {
subscribe,
select: view => {
select: async view => {
update(state => ({
...state,
selected: view,
@ -29,18 +29,15 @@ export function createViewsStore() {
...json,
}
update(state => {
const viewTable = get(tables).list.find(
table => table._id === view.tableId
)
const viewTable = get(tables).list.find(
table => table._id === view.tableId
)
if (view.originalName) delete viewTable.views[view.originalName]
viewTable.views[view.name] = viewMeta
if (view.originalName) delete viewTable.views[view.originalName]
viewTable.views[view.name] = viewMeta
await tables.save(viewTable)
state.tables = state.tables
state.selectedView = viewMeta
return state
})
update(state => ({...state, selected: viewMeta}))
},
}
}