Changed pisition handling.
All checks were successful
continuous-integration/drone Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
aminecmi 2022-08-12 22:22:41 +02:00
parent bb0c16501c
commit 9775c6b0c6

View File

@ -26,7 +26,7 @@
</div>
<draggable
v-model="searchResults"
v-model="uncheckedItems"
group="listItems"
@change="onChange"
item-key="id" v-if="searchQ.length <= 0"
@ -35,6 +35,9 @@
<ListItem v-bind:item="element" v-bind:can-move="!element.checked" v-on:updateItem="updateItem" v-on:deleteElement="deleteElement"></ListItem>
</template>
</draggable>
<div v-if="searchQ.length <= 0">
<ListItem v-for="element in checkedItems" v-bind:can-move="false" :key="element.id" v-bind:item="element" v-on:updateItem="updateItem" v-on:deleteElement="deleteElement"></ListItem>
</div>
<div v-if="searchQ.length > 0">
<ListItem v-for="element in searchResults" v-bind:can-move="false" :key="element.id" v-bind:item="element" v-on:updateItem="updateItem" v-on:deleteElement="deleteElement"></ListItem>
</div>
@ -56,6 +59,8 @@ export default {
listName: '',
searchQ: '',
searchResults: [],
uncheckedItems: [],
checkedItems: [],
initialItems: [],
loading: true,
addModalShown: false,
@ -114,23 +119,20 @@ export default {
})
},
recopyItemsObject: function () {
this.searchResults = this.initialItems.map(x => ({...x}));
this.uncheckedItems = this.initialItems.filter(x => !x.checked).map(x => ({...x}));
this.checkedItems = this.initialItems.filter(x => x.checked).map(x => ({...x}));
},
searchItem: function (e) {
if (e.key === 'Enter') {
this.createItem();
} else {
if (this.searchQ.length > 0) {
this.searchResults = this.searchResults.filter(i => i.content.toLowerCase().indexOf(this.searchQ.toLowerCase()) >= 0)
this.searchResults = this.initialItems.filter(i => i.content.toLowerCase().indexOf(this.searchQ.toLowerCase()) >= 0)
} else {
this.recopyItemsObject();
}
}
},
addItem: function (item) {
this.initialItems.push(item);
this.recopyItemsObject();
},
onChange: function (event) {
if (event.moved) {
this.updateItem({