mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
✨ Make it possible to define dependencies for loadOptions
This commit is contained in:
parent
f4acd47f80
commit
bf4c8bc3a2
|
@ -116,6 +116,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
import { get } from 'lodash';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
INodeUi,
|
INodeUi,
|
||||||
|
@ -206,11 +207,34 @@ export default mixins(
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
dependentParametersValues () {
|
||||||
|
// Reload the remote parameters whenever a parameter
|
||||||
|
// on which the current field depends on changes
|
||||||
|
this.loadRemoteParameterOptions();
|
||||||
|
},
|
||||||
value () {
|
value () {
|
||||||
this.tempValue = this.displayValue as string;
|
this.tempValue = this.displayValue as string;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
dependentParametersValues (): string | null {
|
||||||
|
const loadOptionsDependsOn = this.getArgument('loadOptionsDependsOn') as string[] | undefined;
|
||||||
|
|
||||||
|
if (loadOptionsDependsOn === undefined) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the resolved parameter values of the current node
|
||||||
|
const currentNodeParameters = this.$store.getters.activeNode.parameters;
|
||||||
|
const resolvedNodeParameters = this.getResolveNodeParameters(currentNodeParameters);
|
||||||
|
|
||||||
|
let returnValues: string[] = [];
|
||||||
|
for (const parameterPath of loadOptionsDependsOn) {
|
||||||
|
returnValues.push(get(resolvedNodeParameters, parameterPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValues.join('|');
|
||||||
|
},
|
||||||
node (): INodeUi | null {
|
node (): INodeUi | null {
|
||||||
if (this.isCredential === true) {
|
if (this.isCredential === true) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -124,7 +124,7 @@ export default mixins(
|
||||||
getArgument (
|
getArgument (
|
||||||
argumentName: string,
|
argumentName: string,
|
||||||
parameter: INodeProperties,
|
parameter: INodeProperties,
|
||||||
): string | number | boolean | undefined {
|
): string | string[] | number | boolean | undefined{
|
||||||
if (parameter.typeOptions === undefined) {
|
if (parameter.typeOptions === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,9 @@ export const tableFields = [
|
||||||
name: 'tableId',
|
name: 'tableId',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
|
loadOptionsDependsOn: [
|
||||||
|
'docId',
|
||||||
|
],
|
||||||
loadOptionsMethod: 'getTables',
|
loadOptionsMethod: 'getTables',
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -150,6 +153,9 @@ export const tableFields = [
|
||||||
name: 'tableId',
|
name: 'tableId',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
|
loadOptionsDependsOn: [
|
||||||
|
'docId',
|
||||||
|
],
|
||||||
loadOptionsMethod: 'getTables',
|
loadOptionsMethod: 'getTables',
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -271,6 +277,9 @@ export const tableFields = [
|
||||||
name: 'tableId',
|
name: 'tableId',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
|
loadOptionsDependsOn: [
|
||||||
|
'docId',
|
||||||
|
],
|
||||||
loadOptionsMethod: 'getTables',
|
loadOptionsMethod: 'getTables',
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -438,6 +447,9 @@ export const tableFields = [
|
||||||
name: 'tableId',
|
name: 'tableId',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
|
loadOptionsDependsOn: [
|
||||||
|
'docId',
|
||||||
|
],
|
||||||
loadOptionsMethod: 'getTables',
|
loadOptionsMethod: 'getTables',
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -63,6 +63,9 @@ export class EventbriteTrigger implements INodeType {
|
||||||
type: 'options',
|
type: 'options',
|
||||||
required: true,
|
required: true,
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
|
loadOptionsDependsOn: [
|
||||||
|
'organization',
|
||||||
|
],
|
||||||
loadOptionsMethod: 'getEvents'
|
loadOptionsMethod: 'getEvents'
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
|
|
|
@ -332,6 +332,7 @@ export type EditorTypes = 'code';
|
||||||
export interface INodePropertyTypeOptions {
|
export interface INodePropertyTypeOptions {
|
||||||
alwaysOpenEditWindow?: boolean; // Supported by: string
|
alwaysOpenEditWindow?: boolean; // Supported by: string
|
||||||
editor?: EditorTypes; // Supported by: string
|
editor?: EditorTypes; // Supported by: string
|
||||||
|
loadOptionsDependsOn?: string[]; // Supported by: options
|
||||||
loadOptionsMethod?: string; // Supported by: options
|
loadOptionsMethod?: string; // Supported by: options
|
||||||
maxValue?: number; // Supported by: number
|
maxValue?: number; // Supported by: number
|
||||||
minValue?: number; // Supported by: number
|
minValue?: number; // Supported by: number
|
||||||
|
@ -341,7 +342,7 @@ export interface INodePropertyTypeOptions {
|
||||||
numberStepSize?: number; // Supported by: number
|
numberStepSize?: number; // Supported by: number
|
||||||
password?: boolean; // Supported by: string
|
password?: boolean; // Supported by: string
|
||||||
rows?: number; // Supported by: string
|
rows?: number; // Supported by: string
|
||||||
[key: string]: boolean | number | string | EditorTypes | undefined;
|
[key: string]: boolean | number | string | EditorTypes | undefined | string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDisplayOptions {
|
export interface IDisplayOptions {
|
||||||
|
|
Loading…
Reference in a new issue