feat: improve task deletion toast

This commit is contained in:
Johannes Millan 2018-04-07 16:53:28 +02:00
parent 92790cace1
commit 9103e5c2ce

View file

@ -166,15 +166,30 @@
}
// show toast for undo
let toast = this.$mdToast.simple()
.textContent('You deleted "' + task.title + '"')
.action('UNDO')
.hideDelay(15000)
.position('bottom');
this.$mdToast.show(toast)
this.$mdToast.show({
hideDelay: 20000,
controller:
/* @ngInject */
($scope, $mdToast) => {
$scope.undo = () => {
$mdToast.hide('UNDO');
};
},
template: `
<md-toast>
<div class="md-toast-text" flex>
<ng-md-icon icon="delete_forever"
style="fill:#e11826"></ng-md-icon>
You deleted "${task.title}"
<md-button class=""
ng-click="undo()">
<ng-md-icon icon="undo"></ng-md-icon>
UNDO</md-button>
</div>
</md-toast>`
})
.then(function(response) {
if (response === 'ok') {
if (response === 'UNDO') {
// re-add task on undo
that.tasks.splice($index, 0, taskCopy);
}