git ssb

3+

arj / patchbook



Commit 06122043fa2db0b00c35584e6635056adfa5cf63

Getting closer to create

Anders Rune Jensen committed on 10/21/2017, 8:19:33 PM
Parent: 24301103fc79102ebc4d71e1454571b15c58592e

Files changed

book/html/create.jschanged
book/html/layout/detail.jschanged
book/obs/book.jschanged
book/obs/struct.jschanged
book/pull/db.jschanged
book/html/create.jsView
@@ -2,23 +2,54 @@
22 const nest = require('depnest')
33
44 exports.needs = nest({
55 'blob.html.input': 'first',
6- 'message.html.confirm': 'first'
6 + 'message.html.confirm': 'first',
7 + 'book.obs.struct': 'first',
8 + 'book.html': {
9 + 'title': 'first',
10 + 'authors': 'first',
11 + 'description': 'first'
12 + }
713 })
814
915 exports.gives = nest('book.html.create')
1016
1117 exports.create = function (api) {
1218 return nest({ 'book.html.create': create })
1319
14- // FIXME: UI to set
15- function create() {
16- // FIXME: create using db & the observable
20 + function createBook() {
21 + const { title, authors, description } = api.book.html
22 + let book = api.book.obs.struct()
23 +
24 + return h('Message -book-detail', [
25 + title({ title: '', msg: { key: '' }, isEditing: true, onUpdate: book().common.title.set }),
26 + h('section.content', [
27 + //images({images: obs.images, msg, isEditing, onUpdate: book.images.add}),
28 + h('section.authors', authors({authors: '', isEditing: true,
29 + onUpdate: book().common.authors.set})),
30 + h('section.description', description({description: '',
31 + isEditing: true,
32 + onUpdate: book().common.description.set})),
33 + //h('section.time', startDateTime({startDateTime: obs.startDateTime, msg, isEditing, onUpdate: editedGathering.startDateTime.set})),
34 + ]),
35 + h('section.actions', [
36 + h('button.edit', { 'ev-click': () => {
37 + // FIXME: close?
38 + }}, 'Cancel'),
39 + h('button', {'ev-click': () => save(book)}, 'Create book')
40 + ])
41 + ])
42 +
43 + function save (book) {
44 + book.create()
45 +
46 + // FIXME: close/update?
47 + }
1748 }
1849
1950 function create () {
20- const actions = h('button', {'ev-click': () => create()}, 'Create')
51 + const actions = h('button', {'ev-click': () => createBook()}, 'Create')
2152 const composer = h('div', [
2253 actions
2354 ])
2455 return composer
book/html/layout/detail.jsView
@@ -9,8 +9,9 @@
99 'markdown': 'first'
1010 },
1111 'book.html': {
1212 'title': 'first',
13 + 'authors': 'first',
1314 'description': 'first'
1415 }
1516 })
1617
book/obs/book.jsView
@@ -24,16 +24,8 @@
2424 }
2525 })
2626 })
2727
28- // FIXME: usage
29- book.create = function(commonObj, subjectiveObj, cb)
30- {
31- api.sbot.async.publish({ type: 'bookclub',
32- common: commonObj,
33- subjective: subjectiveObj }, cb)
34- }
35-
3628 book.amend = function(cb)
3729 {
3830 let msg = { type: 'bookclub-update', root: id }
3931
book/obs/struct.jsView
@@ -16,13 +16,34 @@
1616 subjective: Set([])
1717 })
1818
1919 // FIXME: subjective
20- Object.keys(opts.common).forEach((k) => {
21- if (opts.common[k]) {
22- struct.common[k].set(opts.common[k])
23- }
24- })
20 + if (opts.common) {
21 + Object.keys(opts.common).forEach((k) => {
22 + if (opts.common[k]) {
23 + struct.common[k].set(opts.common[k])
24 + }
25 + })
26 + }
2527
28 + struct.create = function(cb)
29 + {
30 + let commonObj = {}
31 + Object.keys(struct.common).forEach((k) => {
32 + if (struct.common[k]) {
33 + commonObj[k] = struct.common[k]()
34 + }
35 + })
36 +
37 + let subjectiveObj = null // FIXME
38 +
39 + console.log(commonObj)
40 + return
41 +
42 + api.sbot.async.publish({ type: 'bookclub',
43 + common: commonObj,
44 + subjective: subjectiveObj }, cb)
45 + }
46 +
2647 return struct
2748 })
2849 }
book/pull/db.jsView
@@ -1,9 +1,9 @@
11 const pull = require('pull-stream')
22 const nest = require('depnest')
33
44 exports.gives = nest({
5- 'book.pull': ['get', 'getAll', 'create', 'amend']
5 + 'book.pull': ['get', 'getAll']
66 })
77
88 exports.needs = nest({
99 'sbot.pull.messagesByType': 'first',

Built with git-ssb-web