Skip to content

Commit

Permalink
Merge pull request #1 from brancusi/aramzadikian/ch419/can-delete-fla…
Browse files Browse the repository at this point in the history
…sh-cards

Add destroy flash card button
  • Loading branch information
brancusi authored Apr 19, 2017
2 parents d682e6d + 7fceb24 commit eca4a29
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/components/audio-recorder/template.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{ui/icon-button
label="Push to record"
label="Push & hold to record"
leftIcon="microphone"}}
10 changes: 9 additions & 1 deletion app/components/flash-card/template.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<header>
<header class="row">
<div class="index">
{{position}}.
</div>
<div class="stretch">

</div>
<div class="ui-container">
{{ui/icon-button
label="X"
click=destroyModel}}
</div>
</header>

<div class="row fieldsContainer">
Expand Down
12 changes: 11 additions & 1 deletion app/routes/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import moment from 'moment';
export default Ember.Route.extend({
setupController(controller, model) {
const { record, sessionId } = model;
this._super(...arguments);

controller.set('session', record);
controller.set('sessionId', sessionId);

this._super(...arguments);
},

async model(params) {
Expand Down Expand Up @@ -49,6 +50,15 @@ export default Ember.Route.extend({
model.save();
},

// @TODO: Not sure why this is failing.
async destroyModel(flashCard, lesson) {
await flashCard
.destroyRecord()
.catch(() => {});

await lesson.save();
},

async createFlashCard(lesson) {
await this.store
.createRecord('flash-card', { lesson, ts:moment().valueOf() })
Expand Down
1 change: 1 addition & 0 deletions app/templates/session.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
total=cardCount
index=index
onAudioCreated=(route-action 'onAudioCreated' flashCard)
destroyModel=(route-action 'destroyModel' flashCard session)
saveModel=(route-action 'saveModel')}}
{{/each}}
{{else}}
Expand Down
16 changes: 0 additions & 16 deletions tests/integration/components/audio-recorder/component-test.js

This file was deleted.

0 comments on commit eca4a29

Please sign in to comment.