@@ -2,26 +2,29 @@ import { not, notEmpty, and, readOnly } from '@ember/object/computed';
22import { defineProperty } from '@ember/object' ;
33import BsFormElement from 'ember-bootstrap/components/bs-form/element' ;
44
5- export default BsFormElement . extend ( {
6- _attrValidations : null ,
7- notValidating : not ( 'isValidating' ) . readOnly ( ) ,
8- notDisabled : not ( 'disabled' ) . readOnly ( ) ,
9- _presenceEnabled : not ( '_attrValidations.options.presence.disabled' ) ,
5+ export default class ValidatedBsFormElement extends BsFormElement {
6+ '__ember-bootstrap_subclass' = true ;
107
118 // Overwrite
12- hasValidator : notEmpty ( '_attrValidations' ) . readOnly ( ) ,
13- hasErrors : and ( '_attrValidations.isInvalid' , 'notValidating' ) . readOnly ( ) ,
14- isValidating : readOnly ( '_attrValidations.isValidating' ) ,
9+ @notEmpty ( '_attrValidations' )
10+ hasValidator ;
1511
16- // mark as required only if:
17- // - field is not disabled,
18- // - presence validator requires presence
19- // - presence validator is enabled
20- required : and ( 'notDisabled' , '_attrValidations.options.presence.presence' , '_presenceEnabled' ) ,
12+ @not ( 'isValidating' )
13+ notValidating ;
14+
15+ @and ( '_attrValidations.isInvalid' , 'notValidating' )
16+ hasErrors ;
17+
18+ @readOnly ( '_attrValidations.isValidating' )
19+ isValidating ;
20+
21+ @readOnly ( '_attrValidations.messages' )
22+ errors ;
23+
24+ @readOnly ( '_attrValidations.warningMessages' )
25+ warnings ;
2126
2227 setupValidations ( ) {
2328 defineProperty ( this , '_attrValidations' , readOnly ( `model.validations.attrs.${ this . property } ` ) ) ;
24- defineProperty ( this , 'errors' , readOnly ( '_attrValidations.messages' ) ) ;
25- defineProperty ( this , 'warnings' , readOnly ( '_attrValidations.warningMessages' ) ) ;
2629 }
27- } ) ;
30+ }
0 commit comments