-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fire properties have low/high and input suggestions
- Loading branch information
Showing
8 changed files
with
268 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<template> | ||
<div> | ||
<div class="q-mb-sm"> | ||
{{ $t(property) }} | ||
</div> | ||
|
||
<div class="row q-col-gutter-sm q-mb-sm"> | ||
<div class="col"> | ||
<q-input | ||
filled | ||
v-model="selected[`${property}_low`]" | ||
:label="$t('low')" | ||
@update:model-value="onUpdate(`${property}_low`)" | ||
> | ||
<q-menu v-model="showLowSuggestions" no-parent-event no-focus auto-close> | ||
<q-list style="min-width: 100px"> | ||
<q-item | ||
clickable | ||
v-close-popup | ||
v-for="sugg in suggestions.options" | ||
:key="sugg" | ||
@click="selected[`${property}_low`] = sugg" | ||
> | ||
<q-item-section>{{ sugg }}</q-item-section> | ||
</q-item> | ||
</q-list> | ||
</q-menu> | ||
</q-input> | ||
</div> | ||
<div class="col"> | ||
<q-input filled v-model="selected[property]" :label="$t('std')" @update:model-value="onUpdate(property)"> | ||
<q-menu v-model="showStdSuggestions" no-parent-event no-focus auto-close> | ||
<q-list style="min-width: 100px"> | ||
<q-item | ||
clickable | ||
v-close-popup | ||
v-for="sugg in suggestions.options" | ||
:key="sugg" | ||
@click="selected[property] = sugg" | ||
> | ||
<q-item-section>{{ sugg }}</q-item-section> | ||
</q-item> | ||
</q-list> | ||
</q-menu> | ||
</q-input> | ||
</div> | ||
<div class="col"> | ||
<q-input | ||
filled | ||
v-model="selected[`${property}_high`]" | ||
:label="$t('high')" | ||
@update:model-value="onUpdate(`${property}_high`)" | ||
> | ||
<q-menu v-model="showHighSuggestions" no-parent-event no-focus auto-close> | ||
<q-list style="min-width: 100px"> | ||
<q-item | ||
clickable | ||
v-close-popup | ||
v-for="sugg in suggestions.options" | ||
:key="sugg" | ||
@click="selected[`${property}_high`] = sugg" | ||
> | ||
<q-item-section>{{ sugg }}</q-item-section> | ||
</q-item> | ||
</q-list> | ||
</q-menu> | ||
</q-input> | ||
</div> | ||
</div> | ||
<div class="q-mb-md text-hint"> | ||
{{ $t(`${property}_hint`) }} | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
export default defineComponent({ | ||
name: 'PropertyFormSuggest', | ||
}); | ||
</script> | ||
<script setup lang="ts"> | ||
import { PhysicalEntity } from 'src/models'; | ||
import { Suggestions } from 'src/components/models'; | ||
interface Props { | ||
modelValue: PhysicalEntity; | ||
property: string; | ||
suggestions?: Suggestions; | ||
} | ||
const props = defineProps<Props>(); | ||
const emits = defineEmits(['suggest']); | ||
const showLowSuggestions = ref(false); | ||
const showStdSuggestions = ref(false); | ||
const showHighSuggestions = ref(false); | ||
const selected = ref(props.modelValue); | ||
watch( | ||
() => props.suggestions, | ||
(val) => { | ||
if (val) { | ||
showLowSuggestions.value = val.key.endsWith('_low'); | ||
showHighSuggestions.value = val.key.endsWith('_high'); | ||
showStdSuggestions.value = !showLowSuggestions.value && !showHighSuggestions.value; | ||
} else { | ||
showLowSuggestions.value = false; | ||
showHighSuggestions.value = false; | ||
showStdSuggestions.value = false; | ||
} | ||
}, | ||
); | ||
function onUpdate(key: string) { | ||
if (selected.value[key] === '') { | ||
selected.value[key] = null; | ||
} | ||
emits('suggest', props.property, key, selected.value[key]); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.