Skip to content

Commit

Permalink
fix(editor): Fix typing $ in inline expression field reloading node…
Browse files Browse the repository at this point in the history
… parameters form (#6374)

* fix(editor): Fix typing `$` in inline expression field reloading node parameters form
* ⚡ Setting resource mapper empty field values to empty strings
  • Loading branch information
MiloradFilipovic committed Jun 3, 2023
1 parent f61b776 commit 4c0d4eb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/editor-ui/src/components/ParameterInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions packages/editor-ui/src/components/ParameterInputList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4c0d4eb

Please sign in to comment.