discourse/app/assets/javascripts/wizard/addon/models/wizard-field.js
Jarek Radosz fcb4e5a1a1
DEV: Make wizard an ember addon (#17027)
Co-authored-by: David Taylor <david@taylorhq.com>
2022-06-17 14:50:21 +02:00

24 lines
433 B
JavaScript

import EmberObject from "@ember/object";
import ValidState from "wizard/mixins/valid-state";
export default EmberObject.extend(ValidState, {
id: null,
type: null,
value: null,
required: null,
warning: null,
check() {
if (!this.required) {
this.setValid(true);
return true;
}
const val = this.value;
const valid = val && val.length > 0;
this.setValid(valid);
return valid;
},
});