Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin: Create a demo adapter #141

Open
eirikurn opened this issue Sep 11, 2017 · 0 comments
Open

Admin: Create a demo adapter #141

eirikurn opened this issue Sep 11, 2017 · 0 comments

Comments

@eirikurn
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant