open-vault/ui/app/components/message-error.js
Matthew Irish d509588cd2
Ember update (#5386)
Ember update - update ember-cli, ember-data, and ember to 3.4 series
2018-09-25 11:28:26 -05:00

37 lines
901 B
JavaScript

import { computed } from '@ember/object';
import Component from '@ember/component';
export default Component.extend({
model: null,
errors: computed(function() {
return [];
}),
errorMessage: null,
displayErrors: computed(
'errorMessage',
'model.{isError,adapterError.message,adapterError.errors.@each}',
'errors',
'errors.@each',
function() {
const errorMessage = this.get('errorMessage');
const errors = this.get('errors');
const modelIsError = this.get('model.isError');
if (errorMessage) {
return [errorMessage];
}
if (errors && errors.length > 0) {
return errors;
}
if (modelIsError) {
if (this.get('model.adapterError.errors.length') > 0) {
return this.get('model.adapterError.errors');
}
return [this.get('model.adapterError.message')];
}
}
),
});