2022-08-04 20:57:43 +02:00
|
|
|
import AbstractModel from './abstractModel'
|
|
|
|
import UserModel from '@/models/user'
|
2020-09-26 23:02:37 +02:00
|
|
|
|
2022-08-04 20:57:43 +02:00
|
|
|
import type {ISavedFilter} from '@/modelTypes/ISavedFilter'
|
|
|
|
import type {IUser} from '@/modelTypes/IUser'
|
2022-07-21 00:42:36 +02:00
|
|
|
|
2022-09-06 11:36:01 +02:00
|
|
|
export default class SavedFilterModel extends AbstractModel<ISavedFilter> implements ISavedFilter {
|
2022-08-14 12:15:45 +02:00
|
|
|
id = 0
|
|
|
|
title = ''
|
|
|
|
description = ''
|
2022-08-04 20:57:43 +02:00
|
|
|
filters: ISavedFilter['filters'] = {
|
2022-08-14 12:15:45 +02:00
|
|
|
sortBy: ['done', 'id'],
|
|
|
|
orderBy: ['asc', 'desc'],
|
|
|
|
filterBy: ['done'],
|
|
|
|
filterValue: ['false'],
|
|
|
|
filterComparator: ['equals'],
|
|
|
|
filterConcat: 'and',
|
|
|
|
filterIncludeNulls: true,
|
2022-07-21 00:42:36 +02:00
|
|
|
}
|
|
|
|
|
2022-08-14 12:15:45 +02:00
|
|
|
owner: IUser = {}
|
|
|
|
created: Date = null
|
|
|
|
updated: Date = null
|
2022-06-23 03:22:21 +02:00
|
|
|
|
2022-09-02 11:15:29 +02:00
|
|
|
constructor(data: Partial<ISavedFilter> = {}) {
|
2022-08-14 12:15:45 +02:00
|
|
|
super()
|
|
|
|
this.assignData(data)
|
2020-09-26 23:02:37 +02:00
|
|
|
|
|
|
|
this.owner = new UserModel(this.owner)
|
|
|
|
|
|
|
|
this.created = new Date(this.created)
|
|
|
|
this.updated = new Date(this.updated)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates the corresponding list id to this saved filter.
|
|
|
|
* This function matches the one in the api.
|
|
|
|
* @returns {number}
|
|
|
|
*/
|
|
|
|
getListId() {
|
|
|
|
let listId = this.id * -1 - 1
|
|
|
|
if (listId > 0) {
|
|
|
|
listId = 0
|
|
|
|
}
|
|
|
|
return listId
|
|
|
|
}
|
|
|
|
}
|