Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
demtario committed Aug 22, 2024
2 parents a633bf5 + b2b20a5 commit 24e71ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "store-admin",
"version": "7.0.1",
"version": "7.0.2",
"private": true,
"description": "Admin panel for Heseya Store API",
"author": "Heseya",
Expand Down
29 changes: 11 additions & 18 deletions src/components/AutocompleteInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ export default defineComponent({
SelectType(): typeof SelectType {
return SelectType
},
allOptions(): AutocompleteBaseItem[] {
return uniqBy([...this.initialValueOptions, ...this.searchedOptions], this.propMode || 'id')
},
singleOptionId: {
get(): AutocompleteBaseItem | undefined {
if (isEmpty(this.value)) return undefined
if (this.propMode)
return this.searchedOptions.find(
(option) => option[this.propMode] === (this.value as string),
)
return this.allOptions.find((option) => option[this.propMode] === (this.value as string))
return (this.value as AutocompleteBaseItem[])?.[0] || this.value
},
set(v: AutocompleteBaseItem) {
Expand All @@ -124,7 +125,7 @@ export default defineComponent({
multiOptionsIds: {
get(): AutocompleteBaseItem[] {
if (this.propMode)
return [...this.initialValueOptions, ...this.searchedOptions].filter((option) =>
return this.allOptions.filter((option) =>
(this.value as string[]).includes(String(option[this.propMode])),
)
return this.value as AutocompleteBaseItem[]
Expand Down Expand Up @@ -153,18 +154,11 @@ export default defineComponent({
options(): AutocompleteBaseItem[] {
if (this.mode === this.SelectType.Multiple) {
return (
uniqBy(
[...this.initialValueOptions, ...this.multiOptionsIds, ...this.searchedOptions],
this.propMode || 'id',
).filter((item) => !this.bannedSetIds.includes(item.id)) || []
)
} else
return (
uniqBy(
[...this.initialValueOptions, ...this.searchedOptions],
this.propMode || 'id',
).filter((item) => !this.bannedSetIds.includes(item.id)) || []
uniqBy([...this.allOptions, ...this.multiOptionsIds], this.propMode || 'id').filter(
(item) => !this.bannedSetIds.includes(item.id),
) || []
)
} else return this.allOptions.filter((item) => !this.bannedSetIds.includes(item.id)) || []
},
},
mounted() {
Expand Down Expand Up @@ -226,9 +220,8 @@ export default defineComponent({
} = await api.get<{ data: AutocompleteBaseItem[] }>(`/${this.modelUrl}${query}`)
this.searchedOptions = data
} catch (e) {
// eslint-disable-next-line no-console
console.error(e)
} catch (e: any) {
this.$toast.warning(`Failed to fetch model "${this.modelUrl}": ${e.message}`)
}
},
Expand Down

0 comments on commit 24e71ca

Please sign in to comment.