Update for new time format

This commit is contained in:
Andrea 2018-04-12 16:15:18 +02:00
parent 7d8746f40a
commit 721df5833d

View file

@ -99,16 +99,16 @@
if (extraWorkingDay != null) { if (extraWorkingDay != null) {
$('#' + index).prop('checked', true); $('#' + index).prop('checked', true);
$('#' + index + '-start').val(Date.parse(extraWorkingDay.start).toString(GlobalVariables.timeFormat).toUpperCase()); $('#' + index + '-start').val(Date.parse(extraWorkingDay.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
$('#' + index + '-end').val(Date.parse(extraWorkingDay.end).toString(GlobalVariables.timeFormat).toUpperCase()); $('#' + index + '-end').val(Date.parse(extraWorkingDay.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
var day = GeneralFunctions.formatDate(Date.parse(index), GlobalVariables.dateFormat, false); var day = GeneralFunctions.formatDate(Date.parse(index), GlobalVariables.dateFormat, false);
var tr = var tr =
'<tr>' + '<tr>' +
'<td class="extra-day editable">' + day + '</td>' + '<td class="extra-day editable">' + day + '</td>' +
'<td class="extra-start editable">' + Date.parse(extraWorkingDay.start).toString(GlobalVariables.timeFormat).toUpperCase() + '</td>' + '<td class="extra-start editable">' + Date.parse(extraWorkingDay.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase()).toUpperCase() + '</td>' +
'<td class="extra-end editable">' + Date.parse(extraWorkingDay.end).toString(GlobalVariables.timeFormat).toUpperCase() + '</td>' + '<td class="extra-end editable">' + Date.parse(extraWorkingDay.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase()).toUpperCase() + '</td>' +
'<td>' + '<td>' +
'<button type="button" class="btn btn-default btn-sm edit-extra" title="' + EALang.edit + '">' + '<button type="button" class="btn btn-default btn-sm edit-extra" title="' + EALang.edit + '">' +
'<span class="glyphicon glyphicon-pencil"></span>' + '<span class="glyphicon glyphicon-pencil"></span>' +
@ -220,8 +220,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(GlobalVariables.timeFormat === 'regular' ? '9:00 AM' : '09:00'); $('#' + id + '-start').prop('disabled', false).val('9:00 AM');
$('#' + id + '-end').prop('disabled', false).val(GlobalVariables.timeFormat === 'regular' ? '6:00 PM' : '18:00'); $('#' + id + '-end').prop('disabled', false).val('6: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('');
@ -238,8 +238,8 @@
var tr = var tr =
'<tr>' + '<tr>' +
'<td class="break-day editable">' + EALang.sunday + '</td>' + '<td class="break-day editable">' + EALang.sunday + '</td>' +
'<td class="break-start editable">' + (GlobalVariables.timeFormat === 'regular' ? '9:00 AM' : '09:00') + '</td>' + '<td class="break-start editable">9:00 AM</td>' +
'<td class="break-end editable">' + (GlobalVariables.timeFormat === 'regular' ? '10:00 AM' : '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>' +
@ -343,7 +343,7 @@
end = Date.parse($modifiedRow.find('.break-end input').val()); end = Date.parse($modifiedRow.find('.break-end input').val());
if (start > end) { if (start > end) {
$modifiedRow.find('.break-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat)); $modifiedRow.find('.break-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm'));
} }
this.enableSubmit = true; this.enableSubmit = true;
@ -366,8 +366,8 @@
var tr = var tr =
'<tr>' + '<tr>' +
'<td class="extra-day editable">' + today + '</td>' + '<td class="extra-day editable">' + today + '</td>' +
'<td class="extra-start editable">' + ((GlobalVariables.timeFormat === 'h:mm tt') ? '9:00 AM' : '09:00') + '</td>' + '<td class="extra-start editable">' + (GlobalVariables.timeFormat === 'regular' ? '9:00 AM' : '09:00').toUpperCase() + '</td>' +
'<td class="extra-end editable">' + ((GlobalVariables.timeFormat === 'h:mm tt') ? '10:00 AM' : '10:00') + '</td>' + '<td class="extra-end editable">' + (GlobalVariables.timeFormat === 'regular' ? '10:00 AM' : '10:00').toUpperCase() + '</td>' +
'<td>' + '<td>' +
'<button type="button" class="btn btn-default btn-sm edit-extra" title="' + EALang.edit + '">' + '<button type="button" class="btn btn-default btn-sm edit-extra" title="' + EALang.edit + '">' +
'<span class="glyphicon glyphicon-pencil"></span>' + '<span class="glyphicon glyphicon-pencil"></span>' +
@ -410,7 +410,7 @@
// Make all cells in current row editable. // Make all cells in current row editable.
$(this).parent().parent().children().trigger('edit'); $(this).parent().parent().children().trigger('edit');
$(this).parent().parent().find('.extra-start input, .extra-end input').timepicker({ $(this).parent().parent().find('.extra-start input, .extra-end input').timepicker({
timeFormat: (GlobalVariables.timeFormat === 'h:mm tt') ? 'h:mm TT' : GlobalVariables.timeFormat, timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm',
currentText: EALang.now, currentText: EALang.now,
closeText: EALang.close, closeText: EALang.close,
timeOnlyTitle: EALang.select_time, timeOnlyTitle: EALang.select_time,
@ -509,7 +509,7 @@
end = Date.parse($modifiedRow.find('.extra-end input').val()); end = Date.parse($modifiedRow.find('.extra-end input').val());
if (start > end) { if (start > end) {
$modifiedRow.find('.extra-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat)); $modifiedRow.find('.extra-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
} }
this.enableSubmit = true; this.enableSubmit = true;
@ -599,7 +599,7 @@
if (disabled == false) { if (disabled == false) {
// Set timepickers where needed. // Set timepickers where needed.
$('.working-plan input:text').timepicker({ $('.working-plan input:text').timepicker({
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : GlobalVariables.timeFormat, timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm',
currentText: EALang.now, currentText: EALang.now,
closeText: EALang.close, closeText: EALang.close,
timeOnlyTitle: EALang.select_time, timeOnlyTitle: EALang.select_time,
@ -613,7 +613,7 @@
end = Date.parse($(this).parent().parent().find('.work-end').val()); end = Date.parse($(this).parent().parent().find('.work-end').val());
if (start > end) { if (start > end) {
$(this).parent().parent().find('.work-end').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : GlobalVariables.timeFormat)); $(this).parent().parent().find('.work-end').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm'));
} }
} }
}); });