-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: show/change experiment default template
- Loading branch information
Showing
8 changed files
with
131 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/app/dialogs/choose-template/choose-template.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<h1 mat-dialog-title>Choose Template</h1> | ||
<div mat-dialog-content> | ||
<div> | ||
<qhana-growing-list [rels]="['ui-template', 'collection']" [newItemRels]="['ui-template']" | ||
[highlighted]="highlightedTemplateSet" [highlightByKey]="'uiTemplateId'" (clickItem)="selectTemplate($event)"> | ||
</qhana-growing-list> | ||
</div> | ||
</div> | ||
<div class="dialog-actions" mat-dialog-actions> | ||
<button mat-button (click)="onCancel()">Cancel</button> | ||
<button mat-button [mat-dialog-close]="templateId" | ||
[disabled]="templateId == null"> | ||
Choose | ||
</button> | ||
</div> |
Empty file.
23 changes: 23 additions & 0 deletions
23
src/app/dialogs/choose-template/choose-template.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ChooseTemplateComponent } from './choose-template.component'; | ||
|
||
describe('ChooseTemplateDialog', () => { | ||
let component: ChooseTemplateComponent; | ||
let fixture: ComponentFixture<ChooseTemplateComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ChooseTemplateComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ChooseTemplateComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
src/app/dialogs/choose-template/choose-template.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { TemplateApiObject } from 'src/app/services/qhana-backend.service'; | ||
import { MatDialogRef } from '@angular/material/dialog'; | ||
import { ApiLink } from 'src/app/services/api-data-types'; | ||
import { PluginRegistryBaseService } from 'src/app/services/registry.service'; | ||
|
||
@Component({ | ||
selector: 'qhana-choose-template', | ||
templateUrl: './choose-template.component.html', | ||
styleUrls: ['./choose-template.component.sass'] | ||
}) | ||
export class ChooseTemplateComponent implements OnInit { | ||
highlightedTemplateSet: Set<string> = new Set(); | ||
templateId: string | null = null; | ||
|
||
constructor(public dialogRef: MatDialogRef<ChooseTemplateComponent>) { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
async selectTemplate(templateLink: ApiLink) { | ||
const templateId = templateLink.resourceKey?.uiTemplateId ?? null; | ||
if (templateId == null) { | ||
return; | ||
} | ||
if (this.highlightedTemplateSet.has(templateId)) { | ||
// double click deselects template | ||
this.highlightedTemplateSet.clear(); | ||
this.templateId = null; | ||
return; | ||
} | ||
this.highlightedTemplateSet.clear(); | ||
this.highlightedTemplateSet = new Set([templateId]); | ||
this.templateId = templateId; | ||
} | ||
|
||
onCancel(): void { | ||
this.dialogRef.close(); | ||
} | ||
} |