-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
We need a demo adapter to better demonstrate the functionality of Tux Admin in tux-example-site.
The adapter should have a simple way to initialise data. Something like this:
import { define } from 'tux-adapter-localstorage'
import { registerEditable, MarkdownField, Input } from 'tux'
// interface Instance {
// id: string
// }
// function define<T extends Instance>(model: string, instance: T): void
registerEditable('Quote', [
{
field: 'quote',
label: 'Quote',
component: MarkdownField,
}
{
field: 'author',
label: 'Author',
component: Input,
}
])
define('Quote', {
id: 'foo',
quote: '50% of the time, it works 100%',
author: 'Eirikur',
})
// [snip]
import { Adapter } from 'tux-adapter-localstorage'
import { tuxMiddleware } from 'tux'
createChain()
.chain(tuxMiddleware({
adapter: new Adapter()
}))
The define method should only save the instance if one doesn't already exist with the same id. It should only perform soft-deletes (so instances aren't recreated when you refresh).
The adapter's query api should be able to query in instance by id and type.
benediktvaldez