Sort options on Salesforce-Node

This commit is contained in:
Jan Oberhauser
2020-10-16 11:13:04 +02:00
parent a77e96592f
commit f3b92a8502
2 changed files with 43 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
import {
OptionsWithUri,
} from 'request';
} from 'request';
import {
IExecuteFunctions,
@@ -9,7 +9,8 @@ import {
} from 'n8n-core';
import {
IDataObject
IDataObject,
INodePropertyOptions,
} from 'n8n-workflow';
export async function salesforceApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
@@ -52,3 +53,20 @@ export async function salesforceApiRequestAllItems(this: IExecuteFunctions | ILo
return returnData;
}
/**
* Sorts the given options alphabetically
*
* @export
* @param {INodePropertyOptions[]} options
* @returns {INodePropertyOptions[]}
*/
export function sortOptions(options: INodePropertyOptions[]): void {
options.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
}