mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-11 00:02:05 -05:00
37 lines
778 B
JavaScript
37 lines
778 B
JavaScript
import computed from 'ember-addons/ember-computed-decorators';
|
|
|
|
export const States = {
|
|
UNCHECKED: 0,
|
|
INVALID: 1,
|
|
VALID: 2
|
|
};
|
|
|
|
export default {
|
|
_validState: null,
|
|
errorDescription: null,
|
|
|
|
init() {
|
|
this._super();
|
|
this.set('_validState', States.UNCHECKED);
|
|
},
|
|
|
|
@computed('_validState')
|
|
valid: state => state === States.VALID,
|
|
|
|
@computed('_validState')
|
|
invalid: state => state === States.INVALID,
|
|
|
|
@computed('_validState')
|
|
unchecked: state => state === States.UNCHECKED,
|
|
|
|
setValid(valid, description) {
|
|
this.set('_validState', valid ? States.VALID : States.INVALID);
|
|
|
|
if (!valid && description && description.length) {
|
|
this.set('errorDescription', description);
|
|
} else {
|
|
this.set('errorDescription', null);
|
|
}
|
|
}
|
|
|
|
};
|