mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 09:53:32 +03:00
8d01fb5556
no issue - ran [ember-native-class-codemod](https://github.com/ember-codemods/ember-native-class-codemod) to convert the majority of remaining EmberObject based controllers and components to native class syntax using the `@classic` decorator - skipped older style modal components (`components/modal-*.js`) due to observed incompatibilities in some cases
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
import Component from '@ember/component';
|
|
import ValidationStateMixin from 'ghost-admin/mixins/validation-state';
|
|
import classic from 'ember-classic-decorator';
|
|
import {classNameBindings} from '@ember-decorators/component';
|
|
import {computed} from '@ember/object';
|
|
|
|
/**
|
|
* Handles the CSS necessary to show a specific property state. When passed a
|
|
* DS.Errors object and a property name, if the DS.Errors object has errors for
|
|
* the specified property, it will change the CSS to reflect the error state
|
|
* @param {DS.Errors} errors The DS.Errors object
|
|
* @param {string} property Name of the property
|
|
*/
|
|
@classic
|
|
@classNameBindings('errorClass')
|
|
export default class GhValidationStatusContainer extends Component.extend(ValidationStateMixin) {
|
|
@computed('property', 'hasError', 'hasValidated.[]')
|
|
get errorClass() {
|
|
let hasValidated = this.hasValidated;
|
|
let property = this.property;
|
|
|
|
if (hasValidated && hasValidated.includes(property)) {
|
|
return this.hasError ? 'error' : 'success';
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
}
|