@@ -31,7 +31,6 @@ $(document).ready(function () {
31
31
var api = '/api/v1' ;
32
32
var eventsData ;
33
33
34
- getCentres ( ) ;
35
34
36
35
$ ( '#filters' ) . show ( ) ;
37
36
@@ -81,6 +80,8 @@ $(document).ready(function () {
81
80
82
81
}
83
82
83
+ getCentres ( ) ;
84
+
84
85
function getCentre ( centreId ) {
85
86
$ . get ( `${ api } /centres/${ centreId } ` ) . done ( ( centreData ) => {
86
87
if ( centreData . success ) {
@@ -236,7 +237,6 @@ $(document).ready(function () {
236
237
const events = [ ] ;
237
238
const resources = [ ] ;
238
239
const colors = [ '#EB5667' , '#1E88E5' , '#B96BC6' , '#28B294' , '#FF8F00' , '#31C6C7' ] ;
239
- let batchColors = { } ;
240
240
let colorCounter = 0 ;
241
241
242
242
$ ( '#calendar' ) . remove ( ) ;
@@ -263,6 +263,7 @@ $(document).ready(function () {
263
263
id : room . id ,
264
264
title : room . name ,
265
265
eventColor : currentColor ,
266
+ capacity : room . capacity ,
266
267
centreId : room . centreId
267
268
} ) ;
268
269
$colors . append ( `
@@ -274,63 +275,39 @@ $(document).ready(function () {
274
275
} ) ;
275
276
276
277
$colors . append ( `
277
- <div class="col">
278
- </div>
279
- <div class="col">
280
- </div>
281
- ` ) ;
278
+ <div class="col">
279
+ </div>
280
+ <div class="col">
281
+ </div>
282
+ ` ) ;
282
283
283
284
$ . get ( `${ api } /centres/${ centre . id } /batches/?batch=${ getBatch } ` ) . done ( ( data ) => {
284
285
if ( data . success ) {
285
286
let batches = data . data ;
286
287
287
288
batches . forEach ( function ( batch ) {
288
-
289
- const $lectures = $ ( `#batch-${ batch . id } ` ) ;
290
- let lectures = batch . lectures . sort ( function ( batch1 , batch2 ) {
291
- return batch1 . id - batch2 . id ;
292
- } ) ;
289
+ let lectures = batch . lectures ;
293
290
lectures . forEach ( ( lecture ) => {
294
- let eventObject = {
295
- lectureId : lecture . id ,
296
- title : lecture . name ,
297
- batchCapacity : batch . size ,
298
- batchName : batch . name ,
299
- batchId : batch . id ,
300
- teacherId : batch . teacher . id ,
301
- teacherName : batch . teacher . name ,
302
- courseName : batch . course . name ,
303
- stick : true
304
- } ;
305
-
306
291
if ( lecture . startTime && lecture . endTime ) {
307
-
308
- events . push ( Object . assign ( { } , eventObject , {
292
+ events . push ( {
293
+ lectureId : lecture . id ,
294
+ title : lecture . name ,
309
295
start : moment . utc ( lecture . startTime ) ,
310
296
end : moment . utc ( lecture . endTime ) ,
297
+ stick : true ,
311
298
resourceId : lecture . roomId ,
312
- } ) ) ;
313
-
314
- } else {
315
- $lectures . append ( `
316
- <a id="lecture-${ lecture . id } " class="list-group-item" data-parent="#batch-${ batch . id } ">
317
- ${ lecture . name }
318
- </a>
319
- ` ) ;
320
-
321
- const $lecture = $ ( `#lecture-${ lecture . id } ` ) ;
322
-
323
- $lecture . data ( 'event' , Object . assign ( { } , eventObject , {
324
- hours : batch . hoursPerLecture !== null ? batch . hoursPerLecture : batch . course . hours ,
325
- start : moment ( ) . startOf ( 'day' ) ,
326
- defaultRoom : batch . roomId ,
327
- defaultTime : batch . defaultTime ,
328
- } ) ) ;
299
+ batchCapacity : batch . size ,
300
+ batchId : batch . id ,
301
+ batchName : batch . name ,
302
+ teacherId : batch . teacher . id ,
303
+ teacherName : batch . teacher . name ,
304
+ courseName : batch . course . name
305
+ } ) ;
329
306
}
330
307
} ) ;
331
308
332
309
} ) ;
333
- $ ( '#calendar' ) . css ( 'overflow-y' , 'scroll' ) ;
310
+
334
311
eventsData = events . slice ( ) ;
335
312
$ ( '#calendar' ) . fullCalendar ( {
336
313
// put your options and callbacks here
@@ -377,6 +354,7 @@ $(document).ready(function () {
377
354
groupByDateAndResource : true ,
378
355
dateIncrement : { days : 1 }
379
356
}
357
+
380
358
} ,
381
359
eventMouseover : function ( event , jsEvent , view ) {
382
360
var index = - 1 ;
@@ -399,9 +377,7 @@ $(document).ready(function () {
399
377
`
400
378
} ) . tooltip ( 'show' ) ;
401
379
}
402
-
403
380
} ) ;
404
-
405
381
} else {
406
382
$ . toast ( {
407
383
heading : 'Warning' ,
@@ -454,4 +430,4 @@ $(document).ready(function () {
454
430
console . log ( err )
455
431
} ) ;
456
432
}
457
- } )
433
+ } ) ;
0 commit comments