Skip to content

Commit c3611fe

Browse files
committed
resolve CR comments
1 parent abd255b commit c3611fe

7 files changed

Lines changed: 12 additions & 45 deletions

File tree

src/app/features/files/pages/files/files.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@
145145
(unselectFile)="onFileTreeUnselected($event)"
146146
(clearSelection)="onClearSelection()"
147147
(entryFileClicked)="navigateToFile($event)"
148-
(deleteEntryAction)="deleteEntry($event)"
149148
(renameEntryAction)="renameEntry($event)"
150149
(uploadFilesConfirmed)="uploadFiles($event)"
151150
(loadFiles)="onLoadFiles($event)"

src/app/features/registries/components/custom-step/custom-step.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ <h3 class="mb-2">{{ 'files.actions.uploadFile' | translate }}</h3>
168168
[label]="file.name"
169169
severity="info"
170170
removable="true"
171-
(onRemove)="removeFromAttachedFiles(file, q.responseKey!)"
171+
(onRemove)="removeFromAttachedFiles(file.file_id, q.responseKey!)"
172172
/>
173173
}
174174
</div>
@@ -181,8 +181,7 @@ <h3 class="mb-2">{{ 'files.actions.uploadFile' | translate }}</h3>
181181
(attachFile)="onAttachFile($event, q.responseKey!)"
182182
(openFile)="onOpenFile($event)"
183183
[filesViewOnly]="filesViewOnly()"
184-
[isDraftResource]="true"
185-
(removeFromAttachedFiles)="removeFromAttachedFiles($event, 'uploader')"
184+
(removeFromAttachedFiles)="removeFromAttachedFiles($event, q.responseKey!)"
186185
></osf-files-control>
187186
</div>
188187
}

src/app/features/registries/components/custom-step/custom-step.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ export class CustomStepComponent implements OnDestroy {
143143
}
144144
}
145145

146-
removeFromAttachedFiles(file: AttachedFile, questionKey: string): void {
146+
removeFromAttachedFiles(fileId: string | undefined, questionKey: string): void {
147147
if (!this.attachedFiles[questionKey]) {
148148
return;
149149
}
150150

151-
this.attachedFiles[questionKey] = this.attachedFiles[questionKey].filter((f) => f.file_id !== file.file_id);
151+
this.attachedFiles[questionKey] = this.attachedFiles[questionKey].filter((f) => f.file_id !== fileId);
152152
this.stepForm.patchValue({ [questionKey]: this.attachedFiles[questionKey] });
153153
this.updateAction.emit({
154154
[questionKey]: this.mapFilesToPayload(this.attachedFiles[questionKey]),

src/app/features/registries/components/files-control/files-control.component.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
[resourceId]="projectId()"
5252
[provider]="provider()"
5353
[selectedFiles]="filesSelection"
54-
[isDraftResource]="isDraftResource()"
55-
(deleteEntryAction)="deleteEntry($event)"
56-
(removeFromAttachedFiles)="onRemoveFromAttachedFiles($event)"
5754
(selectFile)="onFileTreeSelected($event)"
5855
(entryFileClicked)="onEntryFileClicked($event)"
5956
(uploadFilesConfirmed)="uploadFiles($event)"

src/app/features/registries/components/files-control/files-control.component.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Button } from 'primeng/button';
88
import { filter, finalize, switchMap, take } from 'rxjs';
99

1010
import { HttpEventType } from '@angular/common/http';
11-
import { ChangeDetectionStrategy, Component, DestroyRef, effect, inject, input, output, signal } from '@angular/core';
11+
import { ChangeDetectionStrategy, Component, DestroyRef, inject, input, output, signal } from '@angular/core';
1212
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
1313

1414
import { CreateFolderDialogComponent } from '@osf/features/files/components';
@@ -54,9 +54,8 @@ export class FilesControlComponent {
5454
projectId = input.required<string>();
5555
provider = input.required<string>();
5656
filesViewOnly = input<boolean>(false);
57-
isDraftResource = input<boolean>(false);
5857
attachFile = output<FileModel>();
59-
removeFromAttachedFiles = output<FileModel>();
58+
removeFromAttachedFiles = output<string>();
6059
openFile = output<FileModel>();
6160

6261
private readonly filesService = inject(FilesService);
@@ -72,7 +71,6 @@ export class FilesControlComponent {
7271
readonly progress = signal(0);
7372
readonly fileName = signal('');
7473
readonly dataLoaded = signal(false);
75-
pageNumber = signal(1);
7674

7775
fileIsUploading = signal(false);
7876
filesSelection: FileModel[] = [];
@@ -89,31 +87,13 @@ export class FilesControlComponent {
8987
constructor() {
9088
this.setupRootFoldersLoader();
9189
this.setupCurrentFolderWatcher();
92-
93-
effect(() => {
94-
const currentFolder = this.currentFolder();
95-
if (currentFolder) {
96-
this.pageNumber.set(1);
97-
this.updateFilesList();
98-
}
99-
});
10090
}
10191

102-
updateFilesList = (): void => {
103-
const currentFolder = this.currentFolder();
104-
const filesLink = currentFolder?.links.filesLink;
105-
if (filesLink) {
106-
this.actions.getFiles(filesLink, this.pageNumber());
107-
}
108-
};
109-
11092
deleteEntry(file: FileModel): void {
11193
this.actions.deleteEntry(file?.links.delete).subscribe(() => {
11294
this.toastService.showSuccess('files.dialogs.deleteFile.success');
113-
this.updateFilesList();
114-
if (this.isDraftResource()) {
115-
this.removeFromAttachedFiles.emit(file);
116-
}
95+
this.refreshFilesList();
96+
this.removeFromAttachedFiles.emit(file.id);
11797
});
11898
}
11999

@@ -200,10 +180,6 @@ export class FilesControlComponent {
200180
this.filesSelection = [...new Set(this.filesSelection)];
201181
}
202182

203-
onRemoveFromAttachedFiles(file: FileModel) {
204-
this.removeFromAttachedFiles.emit(file);
205-
}
206-
207183
onLoadFiles(event: { link: string; page: number }) {
208184
this.actions.getFiles(event.link, event.page);
209185
}

src/app/shared/components/files-tree/files-tree.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@
101101
severity="danger"
102102
text
103103
rounded
104-
[pTooltip]="'Delete'"
104+
[pTooltip]="'common.buttons.cancel' | translate"
105105
tooltipPosition="top"
106-
(onClick)="deleteFile(file)"
106+
(onClick)="deleteEntry(file)"
107107
osfStopPropagation
108108
/>
109109
}

src/app/shared/components/files-tree/files-tree.component.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { TranslatePipe } from '@ngx-translate/core';
44

55
import { PrimeTemplate, TreeNode } from 'primeng/api';
66
import { Button } from 'primeng/button';
7-
import { TooltipModule } from 'primeng/tooltip';
7+
import { Tooltip } from 'primeng/tooltip';
88
import { Tree, TreeLazyLoadEvent, TreeNodeDropEvent, TreeNodeSelectEvent } from 'primeng/tree';
99

1010
import { Clipboard } from '@angular/cdk/clipboard';
@@ -69,7 +69,7 @@ type FileTreeNode = FileModel & TreeNode;
6969
FileMenuComponent,
7070
StopPropagationDirective,
7171
Button,
72-
TooltipModule,
72+
Tooltip,
7373
],
7474
templateUrl: './files-tree.component.html',
7575
styleUrl: './files-tree.component.scss',
@@ -270,10 +270,6 @@ export class FilesTreeComponent implements OnDestroy, AfterViewInit {
270270
this.clearSelection.emit();
271271
}
272272

273-
deleteFile(file: FileModel) {
274-
this.deleteEntry(file);
275-
}
276-
277273
onFileMenuAction(action: FileMenuAction, file: FileModel): void {
278274
const { value, data } = action;
279275

0 commit comments

Comments
 (0)