Commits
Toni Prieto authored and GitHub committed 97e51013902 Merge
1 1 | import { Subject } from 'rxjs'; |
2 2 | import { |
3 3 | DynamicCheckboxGroupModel, |
4 4 | DynamicFormControlLayout, |
5 + | DynamicFormControlRelation, |
5 6 | DynamicFormGroupModelConfig, |
6 7 | serializable |
7 8 | } from '@ng-dynamic-forms/core'; |
8 9 | |
9 10 | import { VocabularyEntry } from '../../../../../../core/submission/vocabularies/models/vocabulary-entry.model'; |
10 11 | import { VocabularyOptions } from '../../../../../../core/submission/vocabularies/models/vocabulary-options.model'; |
11 12 | import { hasValue } from '../../../../../empty.util'; |
12 13 | |
13 14 | export interface DynamicListCheckboxGroupModelConfig extends DynamicFormGroupModelConfig { |
14 15 | vocabularyOptions: VocabularyOptions; |
15 16 | groupLength?: number; |
16 17 | repeatable: boolean; |
17 18 | value?: any; |
19 + | typeBindRelations?: DynamicFormControlRelation[]; |
18 20 | } |
19 21 | |
20 22 | export class DynamicListCheckboxGroupModel extends DynamicCheckboxGroupModel { |
21 23 | |
22 24 | @serializable() vocabularyOptions: VocabularyOptions; |
23 25 | @serializable() repeatable: boolean; |
24 26 | @serializable() groupLength: number; |
25 27 | @serializable() _value: VocabularyEntry[]; |
28 + | @serializable() typeBindRelations: DynamicFormControlRelation[]; |
26 29 | isListGroup = true; |
27 30 | valueUpdates: Subject<any>; |
28 31 | |
29 32 | constructor(config: DynamicListCheckboxGroupModelConfig, layout?: DynamicFormControlLayout) { |
30 33 | super(config, layout); |
31 34 | |
32 35 | this.vocabularyOptions = config.vocabularyOptions; |
33 36 | this.groupLength = config.groupLength || 5; |
34 37 | this._value = []; |
35 38 | this.repeatable = config.repeatable; |
36 39 | |
37 40 | this.valueUpdates = new Subject<any>(); |
38 41 | this.valueUpdates.subscribe((value: VocabularyEntry | VocabularyEntry[]) => this.value = value); |
39 42 | this.valueUpdates.next(config.value); |
43 + | this.typeBindRelations = config.typeBindRelations ? config.typeBindRelations : []; |
40 44 | } |
41 45 | |
42 46 | get hasAuthority(): boolean { |
43 47 | return this.vocabularyOptions && hasValue(this.vocabularyOptions.name); |
44 48 | } |
45 49 | |
46 50 | get value() { |
47 51 | return this._value; |
48 52 | } |
49 53 | |