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-02-08 14:16:06 +01:00
|
|
|
import moment from 'moment'
|
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
|
|
|
|
|
|
|
processModel(model) {
|
|
|
|
model.created = moment(model.created).toISOString()
|
|
|
|
model.updated = moment(model.updated).toISOString()
|
|
|
|
return model
|
|
|
|
}
|
|
|
|
|
2019-03-07 20:48:40 +01:00
|
|
|
modelFactory(data) {
|
|
|
|
return new LabelModel(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeUpdate(label) {
|
|
|
|
label.hex_color = label.hex_color.substring(1, 7)
|
|
|
|
return label
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeCreate(label) {
|
|
|
|
label.hex_color = label.hex_color.substring(1, 7)
|
|
|
|
return label
|
|
|
|
}
|
|
|
|
}
|