@@ -15,7 +15,8 @@ import {
1515 Input ,
1616 ContentChildren ,
1717 forwardRef ,
18- QueryList
18+ QueryList ,
19+ AfterContentInit
1920} from '@angular/core' ;
2021
2122import { DOCUMENT } from '@angular/common' ;
@@ -55,7 +56,7 @@ import { DxiCardViewValidationRuleComponent } from './validation-rule-dxi';
5556 providers : [ NestedOptionHost , DxTemplateHost ]
5657} )
5758export class DxoCardViewFormItemComponent extends NestedOption implements AfterViewInit , OnDestroy , OnInit ,
58- IDxTemplateHost {
59+ IDxTemplateHost , AfterContentInit {
5960 @Input ( )
6061 get colSpan ( ) : number | undefined {
6162 return this . _getOption ( 'colSpan' ) ;
@@ -174,85 +175,52 @@ export class DxoCardViewFormItemComponent extends NestedOption implements AfterV
174175 }
175176
176177
177- @ContentChildren ( forwardRef ( ( ) => DxiCardViewAsyncRuleComponent ) )
178- get asyncRulesChildren ( ) : QueryList < DxiCardViewAsyncRuleComponent > {
179- return this . _getOption ( 'validationRules' ) ;
180- }
181- set asyncRulesChildren ( value ) {
182- this . setChildren ( 'validationRules' , value ) ;
178+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewAsyncRuleComponent ) ) asyncRulesChildren ! : QueryList < DxiCardViewAsyncRuleComponent >
179+
180+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewCompareRuleComponent ) ) compareRulesChildren ! : QueryList < DxiCardViewCompareRuleComponent >
181+
182+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewCustomRuleComponent ) ) customRulesChildren ! : QueryList < DxiCardViewCustomRuleComponent >
183+
184+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewEmailRuleComponent ) ) emailRulesChildren ! : QueryList < DxiCardViewEmailRuleComponent >
185+
186+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewNumericRuleComponent ) ) numericRulesChildren ! : QueryList < DxiCardViewNumericRuleComponent >
187+
188+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewPatternRuleComponent ) ) patternRulesChildren ! : QueryList < DxiCardViewPatternRuleComponent >
189+
190+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewRangeRuleComponent ) ) rangeRulesChildren ! : QueryList < DxiCardViewRangeRuleComponent >
191+
192+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewRequiredRuleComponent ) ) requiredRulesChildren ! : QueryList < DxiCardViewRequiredRuleComponent >
193+
194+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewStringLengthRuleComponent ) ) stringLengthRulesChildren ! : QueryList < DxiCardViewStringLengthRuleComponent >
195+
196+ @ContentChildren ( forwardRef ( ( ) => DxiCardViewValidationRuleComponent ) ) validationRulesChildren ! : QueryList < DxiCardViewValidationRuleComponent >
197+
198+ setValidationRules ( ) {
199+ const q : QueryList < any > = new QueryList ( ) ;
200+ q . reset ( [
201+ ...this . asyncRulesChildren . toArray ( ) ,
202+ ...this . compareRulesChildren . toArray ( ) ,
203+ ...this . customRulesChildren . toArray ( ) ,
204+ ...this . emailRulesChildren . toArray ( ) ,
205+ ...this . numericRulesChildren . toArray ( ) ,
206+ ...this . patternRulesChildren . toArray ( ) ,
207+ ...this . rangeRulesChildren . toArray ( ) ,
208+ ...this . requiredRulesChildren . toArray ( ) ,
209+ ...this . stringLengthRulesChildren . toArray ( ) ,
210+ ...this . validationRulesChildren . toArray ( ) ,
211+ ] ) ;
212+ this . setChildren ( 'validationRules' , q ) ;
183213 }
184214
185- @ContentChildren ( forwardRef ( ( ) => DxiCardViewCompareRuleComponent ) )
186- get compareRulesChildren ( ) : QueryList < DxiCardViewCompareRuleComponent > {
187- return this . _getOption ( 'validationRules' ) ;
188- }
189- set compareRulesChildren ( value ) {
190- this . setChildren ( 'validationRules' , value ) ;
191- }
192215
193- @ContentChildren ( forwardRef ( ( ) => DxiCardViewCustomRuleComponent ) )
194- get customRulesChildren ( ) : QueryList < DxiCardViewCustomRuleComponent > {
195- return this . _getOption ( 'validationRules' ) ;
196- }
197- set customRulesChildren ( value ) {
198- this . setChildren ( 'validationRules' , value ) ;
199- }
200216
201- @ContentChildren ( forwardRef ( ( ) => DxiCardViewEmailRuleComponent ) )
202- get emailRulesChildren ( ) : QueryList < DxiCardViewEmailRuleComponent > {
203- return this . _getOption ( 'validationRules' ) ;
204- }
205- set emailRulesChildren ( value ) {
206- this . setChildren ( 'validationRules' , value ) ;
207- }
208217
209- @ContentChildren ( forwardRef ( ( ) => DxiCardViewNumericRuleComponent ) )
210- get numericRulesChildren ( ) : QueryList < DxiCardViewNumericRuleComponent > {
211- return this . _getOption ( 'validationRules' ) ;
212- }
213- set numericRulesChildren ( value ) {
214- this . setChildren ( 'validationRules' , value ) ;
215- }
216218
217- @ContentChildren ( forwardRef ( ( ) => DxiCardViewPatternRuleComponent ) )
218- get patternRulesChildren ( ) : QueryList < DxiCardViewPatternRuleComponent > {
219- return this . _getOption ( 'validationRules' ) ;
220- }
221- set patternRulesChildren ( value ) {
222- this . setChildren ( 'validationRules' , value ) ;
223- }
224219
225- @ContentChildren ( forwardRef ( ( ) => DxiCardViewRangeRuleComponent ) )
226- get rangeRulesChildren ( ) : QueryList < DxiCardViewRangeRuleComponent > {
227- return this . _getOption ( 'validationRules' ) ;
228- }
229- set rangeRulesChildren ( value ) {
230- this . setChildren ( 'validationRules' , value ) ;
231- }
232220
233- @ContentChildren ( forwardRef ( ( ) => DxiCardViewRequiredRuleComponent ) )
234- get requiredRulesChildren ( ) : QueryList < DxiCardViewRequiredRuleComponent > {
235- return this . _getOption ( 'validationRules' ) ;
236- }
237- set requiredRulesChildren ( value ) {
238- this . setChildren ( 'validationRules' , value ) ;
239- }
240221
241- @ContentChildren ( forwardRef ( ( ) => DxiCardViewStringLengthRuleComponent ) )
242- get stringLengthRulesChildren ( ) : QueryList < DxiCardViewStringLengthRuleComponent > {
243- return this . _getOption ( 'validationRules' ) ;
244- }
245- set stringLengthRulesChildren ( value ) {
246- this . setChildren ( 'validationRules' , value ) ;
247- }
248222
249- @ContentChildren ( forwardRef ( ( ) => DxiCardViewValidationRuleComponent ) )
250- get validationRulesChildren ( ) : QueryList < DxiCardViewValidationRuleComponent > {
251- return this . _getOption ( 'validationRules' ) ;
252- }
253- set validationRulesChildren ( value ) {
254- this . setChildren ( 'validationRules' , value ) ;
255- }
223+
256224
257225 constructor ( @SkipSelf ( ) @Host ( ) parentOptionHost : NestedOptionHost ,
258226 @Host ( ) optionHost : NestedOptionHost ,
@@ -283,6 +251,20 @@ export class DxoCardViewFormItemComponent extends NestedOption implements AfterV
283251 }
284252
285253
254+ ngAfterContentInit ( ) {
255+ this . setValidationRules ( ) ;
256+
257+ this . asyncRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
258+ this . compareRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
259+ this . customRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
260+ this . emailRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
261+ this . numericRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
262+ this . patternRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
263+ this . rangeRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
264+ this . requiredRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
265+ this . stringLengthRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
266+ this . validationRulesChildren . changes . subscribe ( ( ) => { this . setValidationRules ( ) } ) ;
267+ }
286268}
287269
288270@NgModule ( {
0 commit comments