From 1613eb8f94050ebd51f6b3f5f1ce8b8bd8211f8e Mon Sep 17 00:00:00 2001 From: patrick Date: Sat, 14 Nov 2020 17:35:02 +1100 Subject: [PATCH] add debounce to click copoy to next week, add save all to all jobs , right click to clear all unsaved' --- css/bts_office.css | 14 ++++---- html/timesheet_canvas_v1.html | 2 +- js/bts_office.js | 64 ++++++++++++++++++++++++----------- ts.php | 14 ++++---- 4 files changed, 59 insertions(+), 35 deletions(-) diff --git a/css/bts_office.css b/css/bts_office.css index 440e442..16a50bc 100644 --- a/css/bts_office.css +++ b/css/bts_office.css @@ -614,14 +614,14 @@ div.week2 > div { } .week2color { - color: white; + color: black; - /* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#627d4d+0,1f3b08+100;Olive+3D */ - background: #627d4d; /* Old browsers */ - background: -moz-linear-gradient(top, #627d4d 0%, #1f3b08 100%); /* FF3.6-15 */ - background: -webkit-linear-gradient(top, #627d4d 0%,#1f3b08 100%); /* Chrome10-25,Safari5.1-6 */ - background: linear-gradient(to bottom, #627d4d 0%,#1f3b08 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#627d4d', endColorstr='#1f3b08',GradientType=0 ); /* IE6-9 */ + /* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#a7ca8c+0,1f3b08+100;Olive+3D */ + background: #a7ca8c; /* Old browsers */ + background: -moz-linear-gradient(top, #a7ca8c 0%, #9de165 100%); /* FF3.6-15 */ + background: -webkit-linear-gradient(top, #a7ca8c 0%,#9de165 100%); /* Chrome10-25,Safari5.1-6 */ + background: linear-gradient(to bottom, #a7ca8c 0%,#9de165 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a7ca8c', endColorstr='#9de165',GradientType=0 ); /* IE6-9 */ } div.assignment > div { diff --git a/html/timesheet_canvas_v1.html b/html/timesheet_canvas_v1.html index 7c9130f..6634a22 100644 --- a/html/timesheet_canvas_v1.html +++ b/html/timesheet_canvas_v1.html @@ -157,7 +157,7 @@
- +
diff --git a/js/bts_office.js b/js/bts_office.js index 2fc3b32..15f58e5 100644 --- a/js/bts_office.js +++ b/js/bts_office.js @@ -254,7 +254,7 @@ } function filter_user(input){ - var value = $(input).attr('value'); + var value = $(input).val(); value = value.toLowerCase(); var selector = get_selector_for_filter_people(input); $.each( $(selector).find('div.peopleitem'), function(index, e){ @@ -885,7 +885,7 @@ } get_ack() { - return this.el.find('div.bconfirmed input:checked').length > 0? 1:0; + return this.el.find('div.bconfirmed input:checked').length > 0? 'true':0; } set_ack(val) { @@ -1495,9 +1495,14 @@ }); - $('div.week1 > div').click(function(e){ + $('div.week1 > div').click(copy_to_next_week); + function copy_to_next_week (e){ e.stopPropagation(); - blink_same_date_by_div(this); + debounced_copy_to_next_week(e, this); + } + + var debounced_copy_to_next_week = debounce(function (e, self) { + blink_same_date_by_div(self); if ($('div.bstart.blink_me').length == 0){ alert("nothing to copy"); return; @@ -1514,8 +1519,9 @@ }); show_jobs(new_jobs); unblink_all_date(); - alert("Copied " + new_jobs.length + " jobs"); - }); + //alert("Copied " + new_jobs.length + " jobs"); + }, 500); + $('div.week1,div.week2').click(function(e){ e.stopPropagation(); @@ -1794,6 +1800,8 @@ } }); + $('div.jobTable').show();//show non-week1 and none-week2 + filter_workspace(staffs, clients); filter_workspace_by_weeks(); debounced_calculate(); @@ -1876,14 +1884,14 @@ if (hide_week1 && hide_week2 ){ alert("You are hiding both weeks"); - $('div.jobTable').show();//show non-week1 and none-week2 + //$('div.jobTable').show();//show non-week1 and none-week2 $('div.jobTable.week1job,div.jobTable.week2job').hide(); //hide week1 or week2; }else if (hide_week1){ - $('div.jobTable:not(.week1job)').show();//show non-week1 + //$('div.jobTable:not(.week1job)').show();//show non-week1 $('div.jobTable.week1job').hide(); //hide week1; }else if (hide_week2){ $('div.jobTable.week2job').hide(); //show non-week2 - $('div.jobTable:not(.week2job)').show(); //hide week2 + //$('div.jobTable:not(.week2job)').show(); //hide week2 } } @@ -1971,6 +1979,7 @@ } function find_driving_partner_job(selector){ + return false; if (typeof $(selector).attr('data-parent') != "undefined" && $(selector).attr('data-parent') !="") return $(selector).attr('data-parent'); @@ -1989,9 +1998,9 @@ } }); if (matches.length != 1){ - $(selector).find('.bstart').addClass("error"); - $(selector).find(".bstart_err").html("No matched driving Job"); - ensure_visible(selector); + //$(selector).find('.bstart').addClass("error"); + //$(selector).find(".bstart_err").html("No matched driving Job"); + //ensure_visible(selector); console.warn("1 driving job has more than 1 matching", $(selector).attr('id'), matches); return false; } @@ -2335,14 +2344,14 @@ }); init_ts(); - $('div.divTableHeading div.bsave span.ticon-search').mouseenter(function(){//highlight unsaved + $('div.divTableHeading div.bsave span.ticon-save').mouseenter(function(){//highlight unsaved var el = $('div.jobTable.dirty .bsave'); if (el.length > 0){ el.addClass('blink_me'); el.get(0).scrollIntoView(); } }) - $('div.divTableHeading div.bsave span.ticon-search').mouseleave(function(){//highlight unsaved + $('div.divTableHeading div.bsave span.ticon-save').mouseleave(function(){//highlight unsaved var el = $('div.jobTable.dirty .bsave'); if (el.length > 0 ) { el.removeClass('blink_me'); @@ -2357,9 +2366,25 @@ el.removeClass('to_be_deleted_duplicate'); }); - $('div.divTableHeading div.bsave span.ticon-search').click(do_delete_unsaved_copy); - function do_delete_unsaved_copy() - { //TODO: remove this search function + $('div.divTableHeading div.bsave span.ticon-save').click(save_unsaved_copy); + function save_unsaved_copy(event) + { + event.preventDefault(); + var num = $('div.jobTable.dirty').length; + if (num > 0){ + if ( !confirm('save all '+ num + ' jobs?')){ + return; + } + $('div.jobTable.dirty').each(function(){ + $(this).find('span.ticon.ticon-save').trigger('click'); + }) + }else{ + alert("nothing to save"); + } + } + $('div.divTableHeading div.bsave span.ticon-save').contextmenu(function(event){ + //clearn all unsaved jobs. + event.preventDefault(); var num = $('div.jobTable.dirty').length; if (num > 0){ if ( !confirm('delete all '+ num + ' unsaved?')){ @@ -2372,9 +2397,8 @@ }) }else{ alert("nothing to clean up"); - } - } - + } + }); /*________________________________________________________________________*/ }); })(jQuery); diff --git a/ts.php b/ts.php index 22eb504..0bdc532 100644 --- a/ts.php +++ b/ts.php @@ -19,7 +19,7 @@ require_once (ABSPATH . 'wp-includes/pluggable.php'); class AcareOffice{ private $acare_ndis_registration = "4050024758"; private $nonce; //for ajax verification - private $pages = array('time-sheets', 'user-list'); + //private $pages = array('time-sheets', 'user-list'); private $bts_user_id = 0; private $bts_week_id = 1; //week 1, we will try to calculate current week; private $xero ; @@ -363,7 +363,7 @@ class AcareOffice{ //no auto login is required if reach here. $current = wp_get_current_user(); if ($this->is_admin($current)){ - wp_redirect("/time-sheets/"); + wp_redirect("/office/"); return; } @@ -406,7 +406,7 @@ class AcareOffice{ //no auto login is required if reach here. $current = wp_get_current_user(); if ($this->is_admin($current)){ - wp_redirect("/time-sheets/"); + wp_redirect("/office/"); return; } if (!$this->is_client($current) && ! $this->is_admin($current)) @@ -679,10 +679,10 @@ class AcareOffice{ $map = array(); foreach($tosarray as $item){ $map[$item->code] = $item->id; - if ( $item->year ==2019) { - $newid = $nd->get_id_by_tos($item->code, 20200325); + if ( $item->year ==20200325) { + $newid = $nd->get_id_by_tos($item->code, 20200701); if ($newid != 0){ - echo "UPDATE wp1m_acare_ts SET tos=$newid WHERE tos= $item->id and id > 0 and start>='2020-03-25 00:00:00'; \n" ; + echo "UPDATE wp1m_acare_ts SET tos=$newid WHERE tos= $item->id and id > 0 and start>='2020-07-01 00:00:00'; \n" ; } } //echo "UPDATE wp1m_acare_ts SET tos_id=$item->id WHERE tos='$item->code' and id > 0; \n"; @@ -894,7 +894,7 @@ ZOT; 'login' => $s->user_login, 'firstname'=> $s->first_name, 'lastname'=> $s->last_name, - 'display_name' => $s->display_name, + 'display_name' => str_replace("/", "/ ", $s->display_name), 'mobile'=> get_user_meta($s->ID, 'mobile', true), 'email'=> $s->user_email, 'wages'=> 0,