Skip to content

Commit

Permalink
fix location autocomplete bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ech0-de committed Nov 23, 2024
1 parent 9b0cd29 commit ebfbae9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
15 changes: 1 addition & 14 deletions src/components/CreateComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,7 @@
<input id="invwiki-form-invoice" type="text" v-model="invoice" @focus="$refs.c?.close?.()" />

<template v-if="!edit">
<search-autocomplete v-model="classification" :items="din6779" label="Kennbuchstabe" icon="shape-outline" grouped :keys="weights" :serializer="(e) => e.value" ref="c" :disabled="sub">
<template #group="item">
<b>{{ item.group.group }}:</b>
<div>{{ item.group.text }}</div>
</template>

<template #item="item">
<b>{{ item.value }}:</b>
<div>
{{ item.text }}
<pre v-if="item.example">{{item.example}}</pre>
</div>
</template>
</search-autocomplete>
<search-autocomplete v-model="classification" :items="din6779" label="Kennbuchstabe" icon="shape-outline" grouped :keys="weights" :serializer="(e) => e.value" ref="c" :disabled="sub" />
<blockquote v-if="classification?.text">
{{ classification.text }}
</blockquote>
Expand Down
20 changes: 17 additions & 3 deletions src/components/LocationComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@

<x-dialog :title="`Ort Aktualisieren (${$parent.inventoryId})`" icon="home-map-marker" ref="dialog" :loading="loading">
<div>
<search-autocomplete v-model="location" :items="locations" :keys="[]" label="Ort" autofocus />
<search-autocomplete v-model="location" :items="locations" :keys="[]" label="Ort" autofocus>
<template #group="item">
<b>{{ item.group.group }}:</b>
<div>{{ item.group.text }}</div>
</template>

<template #item="item">
<b>{{ item.value }}:</b>
<div>
{{ item.text }}
<pre v-if="item.example">{{item.example}}</pre>
</div>
</template>
</search-autocomplete>

<label for="invwiki-location-description">Weitere Infos</label>
<textarea id="invwiki-location-description" v-model="description" />
Expand Down Expand Up @@ -54,8 +67,9 @@ export default {
async open() {
this.$refs.dialog.show();
this.loading = true;
this.location = this.$parent.temporary?.location || this.$parent.nominal?.location || '';
this.description = this.$parent.temporary?.description || this.$parent.nominal?.description || '';
this.location = this.$parent?.temporary?.location || this.$parent?.nominal?.location || '';
this.description = this.$parent?.temporary?.description || this.$parent?.nominal?.description || '';
this.locations = (await Promise.all([
fetchLocations(),
Expand Down
16 changes: 10 additions & 6 deletions src/components/SearchAutocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
</li>
<template v-for="(result, i) in filteredResults" :key="i">
<li class="invwiki-autocomplete-result invwiki-autocomplete-group" v-if="result.first">
<slot name="group" v-bind="result">
{{ result.group }}
</slot>
<b>{{ result.group.group }}:</b>
<div>{{ result.group.text }}</div>
</li>
<li @click="setResult(result)" :class="`invwiki-autocomplete-result invwiki-autocomplete-indent ${i === arrowCounter ? 'is-active' : ''}`">
<slot name="item" v-bind="result">
{{ result }}
</slot>
<template v-if="typeof(result) === 'object'">
<b>{{ result.value }}:</b>
<div>
{{ result.text }}
<pre v-if="result.example">{{result.example}}</pre>
</div>
</template>
<div style="grid-column: 1 / 3" v-else>{{ result }}</div>
</li>
</template>
</ul>
Expand Down

0 comments on commit ebfbae9

Please sign in to comment.