fix(editor): Fix typing $ in inline expression field reloading node parameters form (#6374)

* fix(editor): Fix typing `$` in inline expression field reloading node parameters form
*  Setting resource mapper empty field values to empty strings
This commit is contained in:
Milorad FIlipović 2023-06-03 17:58:09 +02:00 committed by GitHub
parent f61b776bea
commit 4c0d4ebd99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 11 deletions

View file

@ -514,10 +514,10 @@ export default defineComponent({
}; };
}, },
watch: { watch: {
dependentParametersValues() { async dependentParametersValues() {
// Reload the remote parameters whenever a parameter // Reload the remote parameters whenever a parameter
// on which the current field depends on changes // on which the current field depends on changes
void this.loadRemoteParameterOptions(); await this.loadRemoteParameterOptions();
}, },
value() { value() {
if (this.parameter.type === 'color' && this.getArgument('showAlpha') === true) { if (this.parameter.type === 'color' && this.getArgument('showAlpha') === true) {

View file

@ -129,7 +129,12 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import type { PropType } from 'vue'; import type { PropType } from 'vue';
import { mapStores } from 'pinia'; import { mapStores } from 'pinia';
import type { INodeParameters, INodeProperties, NodeParameterValue } from 'n8n-workflow'; import type {
INodeParameters,
INodeProperties,
INodeTypeDescription,
NodeParameterValue,
} from 'n8n-workflow';
import { deepCopy } from 'n8n-workflow'; import { deepCopy } from 'n8n-workflow';
import type { INodeUi, IUpdateInformation } from '@/Interface'; import type { INodeUi, IUpdateInformation } from '@/Interface';
@ -236,7 +241,7 @@ export default defineComponent({
return index < this.filteredParameters.length ? index : this.filteredParameters.length - 1; return index < this.filteredParameters.length ? index : this.filteredParameters.length - 1;
}, },
mainNodeAuthField(): INodeProperties | null { mainNodeAuthField(): INodeProperties | null {
return getMainAuthField(this.nodeType || undefined); return getMainAuthField(this.nodeType || null);
}, },
}, },
methods: { methods: {

View file

@ -456,9 +456,15 @@ export default defineComponent({
this.$emit('input', { ...this.value, __regex: mode.extractValue.regex }); this.$emit('input', { ...this.value, __regex: mode.extractValue.regex });
} }
}, },
dependentParametersValues() { dependentParametersValues(currentValue, oldValue) {
const isUpdated = oldValue !== null && currentValue !== null && oldValue !== currentValue;
// Reset value if dependent parameters change // Reset value if dependent parameters change
if (this.value && isResourceLocatorValue(this.value) && this.value.value !== '') { if (
isUpdated &&
this.value &&
isResourceLocatorValue(this.value) &&
this.value.value !== ''
) {
this.$emit('input', { this.$emit('input', {
...this.value, ...this.value,
cachedResultName: '', cachedResultName: '',

View file

@ -186,10 +186,10 @@ function getFieldDescription(field: ResourceMapperField): string {
return ''; return '';
} }
function getParameterValue(parameterName: string) { function getParameterValue(parameterName: string): string | number | boolean | null {
const fieldName = parseResourceMapperFieldName(parameterName); const fieldName = parseResourceMapperFieldName(parameterName);
if (fieldName && props.paramValue.value) { if (fieldName && props.paramValue.value) {
return props.paramValue.value[fieldName]; return props.paramValue.value[fieldName] || '';
} }
return null; return null;
} }

View file

@ -19,14 +19,14 @@ import { fieldCannotBeDeleted, isResourceMapperValue, parseResourceMapperFieldNa
import { i18n as locale } from '@/plugins/i18n'; import { i18n as locale } from '@/plugins/i18n';
import { useNDVStore } from '@/stores/ndv.store'; import { useNDVStore } from '@/stores/ndv.store';
interface Props { type Props = {
parameter: INodeProperties; parameter: INodeProperties;
node: INode | null; node: INode | null;
path: string; path: string;
inputSize: string; inputSize: string;
labelSize: string; labelSize: string;
dependentParametersValues: string | null; dependentParametersValues?: string | null;
} };
const nodeTypesStore = useNodeTypesStore(); const nodeTypesStore = useNodeTypesStore();
const ndvStore = useNDVStore(); const ndvStore = useNDVStore();