Skip to content

Commit 9103e5c

Browse files
committed
feat: improve task deletion toast
1 parent 92790ca commit 9103e5c

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

app-src/scripts/task-list/task-list-d.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,30 @@
166166
}
167167

168168
// show toast for undo
169-
let toast = this.$mdToast.simple()
170-
.textContent('You deleted "' + task.title + '"')
171-
.action('UNDO')
172-
.hideDelay(15000)
173-
.position('bottom');
174-
175-
this.$mdToast.show(toast)
169+
this.$mdToast.show({
170+
hideDelay: 20000,
171+
controller:
172+
/* @ngInject */
173+
($scope, $mdToast) => {
174+
$scope.undo = () => {
175+
$mdToast.hide('UNDO');
176+
};
177+
},
178+
template: `
179+
<md-toast>
180+
<div class="md-toast-text" flex>
181+
<ng-md-icon icon="delete_forever"
182+
style="fill:#e11826"></ng-md-icon>
183+
You deleted "${task.title}"
184+
<md-button class=""
185+
ng-click="undo()">
186+
<ng-md-icon icon="undo"></ng-md-icon>
187+
UNDO</md-button>
188+
</div>
189+
</md-toast>`
190+
})
176191
.then(function(response) {
177-
if (response === 'ok') {
192+
if (response === 'UNDO') {
178193
// re-add task on undo
179194
that.tasks.splice($index, 0, taskCopy);
180195
}

0 commit comments

Comments
 (0)