discourse/app/assets/javascripts/wizard/mixins/valid-state.js

Failed to ignore revisions in .git-blame-ignore-revs.

37 lines
820 B
JavaScript
Raw Normal View History

import discourseComputed from "discourse-common/utils/decorators";
2016-08-25 13:14:56 -04:00
export const States = {
UNCHECKED: 0,
INVALID: 1,
VALID: 2
};
export default {
_validState: null,
errorDescription: null,
2016-08-25 13:14:56 -04:00
init() {
this._super(...arguments);
2018-06-15 11:03:24 -04:00
this.set("_validState", States.UNCHECKED);
2016-08-25 13:14:56 -04:00
},
@discourseComputed("_validState")
2018-07-30 11:56:48 -04:00
valid: state => state === States.VALID,
2016-08-25 13:14:56 -04:00
@discourseComputed("_validState")
2018-07-30 11:56:48 -04:00
invalid: state => state === States.INVALID,
2016-08-25 13:14:56 -04:00
@discourseComputed("_validState")
2018-07-30 11:56:48 -04:00
unchecked: state => state === States.UNCHECKED,
2016-08-25 13:14:56 -04:00
setValid(valid, description) {
2018-06-15 11:03:24 -04:00
this.set("_validState", valid ? States.VALID : States.INVALID);
if (!valid && description && description.length) {
2018-06-15 11:03:24 -04:00
this.set("errorDescription", description);
} else {
2018-06-15 11:03:24 -04:00
this.set("errorDescription", null);
}
2016-08-25 13:14:56 -04:00
}
};