2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
|
|
|
<div v-if="dialogVisible">
|
2022-01-07 13:02:21 -08:00
|
|
|
<el-dialog
|
2023-12-28 00:49:58 -08:00
|
|
|
:model-value="dialogVisible"
|
2022-01-07 13:02:21 -08:00
|
|
|
append-to-body
|
|
|
|
width="80%"
|
|
|
|
:title="`${$locale.baseText('textEdit.edit')} ${$locale
|
|
|
|
.nodeText()
|
|
|
|
.inputLabelDisplayName(parameter, path)}`"
|
|
|
|
:before-close="closeDialog"
|
|
|
|
>
|
2021-10-27 12:55:37 -07:00
|
|
|
<div class="ignore-key-press">
|
2022-01-07 13:02:21 -08:00
|
|
|
<n8n-input-label :label="$locale.nodeText().inputLabelDisplayName(parameter, path)">
|
2024-07-12 06:43:07 -07:00
|
|
|
<div @keydown.stop @keydown.esc="onKeyDownEsc">
|
2022-10-24 11:17:25 -07:00
|
|
|
<n8n-input
|
2023-12-28 00:49:58 -08:00
|
|
|
ref="inputField"
|
2022-10-24 11:17:25 -07:00
|
|
|
v-model="tempValue"
|
|
|
|
type="textarea"
|
|
|
|
:placeholder="$locale.nodeText().placeholder(parameter, path)"
|
2023-12-28 00:49:58 -08:00
|
|
|
:read-only="isReadOnly"
|
2022-10-24 11:17:25 -07:00
|
|
|
:rows="15"
|
2024-03-26 06:22:57 -07:00
|
|
|
@update:model-value="valueChanged"
|
2022-10-24 11:17:25 -07:00
|
|
|
/>
|
2021-10-27 12:55:37 -07:00
|
|
|
</div>
|
|
|
|
</n8n-input-label>
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2024-07-12 06:43:07 -07:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { ref, watch, onMounted, nextTick } from 'vue';
|
|
|
|
import type { INodeProperties } from 'n8n-workflow';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2024-07-12 06:43:07 -07:00
|
|
|
const props = defineProps<{
|
|
|
|
dialogVisible: boolean;
|
|
|
|
parameter: INodeProperties;
|
|
|
|
path: string;
|
|
|
|
modelValue: string;
|
|
|
|
isReadOnly: boolean;
|
|
|
|
}>();
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2024-07-12 06:43:07 -07:00
|
|
|
const emit = defineEmits<{
|
|
|
|
'update:modelValue': [value: string];
|
|
|
|
closeDialog: [];
|
|
|
|
}>();
|
2022-04-14 00:30:31 -07:00
|
|
|
|
2024-07-12 06:43:07 -07:00
|
|
|
const inputField = ref<HTMLInputElement | null>(null);
|
|
|
|
const tempValue = ref('');
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => props.dialogVisible,
|
|
|
|
async (newValue) => {
|
|
|
|
if (newValue) {
|
|
|
|
await nextTick();
|
|
|
|
inputField.value?.focus();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
2022-04-14 00:30:31 -07:00
|
|
|
|
2024-07-12 06:43:07 -07:00
|
|
|
watch(
|
|
|
|
() => props.modelValue,
|
|
|
|
(value: string) => {
|
|
|
|
tempValue.value = value;
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
2024-07-12 06:43:07 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
tempValue.value = props.modelValue;
|
2019-06-23 03:35:23 -07:00
|
|
|
});
|
2024-07-12 06:43:07 -07:00
|
|
|
|
|
|
|
const valueChanged = (value: string) => {
|
|
|
|
emit('update:modelValue', value);
|
|
|
|
};
|
|
|
|
|
|
|
|
const onKeyDownEsc = () => {
|
|
|
|
// Resetting input value when closing the dialog, required when closing it using the `Esc` key
|
|
|
|
tempValue.value = props.modelValue;
|
|
|
|
closeDialog();
|
|
|
|
};
|
|
|
|
|
|
|
|
const closeDialog = () => {
|
|
|
|
// Handle the close externally as the visible parameter is an external prop
|
|
|
|
// and is so not allowed to be changed here.
|
|
|
|
emit('closeDialog');
|
|
|
|
};
|
2019-06-23 03:35:23 -07:00
|
|
|
</script>
|