filter mediafiles by hidden status, and by 'pdf/not pdf'
This commit is contained in:
parent
56a804eb47
commit
c1c0611d86
@ -46,6 +46,22 @@ export class ViewMediafile extends BaseViewModel {
|
|||||||
return this.mediafile ? this.mediafile.getDownloadUrl() : null;
|
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) {
|
public constructor(mediafile?: Mediafile, uploader?: User) {
|
||||||
super();
|
super();
|
||||||
this._mediafile = mediafile;
|
this._mediafile = mediafile;
|
||||||
@ -118,8 +134,4 @@ export class ViewMediafile extends BaseViewModel {
|
|||||||
this._mediafile = update;
|
this._mediafile = update;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public is_hidden(): boolean {
|
|
||||||
return this._mediafile.hidden;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
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 { Mediafile } from '../../../shared/models/mediafiles/mediafile';
|
||||||
import { ViewMediafile } from '../models/view-mediafile';
|
import { ViewMediafile } from '../models/view-mediafile';
|
||||||
import { StorageService } from 'app/core/services/storage.service';
|
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> {
|
export class MediafileFilterListService extends FilterListService<Mediafile, ViewMediafile> {
|
||||||
protected name = 'Mediafile';
|
protected name = 'Mediafile';
|
||||||
|
|
||||||
public filterOptions = [
|
public filterOptions: OsFilter[] = [
|
||||||
{
|
{
|
||||||
property: 'is_hidden',
|
property: 'is_hidden',
|
||||||
label: 'Hidden',
|
label: 'Hidden',
|
||||||
@ -20,17 +20,25 @@ export class MediafileFilterListService extends FilterListService<Mediafile, Vie
|
|||||||
{ condition: true, label: 'is hidden' },
|
{ condition: true, label: 'is hidden' },
|
||||||
{ condition: false, label: 'is not hidden', isActive: true }
|
{ 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) {
|
public constructor(store: StorageService, repo: MediafileRepositoryService) {
|
||||||
super(store, repo);
|
super(store, repo);
|
||||||
|
this.updateFilterDefinitions(this.filterOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,7 @@ export class MediafilesSortListService extends SortListService<ViewMediafile> {
|
|||||||
public sortOptions: OsSortingDefinition<ViewMediafile> = {
|
public sortOptions: OsSortingDefinition<ViewMediafile> = {
|
||||||
sortProperty: 'title',
|
sortProperty: 'title',
|
||||||
sortAscending: true,
|
sortAscending: true,
|
||||||
options: [
|
options: [{ property: 'title' }, { property: 'type' }, { property: 'size' }]
|
||||||
{ property: 'title' },
|
|
||||||
{ property: 'type' },
|
|
||||||
{ property: 'size' },
|
|
||||||
// { property: 'upload_date' }
|
|
||||||
{ property: 'uploader' }
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
protected name = 'Mediafile';
|
protected name = 'Mediafile';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user