Skip to content

Commit

Permalink
use (custom) default template id if 'template' URL parameter is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
infacc committed Jul 20, 2023
1 parent ce6ba54 commit dcba177
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class ExperimentWorkspaceDetailComponent implements OnInit {

templateId: string | null = null;
tabId: string | null = null;
defaultTemplateId: string | null = null;

templateObject: TemplateApiObject | null = null;
tabObject: TemplateTabApiObject | null = null;
Expand Down Expand Up @@ -57,11 +58,13 @@ export class ExperimentWorkspaceDetailComponent implements OnInit {
private changedTabSubscription: Subscription | null = null;
private routeParamSubscription: Subscription | null = null;

private defaultTemplateIdSubscription: Subscription | null = null;

constructor(private route: ActivatedRoute, private router: Router, private registry: PluginRegistryBaseService, private fb: FormBuilder, private dialog: MatDialog, private templates: TemplatesService) { }

ngOnInit() {
this.routeParamSubscription = this.route.queryParamMap.subscribe(async params => {
const templateId = params.get('template');
const templateId = params.get('template') ?? this.defaultTemplateId;
const tabId = params.get('tab');

if (templateId && templateId !== this.templateId) {
Expand Down Expand Up @@ -89,6 +92,7 @@ export class ExperimentWorkspaceDetailComponent implements OnInit {
this.deletedTabSubscription?.unsubscribe();
this.changedTabSubscription?.unsubscribe();
this.routeParamSubscription?.unsubscribe();
this.defaultTemplateIdSubscription?.unsubscribe();
}

private sortTabs(group: string) {
Expand Down Expand Up @@ -188,6 +192,13 @@ export class ExperimentWorkspaceDetailComponent implements OnInit {
this.sortTabs(group);
}
});

this.defaultTemplateIdSubscription = this.templates.defaultTemplateId.subscribe(defaultTemplateId => {
this.defaultTemplateId = defaultTemplateId;
if (this.templateId == null && this.defaultTemplateId != null) {
this.updateTemplateId(this.defaultTemplateId);
}
});
}

private async updateTemplateId(templateId: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h2 class="template-header">
</div>
<div class="template-tab-sidebar" [hidden]="activeArea != 'detail'">
<mat-divider></mat-divider>
<qhana-tab-group-list [templateId]="templateId" [selectedTab]="tabId"
<qhana-tab-group-list [templateId]="effectiveTemplateId" [selectedTab]="tabId"
(clickedOnTab)="selectTab($event)"></qhana-tab-group-list>
</div>
<details class="plugin-group" [open]="group.open" *ngFor="let group of pluginGroups"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export class PluginSidebarComponent implements OnInit, OnDestroy {
// and external default templates should not be used
return this.templateId ?? ALL_PLUGINS_TEMPLATE_ID;
}
return this.templateId;
const defaultTemplateId = this.defaultTemplate?.self?.resourceKey?.uiTemplateId ?? null
return this.templateId ?? defaultTemplateId;
}

@ViewChild('searchInput', { static: true }) searchInput: ElementRef<HTMLInputElement> | null = null;
Expand Down

0 comments on commit dcba177

Please sign in to comment.