mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 12:44:07 -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">
|
||||
import Vue from 'vue';
|
||||
import { get } from 'lodash';
|
||||
|
||||
import {
|
||||
INodeUi,
|
||||
|
@ -206,11 +207,34 @@ export default mixins(
|
|||
};
|
||||
},
|
||||
watch: {
|
||||
dependentParametersValues () {
|
||||
// Reload the remote parameters whenever a parameter
|
||||
// on which the current field depends on changes
|
||||
this.loadRemoteParameterOptions();
|
||||
},
|
||||
value () {
|
||||
this.tempValue = this.displayValue as string;
|
||||
},
|
||||
},
|
||||
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 {
|
||||
if (this.isCredential === true) {
|
||||
return null;
|
||||
|
|
|
@ -124,7 +124,7 @@ export default mixins(
|
|||
getArgument (
|
||||
argumentName: string,
|
||||
parameter: INodeProperties,
|
||||
): string | number | boolean | undefined {
|
||||
): string | string[] | number | boolean | undefined{
|
||||
if (parameter.typeOptions === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,9 @@ export const tableFields = [
|
|||
name: 'tableId',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: [
|
||||
'docId',
|
||||
],
|
||||
loadOptionsMethod: 'getTables',
|
||||
},
|
||||
required: true,
|
||||
|
@ -150,6 +153,9 @@ export const tableFields = [
|
|||
name: 'tableId',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: [
|
||||
'docId',
|
||||
],
|
||||
loadOptionsMethod: 'getTables',
|
||||
},
|
||||
required: true,
|
||||
|
@ -271,6 +277,9 @@ export const tableFields = [
|
|||
name: 'tableId',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: [
|
||||
'docId',
|
||||
],
|
||||
loadOptionsMethod: 'getTables',
|
||||
},
|
||||
required: true,
|
||||
|
@ -438,6 +447,9 @@ export const tableFields = [
|
|||
name: 'tableId',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: [
|
||||
'docId',
|
||||
],
|
||||
loadOptionsMethod: 'getTables',
|
||||
},
|
||||
required: true,
|
||||
|
|
|
@ -63,6 +63,9 @@ export class EventbriteTrigger implements INodeType {
|
|||
type: 'options',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: [
|
||||
'organization',
|
||||
],
|
||||
loadOptionsMethod: 'getEvents'
|
||||
},
|
||||
default: '',
|
||||
|
|
|
@ -332,6 +332,7 @@ export type EditorTypes = 'code';
|
|||
export interface INodePropertyTypeOptions {
|
||||
alwaysOpenEditWindow?: boolean; // Supported by: string
|
||||
editor?: EditorTypes; // Supported by: string
|
||||
loadOptionsDependsOn?: string[]; // Supported by: options
|
||||
loadOptionsMethod?: string; // Supported by: options
|
||||
maxValue?: number; // Supported by: number
|
||||
minValue?: number; // Supported by: number
|
||||
|
@ -341,7 +342,7 @@ export interface INodePropertyTypeOptions {
|
|||
numberStepSize?: number; // Supported by: number
|
||||
password?: boolean; // 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 {
|
||||
|
|
Loading…
Reference in a new issue