File tree Expand file tree Collapse file tree 1 file changed +10
-19
lines changed
Expand file tree Collapse file tree 1 file changed +10
-19
lines changed Original file line number Diff line number Diff line change 1- import { notEmpty } from '@ember/object/computed' ;
2- import { defineProperty , computed } from '@ember/object' ;
3- import { A } from '@ember/array' ;
41import BsFormElement from 'ember-bootstrap/components/bs-form/element' ;
52
6- export default BsFormElement . extend ( {
7- '__ember-bootstrap_subclass' : true ,
3+ export default class BsFormElementWithChangesetValidationsSupport extends BsFormElement {
4+ '__ember-bootstrap_subclass' = true ;
85
9- hasValidator : notEmpty ( 'model.validate' ) ,
6+ get errors ( ) {
7+ return [
8+ this . model . error [ this . property ] ?. validation
9+ ] ;
10+ }
1011
11- setupValidations ( ) {
12- // `Changeset.error` is a getter based on a tracked property. Since it's a
13- // derived state it's not working together with computed properties smoothly.
14- // As a work-a-round we observe the `Changeset._errors` computed property
15- // directly, which holds the state. This is not optimal cause it's private.
16- // Should refactor to native getter as soon as `<FormElement>` component
17- // of Ember Bootstrap supports native getters for `FormElement.errors`
18- // property.
19- let key = `model.error.${ this . get ( 'property' ) } .validation` ;
20- defineProperty ( this , 'errors' , computed ( `model._errors` , function ( ) {
21- return A ( this . get ( key ) ) ;
22- } ) ) ;
12+ get hasValidator ( ) {
13+ return typeof this . model . validate === 'function' ;
2314 }
24- } ) ;
15+ }
You can’t perform that action at this time.
0 commit comments