Skip to content

Commit 0dc2f8d

Browse files
authored
Update Necropsy Schedule fullcalendar library (#799)
* update necropsy schedule to full calendar 6 * fix typo * set a background color * fix location bug * refetch calendar events correctly * remove old fullcalendar
1 parent 7f94383 commit 0dc2f8d

1 file changed

Lines changed: 31 additions & 15 deletions

File tree

WNPRC_EHR/src/org/labkey/wnprc_ehr/pages/dataentry/NecropsySchedule.jsp

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
<%@ page import="org.labkey.webutils.api.json.JsonUtils" %>
1313
<%@ page import="org.labkey.wnprc_ehr.WNPRC_EHRController" %>
1414
<%@ page import="java.util.List" %>
15+
<%@ page import="org.labkey.api.view.template.ClientDependencies" %>
1516
<%@ page extends="org.labkey.api.jsp.JspBase" %>
1617

18+
<%!
19+
@Override
20+
public void addClientDependencies(ClientDependencies dependencies)
21+
{
22+
dependencies.add("fullcalendar");
23+
}
24+
%>
1725
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
18-
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.6.0/fullcalendar.css' />
19-
<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.6.0/fullcalendar.min.js'></script>
2026
<%--<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.6.0/fullcalendar.js'></script>--%>
2127
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
2228
<%--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css">--%>
@@ -327,26 +333,34 @@
327333
var necropsySuiteLookup = <%=necropsySuiteLookup%>;
328334
WebUtils.VM.necropsySuiteLookup = necropsySuiteLookup;
329335
330-
var $calendar = $('#calendar');
331336
$(document).ready(function() {
332-
$calendar.fullCalendar({
333-
header: {
334-
left: 'prev,next today',
337+
let calendarEl = document.getElementById('calendar');
338+
calendar = new FullCalendar.Calendar(calendarEl, {
339+
themeSystem: 'bootstrap',
340+
height: 800,
341+
initialView: 'dayGridMonth',
342+
headerToolbar: {
343+
left: 'prev,next,today',
335344
center: 'title',
336-
right: 'month,agendaWeek'
345+
right: 'dayGridMonth,timeGridWeek,timeGridDay'
337346
},
338-
events: function(startMoment, endMoment, timezone, callback) {
347+
eventSources: [{
348+
events: function (fetchInfo, callback) {
349+
console.log(" startStr " + fetchInfo.startStr);
350+
console.log(" endtStr " + moment(fetchInfo.startStr).format( "YYYY-MM-DD"));
351+
339352
WebUtils.API.selectRows("study", "Necropsy Schedule", {
340-
"date~gte": startMoment.format('Y-MM-DD'),
341-
"date~lte": endMoment.format('Y-MM-DD')
353+
"date~gte": moment(fetchInfo.startStr).format( "YYYY-MM-DD"),
354+
"date~lte": moment(fetchInfo.endStr).format( "YYYY-MM-DD")
342355
}).then(function(data) {
343356
var events = data.rows;
344357
345358
callback(events.map(function(row) {
346359
var eventObj = {
347360
title: row.animalid,
348361
start: row.date,
349-
rawRowData: row
362+
rawRowData: row,
363+
display: 'block'
350364
};
351365
352366
if (row.location in necropsySuiteLookup) {
@@ -356,9 +370,9 @@
356370
return eventObj;
357371
}))
358372
})
359-
},
373+
}}],
360374
eventClick: function(calEvent, jsEvent, view) {
361-
jQuery.each(calEvent.rawRowData, function(key, value) {
375+
jQuery.each(calEvent.event.extendedProps.rawRowData, function(key, value) {
362376
if (key in WebUtils.VM.taskDetails) {
363377
if (key == "date") {
364378
value = displayDate(value);
@@ -367,7 +381,8 @@
367381
}
368382
});
369383
}
370-
})
384+
},);
385+
calendar.render()
371386
});
372387
373388
@@ -670,6 +685,7 @@
670685
rowsToUpdate[0] = rowsToUpdate[0].map(function(row) {
671686
row.performedby = pathologistLookup[form.pathologist];
672687
row.assistant = pathologistLookup[form.assistant];
688+
row.location = form.location;
673689
674690
return row;
675691
});
@@ -682,7 +698,7 @@
682698
]);
683699
}).then(function() {
684700
// Refresh the calendar view.
685-
$calendar.fullCalendar('refetchEvents');
701+
calendar.refetchEvents();
686702
687703
WebUtils.VM.pendingRequestTable.rows.remove(WebUtils.VM.requestRowInForm);
688704

0 commit comments

Comments
 (0)