X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=WEB-INF%2Ftemplates%2Fmobile%2Fuser_add.tpl;h=9df99ff0000b1ed981dca0c7ea95c6efac367a4b;hb=265754c2f6e9d016e7f58591f08fe4e97f96b05d;hp=9fe22314cac26c99949c688d281d2537ef4b9f97;hpb=fec361583dcdb716abd921ca19f68c9d6e98b9f0;p=timetracker.git diff --git a/WEB-INF/templates/mobile/user_add.tpl b/WEB-INF/templates/mobile/user_add.tpl index 9fe22314..9df99ff0 100644 --- a/WEB-INF/templates/mobile/user_add.tpl +++ b/WEB-INF/templates/mobile/user_add.tpl @@ -29,19 +29,35 @@ 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 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; } } @@ -77,25 +93,29 @@ function handleClientControl() {