git ssb

3+

arj / patchbook



Commit 634cfef04dcecb5941cb11eaaaa31fb511844f72

Create more or less working

Anders Rune Jensen committed on 10/22/2017, 7:56:37 PM
Parent: 06122043fa2db0b00c35584e6635056adfa5cf63

Files changed

book/html/create.jschanged
book/html/layout/detail.mcsschanged
book/html/create.mcssadded
book/obs/book.jschanged
book/obs/struct.jschanged
book/html/create.jsView
@@ -1,5 +1,5 @@
1-const { h } = require('mutant')
1 +const { h, when, Value } = require('mutant')
22 const nest = require('depnest')
33
44 exports.needs = nest({
55 'blob.html.input': 'first',
@@ -14,44 +14,48 @@
1414
1515 exports.gives = nest('book.html.create')
1616
1717 exports.create = function (api) {
18 + var showCreate = Value(false)
19 +
1820 return nest({ 'book.html.create': create })
1921
2022 function createBook() {
21- const { title, authors, description } = api.book.html
2223 let book = api.book.obs.struct()
2324
24- return h('Message -book-detail', [
25- title({ title: '', msg: { key: '' }, isEditing: true, onUpdate: book().common.title.set }),
25 + return h('Create -book',
26 + { classList: when(showCreate, '-expanded', '-contracted') }, [
2627 h('section.content', [
28 + h('div.title', [h('label', 'Title'),
29 + h('input', {'ev-input': e => book.title.set(e.target.value),
30 + value: '' })]),
2731 //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})),
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: '' }) ])
3338 //h('section.time', startDateTime({startDateTime: obs.startDateTime, msg, isEditing, onUpdate: editedGathering.startDateTime.set})),
3439 ]),
3540 h('section.actions', [
36- h('button.edit', { 'ev-click': () => {
37- // FIXME: close?
38- }}, 'Cancel'),
41 + h('button', { 'ev-click': () => showCreate.set(false) }, 'Cancel'),
3942 h('button', {'ev-click': () => save(book)}, 'Create book')
4043 ])
4144 ])
4245
4346 function save (book) {
4447 book.create()
4548
46- // FIXME: close/update?
49 + showCreate.set(false)
4750 }
4851 }
4952
5053 function create () {
51- const actions = h('button', {'ev-click': () => createBook()}, 'Create')
54 + const actions = h('button', {'ev-click': () => showCreate.set(true) }, 'Create')
5255 const composer = h('div', [
53- actions
56 + actions,
57 + createBook()
5458 ])
5559 return composer
5660 }
5761 }
book/html/layout/detail.mcssView
@@ -55,16 +55,11 @@
5555 section.actions {
5656 display: flex
5757 justify-content: flex-start
5858
59- button.attend {
60- margin-left: 0
61- }
62-
6359 button.edit {
6460 margin-left: auto
6561 }
66-
6762 }
6863 }
6964
7065 StartDateTime {
book/html/create.mcssView
@@ -1,0 +1,30 @@
1 +Create -book {
2 + section.content input {
3 + margin-left: 5px
4 + border: 1px solid gainsboro
5 + }
6 +
7 + section.content textarea {
8 + margin-left: 5px
9 + border: 1px solid gainsboro
10 + }
11 +
12 + -contracted {
13 + section.actions {
14 + display: none
15 + }
16 + section.content {
17 + display: none
18 + }
19 + }
20 +
21 + -expanded {
22 + section.actions {
23 + display: block
24 + }
25 + section.content {
26 + display: block
27 + }
28 + }
29 +}
30 +
book/obs/book.jsView
@@ -19,26 +19,28 @@
1919 api.book.pull.get(id, dbBook => {
2020 // FIXME: subjective
2121 Object.keys(dbBook.common).forEach((k) => {
2222 if (dbBook.common[k]) {
23- book.common[k].set(dbBook.common[k])
23 + book[k].set(dbBook.common[k])
2424 }
2525 })
2626 })
2727
2828 book.amend = function(cb)
2929 {
3030 let msg = { type: 'bookclub-update', root: id }
3131
32- if (book.common) {
33- msg.common = {}
34- Object.keys(book.common).forEach((k) => {
35- if (book.common[k]) {
36- msg.common[k] = book.common[k]()
37- }
38- })
32 + let s = book()
33 +
34 + msg.common = {
35 + title: s.title,
36 + authors: s.authors,
37 + description: s.description
3938 }
4039
40 + console.log(msg)
41 + return
42 +
4143 /* FIXME
4244 if (book.subjective)
4345 msg.subjective = subjectiveObj
4446 */
book/obs/struct.jsView
@@ -6,35 +6,24 @@
66 exports.create = function (api) {
77 return nest('book.obs.struct', function (opts = {}) {
88 const struct = Struct({
99 key: Value(''),
10- common: {
11- title: Value(''),
12- authors: Value(''),
13- description: Value(''),
14- images: Set([])
15- },
10 + title: Value(''),
11 + authors: Value(''),
12 + description: Value(''),
13 + images: Set([]),
1614 subjective: Set([])
1715 })
1816
19- // FIXME: subjective
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- }
27-
2817 struct.create = function(cb)
2918 {
30- let commonObj = {}
31- Object.keys(struct.common).forEach((k) => {
32- if (struct.common[k]) {
33- commonObj[k] = struct.common[k]()
34- }
35- })
19 + let s = struct()
3620
21 + let commonObj = {
22 + title: s.title,
23 + authors: s.authors,
24 + description: s.description
25 + }
3726 let subjectiveObj = null // FIXME
3827
3928 console.log(commonObj)
4029 return

Built with git-ssb-web