git ssb

3+

arj / patchbook



Commit 9c6467e267ec5e13ac657da60215077fc7b42510

Fix cancel edit + selecting emoji

Anders Rune Jensen committed on 11/6/2017, 11:29:59 PM
Parent: 363c1fceec796d28922e74365e68a01c75b5e076

Files changed

book/html/layout/detail.jschanged
book/html/layout/detail.jsView
@@ -65,8 +65,12 @@
6565 cb(null, getEmojiSuggestions(inputText.slice(1)))
6666 }
6767 }, {cls: 'PatchSuggest'})
6868
69 + ratingTypeInput.addEventListener('suggestselect', ev => {
70 + value.set(ev.detail.value)
71 + })
72 +
6973 return when(isEditing, suggestWrapper,
7074 h('span.text', { innerHTML: computed(value, simpleMarkdown) }))
7175 }
7276
@@ -97,8 +101,10 @@
97101
98102 const { title, authors, description, images } = api.book.html
99103
100104 let isEditingSubjective = Value(false)
105 + let originalSubjective = {}
106 + let originalBook = {}
101107 let reviews = []
102108
103109 return [h('Message -book-detail', [
104110 title({ title: obs.title, msg, isEditing, onUpdate: obs.title.set }),
@@ -108,9 +114,18 @@
108114 h('section.description',
109115 description({description: obs.description, isEditing, onUpdate: obs.description.set})),
110116 ]),
111117 h('section.actions', [
112- h('button.edit', { 'ev-click': () => isEditing.set(!isEditing()) },
118 + h('button.edit', { 'ev-click': () => {
119 + if (isEditing()) { // cancel
120 + Object.keys(originalBook).forEach((v) => {
121 + obs[v].set(originalBook[v])
122 + })
123 + } else
124 + originalBook = JSON.parse(JSON.stringify(obs()))
125 +
126 + isEditing.set(!isEditing())
127 + } },
113128 when(isEditing, 'Cancel', 'Edit book')),
114129 when(isEditing, h('button', {'ev-click': () => saveBook(obs)}, 'Update book'))
115130 ]),
116131 h('section.subjective', [
@@ -138,9 +153,21 @@
138153 return reviews
139154 })
140155 ]),
141156 h('section.actions', [
142- h('button.subjective', { 'ev-click': () => isEditingSubjective.set(!isEditingSubjective()) },
157 + h('button.subjective', {
158 + 'ev-click': () => {
159 + if (isEditingSubjective()) { // cancel
160 + let subj = obs.subjective.get(api.keys.sync.id())
161 + Object.keys(originalSubjective).forEach((v) => {
162 + subj[v].set(originalSubjective[v])
163 + })
164 + } else
165 + originalSubjective = JSON.parse(JSON.stringify(obs.subjective.get(api.keys.sync.id())()))
166 +
167 + isEditingSubjective.set(!isEditingSubjective())
168 + }
169 + },
143170 when(isEditingSubjective, 'Cancel', 'Edit rating')),
144171 when(isEditingSubjective, h('button', { 'ev-click': () => saveSubjective(obs) }, 'Update rating'))
145172 ]),
146173 ])]

Built with git-ssb-web