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: {
dependentParametersValues() {
async dependentParametersValues() {
// Reload the remote parameters whenever a parameter
// on which the current field depends on changes
void this.loadRemoteParameterOptions();
await this.loadRemoteParameterOptions();
},
value() {
if (this.parameter.type === 'color' && this.getArgument('showAlpha') === true) {

View file

@ -129,7 +129,12 @@
import { defineComponent } from 'vue';
import type { PropType } from 'vue';
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 type { INodeUi, IUpdateInformation } from '@/Interface';
@ -236,7 +241,7 @@ export default defineComponent({
return index < this.filteredParameters.length ? index : this.filteredParameters.length - 1;
},
mainNodeAuthField(): INodeProperties | null {
return getMainAuthField(this.nodeType || undefined);
return getMainAuthField(this.nodeType || null);
},
},
methods: {

View file

@ -456,9 +456,15 @@ export default defineComponent({
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
if (this.value && isResourceLocatorValue(this.value) && this.value.value !== '') {
if (
isUpdated &&
this.value &&
isResourceLocatorValue(this.value) &&
this.value.value !== ''
) {
this.$emit('input', {
...this.value,
cachedResultName: '',

View file

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

View file

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