mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
feat(ui): render the CCTV calibration readout and its pose editor from the store
presentCctvCalibration() joins the panel view: ADJUST, SAVE CAL, RESET CAL and the seven pose chips render from the gev-cctv store. The inline editor is store state: starting an edit publishes its field, starting value and finish(), and the CctvCalValue chip renders the number input. The draft is set once on mount so a refresh while typing keeps it; each edit gets its own input. Commit and cancel rules, the captured base pose and the camera guards stay with CctvControls. formField.js had no other user and is removed.
This commit is contained in:
1 parent
5b8cb40fce
commit
6c7035f617
13 files changed
+337
-240
No files matched your search
@@ -0,0 +1,65 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { useCctvStore } from '../stores/cctv.js';
|
||||
|
||||
// One click-to-type pose chip. The panel's delegated click starts an edit
|
||||
// in CctvControls, which publishes it; the chip then holds a number input
|
||||
// that ends the edit on Enter, blur or Escape.
|
||||
const props = defineProps({
|
||||
field: { type: String, required: true },
|
||||
/** Message for the label shown before the first render. */
|
||||
label: { type: String, required: true },
|
||||
});
|
||||
const { view, calEdit } = storeToRefs(useCctvStore());
|
||||
const edit = computed(() =>
|
||||
calEdit.value?.field === props.field ? calEdit.value : null,
|
||||
);
|
||||
|
||||
// The draft is the user's once the input exists: the starting value is set
|
||||
// on mount only, since re-renders would otherwise write it back.
|
||||
const vDraft = {
|
||||
mounted(el, { value }) {
|
||||
el.value = value;
|
||||
el.focus();
|
||||
el.select();
|
||||
},
|
||||
};
|
||||
|
||||
function onKeydown(event) {
|
||||
if (event.key === 'Enter') edit.value?.finish(true, event.target.value);
|
||||
else if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
edit.value?.finish(false);
|
||||
}
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
function onBlur(event) {
|
||||
edit.value?.finish(true, event.target.value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
class="cctv-cal-value"
|
||||
:data-cal-field="field"
|
||||
:disabled="edit ? false : view?.calibration.disabled"
|
||||
><template v-if="edit"
|
||||
>{{ edit.label
|
||||
}}<input
|
||||
:key="edit.id"
|
||||
v-draft="edit.value"
|
||||
type="number"
|
||||
class="gev-field gev-field--inline cctv-cal-input"
|
||||
:step="edit.step"
|
||||
:aria-label="edit.ariaLabel"
|
||||
@keydown="onKeydown"
|
||||
@blur="onBlur"
|
||||
@click.stop /></template
|
||||
><template v-else>{{
|
||||
view?.calibration.values[field] ?? `${t(label)} --`
|
||||
}}</template></button
|
||||
>
|
||||
</template>
|
||||
Reference in new issue
Block a user