Merge pull request #4189 from alfonso-salces/MOBILE-2256

MOBILE-2256 privatefiles: Remove private files
main
Dani Palou 2024-09-27 12:28:21 +02:00 committed by GitHub
commit 6411630dc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 3 deletions

View File

@ -40,6 +40,9 @@ export class AddonPrivateFilesFileComponent extends CoreFileComponent implements
this.onOpenMenuClick = new EventEmitter<CoreFileComponent>(); this.onOpenMenuClick = new EventEmitter<CoreFileComponent>();
} }
/**
* Emits onOpenMenuClick event with the current instance.
*/
openMenuClick(): void { openMenuClick(): void {
this.onOpenMenuClick.emit(this); this.onOpenMenuClick.emit(this);
} }

View File

@ -13,7 +13,7 @@
<h1>{{ selectFilesEnabled() ? (selectedFiles.length + ' ' + title) : title }}</h1> <h1>{{ selectFilesEnabled() ? (selectedFiles.length + ' ' + title) : title }}</h1>
</ion-title> </ion-title>
<ion-buttons slot="end"> <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-button fill="clear" (click)="deleteSelectedFiles(true)" [ariaLabel]="'core.delete' | translate" color="danger">
<ion-icon slot="icon-only" name="fas-trash" aria-hidden="true" /> <ion-icon slot="icon-only" name="fas-trash" aria-hidden="true" />
</ion-button> </ion-button>
@ -76,7 +76,7 @@
@if (showUpload && root !== 'site' && !path && !selectFilesEnabled()) { @if (showUpload && root !== 'site' && !path && !selectFilesEnabled()) {
<ion-fab slot="fixed" core-fab vertical="bottom" horizontal="end"> <ion-fab slot="fixed" core-fab vertical="bottom" horizontal="end">
<ion-fab-button (click)="uploadFile()" [attr.aria-label]="'core.fileuploader.uploadafile' | translate"> <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> <span class="sr-only">{{ 'core.fileuploader.uploadafile' | translate }}</span>
</ion-fab-button> </ion-fab-button>
</ion-fab> </ion-fab>

View File

@ -298,9 +298,18 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy {
* Delete private files. * Delete private files.
*/ */
async deleteSelectedFiles(showConfirmation = false): Promise<void> { async deleteSelectedFiles(showConfirmation = false): Promise<void> {
if (this.selectedFiles.length === 0) {
return;
}
if (showConfirmation) { if (showConfirmation) {
try { 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 { } catch {
return; return;
} }
@ -360,6 +369,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy {
cancelFileSelection(): void { cancelFileSelection(): void {
this.selectFilesEnabled.set(false); this.selectFilesEnabled.set(false);
this.selectedFiles = []; this.selectedFiles = [];
this.files = this.files?.map(file => ({ ...file, selected: false }));
} }
/** /**