55946: Refactored item-select to object-select to allow for easier implementation of collection-select

This commit is contained in:
Kristof De Langhe
2018-10-09 17:16:43 +02:00
parent 7021527f5c
commit c4203f25d5
17 changed files with 434 additions and 440 deletions

View File

@@ -0,0 +1,37 @@
import { Observable } from 'rxjs/Observable';
export class ObjectSelectServiceStub {
ids: string[] = [];
constructor(ids?: string[]) {
if (ids) {
this.ids = ids;
}
}
getSelected(id: string): Observable<boolean> {
if (this.ids.indexOf(id) > -1) {
return Observable.of(true);
} else {
return Observable.of(false);
}
}
getAllSelected(): Observable<string[]> {
return Observable.of(this.ids);
}
switch(id: string) {
const index = this.ids.indexOf(id);
if (index > -1) {
this.ids.splice(index, 1);
} else {
this.ids.push(id);
}
}
reset() {
this.ids = [];
}
}