2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
2021-10-27 12:55:37 -07:00
|
|
|
<n8n-input-label
|
2023-07-28 00:51:07 -07:00
|
|
|
:label="hideLabel ? '' : i18n.nodeText().inputLabelDisplayName(parameter, path)"
|
|
|
|
:tooltipText="hideLabel ? '' : i18n.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"
|
2023-01-20 08:07:28 -08:00
|
|
|
:size="label.size"
|
2022-10-12 05:06:28 -07:00
|
|
|
color="text-dark"
|
2021-10-27 12:55:37 -07:00
|
|
|
>
|
2022-07-20 04:32:51 -07:00
|
|
|
<template #options>
|
|
|
|
<parameter-options
|
feat(editor): Implement Resource Mapper component (#6207)
* :zap: scaffolding
* :zap: finished scaffolding
* :zap: renamed types
* :zap: updated subtitle
* :zap: renamed functions file, UI updates
* :zap: query parameters fixes, ui updates, refactoring
* :zap: fixes for credentials test, setup for error parsing
* :zap: rlc for schema and table, error handling tweaks
* :zap: delete operation, new options
* :zap: columns loader
* :zap: linter fixes
* :zap: where clauses setup
* :zap: logic for processing where clauses
* :zap: select operation
* :zap: refactoring
* :zap: data mode for insert and update, wip
* :zap: data mapping, insert update, skip on conflict option
* :zap: select columns with spaces fix
* :zap: update operation update, wip
* :zap: finished update operation
* :zap: upsert operation
* :zap: ui fixes
* Copy updates.
* Copy updates.
* :zap: option to convert empty strings to nulls, schema checks
* :zap: UI requested updates
* :zap: ssh setup WIP
* :zap: fixes, ssh WIP
* :zap: ssh fixes, credentials
* :zap: credentials testing update
* :zap: uncaught error fix
* :zap: clean up
* :zap: address in use fix
* :zap: improved error message
* :zap: tests setup
* :zap: unit tests wip
* :zap: config files clean up
* :zap: utils unit tests
* :zap: refactoring
* :zap: setup for testing operations, tests for deleteTable operation
* :zap: executeQuery and insert operations tests
* :zap: select, update, upsert operations tests
* :zap: runQueries tests setup
* :zap: hint to query
* Copy updates.
* :zap: ui fixes
* :zap: clean up
* :zap: error message update
* :zap: ui update
* Minor tweaks to query params decription.
* feat(Google Sheets Node): Implement Resource mapper in Google Sheets node (#5752)
* ✨ Added initial resource mapping support in google sheets node
* ✨ Wired mapping API endpoint with node-specific logic for fetching mapping fields
* ✨ Implementing mapping fields logic for google sheets
* ✨ Updating Google Sheets execute methods to support resource mapper fields
* 🚧 Added initial version of `ResourceLocator` component
* 👌 Added `update` mode to resource mapper modes
* 👌 Addressing PR feedback
* 👌 Removing leftover const reference
* 👕 Fixing lint errors
* :zap: singlton for conections
* :zap: credentials test fix, clean up
* feat(Postgres Node): Add resource mapper to new version of Postgres node (#5814)
* :zap: scaffolding
* :zap: finished scaffolding
* :zap: renamed types
* :zap: updated subtitle
* :zap: renamed functions file, UI updates
* :zap: query parameters fixes, ui updates, refactoring
* :zap: fixes for credentials test, setup for error parsing
* :zap: rlc for schema and table, error handling tweaks
* :zap: delete operation, new options
* :zap: columns loader
* :zap: linter fixes
* :zap: where clauses setup
* :zap: logic for processing where clauses
* :zap: select operation
* :zap: refactoring
* :zap: data mode for insert and update, wip
* :zap: data mapping, insert update, skip on conflict option
* :zap: select columns with spaces fix
* :zap: update operation update, wip
* :zap: finished update operation
* :zap: upsert operation
* :zap: ui fixes
* Copy updates.
* Copy updates.
* :zap: option to convert empty strings to nulls, schema checks
* :zap: UI requested updates
* :zap: ssh setup WIP
* :zap: fixes, ssh WIP
* :zap: ssh fixes, credentials
* :zap: credentials testing update
* :zap: uncaught error fix
* :zap: clean up
* :zap: address in use fix
* :zap: improved error message
* :zap: tests setup
* :zap: unit tests wip
* :zap: config files clean up
* :zap: utils unit tests
* :zap: refactoring
* :zap: setup for testing operations, tests for deleteTable operation
* :zap: executeQuery and insert operations tests
* :zap: select, update, upsert operations tests
* :zap: runQueries tests setup
* :zap: hint to query
* Copy updates.
* :zap: ui fixes
* :zap: clean up
* :zap: error message update
* :zap: ui update
* Minor tweaks to query params decription.
* ✨ Updated Postgres node to use resource mapper component
* ✨ Implemented postgres <-> resource mapper type mapping
* ✨ Updated Postgres node execution to use resource mapper fields in v3
* 🔥 Removing unused import
---------
Co-authored-by: Michael Kret <michael.k@radency.com>
Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
* feat(core): Resource editor componend P0 (#5970)
* ✨ Added inital value of mapping mode dropdown
* ✨ Finished mapping mode selector
* ✨ Finished implementing mapping mode selector
* ✨ Implemented 'Columns to match on' dropdown
* ✨ Implemented `loadOptionsDependOn` support in resource mapper
* ✨ Implemented initial version of mapping fields
* ✨ Implementing dependant fields watcher in new component setup
* ✨ Generating correct resource mapper field types. Added `supportAutoMap` to node specification and UI. Not showing fields with `display=false`. Pre-selecting matching columns if it's the only one
* ✨ Handling matching columns correctly in UI
* ✨ Saving and loading resourceMapper values in component
* ✨ Implemented proper data saving and loading
* ✨ ResourceMapper component refactor, fixing value save/load
* ✨ Refactoring MatchingColumnSelect component. Updating Sheets node to use single key match and Postgres to use multi key
* ✨ Updated Google Sheets node to work with the new UI
* ✨ Updating Postgres Node to work with new UI
* ✨ Additional loading indicator that shown if there is no mapping mode selector
* ✨ Removing hard-coded values, fixing matching columns ordering, refactoring
* ✨ Updating field names in nodes
* ✨ Fixing minor UI issues
* ✨ Implemented matching fields filter logic
* ✨ Moving loading label outside of fields list
* ✅ Added initial unit tests for resource mapper
* ✅ Finished default rendering test
* ✅ Test refactoring
* ✅ Finished unit tests
* 🔨 Updating the way i18n is used in resource mapper components
* ✔️ Fixing value to match on logic for postgres node
* ✨ Hiding mapping fields when auto-map mode is selected
* ✨ Syncing selected mapping mode between components
* ✨ Fixing dateTime input rendering and adding update check to Postgres node
* ✨ Properly handling database connections. Sending null for empty string values.
* 💄 Updated wording in the error message for non-existing rows
* ✨ Fixing issues with selected matching values
* ✔️ Updating unit tests after matching logic update
* ✨ Updating matching columns when new fields are loaded
* ✨ Defaulting to null for empty parameter values
* ✨ Allowing zero as valid value for number imputs
* ✨ Updated list of types that use datepicker as widger
* ✨ Using text inputs for time types
* ✨ Initial mapping field rework
* ✨ Added new component for mapping fields, moved bit of logic from root component to matching selector, fixing some lint errors
* ✨ Added tooltip for columns that cannot be deleted
* ✨ Saving deleted values in parameter value
* ✨ Implemented control to add/remove mapping fields
* ✨ Syncing field list with add field dropdown when changing dependent values
* ✨ Not showing removed fields in matching columns selector. Updating wording in matching columns selector description
* ✨ Implementing disabled states for add/remove all fields options
* ✨ Saving removed columns separately, updating copy
* ✨ Implemented resource mapper values validation
* ✨ Updated validation logic and error input styling
* ✨ Validating resource mapper fields when new nodes are added
* ✨ Using node field words in validation, refactoring resource mapper component
* ✨ Implemented schema syncing and add/remove all fields
* ✨ Implemented custom parameter actions
* ✨ Implemented loading indicator in parameter options
* 🔨 Removing unnecessary constants and vue props
* ✨ Handling default values properly
* ✨ Fixing validation logic
* 👕 Fixing lint errors
* ⚡ Fixing type issues
* ⚡ Not showing fields by default if `addAllFields` is set to `false`
* ✨ Implemented field type validation in resource mapper
* ✨ Updated casing in copy, removed all/remove all option from bottom menu
* ✨ Added auto mapping mode notice
* ✨ Added support for more types in validation
* ✨ Added support for enumerated values
* ✨ Fixing imports after merging
* ✨ Not showing removed fields in matching columns selector. Refactoring validation logic.
* 👕 Fixing imports
* ✔️ Updating unit tests
* ✅ Added resource mapper schema tests
* ⚡ Removing `match` from resource mapper field definition, fixing matching columns loading
* ⚡ Fixed schema merging
* :zap: update operation return data fix
* :zap: review
* 🐛 Added missing import
* 💄 Updating parameter actions icon based on the ui review
* 💄 Updating word capitalisation in tooltips
* 💄 Added empty state to mapping fields list
* 💄 Removing asterisk from fields, updating tooltips for matching fields
* ⚡ Preventing matching fields from being removed by 'Remove All option'
* ⚡ Not showing hidden fields in the `Add field` dropdown
* ⚡ Added support for custom matching columns labels
* :zap: query optimization
* :zap: fix
* ⚡ Optimizing Postgres node enumeration logic
* ⚡ Added empty state for matching columns
* ⚡ Only fully loading fields if there is no schema fetched
* ⚡ Hiding mapping fields if there is no matching columns available in the schema
* ✔️ Fixing minor issues
* ✨ Implemented runtime type validation
* 🔨 Refactoring validation logic
* ✨ Implemented required check, added more custom messages
* ✨ Skipping boolean type in required check
* Type check improvements
* ✨ Only reloading fields if dependent values actually change
* ✨ Adding item index to validation error title
* ✨ Updating Postgres fetching logic, using resource mapper mode to determine if a field can be deleted
* ✨ Resetting field values when adding them via the addAll option
* ⚡ Using minor version (2.2) for new Postgres node
* ⚡ Implemented proper date validation and type casting
* 👕 Consolidating typing
* ✅ Added unit tests for type validations
* 👌 Addressing front-end review comments
* ⚡ More refactoring to address review changes
* ⚡ Updating leftover props
* ⚡ Added fallback for ISO dates with invalid timezones
* Added timestamp to datetime test cases
* ⚡ Reseting matching columns if operation changes
* ⚡ Not forcing auto-increment fields to be filled in in Postgres node. Handling null values
* 💄 Added a custom message for invalid dates
* ⚡ Better handling of JSON values
* ⚡ Updating codemirror readonly stauts based on component property, handling objects in json validation
* Deleting leftover console.log
* ⚡ Better time validation
* ⚡ Fixing build error after merging
* 👕 Fixing lint error
* ⚡ Updating node configuration values
* ⚡ Handling postgres arrays better
* ⚡ Handling SQL array syntax
* ⚡ Updating time validation rules to include timezone
* ⚡ Sending expressions that resolve to `null` or `undefined` by the resource mapper to delete cell content in Google Sheets
* ⚡ Allowing removed fields to be selected for match
* ⚡ Updated the query for fetching unique columns and primary keys
* ⚡ Optimizing the unique query
* ⚡ Setting timezone to all parsed dates
* ⚡ Addressing PR review feedback
* ⚡ Configuring Sheets node for production, minor vue component update
* New cases added to the TypeValidation test.
* ✅ Tweaking validation rules for arrays/objects and updating test cases
---------
Co-authored-by: Michael Kret <michael.k@radency.com>
Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
2023-05-31 02:56:09 -07:00
|
|
|
v-if="displayOptions"
|
2022-07-20 04:32:51 -07:00
|
|
|
:parameter="parameter"
|
|
|
|
:value="value"
|
|
|
|
:isReadOnly="isReadOnly"
|
|
|
|
:showOptions="displayOptions"
|
2022-09-21 06:44:45 -07:00
|
|
|
:showExpressionSelector="showExpressionSelector"
|
2023-07-28 00:51:07 -07:00
|
|
|
@update:modelValue="optionSelected"
|
2022-07-20 04:32:51 -07:00
|
|
|
@menu-expanded="onMenuExpanded"
|
|
|
|
/>
|
|
|
|
</template>
|
2023-07-28 00:51:07 -07:00
|
|
|
<draggable-target
|
|
|
|
type="mapping"
|
|
|
|
:disabled="isDropDisabled"
|
|
|
|
:sticky="true"
|
|
|
|
:stickyOffset="isValueExpression ? [26, 3] : [3, 3]"
|
|
|
|
@drop="onDrop"
|
|
|
|
>
|
|
|
|
<template #default="{ droppable, activeDrop }">
|
|
|
|
<n8n-tooltip
|
|
|
|
placement="left"
|
|
|
|
:visible="showMappingTooltip"
|
|
|
|
:buttons="dataMappingTooltipButtons"
|
|
|
|
>
|
|
|
|
<template #content>
|
|
|
|
<span
|
|
|
|
v-html="
|
|
|
|
i18n.baseText(`dataMapping.${displayMode}Hint`, {
|
|
|
|
interpolate: { name: parameter.displayName },
|
|
|
|
})
|
|
|
|
"
|
2022-10-06 06:03:55 -07:00
|
|
|
/>
|
2023-07-28 00:51:07 -07:00
|
|
|
</template>
|
|
|
|
<parameter-input-wrapper
|
|
|
|
ref="param"
|
|
|
|
:parameter="parameter"
|
|
|
|
:modelValue="value"
|
|
|
|
:path="path"
|
|
|
|
:isReadOnly="isReadOnly"
|
|
|
|
:droppable="droppable"
|
|
|
|
:activeDrop="activeDrop"
|
|
|
|
:forceShowExpression="forceShowExpression"
|
|
|
|
:hint="hint"
|
|
|
|
:hide-issues="hideIssues"
|
|
|
|
:label="label"
|
|
|
|
:event-bus="eventBus"
|
|
|
|
@update="valueChanged"
|
|
|
|
@textInput="onTextInput"
|
|
|
|
@focus="onFocus"
|
|
|
|
@blur="onBlur"
|
|
|
|
@drop="onDrop"
|
|
|
|
inputSize="small"
|
|
|
|
/>
|
|
|
|
</n8n-tooltip>
|
|
|
|
</template>
|
|
|
|
</draggable-target>
|
2021-10-27 12:55:37 -07:00
|
|
|
</n8n-input-label>
|
2019-06-23 03:35:23 -07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-05-16 02:43:46 -07:00
|
|
|
import { defineComponent } from 'vue';
|
2023-04-24 03:18:24 -07:00
|
|
|
import type { PropType } from 'vue';
|
2023-05-16 02:43:46 -07:00
|
|
|
import { mapStores } from 'pinia';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2023-04-24 03:18:24 -07:00
|
|
|
import type { IN8nButton, INodeUi, IRunDataDisplayMode, IUpdateInformation } from '@/Interface';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2022-11-03 05:04:53 -07:00
|
|
|
import ParameterOptions from '@/components/ParameterOptions.vue';
|
2022-07-20 04:32:51 -07:00
|
|
|
import DraggableTarget from '@/components/DraggableTarget.vue';
|
2023-07-28 00:51:07 -07:00
|
|
|
import { useI18n, useToast } from '@/composables';
|
2022-12-14 05:43:02 -08:00
|
|
|
import {
|
|
|
|
hasExpressionMapping,
|
|
|
|
isResourceLocatorValue,
|
|
|
|
hasOnlyListMode,
|
|
|
|
isValueExpression,
|
|
|
|
} from '@/utils';
|
2022-11-03 05:04:53 -07:00
|
|
|
import ParameterInputWrapper from '@/components/ParameterInputWrapper.vue';
|
2023-04-24 03:18:24 -07:00
|
|
|
import type {
|
|
|
|
INodeParameters,
|
|
|
|
INodeProperties,
|
|
|
|
INodePropertyMode,
|
|
|
|
IParameterLabel,
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
import type { BaseTextKey } from '@/plugins/i18n';
|
2023-05-05 01:41:54 -07:00
|
|
|
import { useNDVStore } from '@/stores/ndv.store';
|
|
|
|
import { useSegment } from '@/stores/segment.store';
|
2023-02-21 05:34:39 -08:00
|
|
|
import { externalHooks } from '@/mixins/externalHooks';
|
2023-05-15 09:41:13 -07:00
|
|
|
import { getMappedResult } from '@/utils/mappingUtils';
|
2023-06-20 03:00:53 -07:00
|
|
|
import { createEventBus } from 'n8n-design-system/utils';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2023-03-17 05:24:08 -07:00
|
|
|
const DISPLAY_MODES_WITH_DATA_MAPPING = ['table', 'json', 'schema'];
|
|
|
|
|
2023-05-16 02:43:46 -07:00
|
|
|
export default defineComponent({
|
2022-12-14 01:04:10 -08:00
|
|
|
name: 'parameter-input-full',
|
2023-05-16 02:43:46 -07:00
|
|
|
mixins: [externalHooks],
|
2022-12-14 01:04:10 -08:00
|
|
|
components: {
|
|
|
|
ParameterOptions,
|
|
|
|
DraggableTarget,
|
|
|
|
ParameterInputWrapper,
|
|
|
|
},
|
2023-05-15 09:41:13 -07:00
|
|
|
setup() {
|
2023-06-20 03:00:53 -07:00
|
|
|
const eventBus = createEventBus();
|
2023-07-28 00:51:07 -07:00
|
|
|
const i18n = useI18n();
|
2023-06-20 03:00:53 -07:00
|
|
|
|
2023-05-15 09:41:13 -07:00
|
|
|
return {
|
2023-07-28 00:51:07 -07:00
|
|
|
i18n,
|
2023-06-20 03:00:53 -07:00
|
|
|
eventBus,
|
2023-05-15 09:41:13 -07:00
|
|
|
...useToast(),
|
|
|
|
};
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
focused: false,
|
|
|
|
menuExpanded: false,
|
|
|
|
forceShowExpression: false,
|
|
|
|
dataMappingTooltipButtons: [] as IN8nButton[],
|
|
|
|
mappingTooltipEnabled: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
displayOptions: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
isReadOnly: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
hideLabel: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
2022-11-03 05:04:53 -07:00
|
|
|
},
|
2023-01-16 05:55:58 -08:00
|
|
|
hideIssues: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
parameter: {
|
|
|
|
type: Object as PropType<INodeProperties>,
|
2022-10-06 06:03:55 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
path: {
|
|
|
|
type: String,
|
2022-07-20 04:32:51 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
value: {
|
|
|
|
type: [Number, String, Boolean, Array, Object] as PropType<INodeParameters>,
|
|
|
|
},
|
2023-01-20 08:07:28 -08:00
|
|
|
label: {
|
|
|
|
type: Object as PropType<IParameterLabel>,
|
|
|
|
default: () => ({
|
|
|
|
size: 'small',
|
|
|
|
}),
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
2023-07-28 00:51:07 -07:00
|
|
|
mounted() {
|
2022-12-14 01:04:10 -08:00
|
|
|
const mappingTooltipDismissHandler = this.onMappingTooltipDismissed.bind(this);
|
|
|
|
this.dataMappingTooltipButtons = [
|
|
|
|
{
|
|
|
|
attrs: {
|
2023-07-28 00:51:07 -07:00
|
|
|
label: this.i18n.baseText('_reusableBaseText.dismiss' as BaseTextKey),
|
2023-03-02 04:02:29 -08:00
|
|
|
'data-test-id': 'dismiss-mapping-tooltip',
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
|
|
|
listeners: {
|
2023-08-07 11:16:01 -07:00
|
|
|
onClick: mappingTooltipDismissHandler,
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
];
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapStores(useNDVStore),
|
|
|
|
node(): INodeUi | null {
|
|
|
|
return this.ndvStore.activeNode;
|
|
|
|
},
|
|
|
|
hint(): string | null {
|
2023-07-28 00:51:07 -07:00
|
|
|
return this.i18n.nodeText().hint(this.parameter, this.path);
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
|
|
|
isInputTypeString(): boolean {
|
|
|
|
return this.parameter.type === 'string';
|
|
|
|
},
|
|
|
|
isResourceLocator(): boolean {
|
|
|
|
return this.parameter.type === 'resourceLocator';
|
|
|
|
},
|
|
|
|
isDropDisabled(): boolean {
|
|
|
|
return this.parameter.noDataExpression || this.isReadOnly || this.isResourceLocator;
|
|
|
|
},
|
2022-12-14 05:43:02 -08:00
|
|
|
isValueExpression(): boolean {
|
|
|
|
return isValueExpression(this.parameter, this.value);
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
showExpressionSelector(): boolean {
|
|
|
|
return this.isResourceLocator ? !hasOnlyListMode(this.parameter) : true;
|
|
|
|
},
|
|
|
|
isInputDataEmpty(): boolean {
|
|
|
|
return this.ndvStore.isDNVDataEmpty('input');
|
|
|
|
},
|
|
|
|
displayMode(): IRunDataDisplayMode {
|
|
|
|
return this.ndvStore.inputPanelDisplayMode;
|
|
|
|
},
|
|
|
|
showMappingTooltip(): boolean {
|
|
|
|
return (
|
|
|
|
this.mappingTooltipEnabled &&
|
2023-03-01 03:02:34 -08:00
|
|
|
!this.ndvStore.isMappingOnboarded &&
|
2022-12-14 01:04:10 -08:00
|
|
|
this.focused &&
|
|
|
|
this.isInputTypeString &&
|
2023-03-17 05:24:08 -07:00
|
|
|
!this.isInputDataEmpty &&
|
|
|
|
DISPLAY_MODES_WITH_DATA_MAPPING.includes(this.displayMode)
|
2022-12-14 01:04:10 -08:00
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onFocus() {
|
|
|
|
this.focused = true;
|
|
|
|
setTimeout(() => {
|
|
|
|
this.mappingTooltipEnabled = true;
|
|
|
|
}, 500);
|
|
|
|
if (!this.parameter.noDataExpression) {
|
|
|
|
this.ndvStore.setMappableNDVInputFocus(this.parameter.displayName);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onBlur() {
|
|
|
|
this.focused = false;
|
|
|
|
this.mappingTooltipEnabled = false;
|
|
|
|
if (!this.parameter.noDataExpression) {
|
|
|
|
this.ndvStore.setMappableNDVInputFocus('');
|
|
|
|
}
|
2023-01-16 05:55:58 -08:00
|
|
|
this.$emit('blur');
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
|
|
|
onMenuExpanded(expanded: boolean) {
|
|
|
|
this.menuExpanded = expanded;
|
|
|
|
},
|
|
|
|
optionSelected(command: string) {
|
2023-06-20 03:00:53 -07:00
|
|
|
this.eventBus.emit('optionSelected', command);
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
|
|
|
valueChanged(parameterData: IUpdateInformation) {
|
2023-07-28 00:51:07 -07:00
|
|
|
this.$emit('update', parameterData);
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
2022-12-28 01:37:42 -08:00
|
|
|
onTextInput(parameterData: IUpdateInformation) {
|
|
|
|
if (isValueExpression(this.parameter, parameterData.value)) {
|
2023-06-20 03:00:53 -07:00
|
|
|
this.eventBus.emit('optionSelected', 'addExpression');
|
2022-12-28 01:37:42 -08:00
|
|
|
}
|
|
|
|
},
|
2023-03-02 04:02:29 -08:00
|
|
|
onDrop(newParamValue: string) {
|
|
|
|
const updatedValue = getMappedResult(this.parameter, newParamValue, this.value);
|
|
|
|
const prevValue = this.isResourceLocator ? this.value.value : this.value;
|
|
|
|
|
|
|
|
if (updatedValue.startsWith('=')) {
|
2023-01-30 03:42:08 -08:00
|
|
|
this.forceShowExpression = true;
|
|
|
|
}
|
2022-12-14 01:04:10 -08:00
|
|
|
setTimeout(() => {
|
|
|
|
if (this.node) {
|
|
|
|
let parameterData;
|
|
|
|
if (this.isResourceLocator) {
|
|
|
|
if (!isResourceLocatorValue(this.value)) {
|
|
|
|
parameterData = {
|
|
|
|
node: this.node.name,
|
|
|
|
name: this.path,
|
|
|
|
value: { __rl: true, value: updatedValue, mode: '' },
|
|
|
|
};
|
|
|
|
} else if (
|
|
|
|
this.value.mode === 'list' &&
|
|
|
|
this.parameter.modes &&
|
|
|
|
this.parameter.modes.length > 1
|
|
|
|
) {
|
|
|
|
let mode =
|
|
|
|
this.parameter.modes.find((mode: INodePropertyMode) => mode.name === 'id') || null;
|
|
|
|
if (!mode) {
|
|
|
|
mode = this.parameter.modes.filter(
|
|
|
|
(mode: INodePropertyMode) => mode.name !== 'list',
|
|
|
|
)[0];
|
2022-09-21 06:44:45 -07:00
|
|
|
}
|
|
|
|
|
2022-12-14 01:04:10 -08:00
|
|
|
parameterData = {
|
|
|
|
node: this.node.name,
|
|
|
|
name: this.path,
|
|
|
|
value: { __rl: true, value: updatedValue, mode: mode ? mode.name : '' },
|
|
|
|
};
|
2022-09-21 06:44:45 -07:00
|
|
|
} else {
|
|
|
|
parameterData = {
|
|
|
|
node: this.node.name,
|
|
|
|
name: this.path,
|
2022-12-14 01:04:10 -08:00
|
|
|
value: { __rl: true, value: updatedValue, mode: this.value.mode },
|
2022-09-21 06:44:45 -07:00
|
|
|
};
|
|
|
|
}
|
2022-12-14 01:04:10 -08:00
|
|
|
} else {
|
|
|
|
parameterData = {
|
|
|
|
node: this.node.name,
|
|
|
|
name: this.path,
|
|
|
|
value: updatedValue,
|
|
|
|
};
|
|
|
|
}
|
2022-07-20 04:32:51 -07:00
|
|
|
|
2023-07-28 00:51:07 -07:00
|
|
|
this.valueChanged(parameterData);
|
2022-07-20 04:32:51 -07:00
|
|
|
|
2023-03-01 03:02:34 -08:00
|
|
|
if (!this.ndvStore.isMappingOnboarded) {
|
2023-05-15 09:41:13 -07:00
|
|
|
this.showMessage({
|
2023-07-28 00:51:07 -07:00
|
|
|
title: this.i18n.baseText('dataMapping.success.title'),
|
|
|
|
message: this.i18n.baseText('dataMapping.success.moreInfo'),
|
2022-12-14 01:04:10 -08:00
|
|
|
type: 'success',
|
2023-05-22 06:09:29 -07:00
|
|
|
dangerouslyUseHTMLString: true,
|
2022-07-20 04:32:51 -07:00
|
|
|
});
|
2022-12-14 01:04:10 -08:00
|
|
|
|
2023-03-01 03:02:34 -08:00
|
|
|
this.ndvStore.disableMappingHint();
|
2022-07-20 04:32:51 -07:00
|
|
|
}
|
2022-12-14 01:04:10 -08:00
|
|
|
|
|
|
|
this.ndvStore.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,
|
|
|
|
});
|
2023-02-21 05:34:39 -08:00
|
|
|
|
2023-02-28 02:44:37 -08:00
|
|
|
const segment = useSegment();
|
|
|
|
segment.track(segment.EVENTS.MAPPED_DATA);
|
2022-10-06 06:03:55 -07:00
|
|
|
}
|
2022-12-14 01:04:10 -08:00
|
|
|
this.forceShowExpression = false;
|
|
|
|
}, 200);
|
|
|
|
},
|
|
|
|
onMappingTooltipDismissed() {
|
2023-03-02 04:02:29 -08:00
|
|
|
this.ndvStore.disableMappingHint(false);
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
showMappingTooltip(newValue: boolean) {
|
|
|
|
if (!newValue) {
|
|
|
|
this.$telemetry.track('User viewed data mapping tooltip', { type: 'param focus' });
|
|
|
|
}
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
},
|
|
|
|
});
|
2019-06-23 03:35:23 -07:00
|
|
|
</script>
|