Skip to content

Commit

Permalink
feat: track can be put out of no media avialable mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Vieilledent committed Jul 13, 2018
1 parent e730d2a commit 956f4f1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/components/track-edit/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ export default TrackFormComponent.extend({
setMediaAvailable: task(function * (event) {
event.preventDefault()
set(this, 'track.mediaNotAvailable', false)
get(this, 'submitTask').perform(event)
}).drop()
})
4 changes: 2 additions & 2 deletions app/components/track-edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
<button
onclick={{perform submitTask}}
type="submit"
class="Btn Btn--primary"
class="Btn"
title="Save the track"
disabled={{submitTask.isRunning}}>
disabled={{submitDisabled}}>
{{if submitTask.isIdle "Save" "Saving…"}}
</button>

Expand Down
6 changes: 5 additions & 1 deletion app/components/track-form/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import youtubeUrlToId from 'radio4000/utils/youtube-url-to-id';
import {fetchTitle} from 'radio4000/utils/youtube-api';
import {task, timeout} from 'ember-concurrency';

const {Component, get, set, observer} = Ember;
const {Component, get, set, observer, computed} = Ember;

export default Component.extend({
tagName: 'form',
Expand Down Expand Up @@ -43,6 +43,10 @@ export default Component.extend({
}
}),

submitDisabled: computed('track.hasDirtyAttributes', 'submitTask', function() {
return !this.get('track.hasDirtyAttributes') || this.get('submitTask.isRunning')
}),

fetchTitle: task(function * () {
yield timeout(250); // throttle
const track = get(this, 'track')
Expand Down

0 comments on commit 956f4f1

Please sign in to comment.