2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
|
|
|
<div v-if="dialogVisible">
|
2022-12-14 01:04:10 -08:00
|
|
|
<el-dialog
|
|
|
|
:visible="dialogVisible"
|
|
|
|
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)">
|
2022-04-14 00:30:31 -07:00
|
|
|
<div @keydown.stop @keydown.esc="onKeyDownEsc()">
|
2022-12-14 01:04:10 -08:00
|
|
|
<n8n-input
|
|
|
|
v-model="tempValue"
|
|
|
|
type="textarea"
|
|
|
|
ref="inputField"
|
|
|
|
:value="value"
|
|
|
|
:placeholder="$locale.nodeText().placeholder(parameter, path)"
|
|
|
|
:readOnly="isReadOnly"
|
|
|
|
@change="valueChanged"
|
|
|
|
:rows="15"
|
|
|
|
/>
|
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>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
2021-12-07 07:14:40 -08:00
|
|
|
export default Vue.extend({
|
2019-06-23 03:35:23 -07:00
|
|
|
name: 'TextEdit',
|
2022-12-14 01:04:10 -08:00
|
|
|
props: ['dialogVisible', 'parameter', 'path', 'value', 'isReadOnly'],
|
|
|
|
data() {
|
2019-06-23 03:35:23 -07:00
|
|
|
return {
|
2020-01-03 19:48:55 -08:00
|
|
|
tempValue: '', // el-input does not seem to work without v-model so add one
|
2019-06-23 03:35:23 -07:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2022-12-14 01:04:10 -08:00
|
|
|
valueChanged(value: string) {
|
2019-06-23 03:35:23 -07:00
|
|
|
this.$emit('valueChanged', value);
|
|
|
|
},
|
|
|
|
|
2022-12-14 01:04:10 -08:00
|
|
|
onKeyDownEsc() {
|
2022-04-14 00:30:31 -07:00
|
|
|
// Resetting input value when closing the dialog, required when closing it using the `Esc` key
|
|
|
|
this.tempValue = this.value;
|
|
|
|
|
|
|
|
this.closeDialog();
|
|
|
|
},
|
|
|
|
|
2022-12-14 01:04:10 -08:00
|
|
|
closeDialog() {
|
2019-06-23 03:35:23 -07:00
|
|
|
// Handle the close externally as the visible parameter is an external prop
|
|
|
|
// and is so not allowed to be changed here.
|
|
|
|
this.$emit('closeDialog');
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
mounted() {
|
2020-01-08 11:25:35 -08:00
|
|
|
this.tempValue = this.value as string;
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
watch: {
|
2022-12-14 01:04:10 -08:00
|
|
|
dialogVisible() {
|
2019-06-23 03:35:23 -07:00
|
|
|
if (this.dialogVisible === true) {
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
(this.$refs.inputField as HTMLInputElement).focus();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
value() {
|
2020-01-03 19:48:55 -08:00
|
|
|
this.tempValue = this.value as string;
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|