vikunja-frontend/src/services/label.js

35 lines
717 B
JavaScript
Raw Normal View History

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}',
})
}
processModel(model) {
2020-03-02 21:55:22 +01:00
model.created = formatISO(model.created)
model.updated = formatISO(model.updated)
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
}
}