Refactoring, moving plugin config options into config field.
[timetracker.git] / WEB-INF / templates / mobile / user_edit.tpl
index ecbff59..03c5db2 100644 (file)
@@ -51,25 +51,42 @@ 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 nonClientBlock = document.getElementById("non_client_block");
+  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
+        nonClientBlock.style.display = "none";
+        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";
+        nonClientBlock.style.display = "";
+        projectsControl.style.display = "";
+      }
       break;
     }
   }
 }
 </script>
 
+
 {$forms.userForm.open}
 <table cellspacing="4" cellpadding="7" border="0">
   <table cellspacing="1" cellpadding="2" border="0">
@@ -104,16 +121,26 @@ function handleClientControl() {
       <td align="right">{$i18n.label.status}:</td>
       <td>{$forms.userForm.status.control}</td>
     </tr>
+{/if}
+<tbody id="non_client_block">
+{if $show_quota}
+    <tr>
+      <td align="right">{$i18n.label.quota}&nbsp;(%):</td>
+      <td>{$forms.userForm.quota_percent.control}</td>
+    </tr>
 {/if}
     <tr>
       <td align="right">{$i18n.form.users.default_rate}&nbsp;(0{$user->decimal_mark}00):</td>
       <td>{$forms.userForm.rate.control}</td>
     </tr>
-{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+</tbody>
+{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>