From 6adc1f31e963ecad8d2192900db75a2f33723ffa Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 17 May 2023 15:48:10 +0530 Subject: [PATCH] refactor: allow checking `value` prop --- .../dashboard/helper/actionQueryGenerator.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/javascript/dashboard/helper/actionQueryGenerator.js b/app/javascript/dashboard/helper/actionQueryGenerator.js index ccba27681..0eb16cc9b 100644 --- a/app/javascript/dashboard/helper/actionQueryGenerator.js +++ b/app/javascript/dashboard/helper/actionQueryGenerator.js @@ -22,7 +22,7 @@ const allElementsNumbers = arr => { * @returns {Array} - Returns the formatted array of action parameters. */ const formatActionParamsArray = params => { - if (params.length <= 0) { + if (params.length === 0) { return []; } @@ -39,7 +39,11 @@ const formatActionParamsArray = params => { * @returns {Array} - Returns the formatted array of action parameters. */ const formatActionParamsObject = params => { - if (params.id) { + if (params?.value !== undefined) { + return [params.value]; + } + + if (params?.id) { return [params.id]; } @@ -52,6 +56,10 @@ const formatActionParamsObject = params => { * @returns {Array} - Returns the processed and formatted array of action parameters. */ const processActionParams = action_params => { + if (!action_params) { + return []; + } + if (Array.isArray(action_params)) { return formatActionParamsArray(action_params); } @@ -60,10 +68,6 @@ const processActionParams = action_params => { return formatActionParamsObject(action_params); } - if (!action_params) { - return []; - } - return [action_params]; };