6b1ebbabb7
Fix saving Cleanup Fix single value prepare Add prepare percent done stub Fix populating filters with saved values when editing for single values Fix populating filters with saved values when editing Add edit filter view page Hide adding new tasks to pseudolists Make sure all filter values are passed as strings as per requirement from the api Add redirect to list after creating it Add creating saved filter Add filter by percent done Add end date filter Add start date filter Add extra checkbox to enable/disable priority filter Add changing priority Add more filter stubs Fix dates for filters Add saved filter create form Add include nulls and concat to filter options Add new saved filter component Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/239 Co-Authored-By: konrad <konrad@kola-entertainments.de> Co-Committed-By: konrad <konrad@kola-entertainments.de>
38 lines
1 KiB
JavaScript
38 lines
1 KiB
JavaScript
import AbstractService from '@/services/abstractService'
|
|
import SavedFilterModel from '@/models/savedFilter'
|
|
import {objectToCamelCase} from '@/helpers/case'
|
|
|
|
export default class SavedFilterService extends AbstractService {
|
|
constructor() {
|
|
super({
|
|
get: '/filters/{id}',
|
|
create: '/filters',
|
|
update: '/filters/{id}',
|
|
delete: '/filters/{id}',
|
|
})
|
|
}
|
|
|
|
modelFactory(data) {
|
|
return new SavedFilterModel(data)
|
|
}
|
|
|
|
processModel(model) {
|
|
// Make filters from this.filters camelCase and set them to the model property:
|
|
// That's easier than making the whole filter component configurable since that still needs to provide
|
|
// the filter values in snake_sćase for url parameters.
|
|
model.filters = objectToCamelCase(model.filters)
|
|
|
|
// Make sure all filterValues are passes as strings. This is a requirement of the api.
|
|
model.filters.filterValue = model.filters.filterValue.map(v => String(v))
|
|
|
|
return model
|
|
}
|
|
|
|
beforeUpdate(model) {
|
|
return this.processModel(model)
|
|
}
|
|
|
|
beforeCreate(model) {
|
|
return this.processModel(model)
|
|
}
|
|
}
|