roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [roller] 01/01: [ROL-2161] Allow user emails up to 255 characters and add validation to User Edit page.
Date Sat, 14 Mar 2020 22:05:59 GMT
This is an automated email from the ASF dual-hosted git repository.

snoopdave pushed a commit to branch ROL-2161
in repository https://gitbox.apache.org/repos/asf/roller.git

commit 31747ff65e02f5b4b480ceb478fa525bc3586f2b
Author: David M. Johnson <snoopdave@apache.org>
AuthorDate: Sat Mar 14 18:05:47 2020 -0400

    [ROL-2161] Allow user emails up to 255 characters and add validation to User Edit page.
---
 app/src/main/resources/struts.xml                  |  3 ++
 .../main/webapp/WEB-INF/jsps/admin/UserEdit.jsp    | 59 ++++++++++++++++++----
 .../main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp |  3 --
 app/src/main/webapp/WEB-INF/jsps/core/Register.jsp |  4 +-
 4 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/app/src/main/resources/struts.xml b/app/src/main/resources/struts.xml
index 63d5bb3..b52dbcc 100644
--- a/app/src/main/resources/struts.xml
+++ b/app/src/main/resources/struts.xml
@@ -221,6 +221,9 @@
             <param name="pageTitle">userAdmin.title.createNewUser</param>
             <result name="input" type="tiles">.UserEdit</result>
             <result name="success" type="tiles">.UserAdmin</result>
+            <result name="cancel" type="redirectAction">
+                <param name="actionName">userAdmin</param>
+            </result>
             <allowed-methods>execute,firstSave,save</allowed-methods>
         </action>
 
diff --git a/app/src/main/webapp/WEB-INF/jsps/admin/UserEdit.jsp b/app/src/main/webapp/WEB-INF/jsps/admin/UserEdit.jsp
index 9478e9c..f9c65a6 100644
--- a/app/src/main/webapp/WEB-INF/jsps/admin/UserEdit.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/admin/UserEdit.jsp
@@ -21,11 +21,9 @@
 <%-- Titling, processing actions different between add and edit --%>
 <s:if test="actionName == 'createUser'">
     <s:set var="subtitleKey">userAdmin.subtitle.createNewUser</s:set>
-    <s:set var="mainAction">createUser</s:set>
 </s:if>
 <s:else>
     <s:set var="subtitleKey">userAdmin.subtitle.editUser</s:set>
-    <s:set var="mainAction">modifyUser</s:set>
 </s:else>
 
 <p class="subtitle">
@@ -51,27 +49,27 @@
     </s:if>
 
     <s:if test="actionName == 'modifyUser'">
-        <s:textfield name="bean.userName" size="30" maxlength="30"
+        <s:textfield name="bean.userName" size="30" maxlength="30" onkeyup="formChanged()"
                 label="%{getText('userSettings.username')}"
                 tooltip="%{getText('userSettings.tip.username')}"
                 readonly="true" cssStyle="background: #e5e5e5" />
     </s:if>
     <s:else>
-        <s:textfield name="bean.userName" size="30" maxlength="30"
+        <s:textfield name="bean.userName" size="30" maxlength="30" onkeyup="formChanged()"
                 label="%{getText('userSettings.username')}"
                 tooltip="%{getText('userAdmin.tip.username')}" />
     </s:else>
 
-    <s:textfield name="bean.screenName" size="30" maxlength="30"
+    <s:textfield id="bean_userName" name="bean.screenName" size="30" maxlength="30" onkeyup="formChanged()"
                 label="%{getText('userSettings.screenname')}"
                 tooltip="%{getText('userAdmin.tip.screenName')}" />
 
-    <s:textfield name="bean.fullName" size="30" maxlength="30"
+    <s:textfield id="bean_fullName" name="bean.fullName" size="30" maxlength="30" onkeyup="formChanged()"
                  label="%{getText('userSettings.fullname')}"
                  tooltip="%{getText('userAdmin.tip.fullName')}" />
 
     <s:if test="authMethod == 'ROLLERDB' || authMethod == 'DB_OPENID'">
-        <s:password name="bean.password" size="30" maxlength="30"
+        <s:password name="bean.password" size="30" maxlength="30" onkeyup="formChanged()"
                      label="%{getText('userSettings.password')}"
                      tooltip="%{getText('userAdmin.tip.password')}" />
     </s:if>
@@ -82,7 +80,7 @@
                      tooltip="%{getText('userAdmin.tip.openIdUrl')}" />
     </s:if>
 
-    <s:textfield name="bean.emailAddress" size="30" maxlength="30"
+    <s:textfield id="bean_email" name="bean.emailAddress" size="30" maxlength="255" onkeyup="formChanged()"
                  label="%{getText('userSettings.email')}"
                  tooltip="%{getText('userAdmin.tip.email')}" />
 
@@ -153,8 +151,49 @@
     <br />
 
     <div class="control">
-        <s:submit cssClass="btn btn-default" value="%{getText('generic.save')}" action="%{#mainAction}!save"/>
-        <s:submit cssClass="btn" value="%{getText('generic.cancel')}" action="modifyUser!cancel"
/>
+        <s:if test="actionName == 'createUser'">
+            <s:submit cssClass="btn btn-default" id="save_button"
+                      value="%{getText('generic.save')}" action="createUser!save"/>
+            <s:submit cssClass="btn"
+                      value="%{getText('generic.cancel')}" action="createUser!cancel" />
+        </s:if>
+        <s:else>
+            <s:submit cssClass="btn btn-default" id="save_button"
+                      value="%{getText('generic.save')}" action="modifyUser!save"/>
+            <s:submit cssClass="btn"
+                      value="%{getText('generic.cancel')}" action="modifyUser!cancel" />
+        </s:else>
     </div>
 
 </s:form>
+
+
+<script>
+
+    document.forms[0].elements[0].focus();
+    let saveButton;
+
+    $( document ).ready(function() {
+        saveButton = $("#save_button");
+        formChanged()
+    });
+
+    function formChanged() {
+        let userName = $("#bean_userName:first").val();
+        let fullName = $("#bean_fullName:first").val();
+        let email = $("#bean_email:first").val();
+
+        let valid = (userName && userName.trim().length > 0
+            && fullName && fullName.trim().length > 0
+            && email && email.trim().length > 0
+            && validateEmail(email));
+
+        if (valid) {
+            saveButton.attr("disabled", false);
+        } else {
+            saveButton.attr("disabled", true);
+        }
+    }
+
+</script>
+
diff --git a/app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp b/app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp
index 88ca6f8..ebc9d34 100644
--- a/app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp
@@ -143,6 +143,3 @@
 
 </script>
 
-
-</script>
-
diff --git a/app/src/main/webapp/WEB-INF/jsps/core/Register.jsp b/app/src/main/webapp/WEB-INF/jsps/core/Register.jsp
index 6f8fcef..0667e3d 100644
--- a/app/src/main/webapp/WEB-INF/jsps/core/Register.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/core/Register.jsp
@@ -42,8 +42,6 @@
 
         </div>
 
-        <%-- <s:text name="userRegister.tip.userName" /> --%>
-
     </s:if>
     <s:else>
         <s:textfield label="%{getText('userSettings.username')}"
@@ -65,7 +63,7 @@
     <s:textfield label="%{getText('userSettings.email')}"
                  tooltip="%{getText('userRegister.tip.email')}"
                  onkeyup="onChange()"
-                 name="bean.emailAddress" size="40" maxlength="40" />
+                 name="bean.emailAddress" size="40" maxlength="255" />
 
     <s:if test="authMethod != 'LDAP'">
 


Mime
View raw message