diff --git a/src/addons/privatefiles/components/file/file.ts b/src/addons/privatefiles/components/file/file.ts index 6e5659c93..f274a0d4a 100644 --- a/src/addons/privatefiles/components/file/file.ts +++ b/src/addons/privatefiles/components/file/file.ts @@ -40,6 +40,9 @@ export class AddonPrivateFilesFileComponent extends CoreFileComponent implements this.onOpenMenuClick = new EventEmitter(); } + /** + * Emits onOpenMenuClick event with the current instance. + */ openMenuClick(): void { this.onOpenMenuClick.emit(this); } diff --git a/src/addons/privatefiles/pages/index/index.html b/src/addons/privatefiles/pages/index/index.html index dc6f18e8f..3abdd3d5d 100644 --- a/src/addons/privatefiles/pages/index/index.html +++ b/src/addons/privatefiles/pages/index/index.html @@ -13,7 +13,7 @@

{{ selectFilesEnabled() ? (selectedFiles.length + ' ' + title) : title }}

- @if (selectFilesEnabled()) { + @if (selectFilesEnabled() && selectedFiles.length > 0) { @@ -76,7 +76,7 @@ @if (showUpload && root !== 'site' && !path && !selectFilesEnabled()) { - diff --git a/src/addons/privatefiles/pages/index/index.ts b/src/addons/privatefiles/pages/index/index.ts index 2d2c3bc72..8079da293 100644 --- a/src/addons/privatefiles/pages/index/index.ts +++ b/src/addons/privatefiles/pages/index/index.ts @@ -298,9 +298,18 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { * Delete private files. */ async deleteSelectedFiles(showConfirmation = false): Promise { + 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; } @@ -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 })); } /**