From: Nik Okuntseff Date: Wed, 20 Feb 2019 16:09:57 +0000 (+0000) Subject: Fixed mobile user pages for client role. X-Git-Tag: timetracker_1.19-1~306 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2c7be66d72e7f745903e08f49f8d9ab12def1c2d;p=timetracker.git Fixed mobile user pages for client role. --- diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 5d4037a5..751fe2e2 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- {/if} {if $show_projects} + @@ -97,6 +109,7 @@ function handleClientControl() { + {/if} diff --git a/WEB-INF/templates/mobile/user_edit.tpl b/WEB-INF/templates/mobile/user_edit.tpl index 9929e727..6bddbb99 100644 --- a/WEB-INF/templates/mobile/user_edit.tpl +++ b/WEB-INF/templates/mobile/user_edit.tpl @@ -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() { {/if} {if $show_projects} + + {/if} diff --git a/mobile/user_add.php b/mobile/user_add.php index c821c7d4..ed017de8 100644 --- a/mobile/user_add.php +++ b/mobile/user_add.php @@ -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'); diff --git a/mobile/user_edit.php b/mobile/user_edit.php index 1e0845e1..411586bd 100644 --- a/mobile/user_edit.php +++ b/mobile/user_edit.php @@ -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');
 Anuko Time Tracker 1.18.37.4743 | Copyright © Anuko | +  Anuko Time Tracker 1.18.37.4744 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/mobile/user_add.tpl b/WEB-INF/templates/mobile/user_add.tpl index d23dcf93..1bde81b1 100644 --- a/WEB-INF/templates/mobile/user_add.tpl +++ b/WEB-INF/templates/mobile/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,6 +101,7 @@ function handleClientControl() {
{$i18n.label.projects}: {$forms.userForm.projects.control}
{$i18n.label.required_fields}
{$forms.userForm.btn_submit.control}
{$i18n.label.projects}: {$forms.userForm.projects.control}
{$i18n.label.required_fields}