feat: remove lodash dependency (#743)
Co-authored-by: Dominik Pschenitschni <mail@celement.de> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/743 Reviewed-by: konrad <k@knt.li> Co-authored-by: dpschen <dpschen@noreply.kolaente.de> Co-committed-by: dpschen <dpschen@noreply.kolaente.de>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
import {findIndexById} from '@/helpers/find'
|
||||
import {findIndexById} from '@/helpers/utils'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Vue from 'vue'
|
||||
import cloneDeep from 'lodash/cloneDeep'
|
||||
|
||||
import BucketService from '../../services/bucket'
|
||||
import {filterObject} from '@/helpers/filterObject'
|
||||
@ -206,7 +205,7 @@ export default {
|
||||
const cancel = setLoading(ctx, 'kanban')
|
||||
ctx.commit('setBucketLoading', {bucketId: bucketId, loading: true})
|
||||
|
||||
const params = cloneDeep(ps)
|
||||
const params = JSON.parse(JSON.stringify(ps))
|
||||
|
||||
params.sort_by = 'kanban_position'
|
||||
params.order_by = 'asc'
|
||||
|
@ -2,10 +2,37 @@ import LabelService from '@/services/label'
|
||||
import Vue from 'vue'
|
||||
import {setLoading} from '@/store/helper'
|
||||
|
||||
/**
|
||||
* Returns the labels by id if found
|
||||
* @param {Object} state
|
||||
* @param {Array} ids
|
||||
* @returns {Array}
|
||||
*/
|
||||
function getLabelsByIds(state, ids) {
|
||||
return Object.values(state.labels).filter(({id}) => ids.includes(id))
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a list of labels is available in the store and filters them then query
|
||||
* @param {Object} state
|
||||
* @param {Array} labels
|
||||
* @param {String} query
|
||||
* @returns {Array}
|
||||
*/
|
||||
function filterLabelsByQuery(state, labels, query) {
|
||||
const labelIds = labels.map(({id}) => id)
|
||||
const foundLabels = getLabelsByIds(state, labelIds)
|
||||
const labelQuery = query.toLowerCase()
|
||||
|
||||
return foundLabels.filter(({title}) => {
|
||||
return !title.toLowerCase().includes(labelQuery)
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
// The state is an object which has the label ids as keys.
|
||||
state: () => ({
|
||||
// The labels are stored as an object which has the label ids as keys.
|
||||
labels: {},
|
||||
loaded: false,
|
||||
}),
|
||||
@ -25,6 +52,14 @@ export default {
|
||||
state.loaded = loaded
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
getLabelsByIds(state) {
|
||||
return (ids) => getLabelsByIds(state, ids)
|
||||
},
|
||||
filterLabelsByQuery(state) {
|
||||
return (...arr) => filterLabelsByQuery(state, ...arr)
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
loadAllLabels(ctx, {forceLoad} = {}) {
|
||||
if (ctx.state.loaded && !forceLoad) {
|
||||
|
Reference in New Issue
Block a user