Add task filter for assignees
continuous-integration/drone/pr Build was killed
Details
continuous-integration/drone/pr Build was killed
Details
This commit is contained in:
parent
69a9f867b4
commit
718c41275c
|
@ -98,6 +98,38 @@
|
||||||
</fancycheckbox>
|
</fancycheckbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">Assignees</label>
|
||||||
|
<div class="control">
|
||||||
|
<multiselect
|
||||||
|
:clear-on-select="true"
|
||||||
|
:close-on-select="true"
|
||||||
|
:hide-selected="true"
|
||||||
|
:internal-search="true"
|
||||||
|
:loading="userService.loading"
|
||||||
|
:multiple="true"
|
||||||
|
:options="foundUsers"
|
||||||
|
:options-limit="300"
|
||||||
|
:searchable="true"
|
||||||
|
:showNoOptions="false"
|
||||||
|
:taggable="false"
|
||||||
|
@search-change="findUser"
|
||||||
|
@select="user => addUser(user)"
|
||||||
|
@remove="removeUser"
|
||||||
|
label="username"
|
||||||
|
placeholder="Type to search for a user..."
|
||||||
|
track-by="id"
|
||||||
|
v-model="users"
|
||||||
|
>
|
||||||
|
<template slot="clear" slot-scope="props">
|
||||||
|
<div
|
||||||
|
@mousedown.prevent.stop="clearAllUsers(props.search)"
|
||||||
|
class="multiselect__clear"
|
||||||
|
v-if="users.length"></div>
|
||||||
|
</template>
|
||||||
|
</multiselect>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -106,11 +138,16 @@
|
||||||
import Fancycheckbox from '../../input/fancycheckbox'
|
import Fancycheckbox from '../../input/fancycheckbox'
|
||||||
import flatPickr from 'vue-flatpickr-component'
|
import flatPickr from 'vue-flatpickr-component'
|
||||||
import 'flatpickr/dist/flatpickr.css'
|
import 'flatpickr/dist/flatpickr.css'
|
||||||
|
import Multiselect from 'vue-multiselect'
|
||||||
|
|
||||||
import {formatISO} from 'date-fns'
|
import {formatISO} from 'date-fns'
|
||||||
|
import differenceWith from 'lodash/differenceWith'
|
||||||
|
|
||||||
import PrioritySelect from '@/components/tasks/partials/prioritySelect'
|
import PrioritySelect from '@/components/tasks/partials/prioritySelect'
|
||||||
import PercentDoneSelect from '@/components/tasks/partials/percentDoneSelect'
|
import PercentDoneSelect from '@/components/tasks/partials/percentDoneSelect'
|
||||||
|
|
||||||
|
import UserService from '../../../services/user'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'filters',
|
name: 'filters',
|
||||||
components: {
|
components: {
|
||||||
|
@ -118,6 +155,7 @@ export default {
|
||||||
Fancycheckbox,
|
Fancycheckbox,
|
||||||
flatPickr,
|
flatPickr,
|
||||||
PercentDoneSelect,
|
PercentDoneSelect,
|
||||||
|
Multiselect,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -141,6 +179,7 @@ export default {
|
||||||
percentDone: 0,
|
percentDone: 0,
|
||||||
usePercentDone: false,
|
usePercentDone: false,
|
||||||
reminders: '',
|
reminders: '',
|
||||||
|
assignees: '',
|
||||||
},
|
},
|
||||||
flatPickerConfig: {
|
flatPickerConfig: {
|
||||||
altFormat: 'j M Y H:i',
|
altFormat: 'j M Y H:i',
|
||||||
|
@ -150,8 +189,15 @@ export default {
|
||||||
time_24hr: true,
|
time_24hr: true,
|
||||||
mode: 'range',
|
mode: 'range',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
userService: UserService,
|
||||||
|
foundUsers: [],
|
||||||
|
users: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.userService = new UserService()
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.params = this.value
|
this.params = this.value
|
||||||
this.filters.requireAllFilters = this.params.filter_concat === 'and'
|
this.filters.requireAllFilters = this.params.filter_concat === 'and'
|
||||||
|
@ -254,8 +300,8 @@ export default {
|
||||||
this.filters[variableName] = `${start.getFullYear()}-${start.getMonth() + 1}-${start.getDate()} to ${end.getFullYear()}-${end.getMonth() + 1}-${end.getDate()}`
|
this.filters[variableName] = `${start.getFullYear()}-${start.getMonth() + 1}-${start.getDate()} to ${end.getFullYear()}-${end.getMonth() + 1}-${end.getDate()}`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setSingleValueFilter(filterName, variableName, useVariableName) {
|
setSingleValueFilter(filterName, variableName, useVariableName = '', comparator = 'equals') {
|
||||||
if (!this.filters[useVariableName]) {
|
if (useVariableName !== '' && !this.filters[useVariableName]) {
|
||||||
this.removePropertyFromFilter(filterName)
|
this.removePropertyFromFilter(filterName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -270,7 +316,7 @@ export default {
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
this.params.filter_by.push(filterName)
|
this.params.filter_by.push(filterName)
|
||||||
this.params.filter_comparator.push('equals')
|
this.params.filter_comparator.push(comparator)
|
||||||
this.params.filter_value.push(this.filters[variableName])
|
this.params.filter_value.push(this.filters[variableName])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,6 +413,51 @@ export default {
|
||||||
prepareReminders() {
|
prepareReminders() {
|
||||||
this.prepareDate('reminders', 'reminders')
|
this.prepareDate('reminders', 'reminders')
|
||||||
},
|
},
|
||||||
|
clearUsers() {
|
||||||
|
this.$set(this, 'foundUsers', [])
|
||||||
|
},
|
||||||
|
findUser(query) {
|
||||||
|
|
||||||
|
if(query === '') {
|
||||||
|
this.clearUsers()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.userService.getAll({}, {s: query})
|
||||||
|
.then(response => {
|
||||||
|
// Filter the results to not include users who are already assigneid
|
||||||
|
this.$set(this, 'foundUsers', differenceWith(response, this.users, (first, second) => {
|
||||||
|
return first.id === second.id
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
this.error(e, this)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
addUser() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.changeAssigneeFilter()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
removeUser() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.changeAssigneeFilter()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
changeAssigneeFilter() {
|
||||||
|
if(this.users.length === 0) {
|
||||||
|
this.removePropertyFromFilter('assignees')
|
||||||
|
this.change()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let userIDs = []
|
||||||
|
this.users.forEach(u => {
|
||||||
|
userIDs.push(u.id)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.$set(this.filters, 'assignees', userIDs.join(','))
|
||||||
|
this.setSingleValueFilter('assignees', 'assignees', '', 'in')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Reference in New Issue