Fix not all labels being shown

This commit is contained in:
kolaente 2020-05-04 10:14:17 +02:00
parent 40721e7a74
commit 183f1411f9
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 44 additions and 16 deletions

View File

@ -3,25 +3,26 @@
<h1>Manage labels</h1> <h1>Manage labels</h1>
<p> <p>
Click on a label to edit it. Click on a label to edit it.
You can edit all labels you created, you can use all labels which are associated with a task to whose list you have access. You can edit all labels you created, you can use all labels which are associated with a task to whose list
you have access.
</p> </p>
<div class="columns"> <div class="columns">
<div class="labels-list column"> <div class="labels-list column">
<span <span
v-for="l in labels" :key="l.id" v-for="l in labels" :key="l.id"
class="tag" class="tag"
:class="{'disabled': user.infos.id !== l.createdBy.id}" :class="{'disabled': user.infos.id !== l.createdBy.id}"
:style="{'background': l.hexColor, 'color': l.textColor}" :style="{'background': l.hexColor, 'color': l.textColor}"
> >
<span <span
v-if="user.infos.id !== l.createdBy.id" v-if="user.infos.id !== l.createdBy.id"
v-tooltip.bottom="'You are not allowed to edit this label because you dont own it.'"> v-tooltip.bottom="'You are not allowed to edit this label because you dont own it.'">
{{ l.title }} {{ l.title }}
</span> </span>
<a <a
@click="editLabel(l)" @click="editLabel(l)"
:style="{'color': l.textColor}" :style="{'color': l.textColor}"
v-else> v-else>
{{ l.title }} {{ l.title }}
</a> </a>
<a class="delete is-small" @click="deleteLabel(l)" v-if="user.infos.id === l.createdBy.id"></a> <a class="delete is-small" @click="deleteLabel(l)" v-if="user.infos.id === l.createdBy.id"></a>
@ -44,13 +45,20 @@
<div class="field"> <div class="field">
<label class="label">Title</label> <label class="label">Title</label>
<div class="control"> <div class="control">
<input class="input" type="text" placeholder="Label title" v-model="labelEditLabel.title"/> <input
class="input"
type="text"
placeholder="Label title"
v-model="labelEditLabel.title"/>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label class="label">Description</label> <label class="label">Description</label>
<div class="control"> <div class="control">
<textarea class="textarea" placeholder="Label description" v-model="labelEditLabel.description"></textarea> <textarea
class="textarea"
placeholder="Label description"
v-model="labelEditLabel.description"></textarea>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
@ -68,12 +76,15 @@
</div> </div>
<div class="field has-addons"> <div class="field has-addons">
<div class="control is-expanded"> <div class="control is-expanded">
<button type="submit" class="button is-fullwidth is-success" :class="{ 'is-loading': labelService.loading}"> <button type="submit" class="button is-fullwidth is-success"
:class="{ 'is-loading': labelService.loading}">
Save Save
</button> </button>
</div> </div>
<div class="control"> <div class="control">
<a class="button has-icon is-danger" @click="deleteLabel(labelEditLabel);isLabelEdit = false;"> <a
class="button has-icon is-danger"
@click="() => {deleteLabel(labelEditLabel);isLabelEdit = false}">
<span class="icon"> <span class="icon">
<icon icon="trash-alt"/> <icon icon="trash-alt"/>
</span> </span>
@ -117,7 +128,24 @@
}, },
methods: { methods: {
loadLabels() { loadLabels() {
this.labelService.getAll() const getAllLabels = (page = 1) => {
return this.labelService.getAll({}, {}, page)
.then(labels => {
if(page < this.labelService.totalPages) {
return getAllLabels(page + 1)
.then(nextLabels => {
return labels.concat(nextLabels)
})
} else {
return labels
}
})
.catch(e => {
return Promise.reject(e)
})
}
getAllLabels()
.then(r => { .then(r => {
this.$set(this, 'labels', r) this.$set(this, 'labels', r)
}) })
@ -155,7 +183,7 @@
}) })
}, },
editLabel(label) { editLabel(label) {
if(label.createdBy.id !== this.user.infos.id) { if (label.createdBy.id !== this.user.infos.id) {
return return
} }
this.labelEditLabel = label this.labelEditLabel = label