From 768cd79f51628c223a55a8d8e85269bad4d8a105 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Wed, 20 Feb 2019 15:53:01 +0000 Subject: [PATCH] Fixed user add to hide projects for client role. --- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/user_add.tpl | 23 ++++++++++++++++++----- WEB-INF/templates/user_edit.tpl | 2 +- user_add.php | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 8b2787ff..5d4037a5 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- {/if} {if $show_projects} + + {/if} diff --git a/WEB-INF/templates/user_edit.tpl b/WEB-INF/templates/user_edit.tpl index f9ec2334..2bba1842 100644 --- a/WEB-INF/templates/user_edit.tpl +++ b/WEB-INF/templates/user_edit.tpl @@ -135,8 +135,8 @@ function handleClientControl() { {/if} {if $show_projects} - + diff --git a/user_add.php b/user_add.php index cf233d5b..5696d28f 100644 --- a/user_add.php +++ b/user_add.php @@ -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'); -- 2.20.1
 Anuko Time Tracker 1.18.37.4742 | Copyright © Anuko | +  Anuko Time Tracker 1.18.37.4743 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/user_add.tpl b/WEB-INF/templates/user_add.tpl index 0741dc3e..c6dbaa7b 100644 --- a/WEB-INF/templates/user_add.tpl +++ b/WEB-INF/templates/user_add.tpl @@ -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() {
 
{$i18n.label.projects}: {$forms.userForm.projects.control}
{$i18n.label.required_fields}
 
 
{$i18n.label.projects}: {$forms.userForm.projects.control}