mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-25 17:33:19 +03:00
Corrected time handling in working plan management components.
This commit is contained in:
parent
d24f0aea39
commit
faa911276e
1 changed files with 18 additions and 16 deletions
|
@ -48,8 +48,8 @@
|
||||||
$.each(workingPlan, function(index, workingDay) {
|
$.each(workingPlan, function(index, workingDay) {
|
||||||
if (workingDay != null) {
|
if (workingDay != null) {
|
||||||
$('#' + index).prop('checked', true);
|
$('#' + index).prop('checked', true);
|
||||||
$('#' + index + '-start').val(workingDay.start);
|
$('#' + index + '-start').val(Date.parse(workingDay.start).toString('h:mm tt').toUpperCase());
|
||||||
$('#' + index + '-end').val(workingDay.end);
|
$('#' + index + '-end').val(Date.parse(workingDay.end).toString('h:mm tt').toUpperCase());
|
||||||
|
|
||||||
// Add the day's breaks on the breaks table.
|
// Add the day's breaks on the breaks table.
|
||||||
$.each(workingDay.breaks, function(i, brk) {
|
$.each(workingDay.breaks, function(i, brk) {
|
||||||
|
@ -58,8 +58,8 @@
|
||||||
var tr =
|
var tr =
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<td class="break-day editable">' + GeneralFunctions.ucaseFirstLetter(day) + '</td>' +
|
'<td class="break-day editable">' + GeneralFunctions.ucaseFirstLetter(day) + '</td>' +
|
||||||
'<td class="break-start editable">' + brk.start + '</td>' +
|
'<td class="break-start editable">' + Date.parse(brk.start).toString('h:mm tt').toUpperCase() + '</td>' +
|
||||||
'<td class="break-end editable">' + brk.end + '</td>' +
|
'<td class="break-end editable">' + Date.parse(brk.end).toString('h:mm tt').toUpperCase() + '</td>' +
|
||||||
'<td>' +
|
'<td>' +
|
||||||
'<button type="button" class="btn btn-default btn-sm edit-break" title="' + EALang.edit + '">' +
|
'<button type="button" class="btn btn-default btn-sm edit-break" title="' + EALang.edit + '">' +
|
||||||
'<span class="glyphicon glyphicon-pencil"></span>' +
|
'<span class="glyphicon glyphicon-pencil"></span>' +
|
||||||
|
@ -172,8 +172,8 @@
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
|
|
||||||
if ($(this).prop('checked') == true) {
|
if ($(this).prop('checked') == true) {
|
||||||
$('#' + id + '-start').prop('disabled', false).val('09:00');
|
$('#' + id + '-start').prop('disabled', false).val('09:00 AM');
|
||||||
$('#' + id + '-end').prop('disabled', false).val('18:00');
|
$('#' + id + '-end').prop('disabled', false).val('18:00 PM');
|
||||||
} else {
|
} else {
|
||||||
$('#' + id + '-start').prop('disabled', true).val('');
|
$('#' + id + '-start').prop('disabled', true).val('');
|
||||||
$('#' + id + '-end').prop('disabled', true).val('');
|
$('#' + id + '-end').prop('disabled', true).val('');
|
||||||
|
@ -189,9 +189,9 @@
|
||||||
$('.add-break').click(function() {
|
$('.add-break').click(function() {
|
||||||
var tr =
|
var tr =
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<td class="break-day editable">' + EALang.monday + '</td>' +
|
'<td class="break-day editable">' + EALang.sunday + '</td>' +
|
||||||
'<td class="break-start editable">09:00</td>' +
|
'<td class="break-start editable">09:00 AM</td>' +
|
||||||
'<td class="break-end editable">10:00</td>' +
|
'<td class="break-end editable">10:00 AM</td>' +
|
||||||
'<td>' +
|
'<td>' +
|
||||||
'<button type="button" class="btn btn-default btn-sm edit-break" title="' + EALang.edit + '">' +
|
'<button type="button" class="btn btn-default btn-sm edit-break" title="' + EALang.edit + '">' +
|
||||||
'<span class="glyphicon glyphicon-pencil"></span>' +
|
'<span class="glyphicon glyphicon-pencil"></span>' +
|
||||||
|
@ -318,25 +318,27 @@
|
||||||
$('.working-plan input:checkbox').each(function(index, checkbox) {
|
$('.working-plan input:checkbox').each(function(index, checkbox) {
|
||||||
var id = $(checkbox).attr('id');
|
var id = $(checkbox).attr('id');
|
||||||
if ($(checkbox).prop('checked') == true) {
|
if ($(checkbox).prop('checked') == true) {
|
||||||
workingPlan[id] = {};
|
workingPlan[id] = {
|
||||||
workingPlan[id].start = $('#' + id + '-start').val();
|
start: Date.parse($('#' + id + '-start').val()).toString('HH:mm'),
|
||||||
workingPlan[id].end = $('#' + id + '-end').val();
|
end: Date.parse($('#' + id + '-end').val()).toString('HH:mm'),
|
||||||
workingPlan[id].breaks = [];
|
breaks: []
|
||||||
|
};
|
||||||
|
|
||||||
$('.breaks tr').each(function(index, tr) {
|
$('.breaks tr').each(function(index, tr) {
|
||||||
var day = this.convertDayToValue($(tr).find('.break-day').text());
|
var day = this.convertDayToValue($(tr).find('.break-day').text());
|
||||||
|
|
||||||
if (day == id) {
|
if (day == id) {
|
||||||
var start = $(tr).find('.break-start').text();
|
var start = $(tr).find('.break-start').text();
|
||||||
var end = $(tr).find('.break-end').text();
|
var end = $(tr).find('.break-end').text();
|
||||||
|
|
||||||
workingPlan[id].breaks.push({
|
workingPlan[id].breaks.push({
|
||||||
start: start,
|
start: Date.parse(start).toString('HH:mm'),
|
||||||
end: end
|
end: Date.parse(end).toString('HH:mm')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
workingPlan[id].breaks.sort(function(break1, break2) {
|
workingPlan[id].breaks.sort(function(break1, break2) {
|
||||||
// We can do a direct string comparison since we have time based on 24 hours clock
|
// We can do a direct string comparison since we have time based on 24 hours clock.
|
||||||
return break1.start - break2.start;
|
return break1.start - break2.start;
|
||||||
});
|
});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
Loading…
Reference in a new issue