From b5a8191f1370106578bd9949652c05d789a86774 Mon Sep 17 00:00:00 2001 From: chrisala Date: Thu, 7 Mar 2024 14:19:48 +1100 Subject: [PATCH] Support findAll/pluck #238 --- grails-app/assets/javascripts/forms.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/grails-app/assets/javascripts/forms.js b/grails-app/assets/javascripts/forms.js index 7a7be09..c5edf0c 100644 --- a/grails-app/assets/javascripts/forms.js +++ b/grails-app/assets/javascripts/forms.js @@ -306,7 +306,21 @@ function orEmptyArray(v) { } return moment(value).format('DD-MM-YYYY'); - } + }; + + parser.functions.findAll = function(list, property, value) { + var obj = {}; + obj[property] = value; + return _.where(list, obj); + }; + + parser.functions.pluck = function(list, property, defaultValue) { + var result = _.pluck(list, property); + if (!result || result.length == 0) { + result = [defaultValue]; + } + return result; + }; var specialBindings = function() {