--- /dev/null
+<div>
+ <div class="row">
+ <input class="form-control" type="textbox" (change)="valueSelected($event.target.value)"/>
+ <button class="btn btn-outline-dark" (click)="addSelectedValue()" i18n>Add</button>
+ </div>
+ <div class="row" *ngFor="let entry of entrylist">
+ <div class="col-lg-4">{{entry}}</div>
+ <button class="btn btn-sm btn-warning" (click)="removeValue(entry)" i18n>Remove</button>
+ </div>
+</div>
--- /dev/null
+/**
+ * <eg-text-multi-select (onChange)="handler($event)"></eg-multi-select> // $event is an array
+ */
+import {Component, OnInit, Input, Output, ViewChild, EventEmitter, ElementRef} from '@angular/core';
+import {map} from 'rxjs/operators';
+import {Observable, of, Subject} from 'rxjs';
+
+@Component({
+ selector: 'eg-text-multi-select',
+ templateUrl: './text-multi-select.component.html',
+ styles: [`
+ .icons {margin-left:-18px}
+ .material-icons {font-size: 16px;font-weight:bold}
+ `]
+})
+export class TextMultiSelectComponent implements OnInit {
+
+ selected: string;
+ entrylist: string[];
+
+ @Input() startValue: Array<string>;
+
+ @Output() onChange: EventEmitter<string[]>;
+
+ constructor(
+ ) {
+ this.entrylist = [];
+ this.onChange = new EventEmitter<string[]>();
+ }
+
+ valueSelected(entry: any) {
+ if (entry) {
+ this.selected = entry;
+ } else {
+ this.selected = null;
+ }
+ }
+ addSelectedValue() {
+ if (this.selected) {
+ this.entrylist.push(this.selected);
+ }
+ this.onChange.emit([...this.entrylist]);
+ }
+ removeValue(entry: any) {
+ this.entrylist = this.entrylist.filter(ent => ent !== entry);
+ this.onChange.emit([...this.entrylist]);
+ }
+
+ ngOnInit() {
+ this.entrylist = [];
+ if (this.startValue && this.startValue.length) {
+ this.entrylist = [...this.startValue];
+ }
+ }
+
+}
+
+
import {EgHelpPopoverComponent} from '@eg/share/eg-help-popover/eg-help-popover.component';
import {DatetimeValidatorDirective} from '@eg/share/validators/datetime_validator.directive';
import {MultiSelectComponent} from '@eg/share/multi-select/multi-select.component';
+import {TextMultiSelectComponent} from '@eg/share/text-multi-select/text-multi-select.component';
import {NotBeforeMomentValidatorDirective} from '@eg/share/validators/not_before_moment_validator.directive';
import {PatronBarcodeValidatorDirective} from '@eg/share/validators/patron_barcode_validator.directive';
import {BroadcastService} from '@eg/share/util/broadcast.service';
EgHelpPopoverComponent,
DatetimeValidatorDirective,
MultiSelectComponent,
+ TextMultiSelectComponent,
NotBeforeMomentValidatorDirective,
PatronBarcodeValidatorDirective,
],
EgHelpPopoverComponent,
DatetimeValidatorDirective,
MultiSelectComponent,
+ TextMultiSelectComponent,
NotBeforeMomentValidatorDirective,
PatronBarcodeValidatorDirective
]