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

MOBILE-2256 privatefiles: Remove private files #4189

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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