| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <!--
- -->
- <template>
- <main>
- <div v-if="edit" class="d-flex align-center x-editable-input">
- <UiInputText
- class="ma-0 pa-0"
- :type="type"
- :modelValue="inputValue"
- @update="$emit('update:modelValue', $event.target.value)"
- />
- <v-icon
- icon="fas fa-check"
- aria-hidden="false"
- class="valid icons text-ot-green"
- size="small"
- @click="update"
- />
- <v-icon
- icon="fas fa-times"
- aria-hidden="false"
- class="cancel icons text-ot-grey"
- size="small"
- @click="close"
- />
- </div>
- <div v-else class="edit-link" @click="edit=true">
- <slot name="xeditable.read" v-bind="{inputValue}" />
- </div>
- </main>
- </template>
- <script setup lang="ts">
- import {ref, Ref} from "@vue/reactivity";
- const props = defineProps({
- type: {
- type: String,
- required: false,
- default: null
- },
- data: {
- type: [String, Number],
- required: false,
- default: null
- }
- })
- const emit = defineEmits(['update'])
- const edit: Ref<boolean> = ref(false)
- const inputValue: Ref<string|number|null> = ref(props.data)
- const update = () => {
- edit.value = false
- if (inputValue.value !== props.data) { emit('update', inputValue.value) }
- }
- const close = () => {
- edit.value = false
- inputValue.value = props.data
- }
- </script>
- <style scoped lang="scss">
- .v-input {
- height: 24px;
- }
- .v-icon {
- padding: 2px;
- height: 24px;
- width: 24px;
- margin: 0 2px;
- }
- .edit-link {
- cursor: pointer;
- }
- </style>
|