From d618bdcabfd4bc34987c5a22c04c7254b7226b7f Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 4 Aug 2019 21:26:22 -0700 Subject: [PATCH] GUACAMOLE-630: Expand the getFieldHeader() utility function to accept arbitrary field names. --- .../webapp/app/form/directives/formField.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/guacamole/src/main/webapp/app/form/directives/formField.js b/guacamole/src/main/webapp/app/form/directives/formField.js index ea0f35fd7..c2479fa65 100644 --- a/guacamole/src/main/webapp/app/form/directives/formField.js +++ b/guacamole/src/main/webapp/app/form/directives/formField.js @@ -73,8 +73,10 @@ angular.module('form').directive('guacFormField', [function formField() { var fieldContent = $element.find('.form-field'); /** - * Produces the translation string for the header of the current - * field. The translation string will be of the form: + * Produces the translation string for the header of the field with + * the given name. If no name is supplied, then the name of the + * current field will be used. The translation string will be of + * the form: * * NAMESPACE.FIELD_HEADER_NAME * @@ -82,18 +84,24 @@ angular.module('form').directive('guacFormField', [function formField() { * directive and NAME is the field name transformed * via translationStringService.canonicalize(). * + * @param {String} [name] + * The name of the field to produce the translation header + * string for. If omitted, the name of the current field will + * be used. + * * @returns {String} * The translation string which produces the translated header * of the field. */ - $scope.getFieldHeader = function getFieldHeader() { + $scope.getFieldHeader = function getFieldHeader(name) { // If no field, or no name, then no header - if (!$scope.field || !$scope.field.name) + name = name || ($scope.field && $scope.field.name); + if (!name) return ''; return translationStringService.canonicalize($scope.namespace || 'MISSING_NAMESPACE') - + '.FIELD_HEADER_' + translationStringService.canonicalize($scope.field.name); + + '.FIELD_HEADER_' + translationStringService.canonicalize(name); };