From 913d3dde369ef7b3db4c3bba4f15858af1c1b1cb Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Tue, 26 May 2020 15:20:22 +0200 Subject: [PATCH] Fix node select ES5 syntax (#1851) * Do not use object destructering in node select This is not supported in ES5 * Format node select with Prettier --- app/assets/javascripts/alchemy/node_select.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/alchemy/node_select.js b/app/assets/javascripts/alchemy/node_select.js index c58165ac56..a358703905 100644 --- a/app/assets/javascripts/alchemy/node_select.js +++ b/app/assets/javascripts/alchemy/node_select.js @@ -1,10 +1,18 @@ -$.fn.alchemyNodeSelect = function(options) { - var renderNodeTemplate = function(node) { return HandlebarsTemplates.node({ node: node }) } - var queryParamsFromTerm = function(term) { - return {filter: Object.assign({ name_or_page_name_cont: term }, options.query_params)} +$.fn.alchemyNodeSelect = function (options) { + var renderNodeTemplate = function (node) { + return HandlebarsTemplates.node({ node: node }) } - var resultsFromResponse = function(response) { - var { meta, data } = response + var queryParamsFromTerm = function (term) { + return { + filter: Object.assign( + { name_or_page_name_cont: term }, + options.query_params + ) + } + } + var resultsFromResponse = function (response) { + var meta = response.meta + var data = response.data var more = meta.page * meta.per_page < meta.total_count return { results: data, more: more } } @@ -20,7 +28,7 @@ $.fn.alchemyNodeSelect = function(options) { }, ajax: { url: options.url, - datatype: 'json', + datatype: "json", quietMillis: 300, data: queryParamsFromTerm, results: resultsFromResponse