Commit b0b8e31176b8cf099174eeaa8faf5e129916374e
fix profile edit callback from settings
mix irving committed on 8/27/2017, 11:24:45 PMParent: ee8e72469e3082880b91e42e3ed64747ad35033f
Files changed
app/html/header.js | changed |
app/page/settings.js | changed |
app/page/settings.mcss | changed |
app/page/userEdit.js | changed |
app/html/header.js | ||
---|---|---|
@@ -16,9 +16,9 @@ | ||
16 | 16 | // FUTURE breadcrumb here ? |
17 | 17 | // h('h1', computed(nav.location, e => e.element.title)), |
18 | 18 | |
19 | 19 | h('div.tools', [ |
20 | - h('i.fa.fa-user', { 'ev-click': () => nav.push({page:'userEdit', feed: api.keys.sync.id()}) }), // TEMP | |
20 | + // h('i.fa.fa-user', { 'ev-click': () => nav.push({page:'userEdit', feed: api.keys.sync.id()}) }), // TEMP | |
21 | 21 | h('i.fa.fa-address-book', { 'ev-click': () => nav.push({page:'userFind'}) }), |
22 | 22 | h('i.fa.fa-hashtag', { 'ev-click': () => nav.push({page:'groupFind'}) }), |
23 | 23 | h('i.fa.fa-gear', { 'ev-click': () => nav.push({page:'settings'}) }) |
24 | 24 | ]) |
app/page/settings.js | ||
---|---|---|
@@ -31,8 +31,17 @@ | ||
31 | 31 | const feed = api.keys.sync.id() |
32 | 32 | const strings = api.translations.sync.strings() |
33 | 33 | const currentLanguage = api.settings.sync.get('language') |
34 | 34 | |
35 | + const handleEdit = () => api.history.sync.push({ | |
36 | + page:'userEdit', | |
37 | + feed, | |
38 | + callback: (err, didEdit) => { | |
39 | + if (err) throw new Error ('Error editing profile', err) | |
40 | + api.history.sync.push({ page: 'settings' }) | |
41 | + } | |
42 | + }) | |
43 | + | |
35 | 44 | return h('Page -settings', [ |
36 | 45 | h('div.container', [ |
37 | 46 | h('h1', strings.settingsPage.title), |
38 | 47 | h('section -profile', [ |
@@ -41,9 +50,9 @@ | ||
41 | 50 | h('div.name', api.about.obs.name(feed)), |
42 | 51 | api.about.html.image(feed), |
43 | 52 | ]), |
44 | 53 | h('div.actions', [ |
45 | - h('Button', { 'ev-click': () => api.history.sync.push({page:'userEdit', feed}) }, [ | |
54 | + h('Button', { 'ev-click': handleEdit}, [ | |
46 | 55 | strings.settingsPage.action.edit, |
47 | 56 | h('i.fa.fa-pencil') |
48 | 57 | ]) |
49 | 58 | ]) |
app/page/settings.mcss | ||
---|---|---|
@@ -5,8 +5,12 @@ | ||
5 | 5 | background: #fff |
6 | 6 | padding: 1rem |
7 | 7 | $maxWidthSmaller |
8 | 8 | |
9 | + h1 { | |
10 | + margin-top: 0 | |
11 | + } | |
12 | + | |
9 | 13 | section { |
10 | 14 | padding-bottom: 2rem |
11 | 15 | margin-bottom: 2rem |
12 | 16 |
app/page/userEdit.js | ||
---|---|---|
@@ -12,10 +12,10 @@ | ||
12 | 12 | exports.create = (api) => { |
13 | 13 | return nest('app.page.userEdit', userEdit) |
14 | 14 | |
15 | 15 | function userEdit (location) { |
16 | - // location is an object { feed, page: 'userEdit' } | |
17 | - const { feed } = location | |
16 | + // location is an object { feed, page: 'userEdit', callback } | |
17 | + var { feed, callback } = location | |
18 | 18 | |
19 | 19 | const strings = api.translations.sync.strings() |
20 | 20 | |
21 | 21 | const options = Object.assign({}, location, { |
@@ -29,13 +29,16 @@ | ||
29 | 29 | save: strings.userEdit.action.save, |
30 | 30 | } |
31 | 31 | }) |
32 | 32 | |
33 | - const callback = (err, didEdit) => { | |
33 | + const defaultCallback = (err, didEdit) => { | |
34 | 34 | if (err) throw new Error ('Error editing profile', err) |
35 | 35 | |
36 | 36 | api.history.sync.push({ page: 'userShow', feed }) |
37 | 37 | } |
38 | + callback = typeof callback == 'function' | |
39 | + ? callback | |
40 | + : defaultCallback | |
38 | 41 | |
39 | 42 | return h('Page -userEdit', {}, [ |
40 | 43 | h('div.container', [ |
41 | 44 | api.about.page.edit(options, callback) |
Built with git-ssb-web