From f5eb90c0d3f077dc94fae3ad5bd2734a48ca2388 Mon Sep 17 00:00:00 2001 From: Marco R Date: Tue, 29 May 2018 11:35:17 +0200 Subject: [PATCH] Form field default value (for select input only) --- .../pwm/config/value/data/FormConfiguration.java | 3 +++ .../resources/password/pwm/i18n/Config.properties | 1 + server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp | 11 ++++++++++- .../public/resources/js/configeditor-settings-form.js | 11 +++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/password/pwm/config/value/data/FormConfiguration.java b/server/src/main/java/password/pwm/config/value/data/FormConfiguration.java index c74edfb67..e66a17604 100644 --- a/server/src/main/java/password/pwm/config/value/data/FormConfiguration.java +++ b/server/src/main/java/password/pwm/config/value/data/FormConfiguration.java @@ -132,6 +132,9 @@ public enum Source @Builder.Default private Map selectOptions = Collections.emptyMap(); + @Builder.Default + private String defaultValue = ""; + @Builder.Default private List mimeTypes = Arrays.asList( "image/gif", diff --git a/server/src/main/resources/password/pwm/i18n/Config.properties b/server/src/main/resources/password/pwm/i18n/Config.properties index c6cb1040b..1569b6bf7 100644 --- a/server/src/main/resources/password/pwm/i18n/Config.properties +++ b/server/src/main/resources/password/pwm/i18n/Config.properties @@ -161,6 +161,7 @@ Tooltip_FormOptions_LinkLabel=Label to be displayed that tells where the link wi Tooltip_FormOptions_LinkURL=Full url that you want to go to when the link is selected. Tooltip_Form_ShowInNewWindow=Choose if the link will e opened in a new browser window Tooltip_FormOptions_Placeholder=Placeholder text to display in the form field with the field is not populated with a value. +Tooltip_FormOptions_DefaultValue=Field default value. Tooltip_FormOptions_Javascript=Javascript to be added to the browser. This option is depreciated. Use 'Settings -> User Interface -> Look & Feel -> Embedded JavaScript' instead. Tooltip_FormOptions_MultiValue=Display multiple values of the attribute. VerificationMethodDetail_PREVIOUS_AUTH=This method is passed when a user has previously authenticated using their browser. There is no user interaction or display associated with this method. diff --git a/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp b/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp index b32109d43..aad197cdb 100644 --- a/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp +++ b/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp @@ -96,7 +96,16 @@ <% } else if (loopConfiguration.getType() == FormConfiguration.Type.select) { %> '; bodyText += ''; } } @@ -411,6 +416,12 @@ FormTableHandler.showOptionsDialog = function(keyName, iteration) { currentValue['javascript'] = PWM_MAIN.getObject(inputID + "javascript").value; FormTableHandler.write(keyName) }); + + PWM_MAIN.getObject(inputID + "defaultValue").value = currentValue['defaultValue'] ? currentValue['defaultValue'] : ''; + PWM_MAIN.addEventHandler(inputID + "defaultValue", "change", function(){ + currentValue['defaultValue'] = PWM_MAIN.getObject(inputID + "defaultValue").value; + FormTableHandler.write(keyName) + }); } if (showSource) { var nodeID = inputID + 'source';