Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {$gettext} from '../lib/gettext.js';
STUDIP.ready(function () {
//Event definitions:
jQuery(document).on(
'change',
'.room-search-form .criteria-selector',
function (event) {
STUDIP.Resources.addSearchCriteriaToRoomSearchWidget(
event.target
);
}
);
jQuery(document).on(
'click',
'.room-search-form .criteria-list .remove-icon',
function (event) {
STUDIP.Resources.removeSearchCriteriaFromRoomSearchWidget(
event.target
);
}
);
//permission list:
jQuery(document).on(
'click',
'.resource-permission-list-action.apply-to-all-action',
function (event) {
var table = jQuery('#RoomGroupCommonPermissionTable')[0];
var tr = jQuery(event.target).parents('tr')[0];
if (!tr) {
return;
}
var user_id = jQuery(tr).data('user_id');
STUDIP.Resources.addUserToPermissionList(user_id, table);
//Delete the row:
jQuery(tr).remove();
}
);
//Temporary permission list: Set the hidden checkbox to the state of the
//proxy checkbox:
jQuery(document).on('change', '#resource-temporary-permissions input.bulk-proxy', function () {
var bulk_checked = jQuery(this).prop('checked');
var bulk_indeterminate = jQuery(this).prop('indeterminate');
if (bulk_checked || bulk_indeterminate) {
jQuery('#resource-temporary-permissions input.bulk-datetime-enable').prop('checked', true);
} else {
jQuery('#resource-temporary-permissions input.bulk-datetime-enable').prop('checked', false);
}
});
//Dialog for adding/editing bookings:
if (jQuery('form.create-booking-form')) {
let time_option = jQuery('input[name="booking_style"]:checked').val();
if (!time_option) {
time_option = jQuery('input[name="booking_style"]').val();
}
STUDIP.Resources.moveTimeOptions(time_option);
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
}
//Set the date selector in the sidebar to the date from the session,
//if that is set and no date is set in the URL.
var date_set = false;
var url_param_string = window.location.search;
if (url_param_string) {
var url_params = new URLSearchParams(url_param_string);
if (url_params.get('defaultDate')) {
date_set = true;
}
}
if (!date_set) {
var date_input = jQuery('#booking-plan-jmpdate')[0];
if (date_input) {
var session_date_string = sessionStorage.getItem('booking_plan_date');
if (session_date_string) {
//The date string is in the format YYYY-MM-DD and has to be
//converted to the format DD.MM.YYYY.
var date_parts = session_date_string.split('-');
jQuery(date_input).val(date_parts[2] + '.' + date_parts[1] + '.' + date_parts[0]);
}
}
}
jQuery(document).on(
'click',
'.resource-category-properties-table .add-action',
STUDIP.Resources.addResourcePropertyToTable
);
jQuery(document).on(
'click',
'.resource-request-properties-table .add-action',
STUDIP.Resources.addPropertyToRequest
);
jQuery(document).on(
'click',
'.resource-category-properties-table .delete-action, .resource-request-properties-table .delete-action',
function (event) {
var row = jQuery(event.target).parents('tr')[0];
if (!row) {
return;
}
var property_id = jQuery(row).data('property_id');
//Enable the property in the "add property" select element:
var table = jQuery(row).parents('table')[0];
if (!table) {
return;
}
var select = jQuery(table).find('select.available-property-select')[0];
if (!select) {
select = jQuery(table).find('select.requestable-properties-select')[0];
if (!select) {
return;
}
}
var option = jQuery(select).find('option[value="' + property_id + '"]')[0];
if (!option) {
return;
}
jQuery(option).removeAttr('disabled');
//As a final step: delete the row:
jQuery(row).remove();
}
);
//Event handlers for the individual booking plan print view:
jQuery('#sidebar .colour-selector').draggable(
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
{
cursorAt: {
left: 28, top: 15
},
appendTo: 'body',
helper: function () {
var dragged_item = jQuery(
'<div class="dragged-colour"></div>'
);
jQuery(dragged_item).css(
{
backgroundColor: jQuery(this).css('background-color'),
width: jQuery(this).css('width'),
height: jQuery(this).css('height'),
zIndex: 1000
}
);
return dragged_item;
},
revert: true
}
);
jQuery(document).on(
'click',
'.colour-selector',
function (event) {
jQuery(event.target).children().click();
}
);
jQuery(document).on(
'change',
'.colour-selector input[type="color"]',
function (event) {
jQuery(event.target).parent().css(
'background-color',
jQuery(event.target).val()
);
}
);
jQuery(document).on(
'dragenter',
'.individual-booking-plan .appointment-booking-plan .schedule_entry',
function (event) {
jQuery(event.target).css('opacity', '0.7');
}
);
jQuery(document).on(
'dragleave',
'.individual-booking-plan .appointment-booking-plan .schedule_entry',
function (event) {
jQuery(event.target).css('opacity', '1.0');
}
);
jQuery(document).on(
'dragend',
'.dragged-colour',
function (event) {
jQuery(event.target).css(
{
'top': '0px',
'left': '0px'
}
);
}
);
jQuery('.schedule_entry').droppable(
{
drop: function (event, ui_element) {
event.preventDefault();
var booking_plan_entry = event.target;
var new_background_colour = jQuery(
ui_element.helper
).css('background-color');
jQuery(booking_plan_entry).css(
'background-color',
new_background_colour
);
jQuery(booking_plan_entry).find('dl').css(
{
backgroundColor: new_background_colour,
borderColor: new_background_colour
}
);
jQuery(booking_plan_entry).find('dt').css(
'background-color',
new_background_colour
);
}
}
);
//For the message functionality of the resource system:
jQuery(document).on(
'click',
'.resources_messages-form .selection-area .remove-icon',
function (event) {
jQuery(event.target).parent().remove();
}
);
//Handle the selection of room "sources":
jQuery(document).on(
'click',
'.resources_messages-form input[name="room_selection"]',
function (event) {
//Hide the select field or the search field depending
//on the room selection radio button:
var room_selection = jQuery(event.target).val();
if (room_selection == 'search') {
jQuery(
'.resources_messages-form select[name="clipboard_id"]'
).attr('disabled', 'disabled');
jQuery(
'.resources_messages-form input[name="room_name_parameter"]'
).removeAttr('disabled');
} else {
jQuery(
'.resources_messages-form input[name="room_name_parameter"]'
).attr('disabled', 'disabled');
jQuery(
'.resources_messages-form select[name="clipboard_id"]'
).removeAttr('disabled');
}
}
);
//Handle the selection of recipient "sources":
jQuery(document).on(
'click',
'.resources_messages-form input[name="recipient_selection"]',
function (event) {
var recipient_selection = jQuery(event.target).val();
if (recipient_selection == 'permission') {
jQuery('#RecipientMode_Booking').css('display', 'none');
jQuery('#RecipientMode_Permission').css('display', 'block');
} else {
jQuery('#RecipientMode_Permission').css('display', 'none');
jQuery('#RecipientMode_Booking').css('display', 'block');
}
}
)
//For the view resources/resource/assign:
jQuery(document).on(
'change',
'.create-booking-form .booking-type-selection select',
function (event) {
if (jQuery(event.target).prop('tagName') != 'SELECT') {
return;
}
var booking_type = jQuery(event.target).val();
var form = jQuery(event.target).parents('form')[0];
if (!form) {
return;
}
//Activate the correct text for the separable rooms option:
var separable_room_booking_spans = jQuery(form).find(
'label.separable-room-booking span'
);
for (var span of separable_room_booking_spans) {
var span_booking_type = jQuery(span).data('booking_type');
if (span_booking_type == booking_type) {
jQuery(span).css('display', 'inline');
} else {
jQuery(span).css('display', 'none');
}
}
//Activate the correct legend for the comment fieldset:
var comment_fieldset_legends = jQuery(form).find(
'fieldset.comment-fieldset legend'
);
for (var legend of comment_fieldset_legends) {
var legend_booking_type = jQuery(legend).data('booking_type');
if (legend_booking_type == booking_type) {
jQuery(legend).css('display', 'block');
} else {
jQuery(legend).css('display', 'none');
}
}
//Activate the correct booking_type 2 elements:
jQuery("*[data-booking_type='2']").each(function () {
if (booking_type == '2') {
jQuery(this).show();
} else {
jQuery(this).hide();
}
});
}
);
jQuery(document).on(
'change',
'input[name="booking_style"]',
function () {
STUDIP.Resources.moveTimeOptions($(this).val());
}
);
jQuery(document).on(
'change',
'.semester-time-option',
function () {
if (~$(this).attr('name').indexOf("begin")) {
$("#BookingStartDateInput").prop("disabled", true);
} else {
$("#RepetitionEndInput").prop("disabled", true);
$("#RepetitionEndInput").val($("input[name='semester_course_end_date']").val());
$("#HiddenRepetitionEndInput").prop("disabled", false);
$("#HiddenRepetitionEndInput").val($("input[name='semester_course_end_date']").val());
}
$(".semester-selector").parent().show();
}
);
jQuery(document).on(
'change',
'.manual-time-option',
function () {
if (~$(this).attr('name').indexOf("begin")) {
$("#BookingStartDateInput").prop("disabled", false);
} else {
$("#RepetitionEndInput").prop("disabled", false);
$("#HiddenRepetitionEndInput").prop("disabled", true);
}
if (!$("#BookingStartDateInput").prop("disabled")
&& !$("#RepetitionEndInput").prop("disabled")) {
$(".semester-selector").parent().hide();
}
}
);
jQuery(document).on(
'change',
'.manual-time-fields input[type="text"]',
function () {
var ds = $(this).val().split('.');
var d = new Date(ds[1] + '/' + ds[0] + '/' + ds[2]);
var day_numer = (d.getDay() || 7);
if ($(this).attr('id') == 'BookingStartDateInput') {
$("#begin_date-weekdays span").addClass('invisible');
$("#begin_date-weekdays #" + day_numer).removeClass('invisible');
var start_date_parts = jQuery(this).val().split('.');
var repetition_end_date_parts = jQuery("#RepetitionEndInput").val().split('.');
var start_date = new Date(
start_date_parts[2] + '-' + start_date_parts[1] + '-' + start_date_parts[0]
+ 'T00:00:00'
);
var repetition_end_date = new Date(
repetition_end_date_parts[2] + '-' + repetition_end_date_parts[1] + '-'
+ repetition_end_date_parts[0] + 'T00:00:00'
);
if (start_date > repetition_end_date
&& $("input[name='selected_end']:checked").val() != 'semester_course_end') {
$("#RepetitionEndInput").prop('defaultValue', $(this).val());
$("#RepetitionEndInput").val($(this).val()).trigger('change');
}
if (!$('#multiday').prop('checked')
|| $("#BookingEndDateInput").prop('defaultValue') ==
$("#BookingEndDateInput").val()) {
$("#BookingEndDateInput").prop('defaultValue', $(this).val());
$("#BookingEndDateInput").val($(this).val()).trigger('change');
}
updateRepeatEndSemesterByTimestamp(Math.floor(d / 1000));
} else if ($(this).attr('id') == 'BookingEndDateInput') {
$("#end_date-weekdays span").addClass('invisible');
$("#end_date-weekdays #" + day_numer).removeClass('invisible');
}
}
);
jQuery(document).on(
'change',
'input[name="begin_date"]',
function () {
if (!$('#multiday').prop('checked')) {
$('#end_date_section input').val($(this).val());
}
}
);
$(".new-clipboard-form #add-clipboard-button").removeAttr("disabled");
var selected_clipboard_id = $('.clipboard-selector').val();
$(".clipboard-area[data-id='" + selected_clipboard_id + "']").removeClass('invisible');
if ($(".clipboard-area[data-id='" + selected_clipboard_id + "']").find(".empty-clipboard-message").hasClass("invisible")) {
$("#clipboard-group-container").find('.widget-links').removeClass('invisible');
}
jQuery(document).on(
'.special-item-switch',
function () {
let checked = $(this).prop('checked');
jQuery(this).parent().next('.special-item-content').toggle(checked);
jQuery('.special-item-switch').trigger('change');
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
jQuery(document).on(
'change',
'select[name="special__time_range_semester_id"]',
function () {
var selected_option = $(this).find('option:selected');
if (selected_option) {
var begin = new Date(parseInt(selected_option.attr('data-begin') + '000'));
var end = new Date(parseInt(selected_option.attr('data-end') + '000'));
$('input[name="special__time_range_begin_date"]').val(
$.datepicker.formatDate('dd.mm.yy', begin)
);
$('input[name="special__time_range_end_date"]').val(
$.datepicker.formatDate('dd.mm.yy', end)
);
}
}
);
jQuery(document).on(
'click',
'.fc-button',
function () {
if ($(this).hasClass('fc-dayGridMonth-button')) {
updateViewURL('dayGridMonth')
} else if ($(this).hasClass('fc-timeGridWeek-button')) {
updateViewURL('timeGridWeek')
} else if ($(this).hasClass('fc-timeGridDay-button')) {
updateViewURL('timeGridDay')
} else if ($(this).hasClass('fc-today-button')
|| $(this).hasClass('fc-prev-button')
|| $(this).hasClass('fc-next-button')) {
updateDateURL();
}
}
);
jQuery(document).on(
'blur',
'.hasDatepicker',
function () {
var new_val = $(this).val();
switch ($(this).attr('name')) {
case 'permissions[begin_date][]':
case 'permissions[end_date][]':
case 'bulk_begin_date':
case 'bulk_end_date':
var now = new Date();
if (new_val.split('.').length === 1) {
$(this).val(new_val + '.' + ((now.getMonth() + 1) < 10 ? '0' + (now.getMonth() + 1) : (now.getMonth() + 1)) + '.' + now.getFullYear());
} else if (new_val.split('.').length === 2) {
$(this).val(new_val + '.' + now.getFullYear());
}
break;
case 'permissions[begin_time][]':
case 'permissions[end_time][]':
case 'bulk_begin_time':
case 'bulk_end_time':
if (new_val.split(':').length === 1) {
$(this).val(new_val + ':00');
}
break;
}
}
);
jQuery(document).on(
'change blur',
'#resource-temporary-permission-bulk-datetime input',
function () {
var targets = '';
switch ($(this).attr('name')) {
case 'bulk_begin_date':
targets = 'permissions[begin_date][]';
break;
case 'bulk_begin_time':
targets = 'permissions[begin_time][]';
break;
case 'bulk_end_date':
targets = 'permissions[end_date][]';
break;
case 'bulk_end_time':
targets = 'permissions[end_time][]';
break;
}
var new_val = $(this).val();
$('.resource-temporary-permission-row input[name="' + targets + '"]').each(function () {
if ($(this).parents('tr').find('input[name="selected_permission_ids[]"]').prop('checked')) {
$(this).val(new_val);
}
});
}
);
function updateRepeatEndSemesterByTimestamp(timestamp, api_url = 'api.php/semesters') {
var semester = null;
jQuery.ajax(
STUDIP.URLHelper.getURL(api_url),
{
method: 'get',
dataType: 'json',
success: function (data) {
if (data) {
Object.values(data.collection).forEach(item => {
if (timestamp >= item.begin && timestamp < item.end) {
semester = item;
}
});
if (semester) {
$("#semester_course_name").text(semester.title);
$(".semester-time-option").prop('disabled', false);
} else {
if (data.pagination && data.pagination.links.next != api_url) {
semester = updateRepeatEndSemesterByTimestamp(timestamp, data.pagination.links.next);
} else {
$("#semester_course_name").text('außerhalb definierter Zeiten');
$(".semester-time-option").prop('checked', false);
$(".semester-time-option").prop('disabled', true);
$(".manual-time-option").prop('checked', true);
$(".manual-time-option").trigger('change');
}
}
}
}
}
);
}
function updateViewURL(defaultView) {
const url = new URL(window.location.href);
url.searchParams.set('defaultView', defaultView);
// Push current view url to history
history.pushState({}, null, url.toString());
// Set links accordingly
url.searchParams.delete('allday');
$('.booking-plan-std_view').attr('href', url.toString());
url.searchParams.set('allday', 1);
$('.booking-plan-allday_view').attr('href', url.toString());
function submitDatePicker() {
var picked = $('#booking-plan-jmpdate').val();
var iso_date_string = '';
if(picked) {
if (picked.includes('.')) {
let [day, month, year] = picked.split('.');
iso_date_string = year.padStart(4, "20") + '-' + month.padStart(2, "0") + '-' + day.padStart(2, "0");
} else if (picked.includes('/')) {
let [day, month, year] = picked.split('/');
iso_date_string = year.padStart(4, "20") + '-' + month.padStart(2, "0") + '-' + day.padStart(2, "0");
} else if (picked.includes('-')) {
iso_date_string = picked;
}
}
if (iso_date_string) {
$('*[data-resources-fullcalendar="1"]').each(function () {
this.calendar.gotoDate(iso_date_string);
});
updateDateURL();
}
}
let changedMoment;
$('[data-resources-fullcalendar="1"]').each(function () {
changedMoment = $(this)[0].calendar.getDate();
if (changedMoment) {
let changedDate = STUDIP.Fullcalendar.toRFC3339String(changedMoment).split('T')[0];
$('a.resource-bookings-actions').each(function () {
const url = new URL(this.href);
url.searchParams.set('timestamp', timeStamp)
url.searchParams.set('defaultDate', changedDate)
this.href = url.toString();
});
const url = new URL(window.location.href);
// Update url in history
history.pushState({}, null, url.toString());
// Adjust links accordingly
url.searchParams.delete('allday');
$('.booking-plan-std_view').attr('href', url.toString());
url.searchParams.set('allday', 1);
$('.booking-plan-allday_view').attr('href', url.toString());
// Update sidebar value
$('#booking-plan-jmpdate').val(changedMoment.toLocaleDateString('de-DE'));
//Store the date in the sessionStorage:
jQuery('#booking-plan-jmpdate').datepicker(
{
dateFormat: 'dd.mm.yy',
onClose: submitDatePicker
}
);
jQuery('.resource-booking-time-fields input[type="date"]').datepicker(
{
dateFormat: 'yy-mm-dd'
}
);
jQuery('.resource-plan[data-resources-fullcalendar="1"]').each(function () {
STUDIP.loadChunk('fullcalendar').then(() => {
//Get the default date from the sessionStorage, if it is set
//and no date is specified in the url.
let use_session_date = true;
let url_param_string = window.location.search;
let url_params = new URLSearchParams(url_param_string);
if (url_params.get('defaultDate')) {
use_session_date = false;
}
}
if (this.calendar === undefined) {
if (jQuery(this).hasClass('semester-plan')) {
STUDIP.Fullcalendar.createSemesterCalendarFromNode(
{
loading: function (isLoading) {
if (!isLoading) {
let h = jQuery('section.studip-fullcalendar-header');
if (h) {
jQuery(h).removeClass('invisible');
jQuery(h).insertBefore(this);
}
}
}
}
);
} else {
studip_functions: {
drop_event:
STUDIP.Resources.dropEventInRoomGroupBookingPlan,
resize_event:
STUDIP.Resources.resizeEventInRoomGroupBookingPlan
},
loading: function (isLoading) {
if (!isLoading) {
let h = jQuery('section.studip-fullcalendar-header');
if (h) {
jQuery(h).removeClass('invisible');
jQuery(h).insertBefore(this);
}
}
}
};
if (use_session_date) {
let session_date_string = sessionStorage.getItem('booking_plan_date');
if (session_date_string) {
config.defaultDate = session_date_string;
}
}
STUDIP.Fullcalendar.createFromNode(this, config);
}
}
});
});
//Check if an individual booking plan is to be displayed:
jQuery('.individual-booking-plan[data-resources-fullcalendar="1"]').each(function () {
STUDIP.loadChunk('fullcalendar').then(() => {
STUDIP.Fullcalendar.createFromNode(
eventPositioned: function (info) {
jQuery(info.el).droppable({
drop: function (event, ui_element) {
event.preventDefault();
let booking_plan_entry = event.target;
let new_background_colour = jQuery(
ui_element.helper
).css('background-color');
jQuery(booking_plan_entry).css(
'background-color',
new_background_colour
);
jQuery(booking_plan_entry).css(
'border-color',
new_background_colour
);
jQuery(booking_plan_entry).find('dl').css({
backgroundColor: new_background_colour,
borderColor: new_background_colour
});
jQuery(booking_plan_entry).find('dt').css(
'background-color',
new_background_colour
);
}
});
let h = jQuery('section.studip-fullcalendar-header').clone();
if (h) {
jQuery(h).removeClass('invisible');
jQuery(h).insertBefore(this);
}
}
}
);
});
});
jQuery(document).on(
'click',
Moritz Strohm
committed
'.delete-assigned-user-icon',
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
function (event) {
var quicksearch = jQuery(event.target).parent().find('input');
if (!quicksearch) {
return;
}
jQuery(quicksearch).val('');
}
);
jQuery(document).on(
'click',
'.request-list .request-marking-icon',
function (event) {
event.preventDefault();
STUDIP.Resources.toggleRequestMarked(event.target);
}
);
$(document).on(
'click',
"button[name='bulk-book-requests']",
function (event) {
STUDIP.Dialog.confirm(
$gettext('Wollen Sie die im Plan gezeigten Anfragen wirklich buchen?')
).done(function () {
STUDIP.Resources.bookAllCalendarRequests();
});
}
);
$(document).on('click', '.fc-request-event',
function () {
var parent_table_row = $(this).closest('tr');
if($(parent_table_row).length) {
$(parent_table_row).toggleClass('resource-planning-selected-request')
}
var objectData = $(this).data();
var eventData = {
id: objectData.eventId,
title: objectData.eventTitle,
start: objectData.eventBegin,
end: objectData.eventEnd,
studip_weekday_begin: objectData.eventStudip_weekday_begin,
studip_weekday_end: objectData.eventStudip_weekday_end,
request_id: objectData.eventRequest,
tooltip: objectData.eventTooltip,
studip_api_urls: {},
studip_view_urls: {edit: objectData.eventView_urls_edit},
editable: false,
color: objectData.eventColor,
textColor: '#000'
};
var calendarSektion = $('*[data-resources-fullcalendar="1"]')[0];
if (calendarSektion) {
var calendar = calendarSektion.calendar;
if (calendar && eventData) {
var existingRequestEvent = calendar.getEventById(eventData.id);
if (existingRequestEvent) {
existingRequestEvent.remove();
var remainingRequestEvents = 0;
$('.fc-request-event').each(function () {
if (calendar.getEventById($(this).data().eventId)) {
remainingRequestEvents++;
}
});
if (remainingRequestEvents < 1) {
$("button[name='bulk-book-requests']").prop('disabled', true);
}
} else {
STUDIP.Fullcalendar.convertSemesterEvents(eventData, calendar.getDate().toString());
var overlap = false;
var checkStart = new Date(eventData.start);
var checkEnd = new Date(eventData.end);
$(calendar.getEvents()).each(function () {
// start-time in between any of the events
if ((checkStart >= this.start && checkStart < this.end)
//end-time in between any of the events
|| (checkEnd > this.start && checkEnd <= this.end)
//any of the events in between/on the start-time and end-time
|| (checkStart <= this.start && checkEnd >= this.end)) {
overlap = true
}
});
if (overlap) {
eventData.icon = 'exclaim-circle-full';
}
calendar.addEvent(eventData);
$("button[name='bulk-book-requests']").prop('disabled', false);
}
}
}
}
);
});
STUDIP.domReady(function() {
Moritz Strohm
committed
jQuery(document).on(
'click',
'.booking-list-interval .takes-place-status-toggle',
STUDIP.Resources.toggleBookingIntervalStatus
);
jQuery(document).on(
'click',
'.room-clipboard-group-action',
function (event) {
//Get the IDs of the rooms of the clipboard:
let active_clipboard = jQuery(event.target).parents("#clipboard-group-container").find(
'.clipboard-area:not(.invisible)'
)[0];
if (!active_clipboard) {
//Something is wrong with the HTML.
return;
}
let clipboard_id = jQuery(active_clipboard).data('id');
let show_in_dialog = jQuery(event.target).data('show_in_dialog');
let url_path = jQuery(event.target).attr('href');
url_path = url_path.replace(/CLIPBOARD_ID/, clipboard_id);
let complete_url = STUDIP.URLHelper.getURL(url_path);
if (show_in_dialog) {
//If we have collected at least one ID we can create a dialog
//displaying the comments of all the selected rooms:
STUDIP.Dialog.fromURL(
complete_url,
{
size: 'auto'