19 lines
507 B
JavaScript
19 lines
507 B
JavaScript
import Ember from 'ember';
|
|
|
|
const { Service, inject: { service } } = Ember;
|
|
|
|
export default Service.extend({
|
|
flashMessages: service(),
|
|
|
|
alert: function(error) {
|
|
const flash = this.get('flashMessages');
|
|
|
|
flash.clearMessages();
|
|
window.scrollTo(0,0);
|
|
error.errors.forEach((error) => {
|
|
console.error(error);
|
|
const source = error.source.pointer.split('/');
|
|
flash.error(`${source[source.length-1].replace(/([A-Z])/g, ' $1').capitalize()} - ${error.detail}`);
|
|
});
|
|
}
|
|
});
|