2019-11-24 13:16:24 +00:00
|
|
|
import AbstractService from './abstractService'
|
2022-09-06 09:36:01 +00:00
|
|
|
import LabelModel from '@/models/label'
|
|
|
|
import type {ILabel} from '@/modelTypes/ILabel'
|
2021-01-17 10:51:07 +00:00
|
|
|
import {colorFromHex} from '@/helpers/color/colorFromHex'
|
2019-03-07 19:48:40 +00:00
|
|
|
|
2022-07-20 22:42:36 +00:00
|
|
|
export default class LabelService extends AbstractService<ILabel> {
|
2019-03-07 19:48:40 +00:00
|
|
|
constructor() {
|
|
|
|
super({
|
|
|
|
create: '/labels',
|
|
|
|
getAll: '/labels',
|
|
|
|
get: '/labels/{id}',
|
|
|
|
update: '/labels/{id}',
|
|
|
|
delete: '/labels/{id}',
|
|
|
|
})
|
|
|
|
}
|
2020-02-08 13:16:06 +00:00
|
|
|
|
2020-04-25 23:11:34 +00:00
|
|
|
processModel(label) {
|
2023-01-03 14:20:06 +00:00
|
|
|
label.created = new Date(label.created).toISOString()
|
|
|
|
label.updated = new Date(label.updated).toISOString()
|
2021-01-17 10:51:07 +00:00
|
|
|
label.hexColor = colorFromHex(label.hexColor)
|
2020-04-25 23:11:34 +00:00
|
|
|
return label
|
2020-02-08 13:16:06 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 19:48:40 +00:00
|
|
|
modelFactory(data) {
|
|
|
|
return new LabelModel(data)
|
|
|
|
}
|
2020-09-05 20:35:52 +00:00
|
|
|
|
2019-03-07 19:48:40 +00:00
|
|
|
beforeUpdate(label) {
|
2020-04-25 23:11:34 +00:00
|
|
|
return this.processModel(label)
|
2019-03-07 19:48:40 +00:00
|
|
|
}
|
2020-09-05 20:35:52 +00:00
|
|
|
|
2019-03-07 19:48:40 +00:00
|
|
|
beforeCreate(label) {
|
2020-04-25 23:11:34 +00:00
|
|
|
return this.processModel(label)
|
2019-03-07 19:48:40 +00:00
|
|
|
}
|
|
|
|
}
|