File

projects/ng-dynamic-forms/core/src/lib/model/select/dynamic-select.model.ts

Extends

DynamicOptionControlModel

Index

Properties
Methods

Constructor

constructor(config: DynamicSelectModelConfig, layout?: DynamicFormControlLayout)
Parameters :
Name Type Optional
config DynamicSelectModelConfig<T> No
layout DynamicFormControlLayout Yes

Properties

compareWithFn
Type : function
filterable
Type : boolean
Decorators :
@serializable()
multiple
Type : boolean
Decorators :
@serializable()
placeholder
Type : string
Decorators :
@serializable()
prefix
Type : string | null
Decorators :
@serializable()
suffix
Type : string | null
Decorators :
@serializable()
Readonly type
Type : string
Default value : DYNAMIC_FORM_CONTROL_TYPE_SELECT
Decorators :
@serializable()
Private _options
Type : DynamicFormOption<T>[]
Default value : []
Decorators :
@serializable('options')
options$
Type : Observable<DynamicFormOption[]>
Private _value
Type : T | null
Decorators :
@serializable('value')
additional
Type : literal type | null
Decorators :
@serializable()
hint
Type : string | null
Decorators :
@serializable()
required
Type : boolean
Decorators :
@serializable()
tabIndex
Type : number | null
Decorators :
@serializable()
Private Readonly value$
Type : BehaviorSubject<T>
Readonly valueChanges
Type : Observable<T>
_disabled
Type : boolean
Decorators :
@serializable('disabled')
asyncValidators
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
controlTooltip
Type : string | null
Decorators :
@serializable()
Private Readonly disabled$
Type : BehaviorSubject<boolean>
Readonly disabledChanges
Type : Observable<boolean>
errorMessages
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
hidden
Type : boolean
Decorators :
@serializable()
id
Type : string
Decorators :
@serializable()
label
Type : string | null
Decorators :
@serializable()
labelTooltip
Type : string | null
Decorators :
@serializable()
layout
Type : DynamicFormControlLayout | null
Decorators :
@serializable()
name
Type : string
Decorators :
@serializable()
parent
Type : DynamicPathable | null
Default value : null
relations
Type : DynamicFormControlRelation[]
Decorators :
@serializable()
Abstract Readonly type
Type : string
updateOn
Type : DynamicFormHook | null
Decorators :
@serializable()
validators
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
_disabled
Type : boolean
Decorators :
@serializable('disabled')
asyncValidators
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
controlTooltip
Type : string | null
Decorators :
@serializable()
Private Readonly disabled$
Type : BehaviorSubject<boolean>
Readonly disabledChanges
Type : Observable<boolean>
errorMessages
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
hidden
Type : boolean
Decorators :
@serializable()
id
Type : string
Decorators :
@serializable()
label
Type : string | null
Decorators :
@serializable()
labelTooltip
Type : string | null
Decorators :
@serializable()
layout
Type : DynamicFormControlLayout | null
Decorators :
@serializable()
name
Type : string
Decorators :
@serializable()
parent
Type : DynamicPathable | null
Default value : null
relations
Type : DynamicFormControlRelation[]
Decorators :
@serializable()
Abstract Readonly type
Type : string
updateOn
Type : DynamicFormHook | null
Decorators :
@serializable()
validators
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
Private _value
Type : T | null
Decorators :
@serializable('value')
additional
Type : literal type | null
Decorators :
@serializable()
hint
Type : string | null
Decorators :
@serializable()
required
Type : boolean
Decorators :
@serializable()
tabIndex
Type : number | null
Decorators :
@serializable()
Private Readonly value$
Type : BehaviorSubject<T>
Readonly valueChanges
Type : Observable<T>
_disabled
Type : boolean
Decorators :
@serializable('disabled')
asyncValidators
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
controlTooltip
Type : string | null
Decorators :
@serializable()
Private Readonly disabled$
Type : BehaviorSubject<boolean>
Readonly disabledChanges
Type : Observable<boolean>
errorMessages
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
hidden
Type : boolean
Decorators :
@serializable()
id
Type : string
Decorators :
@serializable()
label
Type : string | null
Decorators :
@serializable()
labelTooltip
Type : string | null
Decorators :
@serializable()
layout
Type : DynamicFormControlLayout | null
Decorators :
@serializable()
name
Type : string
Decorators :
@serializable()
parent
Type : DynamicPathable | null
Default value : null
relations
Type : DynamicFormControlRelation[]
Decorators :
@serializable()
Abstract Readonly type
Type : string
updateOn
Type : DynamicFormHook | null
Decorators :
@serializable()
validators
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
_disabled
Type : boolean
Decorators :
@serializable('disabled')
Inherited from DynamicFormControlModel
asyncValidators
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
Inherited from DynamicFormControlModel
controlTooltip
Type : string | null
Decorators :
@serializable()
Inherited from DynamicFormControlModel
Private Readonly disabled$
Type : BehaviorSubject<boolean>
Inherited from DynamicFormControlModel
Readonly disabledChanges
Type : Observable<boolean>
Inherited from DynamicFormControlModel
errorMessages
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
Inherited from DynamicFormControlModel
hidden
Type : boolean
Decorators :
@serializable()
Inherited from DynamicFormControlModel
id
Type : string
Decorators :
@serializable()
Inherited from DynamicFormControlModel
label
Type : string | null
Decorators :
@serializable()
Inherited from DynamicFormControlModel
labelTooltip
Type : string | null
Decorators :
@serializable()
Inherited from DynamicFormControlModel
layout
Type : DynamicFormControlLayout | null
Decorators :
@serializable()
Inherited from DynamicFormControlModel
name
Type : string
Decorators :
@serializable()
Inherited from DynamicFormControlModel
parent
Type : DynamicPathable | null
Default value : null
Inherited from DynamicFormControlModel
relations
Type : DynamicFormControlRelation[]
Decorators :
@serializable()
Inherited from DynamicFormControlModel
Abstract Readonly type
Type : string
Inherited from DynamicFormControlModel
updateOn
Type : DynamicFormHook | null
Decorators :
@serializable()
Inherited from DynamicFormControlModel
validators
Type : DynamicValidatorsConfig | null
Decorators :
@serializable()
Inherited from DynamicFormControlModel

Methods

select
select(...indices: number[])
Parameters :
Name Type Optional
indices number[] No
Returns : void
add
add(optionConfig: DynamicFormOptionConfig)
Parameters :
Name Type Optional
optionConfig DynamicFormOptionConfig<T> No
get
get(index: number)
Parameters :
Name Type Optional
index number No
insert
insert(index: number, optionConfig: DynamicFormOptionConfig)
Parameters :
Name Type Optional
index number No
optionConfig DynamicFormOptionConfig<T> No
remove
remove(...indices: number[])
Parameters :
Name Type Optional
indices number[] No
Returns : void
Abstract select
select(...indices: number[])
Parameters :
Name Type Optional
indices number[] No
Returns : void
Private updateOptions$
updateOptions$()
Returns : void
getAdditional
getAdditional(key: string, defaultValue?: any | null)
Parameters :
Name Type Optional
key string No
defaultValue any | null Yes
Returns : any
toJSON
toJSON()
Returns : any
toJSON
toJSON()
Returns : any
getAdditional
getAdditional(key: string, defaultValue?: any | null)
Parameters :
Name Type Optional
key string No
defaultValue any | null Yes
Returns : any
toJSON
toJSON()
Returns : any
toJSON
toJSON()
Inherited from DynamicFormControlModel
Returns : any
import { ɵlooseIdentical as looseIdentical } from "@angular/core";
import { DynamicOptionControlModel, DynamicOptionControlModelConfig } from "../dynamic-option-control.model";
import { DynamicFormControlLayout } from "../misc/dynamic-form-control-layout.model";
import { serializable } from "../../decorator/serializable.decorator";
import { isBoolean, isFunction } from "../../utils/core.utils";

export const DYNAMIC_FORM_CONTROL_TYPE_SELECT = "SELECT";

export interface DynamicSelectModelConfig<T> extends DynamicOptionControlModelConfig<T> {

    compareWithFn?: (o1: any, o2: any) => boolean;
    filterable?: boolean;
    multiple?: boolean;
    placeholder?: string;
    prefix?: string;
    suffix?: string;
}

export class DynamicSelectModel<T> extends DynamicOptionControlModel<T> {

    compareWithFn: (value1: any, value2: any) => boolean;
    @serializable() filterable: boolean;
    @serializable() multiple: boolean;
    @serializable() placeholder: string;
    @serializable() prefix: string | null;
    @serializable() suffix: string | null;

    @serializable() readonly type: string = DYNAMIC_FORM_CONTROL_TYPE_SELECT;

    constructor(config: DynamicSelectModelConfig<T>, layout?: DynamicFormControlLayout) {

        super(config, layout);

        this.compareWithFn = isFunction(config.compareWithFn) ? config.compareWithFn : looseIdentical;
        this.filterable = isBoolean(config.filterable) ? config.filterable : false;
        this.multiple = isBoolean(config.multiple) ? config.multiple : false;
        this.placeholder = config.placeholder || "";
        this.prefix = config.prefix || null;
        this.suffix = config.suffix || null;
    }

    select(...indices: number[]): void {
        this.value = this.multiple ? indices.map(index => this.get(index).value) : this.get(indices[0]).value;
    }
}

result-matching ""

    No results matching ""