fixes views store
This commit is contained in:
parent
3a8e753eae
commit
50da4159e1
|
@ -21,6 +21,7 @@ context("Create a View", () => {
|
||||||
cy.get("input").type("Test View")
|
cy.get("input").type("Test View")
|
||||||
cy.contains("Save View").click()
|
cy.contains("Save View").click()
|
||||||
})
|
})
|
||||||
|
cy.wait(1000)
|
||||||
cy.get(".table-title h1").contains("Test View")
|
cy.get(".table-title h1").contains("Test View")
|
||||||
cy.get("[data-cy=table-header]").then($headers => {
|
cy.get("[data-cy=table-header]").then($headers => {
|
||||||
expect($headers).to.have.length(3)
|
expect($headers).to.have.length(3)
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<EditTablePopover {table} />
|
<EditTablePopover {table} />
|
||||||
{/if}
|
{/if}
|
||||||
</NavItem>
|
</NavItem>
|
||||||
{#each Object.keys(table.views || {}) as viewName}
|
{#each Object.keys(table.views || {}) as viewName, idx (idx)}
|
||||||
<NavItem
|
<NavItem
|
||||||
indentLevel={1}
|
indentLevel={1}
|
||||||
icon="ri-eye-line"
|
icon="ri-eye-line"
|
||||||
|
|
|
@ -10,7 +10,7 @@ export function createViewsStore() {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
select: view => {
|
select: async view => {
|
||||||
update(state => ({
|
update(state => ({
|
||||||
...state,
|
...state,
|
||||||
selected: view,
|
selected: view,
|
||||||
|
@ -29,18 +29,15 @@ export function createViewsStore() {
|
||||||
...json,
|
...json,
|
||||||
}
|
}
|
||||||
|
|
||||||
update(state => {
|
|
||||||
const viewTable = get(tables).list.find(
|
const viewTable = get(tables).list.find(
|
||||||
table => table._id === view.tableId
|
table => table._id === view.tableId
|
||||||
)
|
)
|
||||||
|
|
||||||
if (view.originalName) delete viewTable.views[view.originalName]
|
if (view.originalName) delete viewTable.views[view.originalName]
|
||||||
viewTable.views[view.name] = viewMeta
|
viewTable.views[view.name] = viewMeta
|
||||||
|
await tables.save(viewTable)
|
||||||
|
|
||||||
state.tables = state.tables
|
update(state => ({...state, selected: viewMeta}))
|
||||||
state.selectedView = viewMeta
|
|
||||||
return state
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue