hodooor / Hodoor

Server side for Hodoor - Casual attendance system
GNU General Public License v3.0
8 stars 6 forks source link

Frontend - Add Timepicker to Session page #44

Closed OndrejVicar closed 7 years ago

OndrejVicar commented 7 years ago

Time picker in swipe detail is great. It could be also used in Session table.

patriczek2811 commented 7 years ago

Yeah I know, thanks master, but there are two little problems...

  1. In session table, there are many of sub-tables included, so I would make a JS script that add time picker to all of time fields. It will be little bit harder to implement, like in swipe details.
  2. The Timepicker should only count down its value, user cannot overflow maximum time spend in work. So I don't know if there is this option in timepicker settings. Hope it is...
patriczek2811 commented 7 years ago

I found a solution, and made JS for this:

/*Add timepicker to this field*/
//separate max values
var separateTime = $('#id_time_spend').val().split(":");
var TimeHours = separateTime[0];
var TimeMinutes = separateTime[1];
var TimeSeconds = separateTime[2];
//add timepicker with options
$('#id_time_spend').datetimepicker({
  format: "HH:mm:ss",
  maxDate: moment({
    h:TimeHours,
    m:TimeMinutes,
    s:TimeSeconds
  })
});