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 5, 2024
1 parent d800909 commit a5e59cb
Show file tree
Hide file tree
Showing 13 changed files with 403 additions and 15 deletions.
4 changes: 4 additions & 0 deletions scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -1141,11 +1141,15 @@
"addon.notifications.therearentnotificationsyet": "local_moodlemobileapp",
"addon.notifications.typeofnotification": "local_moodlemobileapp",
"addon.notifications.unreadnotification": "message",
"addon.privatefiles.availableoffline": "local_moodlemobileapp",
"addon.privatefiles.confirmremoveselectedfiles": "local_moodlemobileapp",
"addon.privatefiles.couldnotloadfiles": "local_moodlemobileapp",
"addon.privatefiles.emptyfilelist": "local_moodlemobileapp",
"addon.privatefiles.erroruploadnotworking": "local_moodlemobileapp",
"addon.privatefiles.files": "moodle",
"addon.privatefiles.filedeletedsuccessfully": "local_moodlemobileapp",
"addon.privatefiles.privatefiles": "moodle",
"addon.privatefiles.selectall": "local_moodlemobileapp",
"addon.privatefiles.sitefiles": "moodle",
"addon.qtype_essay.maxwordlimitboundary": "qtype_essay",
"addon.qtype_essay.minwordlimitboundary": "qtype_essay",
Expand Down
29 changes: 29 additions & 0 deletions src/addons/privatefiles/components/file-actions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<header>
<ion-item button="false" detail="false" class="ion-text-wrap">
<ion-thumbnail slot="start">
<img [src]="icon" alt="" role="presentation" />
</ion-thumbnail>

<ion-label>{{ filename }}</ion-label>

<ion-button shape="round" size="default" slot="end" fill="clear" [ariaLabel]="'core.close' | translate"
(click)="close({ status: 'cancel' })">
<ion-icon slot="icon-only" name="close" aria-label="hidden" />
</ion-button>
</ion-item>
</header>

<hr>

<ion-list>
<ion-item button="false" detail="false" lines="none">
<ion-icon slot="start" name="fas-cloud" aria-hidden="true" />
<ion-label>{{ 'addon.privatefiles.availableoffline' | translate }}</ion-label>
<ion-toggle slot="end" [(ngModel)]="toggleValue" (ngModelChange)="close({ status: toggleValue ? 'download' : 'deleteOffline' })" />
</ion-item>

<ion-item detail="false" (click)="close({ status: 'deleteOnline' })" lines="none">
<ion-icon slot="start" name="fas-trash" aria-hidden="true" color="danger" />
<ion-label> {{ 'core.delete' | translate }} </ion-label>
</ion-item>
</ion-list>
8 changes: 8 additions & 0 deletions src/addons/privatefiles/components/file-actions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
hr {
background: var(--gray-300);
}

ion-thumbnail {
--size: 1.5rem;
margin-inline-end: 0.5rem;
}
51 changes: 51 additions & 0 deletions src/addons/privatefiles/components/file-actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { CoreSharedModule } from '@/core/shared.module';
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core';
import { CoreModalComponent } from '@classes/modal-component';

@Component({
selector: 'core-privatefiles-file-actions',
styleUrl: './file-actions.scss',
templateUrl: 'file-actions.html',
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [CoreSharedModule],
})
export class AddonPrivateFilesFileActionsComponent extends CoreModalComponent<AddonPrivateFilesFileActionsComponentParams>
implements OnInit {

@Input({ required: true }) selected = false;
@Input({ required: true }) filename = '';
@Input({ required: true }) icon = '';

toggleValue = false;

constructor(elementRef: ElementRef<HTMLElement>) {
super(elementRef);
}

/**
* @inheritdoc
*/
ngOnInit(): void {
this.toggleValue = this.selected;
}

}

export type AddonPrivateFilesFileActionsComponentParams = {
status: 'cancel' | 'deleteOnline' | 'deleteOffline' | 'download';
};
6 changes: 5 additions & 1 deletion src/addons/privatefiles/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"erroruploadnotworking": "Unfortunately it is currently not possible to upload files to your site.",
"files": "Files",
"privatefiles": "Private files",
"sitefiles": "Site files"
"sitefiles": "Site files",
"filedeletedsuccessfully": "You have deleted {{filename}} succesfully",
"availableoffline": "Available offline",
"confirmremoveselectedfiles": "This will permanently delete selected files. Are you sure about this action?",
"selectall": "Select all"
}
34 changes: 31 additions & 3 deletions src/addons/privatefiles/pages/index/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
@if (selectFilesEnabled()) {
<ion-button fill="clear" [ariaLabel]="'core.close' | translate" (click)="cancelFileSelection()">
<ion-icon slot="icon-only" name="fas-xmark" aria-hidden="true" />
</ion-button>
} @else {
<ion-back-button [text]="'core.back' | translate" />
}
</ion-buttons>
<ion-title>
<h1>{{ title }}</h1>
<h1>{{ selectFilesEnabled() ? (selectedFiles.length + ' ' + title) : title }}</h1>
</ion-title>
<ion-buttons slot="end">
@if (selectFilesEnabled()) {
<ion-button fill="clear" (click)="deleteFiles()" [ariaLabel]="'core.delete' | translate" color="danger">
<ion-icon slot="icon-only" name="fas-trash" aria-hidden="true" />
</ion-button>
}
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content class="limited-width">
Expand All @@ -28,6 +41,7 @@ <h1>{{ title }}</h1>
<!-- Display info about space used and space left. -->
<ion-card class="core-info-card" *ngIf="userQuota && filesInfo && filesInfo.filecount > 0">
<ion-item>
<ion-icon slot="start" aria-label="hidden" name="fas-cloud" />
<ion-label>
{{ 'core.quotausage' | translate:{$a: {used: spaceUsed, total: userQuotaReadable} } }}
</ion-label>
Expand All @@ -42,7 +56,11 @@ <h1>{{ title }}</h1>
<ion-icon name="fas-folder" slot="start" [attr.aria-label]="'core.folder' | translate" />
<ion-label>{{file.filename}}</ion-label>
</ion-item>
<core-file *ngIf="!file.isdir" [file]="file" [component]="component" [componentId]="file.contextid" />
<core-file *ngIf="!file.isdir" [file]="file" [component]="component" [componentId]="file.contextid"
(onOpenMenuClick)="openManagementFileMenu(file)" (longPress)="selectFilesEnabled.set(true)"
[downloadState]="file.downloadState" [showCheckbox]="selectFilesEnabled()"
(onSelectedFileChange)="selectedFileValueChanged($event, file)" showDownloadStatus="true" canDownload="false"
[selected]="file.selected" />
</ng-container>
</ion-list>

Expand All @@ -51,10 +69,20 @@ <h1>{{ title }}</h1>
</core-loading>

<!-- Upload a private file. -->
<ion-fab slot="fixed" core-fab vertical="bottom" horizontal="end" *ngIf="showUpload && root !== 'site' && !path">
@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" />
<span class="sr-only">{{ 'core.fileuploader.uploadafile' | translate }}</span>
</ion-fab-button>
</ion-fab>
}
</ion-content>

@if (selectFilesEnabled()) {
<div class="addon-privatefiles-selectall">
<ion-checkbox labelPlacement="end" [(ngModel)]="selectAll" (ngModelChange)="onSelectAllChanges($event)">
{{ 'addon.privatefiles.selectall' | translate }}
</ion-checkbox>
</div>
}
4 changes: 4 additions & 0 deletions src/addons/privatefiles/pages/index/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

.addon-privatefiles-selectall {
padding: 0.3rem 0 0.3rem 1rem;
}
Loading

0 comments on commit a5e59cb

Please sign in to comment.