2019-11-24 14:16:24 +01:00
|
|
|
import AbstractService from './abstractService'
|
2019-03-07 20:48:40 +01:00
|
|
|
import LabelModel from '../models/label'
|
2020-03-02 21:55:22 +01:00
|
|
|
import {formatISO} from 'date-fns'
|
2019-03-07 20:48:40 +01:00
|
|
|
|
|
|
|
export default class LabelService extends AbstractService {
|
|
|
|
constructor() {
|
|
|
|
super({
|
|
|
|
create: '/labels',
|
|
|
|
getAll: '/labels',
|
|
|
|
get: '/labels/{id}',
|
|
|
|
update: '/labels/{id}',
|
|
|
|
delete: '/labels/{id}',
|
|
|
|
})
|
|
|
|
}
|
2020-02-08 14:16:06 +01:00
|
|
|
|
2020-04-26 01:11:34 +02:00
|
|
|
processModel(label) {
|
|
|
|
label.created = formatISO(label.created)
|
|
|
|
label.updated = formatISO(label.updated)
|
|
|
|
label.hexColor = label.hexColor.substring(1, 7)
|
|
|
|
return label
|
2020-02-08 14:16:06 +01:00
|
|
|
}
|
|
|
|
|
2019-03-07 20:48:40 +01:00
|
|
|
modelFactory(data) {
|
|
|
|
return new LabelModel(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeUpdate(label) {
|
2020-04-26 01:11:34 +02:00
|
|
|
return this.processModel(label)
|
2019-03-07 20:48:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
beforeCreate(label) {
|
2020-04-26 01:11:34 +02:00
|
|
|
return this.processModel(label)
|
2019-03-07 20:48:40 +01:00
|
|
|
}
|
|
|
|
}
|