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.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)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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}))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue