2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
2021-10-27 12:55:37 -07:00
|
|
|
<n8n-input-label
|
2022-07-20 04:32:51 -07:00
|
|
|
:label="hideLabel? '': $locale.nodeText().inputLabelDisplayName(parameter, path)"
|
|
|
|
:tooltipText="hideLabel? '': $locale.nodeText().inputLabelDescription(parameter, path)"
|
2021-10-27 12:55:37 -07:00
|
|
|
:showTooltip="focused"
|
2022-07-20 04:32:51 -07:00
|
|
|
:showOptions="menuExpanded || focused || forceShowExpression"
|
2021-10-27 12:55:37 -07:00
|
|
|
:bold="false"
|
|
|
|
size="small"
|
|
|
|
>
|
2022-07-20 04:32:51 -07:00
|
|
|
<template #options>
|
|
|
|
<parameter-options
|
|
|
|
:parameter="parameter"
|
|
|
|
:value="value"
|
|
|
|
:isReadOnly="isReadOnly"
|
|
|
|
:showOptions="displayOptions"
|
|
|
|
@optionSelected="optionSelected"
|
|
|
|
@menu-expanded="onMenuExpanded"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template>
|
|
|
|
<DraggableTarget type="mapping" :disabled="parameter.noDataExpression || isReadOnly" :sticky="true" :stickyOffset="4" @drop="onDrop">
|
|
|
|
<template v-slot="{ droppable, activeDrop }">
|
|
|
|
<parameter-input
|
|
|
|
ref="param"
|
|
|
|
:parameter="parameter"
|
|
|
|
:value="value"
|
|
|
|
:displayOptions="displayOptions"
|
|
|
|
:path="path"
|
|
|
|
:isReadOnly="isReadOnly"
|
|
|
|
:droppable="droppable"
|
|
|
|
:activeDrop="activeDrop"
|
|
|
|
:forceShowExpression="forceShowExpression"
|
|
|
|
@valueChanged="valueChanged"
|
|
|
|
@focus="onFocus"
|
|
|
|
@blur="onBlur"
|
|
|
|
inputSize="small" />
|
|
|
|
</template>
|
|
|
|
</DraggableTarget>
|
|
|
|
<input-hint :class="$style.hint" :hint="$locale.nodeText().hint(parameter, path)" />
|
|
|
|
</template>
|
2021-10-27 12:55:37 -07:00
|
|
|
</n8n-input-label>
|
2019-06-23 03:35:23 -07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
import {
|
2022-07-20 04:32:51 -07:00
|
|
|
INodeUi,
|
2019-06-23 03:35:23 -07:00
|
|
|
IUpdateInformation,
|
|
|
|
} from '@/Interface';
|
|
|
|
|
|
|
|
import ParameterInput from '@/components/ParameterInput.vue';
|
2022-01-27 22:55:25 -08:00
|
|
|
import InputHint from './ParameterInputHint.vue';
|
2022-07-20 04:32:51 -07:00
|
|
|
import ParameterOptions from './ParameterOptions.vue';
|
|
|
|
import DraggableTarget from '@/components/DraggableTarget.vue';
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
import { showMessage } from './mixins/showMessage';
|
|
|
|
import { LOCAL_STORAGE_MAPPING_FLAG } from '@/constants';
|
|
|
|
import { hasExpressionMapping } from './helpers';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2022-07-20 04:32:51 -07:00
|
|
|
export default mixins(
|
|
|
|
showMessage,
|
|
|
|
)
|
2019-06-23 03:35:23 -07:00
|
|
|
.extend({
|
|
|
|
name: 'ParameterInputFull',
|
|
|
|
components: {
|
|
|
|
ParameterInput,
|
2022-01-27 22:55:25 -08:00
|
|
|
InputHint,
|
2022-07-20 04:32:51 -07:00
|
|
|
ParameterOptions,
|
|
|
|
DraggableTarget,
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
2021-10-27 12:55:37 -07:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
focused: false,
|
2022-07-20 04:32:51 -07:00
|
|
|
menuExpanded: false,
|
|
|
|
forceShowExpression: false,
|
2021-10-27 12:55:37 -07:00
|
|
|
};
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
props: [
|
|
|
|
'displayOptions',
|
2021-09-11 01:15:36 -07:00
|
|
|
'isReadOnly',
|
2019-06-23 03:35:23 -07:00
|
|
|
'parameter',
|
|
|
|
'path',
|
|
|
|
'value',
|
2022-07-20 04:32:51 -07:00
|
|
|
'hideLabel',
|
2019-06-23 03:35:23 -07:00
|
|
|
],
|
2022-07-20 04:32:51 -07:00
|
|
|
computed: {
|
|
|
|
node (): INodeUi | null {
|
|
|
|
return this.$store.getters.activeNode;
|
|
|
|
},
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
methods: {
|
2022-07-20 04:32:51 -07:00
|
|
|
onFocus() {
|
|
|
|
this.focused = true;
|
|
|
|
if (!this.parameter.noDataExpression) {
|
|
|
|
this.$store.commit('ui/setMappableNDVInputFocus', this.parameter.displayName);
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|
2022-07-20 04:32:51 -07:00
|
|
|
},
|
|
|
|
onBlur() {
|
|
|
|
this.focused = false;
|
|
|
|
if (!this.parameter.noDataExpression) {
|
|
|
|
this.$store.commit('ui/setMappableNDVInputFocus', '');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onMenuExpanded(expanded: boolean) {
|
|
|
|
this.menuExpanded = expanded;
|
|
|
|
},
|
|
|
|
optionSelected (command: string) {
|
|
|
|
if (this.$refs.param) {
|
|
|
|
(this.$refs.param as Vue).$emit('optionSelected', command);
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
valueChanged (parameterData: IUpdateInformation) {
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
|
|
},
|
2022-07-20 04:32:51 -07:00
|
|
|
onDrop(data: string) {
|
|
|
|
this.forceShowExpression = true;
|
|
|
|
setTimeout(() => {
|
|
|
|
if (this.node) {
|
|
|
|
const prevValue = this.value;
|
|
|
|
let updatedValue: string;
|
|
|
|
if (typeof prevValue === 'string' && prevValue.startsWith('=') && prevValue.length > 1) {
|
|
|
|
updatedValue = `${prevValue} ${data}`;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
updatedValue = `=${data}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const parameterData = {
|
|
|
|
node: this.node.name,
|
|
|
|
name: this.path,
|
|
|
|
value: updatedValue,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$emit('valueChanged', parameterData);
|
|
|
|
|
|
|
|
if (window.localStorage.getItem(LOCAL_STORAGE_MAPPING_FLAG) !== 'true') {
|
|
|
|
this.$showMessage({
|
|
|
|
title: this.$locale.baseText('dataMapping.success.title'),
|
|
|
|
message: this.$locale.baseText('dataMapping.success.moreInfo'),
|
|
|
|
type: 'success',
|
|
|
|
});
|
|
|
|
|
|
|
|
window.localStorage.setItem(LOCAL_STORAGE_MAPPING_FLAG, 'true');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$store.commit('ui/setMappingTelemetry', {
|
|
|
|
dest_node_type: this.node.type,
|
|
|
|
dest_parameter: this.path,
|
|
|
|
dest_parameter_mode: typeof prevValue === 'string' && prevValue.startsWith('=')? 'expression': 'fixed',
|
|
|
|
dest_parameter_empty: prevValue === '' || prevValue === undefined,
|
|
|
|
dest_parameter_had_mapping: typeof prevValue === 'string' && prevValue.startsWith('=') && hasExpressionMapping(prevValue),
|
|
|
|
success: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.forceShowExpression = false;
|
|
|
|
}, 200);
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
2022-01-27 22:55:25 -08:00
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.hint {
|
|
|
|
margin-top: var(--spacing-4xs);
|
|
|
|
}
|
|
|
|
</style>
|