Task assingees (#21)

This commit is contained in:
konrad 2019-03-03 20:07:39 +00:00 committed by Gitea
parent aac137f8a4
commit 4a8a1b0a24
6 changed files with 109 additions and 8 deletions

View file

@ -183,6 +183,44 @@
</div> </div>
</div> </div>
<div class="field">
<label class="label" for="">Assignees</label>
<ul class="assingees">
<li v-for="(a, index) in taskEditTask.assignees" :key="a.id">
{{a.username}}
<a @click="deleteAssigneeByIndex(index)"><icon icon="times"/></a>
</li>
</ul>
</div>
<div class="field has-addons">
<div class="control is-expanded">
<multiselect
v-model="newAssignee"
:options="foundUsers"
:multiple="false"
:searchable="true"
:loading="userService.loading"
:internal-search="true"
@search-change="findUser"
placeholder="Type to search"
label="username"
track-by="id">
<template slot="clear" slot-scope="props">
<div class="multiselect__clear" v-if="newAssignee !== null && newAssignee.id !== 0" @mousedown.prevent.stop="clearAll(props.search)"></div>
</template>
<span slot="noResult">Oops! No user found. Consider changing the search query.</span>
</multiselect>
</div>
<div class="control">
<a @click="addAssignee" class="button is-primary fullheight">
<span class="icon is-small">
<icon icon="plus"/>
</span>
</a>
</div>
</div>
<div class="field"> <div class="field">
<label class="label" for="subtasks">Subtasks</label> <label class="label" for="subtasks">Subtasks</label>
<div class="tasks noborder" v-if="taskEditTask.subtasks && taskEditTask.subtasks.length > 0"> <div class="tasks noborder" v-if="taskEditTask.subtasks && taskEditTask.subtasks.length > 0">
@ -209,7 +247,7 @@
<input @keyup.enter="addSubtask()" :class="{ 'disabled': taskService.loading}" :disabled="taskService.loading" class="input" type="text" id="tasktext" placeholder="New subtask" v-model="newTask.text"/> <input @keyup.enter="addSubtask()" :class="{ 'disabled': taskService.loading}" :disabled="taskService.loading" class="input" type="text" id="tasktext" placeholder="New subtask" v-model="newTask.text"/>
</div> </div>
<div class="control"> <div class="control">
<a class="button" @click="addSubtask()"><icon icon="plus"></icon></a> <a class="button is-primary" @click="addSubtask()"><icon icon="plus"></icon></a>
</div> </div>
</div> </div>
@ -232,11 +270,15 @@
import message from '../../message' import message from '../../message'
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 {differenceWith} from 'lodash'
import ListService from '../../services/list' import ListService from '../../services/list'
import TaskService from '../../services/task' import TaskService from '../../services/task'
import TaskModel from '../../models/task' import TaskModel from '../../models/task'
import ListModel from '../../models/list' import ListModel from '../../models/list'
import UserModel from '../../models/user'
import UserService from '../../services/user'
import priorities from '../../models/priorities' import priorities from '../../models/priorities'
export default { export default {
@ -263,10 +305,15 @@
onOpen: this.updateLastReminderDate, onOpen: this.updateLastReminderDate,
onClose: this.addReminderDate, onClose: this.addReminderDate,
}, },
newAssignee: UserModel,
userService: UserService,
foundUsers: [],
} }
}, },
components: { components: {
flatPickr flatPickr,
multiselect,
}, },
beforeMount() { beforeMount() {
// Check if the user is already logged in, if so, redirect him to the homepage // Check if the user is already logged in, if so, redirect him to the homepage
@ -278,6 +325,8 @@
this.listService = new ListService() this.listService = new ListService()
this.taskService = new TaskService() this.taskService = new TaskService()
this.newTask = new TaskModel() this.newTask = new TaskModel()
this.userService = new UserService()
this.newAssignee = new UserModel()
this.loadList() this.loadList()
}, },
watch: { watch: {
@ -395,7 +444,33 @@
this.taskEditTask.reminderDates.splice(index, 1) this.taskEditTask.reminderDates.splice(index, 1)
// Reset the last to 0 to have the "add reminder" button // Reset the last to 0 to have the "add reminder" button
this.taskEditTask.reminderDates[this.taskEditTask.reminderDates.length - 1] = null this.taskEditTask.reminderDates[this.taskEditTask.reminderDates.length - 1] = null
} },
addAssignee() {
this.taskEditTask.assignees.push(this.newAssignee)
},
deleteAssigneeByIndex(index) {
this.taskEditTask.assignees.splice(index, 1)
},
findUser(query) {
if(query === '') {
this.clearAll()
return
}
this.userService.getAll({}, {s: query})
.then(response => {
// Filter the results to not include users who are already assigned
this.$set(this, 'foundUsers', differenceWith(response, this.taskEditTask.assignees, (first, second) => {
return first.id === second.id
}))
})
.catch(e => {
message.error(e, this)
})
},
clearAll () {
this.$set(this, 'foundUsers', [])
},
} }
} }
</script> </script>

View file

@ -304,9 +304,6 @@
clearAll () { clearAll () {
this.$set(this, 'found', []) this.$set(this, 'found', [])
}, },
limitText (count) {
return `and ${count} others`
},
}, },
} }
</script> </script>

View file

@ -268,6 +268,10 @@ fieldset[disabled] .multiselect {
margin: 0; margin: 0;
min-width: 100%; min-width: 100%;
vertical-align: top; vertical-align: top;
li + li {
margin: 0;
}
} }
.multiselect--above .multiselect__content-wrapper { .multiselect--above .multiselect__content-wrapper {

View file

@ -120,4 +120,23 @@
width: 100%; width: 100%;
} }
} }
ul.assingees {
list-style: none;
margin: 0;
li{
padding: 0.5em 0.5em 0;
a{
float: right;
color: $red;
transition: all $transition;
&:hover{
color: darken($red, 15);
}
}
}
}
} }

View file

@ -13,13 +13,18 @@
font-size: 0.85rem; font-size: 0.85rem;
font-weight: bold; font-weight: bold;
height: 2.648em; height: 2.648em;
box-shadow: 0.3em 0.3em 1em lighten($dark, 75); box-shadow: 0.3em 0.3em 1em lighten($dark, 75);
&.is-hovered, &.is-hovered,
&:hover { &:hover {
box-shadow: 0.6em 0.6em 1em lighten($dark, 75); box-shadow: 0.6em 0.6em 1em lighten($dark, 75);
} }
&.fullheight{
padding-right: 7px;
height: 100%;
}
&.is-active, &.is-active,
&.is-focused, &.is-focused,
&:active, &:active,

View file

@ -91,7 +91,7 @@
* [ ] Teams with access to a namespace * [ ] Teams with access to a namespace
* [x] Priorities * [x] Priorities
* [x] Highlight tasks with high priority * [x] Highlight tasks with high priority
* [ ] Assignees * [x] Assignees
* [ ] Labels * [ ] Labels
* [ ] Timeline/Calendar view -> Dazu tasks die in einem Bestimmten Bereich due sind, macht dann das Frontend * [ ] Timeline/Calendar view -> Dazu tasks die in einem Bestimmten Bereich due sind, macht dann das Frontend
@ -120,3 +120,4 @@
* [ ] "Performance-Statistik" -> Wie viele Tasks man in bestimmten Zeiträumen so geschafft hat etc * [ ] "Performance-Statistik" -> Wie viele Tasks man in bestimmten Zeiträumen so geschafft hat etc
* [ ] Activity Feed, so à la "der und der hat das und das gemacht etc" * [ ] Activity Feed, so à la "der und der hat das und das gemacht etc"
* [ ] Attachments for tasks * [ ] Attachments for tasks
* [ ] Search for users at new task assignees only in users who have access to the list