mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-08-01 18:54:36 -05:00
This is necessary to be able to set .jpeg images as the background for kanban tiles. This extension is equivalent to .jpg, and is the default extension for uploading from iOS. Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2770 Co-authored-by: Sebastien Danthinne <sebastien@danthinne.com> Co-committed-by: Sebastien Danthinne <sebastien@danthinne.com>
29 lines
916 B
TypeScript
29 lines
916 B
TypeScript
import AbstractModel from './abstractModel'
|
|
import UserModel from './user'
|
|
import FileModel from './file'
|
|
import type { IUser } from '@/modelTypes/IUser'
|
|
import type { IFile } from '@/modelTypes/IFile'
|
|
import type { IAttachment } from '@/modelTypes/IAttachment'
|
|
|
|
export const SUPPORTED_IMAGE_SUFFIX = ['.jpeg', '.jpg', '.png', '.bmp', '.gif']
|
|
|
|
export function canPreview(attachment: IAttachment): boolean {
|
|
return SUPPORTED_IMAGE_SUFFIX.some((suffix) => attachment.file.name.toLowerCase().endsWith(suffix))
|
|
}
|
|
|
|
export default class AttachmentModel extends AbstractModel<IAttachment> implements IAttachment {
|
|
id = 0
|
|
taskId = 0
|
|
createdBy: IUser = UserModel
|
|
file: IFile = FileModel
|
|
created: Date = null
|
|
|
|
constructor(data: Partial<IAttachment>) {
|
|
super()
|
|
this.assignData(data)
|
|
|
|
this.createdBy = new UserModel(this.createdBy)
|
|
this.file = new FileModel(this.file)
|
|
this.created = new Date(this.created)
|
|
}
|
|
} |