From 88bd51e2daa99812e11034f7bb4a3f94c3640e00 Mon Sep 17 00:00:00 2001 From: advplyr Date: Wed, 4 Jan 2023 17:21:25 -0600 Subject: [PATCH] Fix:Update authors in different order #1361 --- client/components/ui/MultiSelectQueryInput.vue | 17 ++++++++++++----- client/components/widgets/BookDetailsEdit.vue | 12 +++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/client/components/ui/MultiSelectQueryInput.vue b/client/components/ui/MultiSelectQueryInput.vue index 4c28cae2..27274103 100644 --- a/client/components/ui/MultiSelectQueryInput.vue +++ b/client/components/ui/MultiSelectQueryInput.vue @@ -204,15 +204,21 @@ export default { } if (this.$refs.input) this.$refs.input.focus() - var newSelected = null + let newSelected = null if (this.getIsSelected(item.id)) { newSelected = this.selected.filter((s) => s.id !== item.id) this.$emit('removedItem', item.id) } else { - newSelected = this.selected.concat([item]) + newSelected = this.selected.concat([ + { + id: item.id, + name: item.name + } + ]) } this.textInput = null this.currentSearch = null + this.$emit('input', newSelected) this.$nextTick(() => { this.recalcMenuPos() @@ -246,10 +252,11 @@ export default { submitForm() { if (!this.textInput) return - var cleaned = this.textInput.trim() - var matchesItem = this.items.find((i) => { - return i === cleaned + const cleaned = this.textInput.trim() + const matchesItem = this.items.find((i) => { + return i.name === cleaned }) + if (matchesItem) { this.clickedOption(null, matchesItem) } else { diff --git a/client/components/widgets/BookDetailsEdit.vue b/client/components/widgets/BookDetailsEdit.vue index 5677b563..fcce7cf4 100644 --- a/client/components/widgets/BookDetailsEdit.vue +++ b/client/components/widgets/BookDetailsEdit.vue @@ -210,11 +210,13 @@ export default { // array of objects with id key if (array1.length !== array2.length) return false - for (var item of array1) { - var matchingItem = array2.find((a) => a.id === item.id) - if (!matchingItem) return false - for (var key in item) { - if (item[key] !== matchingItem[key]) { + for (let i = 0; i < array1.length; i++) { + const item1 = array1[i] + const item2 = array2[i] + if (!item1 || !item2) return false + + for (const key in item1) { + if (item1[key] !== item2[key]) { // console.log('Object array item keys changed', key, item[key], matchingItem[key]) return false }