Skip to content

Commit

Permalink
Redo check for delete all frames
Browse files Browse the repository at this point in the history
  • Loading branch information
vikdoro authored and Paul Varache committed Aug 1, 2017
1 parent b919554 commit 6c0806b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions app/elements/kano-bitmap-list/kano-bitmap-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
heading="Do you mean to start again?"
text="You are about to delete all the frames!">
<div slot="actions">
<button class="kano-alert-primary" on-tap="confirmDeleteAll" dialog-confirm>Confirm</button>
<button class="kano-alert-primary" on-tap="_confirmDeleteAll" dialog-confirm>Confirm</button>
<button class="kano-alert-secondary" dialog-dismiss>Cancel</button>
</div>
</kano-alert>
Expand Down Expand Up @@ -311,11 +311,27 @@
}
},
deleteAllFrames () {
if (this.bitmaps.length > 1) {
//alert user
if (Array.isArray(this.bitmaps)
&& this.bitmaps.length > 1
&& this._bitmapsNotEmpty()) {
this.$['delete-all-alert'].open();
//there's only one frame or all frames are empty - delete without alert
} else {
this._confirmDeleteAll();
}
},
confirmDeleteAll () {
_bitmapsNotEmpty () {
let allColors = this.bitmaps.reduce((acc, bitmap, index, bitmaps) => {
if (bitmaps.indexOf(bitmap) === index) {
return acc.concat(bitmap);
}
}, []);
return allColors.some(value => {
return value !== '#000000'
});
},
_confirmDeleteAll () {
this.set('bitmaps', []);
this.fire('tracking-event', {
name: 'all_bitmap_frames_removed'
Expand Down

0 comments on commit 6c0806b

Please sign in to comment.