Fixed user add to hide projects for client role.
authorNik Okuntseff <support@anuko.com>
Wed, 20 Feb 2019 15:53:01 +0000 (15:53 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 20 Feb 2019 15:53:01 +0000 (15:53 +0000)
WEB-INF/templates/footer.tpl
WEB-INF/templates/user_add.tpl
WEB-INF/templates/user_edit.tpl
user_add.php

index 8b2787f..5d4037a 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.4742 | 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.4743 | 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 0741dc3..c6dbaa7 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,11 +101,13 @@ function handleClientControl() {
     </tr>
 {/if}
 {if $show_projects}
+<tbody id="projects_control">
     <tr><td>&nbsp;</td></tr>
     <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 f9ec233..2bba184 100644 (file)
@@ -135,8 +135,8 @@ function handleClientControl() {
     </tr>
 {/if}
 {if $show_projects}
-    <tr><td>&nbsp;</td></tr>
 <tbody id="projects_control">
+    <tr><td>&nbsp;</td></tr>
     <tr valign="top">
       <td align="right">{$i18n.label.projects}:</td>
       <td>{$forms.userForm.projects.control}</td>
index cf233d5..5696d28 100644 (file)
@@ -126,7 +126,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'=>'300','cellspacing'=>'1','cellpadding'=>'3','border'=>'0'));
 $table->setRowOptions(array('valign'=>'top','class'=>'tableHeader'));
 $table->setData($projects);
 $table->setKeyField('id');