Merge branch 'main' into feature-fixStats
This commit is contained in:
@ -158,7 +158,7 @@ async function getAvailabilities(userId) {
|
||||
...item,
|
||||
startTime: item.startTime.toISOString(),
|
||||
endTime: item.endTime.toISOString(),
|
||||
name: common.getTimeFomatted(item.startTime) + "-" + common.getTimeFomatted(item.endTime),
|
||||
name: common.getTimeFormatted(item.startTime) + "-" + common.getTimeFormatted(item.endTime),
|
||||
//endDate can be null
|
||||
endDate: item.endDate ? item.endDate.toISOString() : null,
|
||||
type: 'availability',
|
||||
@ -214,7 +214,7 @@ async function getAvailabilities(userId) {
|
||||
endTime: item.shift.endTime.toISOString(),
|
||||
// name: item.shift.publishers.map(p => p.firstName + " " + p.lastName).join(", "),
|
||||
//name: item.shift.assignments.map(a => a.publisher.firstName[0] + " " + a.publisher.lastName).join(", "),
|
||||
name: common.getTimeFomatted(new Date(item.shift.startTime)) + "-" + common.getTimeFomatted(new Date(item.shift.endTime)),
|
||||
name: common.getTimeFormatted(new Date(item.shift.startTime)) + "-" + common.getTimeFormatted(new Date(item.shift.endTime)),
|
||||
type: 'assignment',
|
||||
//delete shift object
|
||||
shift: null,
|
||||
@ -614,7 +614,7 @@ function convertShiftDates(assignments) {
|
||||
}
|
||||
|
||||
|
||||
async function getCalendarEvents(publisherId, date, availabilities = true, assignments = true) {
|
||||
async function getCalendarEvents(publisherId, availabilities = true, assignments = true, includeUnpublished = false) {
|
||||
const result = [];
|
||||
// let pubs = await filterPublishers("id,firstName,lastName,email".split(","), "", date, assignments, availabilities, date ? true : false, publisherId);
|
||||
|
||||
@ -647,6 +647,7 @@ async function getCalendarEvents(publisherId, date, availabilities = true, assig
|
||||
assignments: {
|
||||
select: {
|
||||
id: true,
|
||||
// publisherId: true,
|
||||
shift: {
|
||||
select: {
|
||||
id: true,
|
||||
@ -665,7 +666,7 @@ async function getCalendarEvents(publisherId, date, availabilities = true, assig
|
||||
publisher.availabilities?.forEach(item => {
|
||||
result.push({
|
||||
...item,
|
||||
title: common.getTimeFomatted(new Date(item.startTime)) + "-" + common.getTimeFomatted(new Date(item.endTime)), //item.name,
|
||||
title: common.getTimeFormatted(new Date(item.startTime)) + "-" + common.getTimeFormatted(new Date(item.endTime)), //item.name,
|
||||
date: new Date(item.startTime),
|
||||
startTime: new Date(item.startTime),
|
||||
endTime: new Date(item.endTime),
|
||||
@ -681,23 +682,21 @@ async function getCalendarEvents(publisherId, date, availabilities = true, assig
|
||||
//only published shifts
|
||||
|
||||
publisher.assignments?.filter(
|
||||
assignment => assignment.shift.isPublished
|
||||
assignment => assignment.shift.isPublished || includeUnpublished
|
||||
).forEach(item => {
|
||||
result.push({
|
||||
...item,
|
||||
title: common.getTimeFomatted(new Date(item.shift.startTime)) + "-" + common.getTimeFomatted(new Date(item.shift.endTime)),
|
||||
title: common.getTimeFormatted(new Date(item.shift.startTime)) + "-" + common.getTimeFormatted(new Date(item.shift.endTime)),
|
||||
date: new Date(item.shift.startTime),
|
||||
startTime: new Date(item.shift.startTime),
|
||||
endTime: new Date(item.shift.endTime),
|
||||
publisherId: item.publisherid,
|
||||
// publisherId: item.publisherId,
|
||||
publisherId: publisher.id,
|
||||
type: "assignment",
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user