diff options
Diffstat (limited to 'client/src/app/shared/shared-forms')
3 files changed, 19 insertions, 10 deletions
diff --git a/client/src/app/shared/shared-forms/select-channel.component.ts b/client/src/app/shared/shared-forms/select-channel.component.ts index de98c8c0a..ef4192095 100644 --- a/client/src/app/shared/shared-forms/select-channel.component.ts +++ b/client/src/app/shared/shared-forms/select-channel.component.ts | |||
@@ -1,7 +1,14 @@ | |||
1 | import { Component, Input, forwardRef, ViewChild } from '@angular/core' | 1 | import { Component, forwardRef, Input } from '@angular/core' |
2 | import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { Actor } from '../shared-main' | 3 | import { Actor } from '../shared-main' |
4 | 4 | ||
5 | export type SelectChannelItem = { | ||
6 | id: number | ||
7 | label: string | ||
8 | support: string | ||
9 | avatarPath?: string | ||
10 | } | ||
11 | |||
5 | @Component({ | 12 | @Component({ |
6 | selector: 'my-select-channel', | 13 | selector: 'my-select-channel', |
7 | styleUrls: [ './select-shared.component.scss' ], | 14 | styleUrls: [ './select-shared.component.scss' ], |
@@ -15,7 +22,7 @@ import { Actor } from '../shared-main' | |||
15 | ] | 22 | ] |
16 | }) | 23 | }) |
17 | export class SelectChannelComponent implements ControlValueAccessor { | 24 | export class SelectChannelComponent implements ControlValueAccessor { |
18 | @Input() items: { id: number, label: string, support: string, avatarPath?: string }[] = [] | 25 | @Input() items: SelectChannelItem[] = [] |
19 | 26 | ||
20 | selectedId: number | 27 | selectedId: number |
21 | 28 | ||
diff --git a/client/src/app/shared/shared-forms/select-tags.component.html b/client/src/app/shared/shared-forms/select-tags.component.html index 0609c9d20..e1cd50882 100644 --- a/client/src/app/shared/shared-forms/select-tags.component.html +++ b/client/src/app/shared/shared-forms/select-tags.component.html | |||
@@ -1,6 +1,6 @@ | |||
1 | <ng-select | 1 | <ng-select |
2 | [items]="items" | 2 | [items]="availableItems" |
3 | [(ngModel)]="_items" | 3 | [(ngModel)]="selectedItems" |
4 | (ngModelChange)="onModelChange()" | 4 | (ngModelChange)="onModelChange()" |
5 | i18n-placeholder placeholder="Enter a new tag" | 5 | i18n-placeholder placeholder="Enter a new tag" |
6 | [maxSelectedItems]="5" | 6 | [maxSelectedItems]="5" |
diff --git a/client/src/app/shared/shared-forms/select-tags.component.ts b/client/src/app/shared/shared-forms/select-tags.component.ts index 2e07d7e8f..a8a19d788 100644 --- a/client/src/app/shared/shared-forms/select-tags.component.ts +++ b/client/src/app/shared/shared-forms/select-tags.component.ts | |||
@@ -14,14 +14,14 @@ import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms' | |||
14 | ] | 14 | ] |
15 | }) | 15 | }) |
16 | export class SelectTagsComponent implements ControlValueAccessor { | 16 | export class SelectTagsComponent implements ControlValueAccessor { |
17 | @Input() items: string[] = [] | 17 | @Input() availableItems: string[] = [] |
18 | @Input() _items: string[] = [] | 18 | @Input() selectedItems: string[] = [] |
19 | 19 | ||
20 | propagateChange = (_: any) => { /* empty */ } | 20 | propagateChange = (_: any) => { /* empty */ } |
21 | 21 | ||
22 | writeValue (items: string[]) { | 22 | writeValue (items: string[]) { |
23 | this._items = items | 23 | this.selectedItems = items |
24 | this.propagateChange(this._items) | 24 | this.propagateChange(this.selectedItems) |
25 | } | 25 | } |
26 | 26 | ||
27 | registerOnChange (fn: (_: any) => void) { | 27 | registerOnChange (fn: (_: any) => void) { |
@@ -33,6 +33,8 @@ export class SelectTagsComponent implements ControlValueAccessor { | |||
33 | } | 33 | } |
34 | 34 | ||
35 | onModelChange () { | 35 | onModelChange () { |
36 | this.propagateChange(this._items) | 36 | console.log(this.selectedItems) |
37 | |||
38 | this.propagateChange(this.selectedItems) | ||
37 | } | 39 | } |
38 | } | 40 | } |