Fix task title on mobile (#54)
Use a contenteditable for task title to make it look good on mobile Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/54
This commit is contained in:
parent
604488c68c
commit
96fddd9bbd
2 changed files with 23 additions and 1 deletions
|
@ -6,7 +6,7 @@
|
||||||
#{{ task.id }}
|
#{{ task.id }}
|
||||||
</h1>
|
</h1>
|
||||||
<div class="is-done" v-if="task.done">Done</div>
|
<div class="is-done" v-if="task.done">Done</div>
|
||||||
<input type="text" v-model="task.text" @change="saveTask()" class="input title" @keyup.enter="saveTask()"/>
|
<h1 class="title input" contenteditable="true" @focusout="saveTaskOnChange()" ref="taskTitle">{{ task.text }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<h6 class="subtitle">
|
<h6 class="subtitle">
|
||||||
{{ namespace.name }} >
|
{{ namespace.name }} >
|
||||||
|
@ -304,6 +304,7 @@
|
||||||
list: ListModel,
|
list: ListModel,
|
||||||
namespace: NamespaceModel,
|
namespace: NamespaceModel,
|
||||||
showDeleteModal: false,
|
showDeleteModal: false,
|
||||||
|
taskTitle: '',
|
||||||
|
|
||||||
priorities: priorites,
|
priorities: priorites,
|
||||||
flatPickerConfig: {
|
flatPickerConfig: {
|
||||||
|
@ -345,6 +346,7 @@
|
||||||
.then(r => {
|
.then(r => {
|
||||||
this.$set(this, 'task', r)
|
this.$set(this, 'task', r)
|
||||||
this.setListAndNamespaceTitleFromParent()
|
this.setListAndNamespaceTitleFromParent()
|
||||||
|
this.taskTitle = this.task.text
|
||||||
|
|
||||||
// Set all active fields based on values in the model
|
// Set all active fields based on values in the model
|
||||||
this.activeFields.assignees = this.task.assignees.length > 0
|
this.activeFields.assignees = this.task.assignees.length > 0
|
||||||
|
@ -363,6 +365,22 @@
|
||||||
this.error(e, this)
|
this.error(e, this)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
saveTaskOnChange() {
|
||||||
|
this.$refs.taskTitle.spellcheck = false
|
||||||
|
|
||||||
|
// Pull the task title from the contenteditable
|
||||||
|
let taskTitle = this.$refs.taskTitle.textContent
|
||||||
|
this.task.text = taskTitle
|
||||||
|
|
||||||
|
// We only want to save if the title was actually change.
|
||||||
|
// Because the contenteditable does not have a change event,
|
||||||
|
// we're building it ourselves and only calling saveTask()
|
||||||
|
// if the task title changed.
|
||||||
|
if (this.task.text !== this.taskTitle) {
|
||||||
|
this.saveTask()
|
||||||
|
this.taskTitle = taskTitle
|
||||||
|
}
|
||||||
|
},
|
||||||
saveTask() {
|
saveTask() {
|
||||||
this.taskService.update(this.task)
|
this.taskService.update(this.task)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
padding: 0 .3em;
|
padding: 0 .3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1.input.title {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.is-done {
|
.is-done {
|
||||||
background: $green;
|
background: $green;
|
||||||
color: $white;
|
color: $white;
|
||||||
|
|
Loading…
Reference in a new issue