Created
February 11, 2019 17:47
-
-
Save chrismllr/05a12ce0c036e914606dba9a724241d5 to your computer and use it in GitHub Desktop.
Confirm action - Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; | |
export default Controller.extend({ | |
confirmAction: service(), | |
api: service(), | |
async deleteRecord(record) { | |
try { | |
const result = await this.confirmAction.ask({ | |
title: 'Are you sure?', | |
message: 'This action cannot be undone!' | |
}); | |
if (result) { | |
await this.api.deleteRecord(record.id); | |
} | |
} catch (err) { | |
// eslint-disable-next-line no-console | |
console.error('Error deleting record', err); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment