Fixed mobile user pages for client role.
authorNik Okuntseff <support@anuko.com>
Wed, 20 Feb 2019 16:09:57 +0000 (16:09 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 20 Feb 2019 16:09:57 +0000 (16:09 +0000)
WEB-INF/templates/footer.tpl
WEB-INF/templates/mobile/user_add.tpl
WEB-INF/templates/mobile/user_edit.tpl
mobile/user_add.php
mobile/user_edit.php

index 5d4037a..751fe2e 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.37.4743 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.37.4744 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index d23dcf9..1bde81b 100644 (file)
@@ -29,20 +29,31 @@ function setDefaultRate(element) {
   }
 }
 
-// handleClientControl - controls visibility of the client dropdown depending on the selected user role.
-// We need to show it only when the "Client" user role is selected.
+// handleClientControl - controls visibility of the client dropdown depending on the selected user role,
+// also hides and unselects projects when "Client" user role is selected.
 function handleClientControl() {
   var selectedRoleId = document.getElementById("role").value;
   var clientControl = document.getElementById("client");
+  var projectsControl = document.getElementById("projects_control");
+
   var len = roles.length;
   for (var i = 0; i < len; i++) {
     if (selectedRoleId == roles[i][0]) {
       var isClient = roles[i][1];
-      if (isClient == 1)
+      if (isClient == 1) {
         clientControl.style.visibility = "visible";
-      else {
-        clientControl.value = '';
+        projectsControl.style.display = "none";
+
+        // Uncheck all project checkboxes.
+        var checkboxes = document.getElementsByName("projects[]");
+        var j;
+        for (j = 0; j < checkboxes.length; j++) {
+          checkboxes[j].checked = false;
+        }
+      } else {
+        clientControl.value = "";
         clientControl.style.visibility = "hidden";
+        projectsControl.style.display = "";
       }
       break;
     }
@@ -90,6 +101,7 @@ function handleClientControl() {
     </tr>
 {/if}
 {if $show_projects}
+<tbody id="projects_control">
     <tr valign="top">
       <td align="right">{$i18n.label.projects}:</td>
       <td>{$forms.userForm.projects.control}</td>
@@ -97,6 +109,7 @@ function handleClientControl() {
     <tr>
       <td colspan="2" align="center">{$i18n.label.required_fields}</td>
     </tr>
+</tbody>
 {/if}
     <tr>
       <td colspan="2" align="center" height="50">{$forms.userForm.btn_submit.control}</td>
index 9929e72..6bddbb9 100644 (file)
@@ -51,20 +51,31 @@ function setRate(element) {
   }
 }
 
-// handleClientControl - controls visibility of the client dropdown depending on the selected user role.
-// We need to show it only when the "Client" user role is selected.
+// handleClientControl - controls visibility of the client dropdown depending on the selected user role,
+// also hides and unselects projects when "Client" user role is selected.
 function handleClientControl() {
   var selectedRoleId = document.getElementById("role").value;
   var clientControl = document.getElementById("client");
+  var projectsControl = document.getElementById("projects_control");
+
   var len = roles.length;
   for (var i = 0; i < len; i++) {
     if (selectedRoleId == roles[i][0]) {
       var isClient = roles[i][1];
-      if (isClient == 1)
+      if (isClient == 1) {
         clientControl.style.visibility = "visible";
-      else {
-        clientControl.value = '';
+        projectsControl.style.display = "none";
+
+        // Uncheck all project checkboxes.
+        var checkboxes = document.getElementsByName("projects[]");
+        var j;
+        for (j = 0; j < checkboxes.length; j++) {
+          checkboxes[j].checked = false;
+        }
+      } else {
+        clientControl.value = "";
         clientControl.style.visibility = "hidden";
+        projectsControl.style.display = "";
       }
       break;
     }
@@ -118,10 +129,12 @@ function handleClientControl() {
     </tr>
 {/if}
 {if $show_projects}
+<tbody id="projects_control">
     <tr valign="top">
       <td align="right">{$i18n.label.projects}:</td>
       <td>{$forms.userForm.projects.control}</td>
     </tr>
+</tbody>
 {/if}
     <tr>
       <td colspan="2" align="center">{$i18n.label.required_fields}</td>
index c821c7d..ed017de 100644 (file)
@@ -125,7 +125,7 @@ class RateCellRenderer extends DefaultCellRenderer {
 // Create projects table.
 $table = new Table('projects');
 $table->setIAScript('setDefaultRate');
-$table->setTableOptions(array('width'=>'100%','cellspacing'=>'1','cellpadding'=>'3','border'=>'0'));
+$table->setTableOptions(array('width'=>'250','cellspacing'=>'1','cellpadding'=>'3','border'=>'0'));
 $table->setRowOptions(array('valign'=>'top','class'=>'tableHeader'));
 $table->setData($projects);
 $table->setKeyField('id');
index 1e0845e..411586b 100644 (file)
@@ -145,7 +145,7 @@ class RateCellRenderer extends DefaultCellRenderer {
 // Create projects table.
 $table = new Table('projects');
 $table->setIAScript('setRate');
-$table->setTableOptions(array('width'=>'100%','cellspacing'=>'1','cellpadding'=>'3','border'=>'0'));
+$table->setTableOptions(array('width'=>'250','cellspacing'=>'1','cellpadding'=>'3','border'=>'0'));
 $table->setRowOptions(array('valign'=>'top','class'=>'tableHeader'));
 $table->setData($projects);
 $table->setKeyField('id');