feat: add action chips to search results

This commit is contained in:
Wieland Schöbl
2021-06-22 15:09:40 +00:00
parent 0aa26020be
commit 67fb4a43c9
27 changed files with 771 additions and 303 deletions

View File

@@ -42,12 +42,14 @@ export class ThingTranslatePipe implements PipeTransform, OnDestroy {
this.value = this.thingTranslate.get(thing, key);
}
transform(query: unknown, thing: SCThings): unknown {
transform<T extends SCThings, P extends string[] | keyof T>(query: P, thing: T):
P extends keyof T ? T[P] : P | unknown {
if (typeof query !== 'string' || query.length <= 0) {
return query;
// tslint:disable-next-line:no-any
return query as any;
}
if (!isThing(thing)){
if (!isThing(thing)) {
throw new SyntaxError(`Wrong parameter in ThingTranslatePipe. Expected a valid SCThing, received: ${thing}`);
}
@@ -69,7 +71,8 @@ export class ThingTranslatePipe implements PipeTransform, OnDestroy {
});
}
return this.value;
// tslint:disable-next-line:no-any
return this.value as any;
}
/**
@@ -111,13 +114,13 @@ export class ThingPropertyNameTranslatePipe implements PipeTransform, OnDestroy
return query;
}
if (!isThing(thingOrType) && typeof thingOrType !== 'string'){
if (!isThing(thingOrType) && typeof thingOrType !== 'string') {
throw new SyntaxError(`Wrong parameter in ThingTranslatePipe. Expected a valid SCThing or String, received: ${thingOrType}`);
}
// store the params, in case they change
this.lastKey = query;
this.lastType= typeof thingOrType === 'string' ? thingOrType : thingOrType.type;
this.lastType = typeof thingOrType === 'string' ? thingOrType : thingOrType.type;
this.updateValue(query, this.lastType);