Make it possible to define dependencies for loadOptions

This commit is contained in:
Jan Oberhauser 2020-01-04 22:28:09 -06:00
parent f4acd47f80
commit bf4c8bc3a2
5 changed files with 42 additions and 2 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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,

View file

@ -63,6 +63,9 @@ export class EventbriteTrigger implements INodeType {
type: 'options',
required: true,
typeOptions: {
loadOptionsDependsOn: [
'organization',
],
loadOptionsMethod: 'getEvents'
},
default: '',

View file

@ -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 {