fix copy availabilities button functionality. when editing manually, the flag is set back to false;
This commit is contained in:
@ -212,7 +212,7 @@ export default function AvailabilityForm({ publisherId, existingItems, inline, o
|
|||||||
availability.dayOfMonth = startTime.getDate();
|
availability.dayOfMonth = startTime.getDate();
|
||||||
availability.endDate = null;
|
availability.endDate = null;
|
||||||
}
|
}
|
||||||
|
availability.isFromPreviousMonth = false;
|
||||||
availability.dateOfEntry = new Date();
|
availability.dateOfEntry = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,6 +402,10 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
|
|||||||
// orange-500 from Tailwind CSS
|
// orange-500 from Tailwind CSS
|
||||||
backgroundColor = '#f56565';
|
backgroundColor = '#f56565';
|
||||||
}
|
}
|
||||||
|
if (event.isFromPreviousMonth) {
|
||||||
|
//gray
|
||||||
|
backgroundColor = '#a0aec0';
|
||||||
|
}
|
||||||
if (event.isActive) {
|
if (event.isActive) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case 'assignment':
|
case 'assignment':
|
||||||
|
@ -30,7 +30,7 @@ export default async function handler(req, res) {
|
|||||||
|
|
||||||
var action = req.query.action;
|
var action = req.query.action;
|
||||||
var filter = req.query.filter;
|
var filter = req.query.filter;
|
||||||
let day: Date, monthInfo: any;
|
let day: Date;
|
||||||
let isExactTime;
|
let isExactTime;
|
||||||
if (req.query.date) {
|
if (req.query.date) {
|
||||||
day = new Date(req.query.date);
|
day = new Date(req.query.date);
|
||||||
@ -42,6 +42,7 @@ export default async function handler(req, res) {
|
|||||||
isExactTime = true;
|
isExactTime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let monthInfo = common.getMonthDatesInfo(day);
|
||||||
const searchText = req.query.searchText?.normalize('NFC');
|
const searchText = req.query.searchText?.normalize('NFC');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -220,6 +221,7 @@ export default async function handler(req, res) {
|
|||||||
|
|
||||||
res.status(200).json(shiftsForDate);
|
res.status(200).json(shiftsForDate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "copyOldAvailabilities":
|
case "copyOldAvailabilities":
|
||||||
//get all publishers that don't have availabilities for the current month
|
//get all publishers that don't have availabilities for the current month
|
||||||
monthInfo = common.getMonthDatesInfo(day);
|
monthInfo = common.getMonthDatesInfo(day);
|
||||||
@ -283,12 +285,12 @@ export default async function handler(req, res) {
|
|||||||
type: AvailabilityType.Monthly,
|
type: AvailabilityType.Monthly,
|
||||||
isFromPreviousMonth: true,
|
isFromPreviousMonth: true,
|
||||||
name: avail.name || "старо предпочитание",
|
name: avail.name || "старо предпочитание",
|
||||||
// parentAvailabilityId: avail.id
|
parentAvailabilityId: avail.id,
|
||||||
parentAvailability: {
|
// parentAvailability: {
|
||||||
connect: {
|
// connect: {
|
||||||
id: avail.id
|
// id: avail.id
|
||||||
}
|
// }
|
||||||
}
|
// },
|
||||||
}
|
}
|
||||||
await prisma.availability.create({ data: data });
|
await prisma.availability.create({ data: data });
|
||||||
|
|
||||||
@ -331,7 +333,6 @@ export default async function handler(req, res) {
|
|||||||
|
|
||||||
case "updateShifts":
|
case "updateShifts":
|
||||||
//get all shifts for the month and publish them (we pass date )
|
//get all shifts for the month and publish them (we pass date )
|
||||||
let monthInfo = common.getMonthDatesInfo(day);
|
|
||||||
let isPublished = common.parseBool(req.query.isPublished);
|
let isPublished = common.parseBool(req.query.isPublished);
|
||||||
let updated = await prisma.shift.updateMany({
|
let updated = await prisma.shift.updateMany({
|
||||||
where: {
|
where: {
|
||||||
|
@ -88,6 +88,7 @@ async function getAvailabilities(userId) {
|
|||||||
name: true,
|
name: true,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
isFromPreviousAssignment: true,
|
isFromPreviousAssignment: true,
|
||||||
|
isFromPreviousMonth: true,
|
||||||
dayofweek: true,
|
dayofweek: true,
|
||||||
dayOfMonth: true,
|
dayOfMonth: true,
|
||||||
startTime: true,
|
startTime: true,
|
||||||
|
Reference in New Issue
Block a user