Browse Source

add data source field to forms and refactor form option UI

Jason Rivard 8 years ago
parent
commit
6952c2e1bd

+ 28 - 6
src/main/java/password/pwm/config/FormConfiguration.java

@@ -51,14 +51,36 @@ import java.util.regex.PatternSyntaxException;
  * @author Jason D. Rivard
  */
 public class FormConfiguration implements Serializable {
-// ------------------------------ FIELDS ------------------------------
 
-    public enum Type {text, email, number, password, random, tel, hidden, date, datetime, time, week, month, url, select, userDN, checkbox}
+    public enum Type {
+        text,
+        email,
+        number,
+        password,
+        random,
+        tel,
+        hidden,
+        date,
+        datetime,
+        time,
+        week,
+        month,
+        url,
+        select,
+        userDN,
+        checkbox,
+    }
+
+    public enum Source {
+        ldap,
+        remote,
+    }
 
-    private String name;
+    private String name = "";
     private int minimumLength;
     private int maximumLength;
     private Type type = Type.text;
+    private Source source = Source.ldap;
     private boolean required;
     private boolean confirmationRequired;
     private boolean readonly;
@@ -67,9 +89,9 @@ public class FormConfiguration implements Serializable {
     private Map<String,String> labels = Collections.singletonMap("", "");
     private Map<String,String> regexErrors = Collections.singletonMap("","");
     private Map<String,String> description = Collections.singletonMap("","");
-    private String regex;
-    private String placeholder;
-    private String javascript;
+    private String regex = "";
+    private String placeholder = "";
+    private String javascript = "";
     private Map<String,String> selectOptions = Collections.emptyMap();
 
 // -------------------------- STATIC METHODS --------------------------

+ 1 - 0
src/main/java/password/pwm/config/PwmSettingFlag.java

@@ -49,6 +49,7 @@ public enum PwmSettingFlag {
     Form_ShowRequiredOption,
     Form_ShowMultiValueOption,
     Form_HideStandardOptions,
+    Form_ShowSource,
 
     Verification_HideMinimumOptional,
 

+ 22 - 21
src/main/resources/password/pwm/config/PwmSetting.xml

@@ -2576,6 +2576,7 @@
         <flag>Form_ShowUniqueOption</flag>
         <flag>Form_ShowRequiredOption</flag>
         <flag>Form_ShowReadOnlyOption</flag>
+        <flag>Form_ShowSource</flag>
         <default>
             <value>{"name":"mail","minimumLength":1,"maximumLength":64,"type":"email","required":true,"confirmationRequired":false,"readonly":false,"unique":true,"labels":{"":"Email Address"},"regexErrors":{"":"Email Address has invalid characters"},"description":{"":""},"placeholder":"username@example.com","selectOptions":{},regex:"^[a-zA-Z0-9 .,'@]*$"}</value>
             <value>{"name":"givenName","minimumLength":1,"maximumLength":64,"type":"text","required":true,"confirmationRequired":false,"readonly":false,"labels":{"":"First Name"},"regexErrors":{"":""},"description":{"":""},"selectOptions":{},regex:"^[a-zA-Z0-9 .,'@]*$"}</value>
@@ -2589,10 +2590,10 @@
             <option value="random">random</option>
             <option value="tel">tel</option>
             <option value="hidden">hidden</option>
-            <option value="date">date</option>
-            <option value="datetime">datetime</option>
-            <option value="week">week</option>
-            <option value="month">month</option>
+            <!--<option value="date">date</option>-->
+            <!--<option value="datetime">datetime</option>-->
+            <!--<option value="week">week</option>-->
+            <!--<option value="month">month</option>-->
             <option value="url">url</option>
             <option value="select">select</option>
             <option value="checkbox">checkbox</option>
@@ -2690,10 +2691,10 @@
             <option value="random">random</option>
             <option value="tel">tel</option>
             <option value="hidden">hidden</option>
-            <option value="date">date</option>
-            <option value="datetime">datetime</option>
-            <option value="week">week</option>
-            <option value="month">month</option>
+            <!--<option value="date">date</option>-->
+            <!--<option value="datetime">datetime</option>-->
+            <!--<option value="week">week</option>-->
+            <!--<option value="month">month</option>-->
             <option value="url">url</option>
             <option value="select">select</option>
             <option value="checkbox">checkbox</option>
@@ -2718,10 +2719,10 @@
             <option value="random">random</option>
             <option value="tel">tel</option>
             <option value="hidden">hidden</option>
-            <option value="date">date</option>
-            <option value="datetime">datetime</option>
-            <option value="week">week</option>
-            <option value="month">month</option>
+            <!--<option value="date">date</option>-->
+            <!--<option value="datetime">datetime</option>-->
+            <!--<option value="week">week</option>-->
+            <!--<option value="month">month</option>-->
             <option value="url">url</option>
             <option value="select">select</option>
             <option value="checkbox">checkbox</option>
@@ -2803,10 +2804,10 @@
             <option value="random">random</option>
             <option value="tel">tel</option>
             <option value="hidden">hidden</option>
-            <option value="date">date</option>
-            <option value="datetime">datetime</option>
-            <option value="week">week</option>
-            <option value="month">month</option>
+            <!--<option value="date">date</option>-->
+            <!--<option value="datetime">datetime</option>-->
+            <!--<option value="week">week</option>-->
+            <!--<option value="month">month</option>-->
             <option value="url">url</option>
             <option value="select">select</option>
             <option value="checkbox">checkbox</option>
@@ -2902,10 +2903,10 @@
             <option value="random">random</option>
             <option value="tel">tel</option>
             <option value="hidden">hidden</option>
-            <option value="date">date</option>
-            <option value="datetime">datetime</option>
-            <option value="week">week</option>
-            <option value="month">month</option>
+            <!--<option value="date">date</option>-->
+            <!--<option value="datetime">datetime</option>-->
+            <!--<option value="week">week</option>-->
+            <!--<option value="month">month</option>-->
             <option value="url">url</option>
             <option value="select">select</option>
             <option value="checkbox">checkbox</option>
@@ -3634,7 +3635,7 @@
         <default/>
         <options>
             <option value="SigningForm">Signing Form Service - /signing/form</option>
-            <option value="Health">Signing Form Service - /health</option>
+            <option value="Health">Health Service - /health</option>
         </options>
     </setting>
     <setting hidden="false" key="webservices.queryMatch" level="2">

+ 152 - 166
src/main/webapp/public/resources/js/configeditor-settings.js

@@ -801,6 +801,7 @@ FormTableHandler.showOptionsDialog = function(keyName, iteration) {
     var type = PWM_VAR['clientSettingCache'][keyName][iteration]['type'];
     var settings = PWM_SETTINGS['settings'][keyName];
     var options = 'options' in PWM_SETTINGS['settings'][keyName] ? PWM_SETTINGS['settings'][keyName]['options'] : {};
+    var currentValue = PWM_VAR['clientSettingCache'][keyName][iteration];
 
     var hideStandardOptions = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_HideStandardOptions');
     var showRequired = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowRequiredOption') && (type != 'checkbox');
@@ -808,197 +809,182 @@ FormTableHandler.showOptionsDialog = function(keyName, iteration) {
     var showReadOnly = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowReadOnlyOption');
     var showMultiValue = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowMultiValueOption');
     var showConfirmation = type != 'checkbox' && type != 'select' && !hideStandardOptions;
+    var showSource = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowSource');
 
 
-    require(["dijit/Dialog","dijit/form/Textarea","dijit/form/CheckBox","dijit/form/NumberSpinner"],function(){
-        var inputID = 'value_' + keyName + '_' + iteration + "_";
-        var bodyText = '<div style="max-height: 500px; overflow-y: auto"><table class="noborder">';
-        if (!hideStandardOptions) {
-            bodyText += '<tr>';
-            var descriptionValue = PWM_VAR['clientSettingCache'][keyName][iteration]['description'][''];
-            bodyText += '<td id="' + inputID + '-label-description" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Description') + '">Description</td><td>';
-            bodyText += '<div class="noWrapTextBox" id="' + inputID + 'description"><span class="btn-icon pwm-icon pwm-icon-edit"></span><span>' + descriptionValue + '...</span></div>';
-            bodyText += '</td>';
-        }
+    var inputID = 'value_' + keyName + '_' + iteration + "_";
+    var bodyText = '<div style="max-height: 500px; overflow-y: auto"><table class="noborder">';
+    if (!hideStandardOptions) {
+        bodyText += '<tr>';
+        var descriptionValue = currentValue['description'][''];
+        bodyText += '<td id="' + inputID + '-label-description" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Description') + '">Description</td><td>';
+        bodyText += '<div class="noWrapTextBox" id="' + inputID + 'description"><span class="btn-icon pwm-icon pwm-icon-edit"></span><span>' + descriptionValue + '...</span></div>';
+        bodyText += '</td>';
+    }
 
+    bodyText += '</tr><tr>';
+    if (showRequired) {
+        bodyText += '<td id="' + inputID + '-label-required" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Required') + '">Required</td><td><input type="checkbox" id="' + inputID + 'required' + '"/></td>';
         bodyText += '</tr><tr>';
-        if (showRequired) {
-            bodyText += '<td id="' + inputID + '-label-required" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Required') + '">Required</td><td><input type="checkbox" id="' + inputID + 'required' + '"/></td>';
-            bodyText += '</tr><tr>';
-        }
-        if (showConfirmation) {
-            bodyText += '<td id="' + inputID + '-label-confirm" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Confirm') + '">Confirm</td><td><input type="checkbox" id="' + inputID + 'confirmationRequired' + '"/></td>';
-            bodyText += '</tr><tr>';
-        }
-        if (showReadOnly) {
-            bodyText += '<td id="' + inputID + '-label-readOnly" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_ReadOnly') + '">Read Only</td><td><input type="checkbox" id="' + inputID + 'readonly' + '"/></td>';
+    }
+    if (showConfirmation) {
+        bodyText += '<td id="' + inputID + '-label-confirm" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Confirm') + '">Confirm</td><td><input type="checkbox" id="' + inputID + 'confirmationRequired' + '"/></td>';
+        bodyText += '</tr><tr>';
+    }
+    if (showReadOnly) {
+        bodyText += '<td id="' + inputID + '-label-readOnly" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_ReadOnly') + '">Read Only</td><td><input type="checkbox" id="' + inputID + 'readonly' + '"/></td>';
+        bodyText += '</tr><tr>';
+    }
+    if (showUnique) {
+        bodyText += '<td id="' + inputID + '-label-unique" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Unique') + '">Unique</td><td><input type="checkbox" id="' + inputID + 'unique' + '"/></td>';
+        bodyText += '</tr><tr>';
+    }
+    if (showMultiValue) {
+        bodyText += '<td id="' + inputID + '-label-multivalue" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_MultiValue') + '">MultiValue</td><td><input type="checkbox" id="' + inputID + 'multivalue' + '"/></td>';
+        bodyText += '</tr><tr>';
+    }
+
+    if (!hideStandardOptions) {
+        bodyText += '<td class="key">Minimum Length</td><td><input min="0", max="65536" style="width: 70px" type="number" id="' + inputID + 'minimumLength' + '"/></td>';
+        bodyText += '</tr><tr>';
+        bodyText += '<td class="key">Maximum Length</td><td><input min="0", max="65536" style="width: 70px" type="number" id="' + inputID + 'maximumLength' + '"/></td>';
+        bodyText += '</tr><tr>';
+
+        { // regex
+            bodyText += '<td id="' + inputID + '-label-regex" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Regex') + '">Regular Expression</td><td><input type="text" class="configStringInput" style="width:300px" id="' + inputID + 'regex' + '"/></td>';
             bodyText += '</tr><tr>';
-        }
-        if (showUnique) {
-            bodyText += '<td id="' + inputID + '-label-unique" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Unique') + '">Unique</td><td><input type="checkbox" id="' + inputID + 'unique' + '"/></td>';
+
+            var regexErrorValue = currentValue['regexErrors'][''];
+            bodyText += '<td id="' + inputID + '-label-regexError" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_RegexError') + '">Regular Expression<br/>Error Message</td><td>';
+            bodyText += '<div class="noWrapTextBox" id="' + inputID + 'regexErrors"><span class="btn-icon pwm-icon pwm-icon-edit"></span><span>' + regexErrorValue + '...</span></div>';
+            bodyText += '</td>';
             bodyText += '</tr><tr>';
         }
-        if (showMultiValue) {
-            bodyText += '<td id="' + inputID + '-label-multivalue" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_MultiValue') + '">MultiValue</td><td><input type="checkbox" id="' + inputID + 'multivalue' + '"/></td>';
-            bodyText += '</tr><tr>';
+        bodyText += '<td id="' + inputID + '-label-placeholder" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Placeholder') + '">Placeholder</td><td><input type="text" class="configStringInput" style="width:300px" id="' + inputID + 'placeholder' + '"/></td>';
+        bodyText += '</tr><tr>';
+        bodyText += '<td id="' + inputID + '-label-js" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Javascript') + '">JavaScript</td><td><input type="text" class="configStringInput" style="width:300px" id="' + inputID + 'javascript' + '"/></td>';
+        bodyText += '</tr><tr>';
+        if (currentValue['type'] === 'select') {
+            bodyText += '<td class="key">Select Options</td><td><button id="' + inputID + 'editOptionsButton"><span class="btn-icon pwm-icon pwm-icon-list-ul"/> Edit</button></td>';
+            bodyText += '</tr>';
         }
+    }
 
-        if (!hideStandardOptions) {
-            bodyText += '<td class="key">Minimum Length</td><td><input type="number" id="' + inputID + 'minimumLength' + '"/></td>';
-            bodyText += '</tr><tr>';
-            bodyText += '<td class="key">Maximum Length</td><td><input type="number" id="' + inputID + 'maximumLength' + '"/></td>';
-            bodyText += '</tr><tr>';
+    if (showSource) {
+        bodyText += '<td id="' + inputID + '-label-source" class="key">Data Source</td>'
+            +  '<td><select id="' + inputID + 'source' + '">'
+            + '<option value="ldap">LDAP</option>'
+            + '<option value="remote">Remote REST API</option>'
+            + '</select></td></tr><tr>';
+    }
 
-            { // regex
-                bodyText += '<td id="' + inputID + '-label-regex" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Regex') + '">Regular Expression</td><td><input type="text" class="configStringInput" id="' + inputID + 'regex' + '"/></td>';
-                bodyText += '</tr><tr>';
+    bodyText += '</table></div>';
 
-                var regexErrorValue = PWM_VAR['clientSettingCache'][keyName][iteration]['regexErrors'][''];
-                bodyText += '<td id="' + inputID + '-label-regexError" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_RegexError') + '">Regular Expression<br/>Error Message</td><td>';
-                bodyText += '<div class="noWrapTextBox" id="' + inputID + 'regexErrors"><span class="btn-icon pwm-icon pwm-icon-edit"></span><span>' + regexErrorValue + '...</span></div>';
-                bodyText += '</td>';
-                bodyText += '</tr><tr>';
-            }
-            bodyText += '<td id="' + inputID + '-label-placeholder" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Placeholder') + '">Placeholder</td><td><input type="text" id="' + inputID + 'placeholder' + '"/></td>';
-            bodyText += '</tr><tr>';
-            bodyText += '<td id="' + inputID + '-label-js" class="key" title="' + PWM_CONFIG.showString('Tooltip_FormOptions_Javascript') + '">JavaScript</td><td><input type="text" id="' + inputID + 'javascript' + '"/></td>';
-            bodyText += '</tr><tr>';
-            if (PWM_VAR['clientSettingCache'][keyName][iteration]['type'] == 'select') {
-                bodyText += '<td class="key">Select Options</td><td><button id="' + inputID + 'editOptionsButton"><span class="btn-icon pwm-icon pwm-icon-list-ul"/> Edit</button></td>';
-                bodyText += '</tr>';
-            }
-        }
-        bodyText += '</table></div>';
+    var initFormElements = function() {
+        var currentValue = PWM_VAR['clientSettingCache'][keyName][iteration];
 
-        var initDialogWidgets = function() {
+        PWM_MAIN.addEventHandler(inputID + 'editOptionsButton', 'click', function(){
+            FormTableHandler.showSelectOptionsDialog(keyName,iteration);
+        });
 
-            PWM_MAIN.addEventHandler(inputID + 'editOptionsButton', 'click', function(){
-                FormTableHandler.showSelectOptionsDialog(keyName,iteration);
+        PWM_MAIN.addEventHandler(inputID + 'description','click',function(){
+            FormTableHandler.showDescriptionDialog(keyName, iteration);
+        });
+
+        if (showRequired) {
+            PWM_MAIN.getObject(inputID + "required").checked = currentValue['required'];
+            PWM_MAIN.addEventHandler(inputID + "required", "change", function(){
+                currentValue['required'] = PWM_MAIN.getObject(inputID + "required").checked;
+                FormTableHandler.write(keyName)
             });
+        }
 
-            PWM_MAIN.addEventHandler(inputID + 'description','click',function(){
-                FormTableHandler.showDescriptionDialog(keyName, iteration);
+        {
+            PWM_MAIN.getObject(inputID + "confirmationRequired").checked = currentValue['confirmationRequired'];
+            PWM_MAIN.addEventHandler(inputID + "confirmationRequired", "change", function () {
+                currentValue['confirmationRequired'] = PWM_MAIN.getObject(inputID + "confirmationRequired").checked;
+                FormTableHandler.write(keyName)
             });
+        }
 
-            if (showRequired) {
-                PWM_MAIN.clearDijitWidget(inputID + "required");
-                new dijit.form.CheckBox({
-                    checked: PWM_VAR['clientSettingCache'][keyName][iteration]['required'],
-                    onChange: function () {
-                        PWM_VAR['clientSettingCache'][keyName][iteration]['required'] = this.checked;
-                        FormTableHandler.write(keyName)
-                    }
-                }, inputID + "required");
-            }
+        if (showReadOnly) {
+            PWM_MAIN.getObject(inputID + "readonly").checked = currentValue['readonly'];
+            PWM_MAIN.addEventHandler(inputID + "readonly", "change", function () {
+                currentValue['readonly'] = PWM_MAIN.getObject(inputID + "readonly").checked;
+                FormTableHandler.write(keyName)
+            });
+        }
 
-            PWM_MAIN.clearDijitWidget(inputID + "confirmationRequired");
-            new dijit.form.CheckBox({
-                checked: PWM_VAR['clientSettingCache'][keyName][iteration]['confirmationRequired'],
-                onChange: function () {
-                    PWM_VAR['clientSettingCache'][keyName][iteration]['confirmationRequired'] = this.checked;
-                    FormTableHandler.write(keyName)
-                }
-            }, inputID + "confirmationRequired");
-
-            if (showReadOnly) {
-                PWM_MAIN.clearDijitWidget(inputID + "readonly");
-                new dijit.form.CheckBox({
-                    checked: PWM_VAR['clientSettingCache'][keyName][iteration]['readonly'],
-                    onChange: function () {
-                        PWM_VAR['clientSettingCache'][keyName][iteration]['readonly'] = this.checked;
-                        FormTableHandler.write(keyName)
-                    }
-                }, inputID + "readonly");
-            }
+        if (showUnique) {
+            PWM_MAIN.getObject(inputID + "unique").checked = currentValue['unique'];
+            PWM_MAIN.addEventHandler(inputID + "unique", "change", function () {
+                currentValue['unique'] = PWM_MAIN.getObject(inputID + "unique").checked;
+                FormTableHandler.write(keyName)
+            });
+        }
 
-            if (showUnique) {
-                PWM_MAIN.clearDijitWidget(inputID + "unique");
-                new dijit.form.CheckBox({
-                    checked: PWM_VAR['clientSettingCache'][keyName][iteration]['unique'],
-                    onChange: function () {
-                        PWM_VAR['clientSettingCache'][keyName][iteration]['unique'] = this.checked;
-                        FormTableHandler.write(keyName)
-                    }
-                }, inputID + "unique");
-            }
+        if (showMultiValue) {
+            PWM_MAIN.getObject(inputID + "multivalue").checked = currentValue['multivalue'];
+            PWM_MAIN.addEventHandler(inputID + "multivalue", "change", function () {
+                currentValue['multivalue'] = PWM_MAIN.getObject(inputID + "multivalue").checked;
+                FormTableHandler.write(keyName)
+            });
+        }
 
-            if (showMultiValue) {
-                PWM_MAIN.clearDijitWidget(inputID + "multivalue");
-                new dijit.form.CheckBox({
-                    checked: PWM_VAR['clientSettingCache'][keyName][iteration]['multivalue'],
-                    onChange: function () {
-                        PWM_VAR['clientSettingCache'][keyName][iteration]['multivalue'] = this.checked;
-                        FormTableHandler.write(keyName)
-                    }
-                }, inputID + "multivalue");
-            }
+        if (!hideStandardOptions) {
+            PWM_MAIN.getObject(inputID + "minimumLength").value = currentValue['minimumLength'];
+            PWM_MAIN.addEventHandler(inputID + "minimumLength", "change", function(){
+                currentValue['minimumLength'] = PWM_MAIN.getObject(inputID + "minimumLength").value;
+                FormTableHandler.write(keyName)
+            });
 
-            if (!hideStandardOptions) {
-                PWM_MAIN.clearDijitWidget(inputID + "minimumLength");
-                new dijit.form.NumberSpinner({
-                    value: PWM_VAR['clientSettingCache'][keyName][iteration]['minimumLength'],
-                    onChange: function () {
-                        PWM_VAR['clientSettingCache'][keyName][iteration]['minimumLength'] = this.value;
-                        FormTableHandler.write(keyName)
-                    },
-                    constraints: {min: 0, max: 65536},
-                    style: "width: 70px"
-                }, inputID + "minimumLength");
-
-                PWM_MAIN.clearDijitWidget(inputID + "maximumLength");
-                new dijit.form.NumberSpinner({
-                    value: PWM_VAR['clientSettingCache'][keyName][iteration]['maximumLength'],
-                    onChange: function () {
-                        PWM_VAR['clientSettingCache'][keyName][iteration]['maximumLength'] = this.value;
-                        FormTableHandler.write(keyName)
-                    },
-                    constraints: {min: 0, max: 65536},
-                    style: "width: 70px"
-                }, inputID + "maximumLength");
-
-                PWM_MAIN.clearDijitWidget(inputID + "regex");
-                new dijit.form.Textarea({
-                    value: PWM_VAR['clientSettingCache'][keyName][iteration]['regex'],
-                    onChange: function () {
-                        PWM_VAR['clientSettingCache'][keyName][iteration]['regex'] = this.value;
-                        FormTableHandler.write(keyName)
-                    }
-                }, inputID + "regex");
+            PWM_MAIN.getObject(inputID + "maximumLength").value = currentValue['maximumLength'];
+            PWM_MAIN.addEventHandler(inputID + "maximumLength", "change", function(){
+                currentValue['maximumLength'] = PWM_MAIN.getObject(inputID + "maximumLength").value;
+                FormTableHandler.write(keyName)
+            });
 
+            PWM_MAIN.getObject(inputID + "regex").value = currentValue['regex'];
+            PWM_MAIN.addEventHandler(inputID + "regex", "change", function(){
+                currentValue['regex'] = PWM_MAIN.getObject(inputID + "regex").value;
+                FormTableHandler.write(keyName)
+            });
 
-                PWM_MAIN.addEventHandler(inputID + 'regexErrors', 'click', function () {
-                    FormTableHandler.showRegexErrorsDialog(keyName, iteration);
-                });
+            PWM_MAIN.addEventHandler(inputID + 'regexErrors', 'click', function () {
+                FormTableHandler.showRegexErrorsDialog(keyName, iteration);
+            });
 
-                PWM_MAIN.clearDijitWidget(inputID + "placeholder");
-                new dijit.form.Textarea({
-                    value: PWM_VAR['clientSettingCache'][keyName][iteration]['placeholder'],
-                    onChange: function () {
-                        PWM_VAR['clientSettingCache'][keyName][iteration]['placeholder'] = this.value;
-                        FormTableHandler.write(keyName)
-                    }
-                }, inputID + "placeholder");
-
-                PWM_MAIN.clearDijitWidget(inputID + "javascript");
-                new dijit.form.Textarea({
-                    value: PWM_VAR['clientSettingCache'][keyName][iteration]['javascript'],
-                    onChange: function () {
-                        PWM_VAR['clientSettingCache'][keyName][iteration]['javascript'] = this.value;
-                        FormTableHandler.write(keyName)
-                    }
-                }, inputID + "javascript");
-            }
-        };
+            PWM_MAIN.getObject(inputID + "placeholder").value = currentValue['placeholder'];
+            PWM_MAIN.addEventHandler(inputID + "placeholder", "change", function(){
+                currentValue['placeholder'] = PWM_MAIN.getObject(inputID + "placeholder").value;
+                FormTableHandler.write(keyName)
+            });
 
-        PWM_MAIN.showDialog({
-            title: PWM_SETTINGS['settings'][keyName]['label'] + ' - ' + PWM_VAR['clientSettingCache'][keyName][iteration]['name'],
-            text:bodyText,
-            allowMove:true,
-            loadFunction:initDialogWidgets,
-            okAction:function(){
-                FormTableHandler.redraw(keyName);
-            }
-        });
+            PWM_MAIN.getObject(inputID + "javascript").value = currentValue['javascript'];
+            PWM_MAIN.addEventHandler(inputID + "javascript", "change", function(){
+                currentValue['javascript'] = PWM_MAIN.getObject(inputID + "javascript").value;
+                FormTableHandler.write(keyName)
+            });
+        }
+        if (showSource) {
+            var nodeID = inputID + 'source';
+            PWM_MAIN.JSLibrary.setValueOfSelectElement(nodeID,currentValue['source']);
+            PWM_MAIN.addEventHandler(nodeID,'change',function(){
+                var newValue = PWM_MAIN.JSLibrary.readValueOfSelectElement(nodeID);
+                currentValue['source'] = newValue;
+                FormTableHandler.write(keyName);
+            });
+        }
+    };
+
+    PWM_MAIN.showDialog({
+        title: PWM_SETTINGS['settings'][keyName]['label'] + ' - ' + currentValue['name'],
+        text:bodyText,
+        allowMove:true,
+        loadFunction:initFormElements,
+        okAction:function(){
+            FormTableHandler.redraw(keyName);
+        }
     });
 };
 

+ 16 - 0
src/main/webapp/public/resources/js/main.js

@@ -1350,6 +1350,22 @@ PWM_MAIN.JSLibrary.removeFromArray = function(array,element) {
     }
 };
 
+PWM_MAIN.JSLibrary.readValueOfSelectElement = function(nodeID) {
+    var element = document.getElementById(nodeID);
+    var stringValue = element.options[element.selectedIndex].value;
+    return stringValue;
+};
+
+PWM_MAIN.JSLibrary.setValueOfSelectElement = function(nodeID, value) {
+    var element = document.getElementById(nodeID);
+    for(var i=0; i < element.options.length; i++) {
+        if (element.options[i].value === value) {
+            element.selectedIndex = i;
+            break;
+        }
+    }
+};
+
 PWM_MAIN.toggleFullscreen = function(iconObj,divName) {
     var obj = PWM_MAIN.getObject(divName);