Skip to content

Commit

Permalink
MOBILE-2256 privatefiles: Remove private files
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonso-salces committed Sep 27, 2024
1 parent 4c9b698 commit 27fd71f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/addons/privatefiles/components/file/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export class AddonPrivateFilesFileComponent extends CoreFileComponent implements
this.onOpenMenuClick = new EventEmitter<CoreFileComponent>();
}

/**
* Emits onOpenMenuClick event with the current instance.
*/
openMenuClick(): void {
this.onOpenMenuClick.emit(this);
}
Expand Down
4 changes: 2 additions & 2 deletions src/addons/privatefiles/pages/index/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<h1>{{ selectFilesEnabled() ? (selectedFiles.length + ' ' + title) : title }}</h1>
</ion-title>
<ion-buttons slot="end">
@if (selectFilesEnabled()) {
@if (selectFilesEnabled() && selectedFiles.length > 0) {
<ion-button fill="clear" (click)="deleteSelectedFiles(true)" [ariaLabel]="'core.delete' | translate" color="danger">
<ion-icon slot="icon-only" name="fas-trash" aria-hidden="true" />
</ion-button>
Expand Down Expand Up @@ -76,7 +76,7 @@ <h1>{{ selectFilesEnabled() ? (selectedFiles.length + ' ' + title) : title }}</h
@if (showUpload && root !== 'site' && !path && !selectFilesEnabled()) {
<ion-fab slot="fixed" core-fab vertical="bottom" horizontal="end">
<ion-fab-button (click)="uploadFile()" [attr.aria-label]="'core.fileuploader.uploadafile' | translate">
<ion-icon name="fas-plus" aria-hidden="true" />
<ion-icon name="fas-arrow-up-from-bracket" aria-hidden="true" />
<span class="sr-only">{{ 'core.fileuploader.uploadafile' | translate }}</span>
</ion-fab-button>
</ion-fab>
Expand Down
12 changes: 11 additions & 1 deletion src/addons/privatefiles/pages/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,18 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy {
* Delete private files.
*/
async deleteSelectedFiles(showConfirmation = false): Promise<void> {
if (this.selectedFiles.length === 0) {
return;
}

if (showConfirmation) {
try {
await CoreDomUtils.showDeleteConfirm('core.confirmremoveselectedfiles');
this.selectedFiles.length === 1
? await CoreDomUtils.showDeleteConfirm(
'core.confirmremoveselectedfile',
{ filename: this.selectedFiles[0].filename },
)
: await CoreDomUtils.showDeleteConfirm('core.confirmremoveselectedfiles');
} catch {
return;
}
Expand Down Expand Up @@ -360,6 +369,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy {
cancelFileSelection(): void {
this.selectFilesEnabled.set(false);
this.selectedFiles = [];
this.files = this.files?.map(file => ({ ...file, selected: false }));
}

/**
Expand Down

0 comments on commit 27fd71f

Please sign in to comment.