[freeside-commits] branch master updated. ded6a5654efd56d2f271970c992133600e0223b1

Christopher Burger burgerc at freeside.biz
Wed Aug 29 11:10:29 PDT 2018


The branch, master has been updated
       via  ded6a5654efd56d2f271970c992133600e0223b1 (commit)
      from  5df83a73541d983c51eff47e875cf63fc45e53ff (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ded6a5654efd56d2f271970c992133600e0223b1
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Aug 29 14:09:58 2018 -0400

    RT# 75817 - updated UI to be more intuitive

diff --git a/httemplate/edit/cust_main-contacts.html b/httemplate/edit/cust_main-contacts.html
index 76929a7c9..3783cb9e9 100644
--- a/httemplate/edit/cust_main-contacts.html
+++ b/httemplate/edit/cust_main-contacts.html
@@ -4,6 +4,19 @@ Hmm, this is now entirely redundant with edit/cust_main/contacts_new.html, and
 this one isn't being maintained well.  :/
 
 </%doc>
+
+  <SCRIPT>
+function checkPasswordValidation(fieldid)  {
+  var validationResult = document.getElementById(fieldid+'_result').innerHTML;
+  if (validationResult.match(/Password valid!/)) {
+    return true;
+  }
+  else {
+    return false;
+  }
+}
+</SCRIPT>
+
 <& elements/edit.html,
      'name_singular'    => 'customer contacts', #yes, we're editing all of them
      'table'            => 'cust_main',
diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html
index 43e520155..85cecd0af 100644
--- a/httemplate/elements/contact.html
+++ b/httemplate/elements/contact.html
@@ -40,6 +40,8 @@
 %         }
 %       } elsif ( $field eq 'emailaddress' ) {
 %         $value = join(', ', map $_->emailaddress, $contact->contact_email);
+%       } elsif ( $field eq 'password' ) {
+%          $value = $contact->get('_password') ? '********' : '';
 %       } elsif ( $field eq 'selfservice_access'
 %              or $field eq 'comment'
 %              or $field eq 'invoice_dest'
@@ -56,7 +58,7 @@
                     ID   = "<%$id%>_<%$field%>"
                     STYLE = "width: 140px"
             >
-              <OPTION VALUE="">Disabled
+              <OPTION VALUE="" <% !$value ? 'SELECTED' : '' %>>Disabled
 %             if ( $value || $self_base_url ) {
                 <OPTION VALUE="<% $value eq 'Y' ? 'Y' : 'E' %>" <% $value eq 'Y' ? 'SELECTED' : '' %>>Enabled
 %               if ( $value eq 'Y' && $self_base_url ) {
@@ -65,18 +67,33 @@
 %               }
 %             }
             </SELECT>
-                  <& /elements/change_password.html,
-                   'contact_num'         => $curr_value,
-                   'custnum'             => $opt{'custnum'},
-                   'curr_value'          => '',
-                   'no_label_display'    => '1',
-                   'noformtag'           => '1',
-                   'pre_pwd_field_label' => $id.'_',
-                  &>
+% #password form
+%         } elsif ( $field eq 'password') {
+            <INPUT TYPE  = "text"
+                   NAME  = "<%$name%>_<%$field%>"
+                   ID    = "changepw<%$id%>_<%$field%>"
+                   SIZE  = "<% $size{$field} || 14 %>"
+                   VALUE = ""
+                   placeholder = "<% $value |h %>"
+            >
+%           my $contactnum = $curr_value ? $curr_value : '0';
+            <& '/elements/validate_password.html',
+             'fieldid'    => "changepw".$id."_password",
+             'svcnum'     => '',
+             'contactnum' => $contactnum,
+             'submitid'   => "submit",
+           &>
+
             <SCRIPT TYPE="text/javascript">
-                    document.getElementById("<%$id%>_<%$field%>").onchange = function() {
-                      if (this.value == "P" || this.value == "E") { changepw<%$id%>_toggle(true); }
-                      return false
+                    var selfService = document.getElementById("<%$id%>_selfservice_access").value;
+
+                    if (selfService !== "Y") { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
+                    document.getElementById("<%$id%>_selfservice_access").onchange = function() {
+                      if (this.value == "P" || this.value == "E" || this.value =="Y") {
+                        document.getElementById("changepw<%$id%>_password").disabled = '';
+                      }
+                      else { document.getElementById("changepw<%$id%>_password").disabled = 'true'; }
+                      return false;
                     }
             </SCRIPT>
 %         } elsif ( $field eq 'invoice_dest' || $field eq 'message_dest' ) {
@@ -101,6 +118,9 @@
 %         }
           <BR>
           <FONT SIZE="-1"><% $label{$field} %></FONT>
+%       if ( $field eq 'password' ) {
+          <div id="changepw<%$id%>_<%$field%>_result"></div>
+%       }
         </TD>
 %     }
     </TR>
@@ -171,6 +191,7 @@ unless ($opt{'for_prospect'}) {
   $label{'invoice_dest'} = 'Send invoices';
   $label{'message_dest'} = 'Send messages';
   $label{'selfservice_access'} = 'Self-service';
+  $label{'password'} = 'Password';
 }
 
 my $first = 0;
diff --git a/httemplate/elements/validate_password.html b/httemplate/elements/validate_password.html
index 4057f5d3f..73c0db281 100644
--- a/httemplate/elements/validate_password.html
+++ b/httemplate/elements/validate_password.html
@@ -29,7 +29,7 @@ function add_password_validation (fieldid, submitid) {
     // some browsers allow the enter key to submit a form even if the submit button is disabled
     // below prevents enter key from submiting form if password has not been validated.
     if (key == '13') {
-      var check = checkPasswordValidation();
+      var check = checkPasswordValidation(fieldid);
       return check;
     }
   }
@@ -61,6 +61,7 @@ function add_password_validation (fieldid, submitid) {
       );
     } else {
       resultfield.innerHTML = '';
+      if (submitid){ document.getElementById(submitid).disabled = false; }
     }
   };
 }
diff --git a/httemplate/misc/xmlhttp-validate_password.html b/httemplate/misc/xmlhttp-validate_password.html
index 4d9716bb9..c53abe883 100644
--- a/httemplate/misc/xmlhttp-validate_password.html
+++ b/httemplate/misc/xmlhttp-validate_password.html
@@ -28,14 +28,14 @@ my $validate_password = sub {
   $result{'syserror'} = 'Invoked without password' unless $password;
   return \%result if $result{'syserror'};
 
-  if ($arg{'contactnum'}) {
+  if ($arg{'contactnum'} =~ /^\d+$/) {
     my $contactnum = $arg{'contactnum'};
     $result{'syserror'} = 'Invalid contactnum' unless $contactnum =~ /^\d*$/;
     return \%result if $result{'syserror'};
 
     my $contact = $contactnum 
       ? qsearchs('contact',{'contactnum' => $contactnum})
-      : '';
+      : (new FS::contact {});
 
     $result{'error'} = $contact->is_password_allowed($password);
   }

-----------------------------------------------------------------------

Summary of changes:
 httemplate/edit/cust_main-contacts.html        | 13 ++++++++
 httemplate/elements/contact.html               | 45 +++++++++++++++++++-------
 httemplate/elements/validate_password.html     |  3 +-
 httemplate/misc/xmlhttp-validate_password.html |  4 +--
 4 files changed, 50 insertions(+), 15 deletions(-)




More information about the freeside-commits mailing list