Skip to content

Commit

Permalink
Detect changes on the channel form
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarrough committed Jan 4, 2020
1 parent d3b9e4b commit 43562d6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/components/channel-edit-details/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ export default Component.extend({
set(this, 'proxy', {})
},

changesToSave: computed.notEmpty('proxy'),

disableSave: computed.or('changesToSave', 'submitTask.isRunning'),
// We want to disable the save button when either
// 1) no changes have been made to the "proxy" object
// 2) it's already saving/submitting
hasNoChanges: computed('proxy.{title,slug,body,link}', function () {
return Object.keys(this.proxy).length < 1
}),
disableSave: computed.or('hasNoChanges', 'submitTask.isRunning'),

actions: {
cancel() {
get(this, 'onCancel')()
},
submit() {
const proxy = get(this, 'proxy')
get(this, 'submitTask').perform(proxy)
get(this, 'submitTask').perform(get(this, 'proxy'))
set(this, 'proxy', {})
}
}
})

0 comments on commit 43562d6

Please sign in to comment.