MOBILE-2612 assign: Show size and time on file submissions

main
Pau Ferrer Ocaña 2018-09-27 13:01:42 +02:00
parent ae60746e40
commit 2ff9393543
5 changed files with 30 additions and 20 deletions

View File

@ -322,19 +322,12 @@ export class AddonModAssignProvider {
} }
filearea.files.forEach((file) => { filearea.files.forEach((file) => {
let filename; if (!file.filename) {
if (file.filename) {
filename = file.filename;
} else {
// We don't have filename, extract it from the path. // We don't have filename, extract it from the path.
filename = file.filepath[0] == '/' ? file.filepath.substr(1) : file.filepath; file.filename = file.filepath[0] == '/' ? file.filepath.substr(1) : file.filepath;
} }
files.push({ files.push(file);
filename: filename,
fileurl: file.fileurl
});
}); });
}); });
} }

View File

@ -1,12 +1,14 @@
<!-- Read only. --> <!-- Read only. -->
<ion-item text-wrap *ngIf="files && files.length && !edit"> <ion-item text-wrap *ngIf="files && files.length && !edit">
<h2>{{plugin.name}}</h2> <h2>{{plugin.name}}</h2>
<div *ngFor="let file of files" no-lines> <div no-lines>
<!-- Files already attached to the submission. --> <ng-container *ngFor="let file of files">
<core-file *ngIf="!file.name" [file]="file" [component]="component" [componentId]="assign.cmid" [alwaysDownload]="true"></core-file> <!-- Files already attached to the submission. -->
<core-file *ngIf="!file.name" [file]="file" [component]="component" [componentId]="assign.cmid" [alwaysDownload]="true"></core-file>
<!-- Files stored in offline to be sent later. --> <!-- Files stored in offline to be sent later. -->
<core-local-file *ngIf="file.name" [file]="file"></core-local-file> <core-local-file *ngIf="file.name" [file]="file"></core-local-file>
</ng-container>
</div> </div>
</ion-item> </ion-item>

View File

@ -1,6 +1,8 @@
<a ion-item text-wrap class="item-media" (click)="download($event, true)" detail-none> <a ion-item text-wrap class="item-media" (click)="download($event, true)" detail-none>
<img [src]="fileIcon" alt="" role="presentation" item-start /> <img [src]="fileIcon" alt="" role="presentation" item-start />
<p>{{fileName}}</p> <h2>{{fileName}}</h2>
<p *ngIf="fileSizeReadable">{{ fileSizeReadable }}</p>
<p *ngIf="showTime">{{ timemodified * 1000 | coreFormatDate:"dfmediumdate" }}</p>
<div class="buttons" item-end> <div class="buttons" item-end>
<button ion-button clear icon-only (click)="download($event)" *ngIf="!isDownloading && showDownload" [attr.aria-label]="'core.download' | translate" color="dark"> <button ion-button clear icon-only (click)="download($event)" *ngIf="!isDownloading && showDownload" [attr.aria-label]="'core.download' | translate" color="dark">
<ion-icon [name]="isDownloaded ? 'refresh' : 'cloud-download'"></ion-icon> <ion-icon [name]="isDownloaded ? 'refresh' : 'cloud-download'"></ion-icon>

View File

@ -1,13 +1,16 @@
ion-app.app-root { ion-app.app-root {
.card-md core-file + core-file > .item-md.item-block > .item-inner { .card-md core-file + core-file > .item-md.item-block > .item-inner,
core-file + core-file > .item-md.item-block > .item-inner {
border-top: 1px solid $list-md-border-color; border-top: 1px solid $list-md-border-color;
} }
.card-ios core-file + core-file > .item-ios.item-block > .item-inner { .card-ios core-file + core-file > .item-ios.item-block > .item-inner,
core-file + core-file > .item-ios.item-block > .item-inner {
border-top: $hairlines-width solid $list-ios-border-color; border-top: $hairlines-width solid $list-ios-border-color;
} }
.card-wp core-file + core-file > .item-wp.item-block > .item-inner { .card-wp core-file + core-file > .item-wp.item-block > .item-inner,
core-file + core-file > .item-wp.item-block > .item-inner {
border-top: 1px solid $list-wp-border-color; border-top: 1px solid $list-wp-border-color;
} }
} }

View File

@ -21,6 +21,7 @@ import { CoreSitesProvider } from '@providers/sites';
import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreMimetypeUtilsProvider } from '@providers/utils/mimetype'; import { CoreMimetypeUtilsProvider } from '@providers/utils/mimetype';
import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreUtilsProvider } from '@providers/utils/utils';
import { CoreTextUtilsProvider } from '@providers/utils/text';
import { CoreConstants } from '@core/constants'; import { CoreConstants } from '@core/constants';
/** /**
@ -39,6 +40,8 @@ export class CoreFileComponent implements OnInit, OnDestroy {
@Input() alwaysDownload?: boolean | string; // Whether it should always display the refresh button when the file is downloaded. @Input() alwaysDownload?: boolean | string; // Whether it should always display the refresh button when the file is downloaded.
// Use it for files that you cannot determine if they're outdated or not. // Use it for files that you cannot determine if they're outdated or not.
@Input() canDownload?: boolean | string = true; // Whether file can be downloaded. @Input() canDownload?: boolean | string = true; // Whether file can be downloaded.
@Input() showSize?: boolean | string = true; // Whether show filesize.
@Input() showTime?: boolean | string = true; // Whether show file time modified.
@Output() onDelete?: EventEmitter<void>; // Will notify when the delete button is clicked. @Output() onDelete?: EventEmitter<void>; // Will notify when the delete button is clicked.
isDownloaded: boolean; isDownloaded: boolean;
@ -46,6 +49,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
showDownload: boolean; showDownload: boolean;
fileIcon: string; fileIcon: string;
fileName: string; fileName: string;
fileSizeReadable: string;
protected fileUrl: string; protected fileUrl: string;
protected siteId: string; protected siteId: string;
@ -57,7 +61,7 @@ export class CoreFileComponent implements OnInit, OnDestroy {
constructor(private sitesProvider: CoreSitesProvider, private utils: CoreUtilsProvider, private domUtils: CoreDomUtilsProvider, constructor(private sitesProvider: CoreSitesProvider, private utils: CoreUtilsProvider, private domUtils: CoreDomUtilsProvider,
private filepoolProvider: CoreFilepoolProvider, private appProvider: CoreAppProvider, private filepoolProvider: CoreFilepoolProvider, private appProvider: CoreAppProvider,
private fileHelper: CoreFileHelperProvider, private mimeUtils: CoreMimetypeUtilsProvider, private fileHelper: CoreFileHelperProvider, private mimeUtils: CoreMimetypeUtilsProvider,
private eventsProvider: CoreEventsProvider) { private eventsProvider: CoreEventsProvider, private textUtils: CoreTextUtilsProvider) {
this.onDelete = new EventEmitter(); this.onDelete = new EventEmitter();
} }
@ -75,6 +79,12 @@ export class CoreFileComponent implements OnInit, OnDestroy {
this.fileSize = this.file.filesize; this.fileSize = this.file.filesize;
this.fileName = this.file.filename; this.fileName = this.file.filename;
if (this.utils.isTrueOrOne(this.showSize) && this.fileSize >= 0) {
this.fileSizeReadable = this.textUtils.bytesToSize(this.fileSize, 2);
}
this.showTime = this.utils.isTrueOrOne(this.showTime) && this.timemodified > 0;
if (this.file.isexternalfile) { if (this.file.isexternalfile) {
this.alwaysDownload = true; // Always show the download button in external files. this.alwaysDownload = true; // Always show the download button in external files.
} }