GUACAMOLE-470: Make getFieldOption() available to all field types.

Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/a8bb6fe9
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/a8bb6fe9
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/a8bb6fe9

Branch: refs/heads/master
Commit: a8bb6fe96640ee7c06d02112cd48aea9e5b7c5e2
Parents: 0163cfc
Author: Michael Jumper <mjum...@apache.org>
Authored: Tue Jun 12 12:09:40 2018 -0700
Committer: Michael Jumper <mjum...@apache.org>
Committed: Tue Jun 12 13:58:04 2018 -0700

----------------------------------------------------------------------
 .../form/controllers/selectFieldController.js   | 34 --------------------
 .../webapp/app/form/directives/formField.js     | 31 ++++++++++++++++++
 2 files changed, 31 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/a8bb6fe9/guacamole/src/main/webapp/app/form/controllers/selectFieldController.js
----------------------------------------------------------------------
diff --git 
a/guacamole/src/main/webapp/app/form/controllers/selectFieldController.js 
b/guacamole/src/main/webapp/app/form/controllers/selectFieldController.js
index 7d5b868..e780378 100644
--- a/guacamole/src/main/webapp/app/form/controllers/selectFieldController.js
+++ b/guacamole/src/main/webapp/app/form/controllers/selectFieldController.js
@@ -24,44 +24,10 @@
 angular.module('form').controller('selectFieldController', ['$scope', 
'$injector',
     function selectFieldController($scope, $injector) {
 
-    // Required services
-    var translationStringService = $injector.get('translationStringService');
-
     // Interpret undefined/null as empty string
     $scope.$watch('model', function setModel(model) {
         if (!model && model !== '')
             $scope.model = '';
     });
 
-    /**
-     * Produces the translation string for the given field option
-     * value. The translation string will be of the form:
-     *
-     * <code>NAMESPACE.FIELD_OPTION_NAME_VALUE<code>
-     *
-     * where <code>NAMESPACE</code> is the namespace provided to the
-     * directive, <code>NAME</code> is the field name transformed
-     * via translationStringService.canonicalize(), and
-     * <code>VALUE</code> is the option value transformed via
-     * translationStringService.canonicalize()
-     *
-     * @param {String} value
-     *     The name of the option value.
-     *
-     * @returns {String}
-     *     The translation string which produces the translated name of the
-     *     value specified.
-     */
-    $scope.getFieldOption = function getFieldOption(value) {
-
-        // If no field, or no value, then no corresponding translation string
-        if (!$scope.field || !$scope.field.name || !value)
-            return '';
-
-        return translationStringService.canonicalize($scope.namespace || 
'MISSING_NAMESPACE')
-                + '.FIELD_OPTION_' + 
translationStringService.canonicalize($scope.field.name)
-                + '_'              + 
translationStringService.canonicalize(value || 'EMPTY');
-
-    };
-
 }]);

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/a8bb6fe9/guacamole/src/main/webapp/app/form/directives/formField.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/form/directives/formField.js 
b/guacamole/src/main/webapp/app/form/directives/formField.js
index 15bde94..9cf785c 100644
--- a/guacamole/src/main/webapp/app/form/directives/formField.js
+++ b/guacamole/src/main/webapp/app/form/directives/formField.js
@@ -98,6 +98,37 @@ angular.module('form').directive('guacFormField', [function 
formField() {
             };
 
             /**
+             * Produces the translation string for the given field option
+             * value. The translation string will be of the form:
+             *
+             * <code>NAMESPACE.FIELD_OPTION_NAME_VALUE<code>
+             *
+             * where <code>NAMESPACE</code> is the namespace provided to the
+             * directive, <code>NAME</code> is the field name transformed
+             * via translationStringService.canonicalize(), and
+             * <code>VALUE</code> is the option value transformed via
+             * translationStringService.canonicalize()
+             *
+             * @param {String} value
+             *     The name of the option value.
+             *
+             * @returns {String}
+             *     The translation string which produces the translated name 
of the
+             *     value specified.
+             */
+            $scope.getFieldOption = function getFieldOption(value) {
+
+                // If no field, or no value, then no corresponding translation 
string
+                if (!$scope.field || !$scope.field.name || !value)
+                    return '';
+
+                return translationStringService.canonicalize($scope.namespace 
|| 'MISSING_NAMESPACE')
+                        + '.FIELD_OPTION_' + 
translationStringService.canonicalize($scope.field.name)
+                        + '_'              + 
translationStringService.canonicalize(value || 'EMPTY');
+
+            };
+
+            /**
              * Returns whether the current field should be displayed.
              *
              * @returns {Boolean}

Reply via email to