filter mediafiles by hidden status, and by 'pdf/not pdf'

This commit is contained in:
Maximilian Krambach 2019-01-24 10:38:47 +01:00
parent 56a804eb47
commit c1c0611d86
3 changed files with 34 additions and 20 deletions

View File

@ -46,6 +46,22 @@ export class ViewMediafile extends BaseViewModel {
return this.mediafile ? this.mediafile.getDownloadUrl() : null;
}
/**
* @returns the file type of the associated media file.
*/
public get fileType(): string {
return this.mediafile ? this.mediafile.mediafile.type : null;
}
/**
* Determines if the file has the 'hidden' attribute
* @returns the hidden attribute, also 'hidden' if there is no file
* TODO Which is the expected behavior for 'no file'?
*/
public get is_hidden(): boolean {
return this.mediafile ? this.mediafile.hidden : true;
}
public constructor(mediafile?: Mediafile, uploader?: User) {
super();
this._mediafile = mediafile;
@ -118,8 +134,4 @@ export class ViewMediafile extends BaseViewModel {
this._mediafile = update;
}
}
public is_hidden(): boolean {
return this._mediafile.hidden;
}
}

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { FilterListService } from '../../../core/services/filter-list.service';
import { FilterListService, OsFilter } from '../../../core/services/filter-list.service';
import { Mediafile } from '../../../shared/models/mediafiles/mediafile';
import { ViewMediafile } from '../models/view-mediafile';
import { StorageService } from 'app/core/services/storage.service';
@ -12,7 +12,7 @@ import { MediafileRepositoryService } from './mediafile-repository.service';
export class MediafileFilterListService extends FilterListService<Mediafile, ViewMediafile> {
protected name = 'Mediafile';
public filterOptions = [
public filterOptions: OsFilter[] = [
{
property: 'is_hidden',
label: 'Hidden',
@ -20,17 +20,25 @@ export class MediafileFilterListService extends FilterListService<Mediafile, Vie
{ condition: true, label: 'is hidden' },
{ condition: false, label: 'is not hidden', isActive: true }
]
},
{
property: 'fileType',
label: 'Is PDF',
options: [
{
condition: 'application/pdf',
label: 'is PDF file'
},
{
condition: null,
label: 'Is no PDF file'
}
]
}
// , { TODO: is_pdf is not yet implemented on mediafile side
// property: 'is_pdf', isActive: false, label: 'PDF',
// options: [
// {condition: true, label: 'is a PDF'},
// {condition: false, label: 'is not a PDF'}
// ]
// }
];
public constructor(store: StorageService, repo: MediafileRepositoryService) {
super(store, repo);
this.updateFilterDefinitions(this.filterOptions);
}
}

View File

@ -9,13 +9,7 @@ export class MediafilesSortListService extends SortListService<ViewMediafile> {
public sortOptions: OsSortingDefinition<ViewMediafile> = {
sortProperty: 'title',
sortAscending: true,
options: [
{ property: 'title' },
{ property: 'type' },
{ property: 'size' },
// { property: 'upload_date' }
{ property: 'uploader' }
]
options: [{ property: 'title' }, { property: 'type' }, { property: 'size' }]
};
protected name = 'Mediafile';
}