Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refresh tree button + go to study list when deleting study #2521

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export abstract class EntityComponent<T extends Entity> implements OnDestroy, On
}

delete(): void {
this.openDeleteConfirmDialog(this.entity)
this.openDeleteConfirmDialog(this.entity);
}

protected openDeleteConfirmDialog = (entity: T) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html
-->
<div class="commands">
<button class="dl-button"
type="button"
(click)="treeService.updateTree()"
title="Refresh">
<i class="fa-solid fa-arrows-rotate"></i>
</button>
<button class="dl-button"
type="button"
(click)="downloadSelected()"
Expand Down
28 changes: 19 additions & 9 deletions shanoir-ng-front/src/app/studies/study/tree.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,29 @@ export class TreeService {
// update everything
let studyId: number = this.study?.id;
this.study = null;
this.initStudy(studyId);
this.initStudy(studyId).then(() => {
this.changeSelection();
});
}

removeCurrentNode() {
const route: string = this.selectedNode.route;
Object.entries(this.selectedNode.parent).forEach((entry, index) => {
if (Array.isArray(entry[1])) {
let i: number = entry[1].findIndex(node => node.route == route);
entry[1].splice(i, 1);
}
});
if (this.selectedNode?.parent) {
const route: string = this.selectedNode.route;
Object.entries(this.selectedNode.parent).forEach((entry, index) => {
if (Array.isArray(entry[1])) {
let i: number = entry[1].findIndex(node => node.route == route);
entry[1].splice(i, 1);
}
});
}
}

goToParent() {
this.router.navigate([this.selectedNode?.parent?.route]);
if (this.selectedNode instanceof StudyNode) {
this.router.navigate(['/study/list']);
} else {
this.router.navigate([this.selectedNode?.parent?.route]);
}
}

activateTree(activatedRoute: ActivatedRoute) {
Expand All @@ -163,6 +171,8 @@ export class TreeService {
if (this.selection?.type == 'study') {
this.initStudy(this.selection.id).then(() => {
this.studyNode.subjectsNode.open();
this.selectedNode = this.studyNode;
this.treeAvailable = !!this.selectedNode;
});
} else {
let studyLoaded: Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion shanoir-ng-front/src/app/tree/tree.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export abstract class ShanoirNode {
setTimeout(() => {
// removing timeout may cause random bugs in the tree
this._opened = true;
})
});
return (this.openPromise || Promise.resolve()).then(() => SuperPromise.timeoutPromise());
} else {
return Promise.resolve();
Expand Down
Loading