Skip to content

Commit

Permalink
Fixed #121 by refactoring competition enabled pipe and quick viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
sauterl committed May 18, 2022
1 parent 532beb7 commit f2dfec2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/objectdetails/quick-viewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1 class="title" matDialogTitle>{{mediaobject.objectid}} ({{mediaobject.name}})
<app-m3d-loader #modelviewer *ngIf="mediaobject.mediatype === 'MODEL3D'" [height]="400" [interaction]="true"
[width]="400" src="{{mediaobject|ObjectPathPipe}}"></app-m3d-loader>

<button color="primary" mat-flat-button *ngIf=" (this._vbs | competitionEnabledPipe | async)" (click)="onSubmitPressed()">
<button color="primary" mat-flat-button *ngIf=" ('lsc' | competitionEnabledPipe | async)" (click)="onSubmitPressed()">
<mat-icon>send</mat-icon>
</button>
</div>
12 changes: 10 additions & 2 deletions src/app/shared/pipes/util/competition-enabled.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ export class CompetitionEnabledPipe implements PipeTransform {

/**
* Returns true if the competition host is set. False otherwise. Doesn't require an input
* @param type The type to check. empty to generically check for competition
*
* @return {boolean}
*/
public transform(_: any): Observable<boolean> {
return this._config.configAsObservable.pipe(map(c => c.get<boolean>('competition.host')));
public transform(type?: string): Observable<boolean> {
if(type){
if(type === 'vbs' || type === 'lsc'){
return this._config.configAsObservable.pipe(map(c => c.get<boolean>('competition.'+type)));
} else{
throw Error(`Invalid competition type: ${type}`);
}
}
return this._config.configAsObservable.pipe(map(c => c.get<boolean>('competition.host')));
}
}

0 comments on commit f2dfec2

Please sign in to comment.