diff --git a/client/src/app/site/mediafiles/models/view-mediafile.ts b/client/src/app/site/mediafiles/models/view-mediafile.ts index eb1a10b2e..d63cb8438 100644 --- a/client/src/app/site/mediafiles/models/view-mediafile.ts +++ b/client/src/app/site/mediafiles/models/view-mediafile.ts @@ -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; @@ -120,8 +136,4 @@ export class ViewMediafile extends BaseViewModel { this._uploader = update; } } - - public is_hidden(): boolean { - return this._mediafile.hidden; - } } diff --git a/client/src/app/site/mediafiles/services/mediafile-filter.service.ts b/client/src/app/site/mediafiles/services/mediafile-filter.service.ts index d59a8165d..b96e436f8 100644 --- a/client/src/app/site/mediafiles/services/mediafile-filter.service.ts +++ b/client/src/app/site/mediafiles/services/mediafile-filter.service.ts @@ -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 { protected name = 'Mediafile'; - public filterOptions = [ + public filterOptions: OsFilter[] = [ { property: 'is_hidden', label: 'Hidden', @@ -20,17 +20,25 @@ export class MediafileFilterListService extends FilterListService { public sortOptions: OsSortingDefinition = { 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'; }