git ssb

3+

arj / patchbook



Tree: 634cfef04dcecb5941cb11eaaaa31fb511844f72

Files: 634cfef04dcecb5941cb11eaaaa31fb511844f72 / book / html / create.js

1959 bytesRaw
1const { h, when, Value } = require('mutant')
2const nest = require('depnest')
3
4exports.needs = nest({
5 'blob.html.input': 'first',
6 'message.html.confirm': 'first',
7 'book.obs.struct': 'first',
8 'book.html': {
9 'title': 'first',
10 'authors': 'first',
11 'description': 'first'
12 }
13})
14
15exports.gives = nest('book.html.create')
16
17exports.create = function (api) {
18 var showCreate = Value(false)
19
20 return nest({ 'book.html.create': create })
21
22 function createBook() {
23 let book = api.book.obs.struct()
24
25 return h('Create -book',
26 { classList: when(showCreate, '-expanded', '-contracted') }, [
27 h('section.content', [
28 h('div.title', [h('label', 'Title'),
29 h('input', {'ev-input': e => book.title.set(e.target.value),
30 value: '' })]),
31 //images({images: obs.images, msg, isEditing, onUpdate: book.images.add}),
32 h('div.authors', [h('label', 'Authors'),
33 h('input', {'ev-input': e => book.authors.set(e.target.value),
34 value: '' })]),
35 h('div.description', [h('label', 'Description'),
36 h('textarea', {'ev-input': e => book.description.set(e.target.value),
37 value: '' }) ])
38 //h('section.time', startDateTime({startDateTime: obs.startDateTime, msg, isEditing, onUpdate: editedGathering.startDateTime.set})),
39 ]),
40 h('section.actions', [
41 h('button', { 'ev-click': () => showCreate.set(false) }, 'Cancel'),
42 h('button', {'ev-click': () => save(book)}, 'Create book')
43 ])
44 ])
45
46 function save (book) {
47 book.create()
48
49 showCreate.set(false)
50 }
51 }
52
53 function create () {
54 const actions = h('button', {'ev-click': () => showCreate.set(true) }, 'Create')
55 const composer = h('div', [
56 actions,
57 createBook()
58 ])
59 return composer
60 }
61}
62

Built with git-ssb-web