-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOBILE-2256 privatefiles: Remove private files
- Loading branch information
1 parent
45008e4
commit 7792f0d
Showing
15 changed files
with
456 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/addons/privatefiles/components/file-actions/file-actions.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<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> | ||
@if (isDownloaded) { | ||
<ion-item button="false" detail="false" lines="none" (click)="close({ status: 'deleteOffline' })"> | ||
<ion-icon slot="start" name="fam-cloud-x" aria-hidden="true" /> | ||
<ion-label>{{ 'core.removedownloadeddata' | translate }}</ion-label> | ||
</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
8
src/addons/privatefiles/components/file-actions/file-actions.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
41 changes: 41 additions & 0 deletions
41
src/addons/privatefiles/components/file-actions/file-actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// (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 } from '@angular/core'; | ||
import { CoreModalComponent } from '@classes/modal-component'; | ||
|
||
@Component({ | ||
selector: 'addon-privatefiles-file-actions', | ||
styleUrl: './file-actions.scss', | ||
templateUrl: 'file-actions.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [CoreSharedModule], | ||
}) | ||
export class AddonPrivateFilesFileActionsComponent extends CoreModalComponent<AddonPrivateFilesFileActionsComponentParams> { | ||
|
||
@Input({ required: false }) isDownloaded = false; | ||
@Input({ required: true }) filename = ''; | ||
@Input({ required: true }) icon = ''; | ||
|
||
constructor(elementRef: ElementRef<HTMLElement>) { | ||
super(elementRef); | ||
} | ||
|
||
} | ||
|
||
export type AddonPrivateFilesFileActionsComponentParams = { | ||
status: 'cancel' | 'deleteOnline' | 'deleteOffline' | 'download'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<ion-card class="card-file"> | ||
|
||
@if (file) { | ||
<ion-item button [ngClass]="{ 'file-selected': showCheckbox && selected }" class="ion-text-wrap item-file" [detail]="false"> | ||
|
||
@if (showCheckbox) { | ||
<ion-checkbox labelPlacement="start" [(ngModel)]="selected" (ngModelChange)="onSelectedFileChange.emit($event)" /> | ||
} @else { | ||
<ion-thumbnail slot="start" (click)="download($event, true)"> | ||
<img [src]="fileIcon" alt="" role="presentation" /> | ||
</ion-thumbnail> | ||
} | ||
|
||
<ion-label (click)="download($event, true)"> | ||
<p class="item-heading"> | ||
{{fileName}} | ||
|
||
@if (state === 'downloaded') { | ||
<ion-icon class="core-icon-downloaded" color="success" name="fam-cloud-done" | ||
[attr.aria-label]="'core.downloaded' | translate" role="status" /> | ||
} | ||
</p> | ||
|
||
|
||
<p *ngIf="fileSizeReadable || showTime"> | ||
<ng-container *ngIf="fileSizeReadable">{{ fileSizeReadable }}</ng-container> | ||
<ng-container *ngIf="fileSizeReadable && showTime"> · </ng-container> | ||
<ng-container *ngIf="showTime">{{ timemodified * 1000 | coreFormatDate }}</ng-container> | ||
</p> | ||
</ion-label> | ||
<div slot="end" class="flex-row"> | ||
<ion-button fill="clear" *ngIf="isDownloaded && isIOS" (click)="openFile($event, true)" [title]="openButtonLabel | translate"> | ||
<ion-icon slot="icon-only" [name]="openButtonIcon" aria-hidden="true" /> | ||
</ion-button> | ||
|
||
@if (!showCheckbox) { | ||
|
||
@if (!isDownloaded) { | ||
<core-download-refresh [status]="state" [enabled]="canDownload" [loading]="isDownloading" [canTrustDownload]="!alwaysDownload" | ||
(action)="download()" /> | ||
} | ||
|
||
<ion-button (click)="openMenuClick()" fill="clear"> | ||
<ion-icon name="ellipsis-vertical" slot="icon-only" aria-hidden="true" /> | ||
</ion-button> | ||
} | ||
</div> | ||
</ion-item> | ||
} | ||
|
||
</ion-card> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ion-checkbox { | ||
flex: none; | ||
width: 3rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// (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 { toBoolean } from '@/core/transforms/boolean'; | ||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; | ||
import { CoreFileComponent } from '@components/file/file'; | ||
|
||
@Component({ | ||
selector: 'addon-privatefiles-file', | ||
templateUrl: 'file.html', | ||
standalone: true, | ||
styleUrls: ['file.scss'], | ||
imports: [CoreSharedModule], | ||
}) | ||
export class AddonPrivateFilesFileComponent extends CoreFileComponent implements OnInit, OnDestroy { | ||
|
||
@Input({ transform: toBoolean }) showCheckbox = true; // Show checkbox | ||
@Input({ transform: toBoolean, required: false }) selected = false; // Selected file. | ||
|
||
@Output() onSelectedFileChange: EventEmitter<boolean>; // Will notify when the checkbox value changes. | ||
@Output() onOpenMenuClick: EventEmitter<CoreFileComponent>; // Will notify when menu clicked. | ||
|
||
constructor() { | ||
super(); | ||
this.onSelectedFileChange = new EventEmitter<boolean>(); | ||
this.onOpenMenuClick = new EventEmitter<CoreFileComponent>(); | ||
} | ||
|
||
openMenuClick(): void { | ||
this.onOpenMenuClick.emit(this); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
:host { | ||
ion-item.item.item-file { | ||
&.file-selected { | ||
--ion-item-background: var(--primary-tint); | ||
} | ||
|
||
--inner-border-width: 0 !important; | ||
} | ||
} |
Oops, something went wrong.