From 21f5691bb01952c412e9a0fef58700fc9c851216 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 5 Jan 2022 11:06:24 -0500 Subject: [PATCH] APIv4 Explorer - Format array params using add methods instead of set when available Improves OOP generated code by using sugar methods `addGroupBy()` and `addRecords()` --- ang/api4Explorer/Explorer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ang/api4Explorer/Explorer.js b/ang/api4Explorer/Explorer.js index b85f4734f0..dcfc702e26 100644 --- a/ang/api4Explorer/Explorer.js +++ b/ang/api4Explorer/Explorer.js @@ -789,6 +789,7 @@ // Format oop params function formatOOP(entity, action, params, indent) { var info = getEntity(entity), + arrayParams = ['groupBy', 'records'], newLine = "\n" + _.repeat(' ', indent), code = '\\' + info.class + '::' + action + '(', perm = params.checkPermissions === false ? 'FALSE' : ''; @@ -804,6 +805,10 @@ val = phpFormat(index) + ', ' + phpFormat(item, 2 + indent); code += newLine + "->add" + ucfirst(key).replace(/s$/, '') + '(' + val + ')'; }); + } else if (_.includes(arrayParams, key)) { + _.each(param, function(item) { + code += newLine + "->add" + ucfirst(key).replace(/s$/, '') + '(' + phpFormat(item, 2 + indent) + ')'; + }); } else if (key === 'where') { _.each(param, function (clause) { if (clause[0] === 'AND' || clause[0] === 'OR' || clause[0] === 'NOT') { -- 2.25.1