1
0

Merge branch 'vue3' into feature/vue3-async-await

# Conflicts:
#	src/i18n/index.js
#	src/store/modules/labels.js
#	src/store/modules/tasks.js
#	src/views/list/views/Kanban.vue
#	src/views/tasks/ShowTasks.vue
#	src/views/tasks/TaskDetailView.vue
This commit is contained in:
Dominik Pschenitschni
2021-10-17 16:06:58 +02:00
14 changed files with 223 additions and 158 deletions

View File

@ -63,6 +63,12 @@ export const store = createStore({
state.online = !!import.meta.env.VITE_IS_ONLINE || online
},
[CURRENT_LIST](state, currentList) {
// Server updates don't return the right. Therefore the right is reset after updating the list which is
// confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right
// when updating the list in global state.
if (typeof state.currentList.maxRight !== 'undefined' && (typeof currentList.maxRight === 'undefined' || currentList.maxRight === null)) {
currentList.maxRight = state.currentList.maxRight
}
state.currentList = currentList
},
[HAS_TASKS](state, hasTasks) {
@ -135,12 +141,6 @@ export const store = createStore({
commit(BACKGROUND, null)
}
// Server updates don't return the right. Therefore the right is reset after updating the list which is
// confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right
// when updating the list in global state.
if (typeof state.currentList.maxRight !== 'undefined' && (typeof currentList.maxRight === 'undefined' || currentList.maxRight === null)) {
currentList.maxRight = state.currentList.maxRight
}
commit(CURRENT_LIST, currentList)
},
},

View File

@ -2,37 +2,10 @@ import LabelService from '@/services/label'
import {setLoading} from '@/store/helper'
import { success } from '@/message'
import {i18n} from '@/i18n'
/**
* 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)
})
}
import {getLabelsByIds, filterLabelsByQuery} from '@/helpers/labels'
const labelService = new LabelService()
const getAllLabels = async (page = 1) => {
async function getAllLabels(page = 1) {
const labels = await labelService.getAll({}, {}, page)
if (page < labelService.totalPages) {
const nextLabels = await getAllLabels(page + 1)
@ -70,7 +43,7 @@ export default {
return (ids) => getLabelsByIds(state, ids)
},
filterLabelsByQuery(state) {
return (...arr) => filterLabelsByQuery(state, ...arr)
return (labelsToHide, query) => filterLabelsByQuery(state, labelsToHide, query)
},
},
actions: {

View File

@ -229,8 +229,8 @@ export default {
// label not found, create it
const labelModel = new LabelModel({title: labelTitle})
await dispatch('labels/createLabel', labelModel)
addLabelToTask(task, label)
await dispatch('labels/createLabel', labelModel, {root: true})
return addLabelToTask(task, label)
})
// This waits until all labels are created and added to the task
@ -238,18 +238,18 @@ export default {
return task
},
findListId({ rootGetters }, { list, listId }) {
findListId({ rootGetters }, { list: listName, listId }) {
let foundListId = null
// Uses the following ways to get the list id of the new task:
// 1. If specified in quick add magic, look in store if it exists and use it if it does
if (list !== null) {
const list = rootGetters['lists/findListByExactname'](list)
if (listName !== null) {
const list = rootGetters['lists/findListByExactname'](listName)
foundListId = list === null ? null : list.id
}
// 2. Else check if a list was passed as parameter
if (listId !== 0) {
if (foundListId === null && listId !== 0) {
foundListId = listId
}
@ -298,7 +298,7 @@ export default {
const createdTask = await taskService.create(task)
return dispatch('addLabelsToTask', {
task: createdTask,
parsedLabels:parsedTask.labels,
parsedLabels: parsedTask.labels,
})
},
},