Added calendar select functionality.
This commit is contained in:
parent
d4594bd583
commit
e0f49c1d54
1 changed files with 38 additions and 1 deletions
|
@ -1051,7 +1051,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
height: _getCalendarHeight(),
|
||||
editable: true,
|
||||
firstDay: 1, // Monday
|
||||
snapDuration: '00:15:00',
|
||||
snapDuration: '00:30:00',
|
||||
timeFormat: 'h:mm A',
|
||||
slotLabelFormat : 'h(:mm) A',
|
||||
allDayText: EALang.all_day,
|
||||
|
@ -1063,6 +1063,43 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
right: 'agendaDay,agendaWeek,month'
|
||||
},
|
||||
|
||||
// Selectable
|
||||
selectable: true,
|
||||
selectHelper: true,
|
||||
select: function(start, end, jsEvent, view) {
|
||||
if (!start.hasTime() || !end.hasTime()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#insert-appointment').trigger('click');
|
||||
|
||||
// Preselect service & provider.
|
||||
if ($('#select-filter-item option:selected').attr('type') === FILTER_TYPE_SERVICE) {
|
||||
var service = GlobalVariables.availableServices.find(function (service) {
|
||||
return service.id == $('#select-filter-item').val()
|
||||
});
|
||||
$('#select-service').val(service.id).trigger('change');
|
||||
|
||||
} else {
|
||||
var provider = GlobalVariables.availableProviders.find(function (provider) {
|
||||
return provider.id == $('#select-filter-item').val();
|
||||
});
|
||||
|
||||
var service = GlobalVariables.availableServices.find(function (service) {
|
||||
return provider.services.indexOf(service.id) !== -1
|
||||
});
|
||||
|
||||
$('#select-service').val(service.id).trigger('change');
|
||||
$('#select-provider').val(provider.id).trigger('change');
|
||||
}
|
||||
|
||||
// Preselect time
|
||||
$('#start-datetime').datepicker('setDate', new Date(start.format('YYYY-MM-DD HH:mm:ss')));
|
||||
$('#end-datetime').datepicker('setDate', new Date(end.format('YYYY-MM-DD HH:mm:ss')));
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
// Translations
|
||||
monthNames: [EALang.january, EALang.february, EALang.march, EALang.april,
|
||||
EALang.may, EALang.june, EALang.july, EALang.august,
|
||||
|
|
Loading…
Reference in a new issue