Merge pull request #205 from dderbentsov/UC-165
Добавлены проверки времени при создании и редактировании событий
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
:owners-data="employeesData",
|
:owners-data="employeesData",
|
||||||
:selected-event-data="selectedEvent",
|
:selected-event-data="selectedEvent",
|
||||||
:event-types="eventTypes",
|
:event-types="eventTypes",
|
||||||
|
:time-information="timeInformation",
|
||||||
@clear-selected-event-data="clearSelectedEvent",
|
@clear-selected-event-data="clearSelectedEvent",
|
||||||
@close-change-form="setChangeFormState"
|
@close-change-form="setChangeFormState"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export default {
|
|||||||
start[1] * this.pixelsPerMinute;
|
start[1] * this.pixelsPerMinute;
|
||||||
if (
|
if (
|
||||||
parseInt(start[0], 10) < this.dayStartTime ||
|
parseInt(start[0], 10) < this.dayStartTime ||
|
||||||
parseInt(end, 10) >= this.dayEndTime
|
parseInt(end, 10) > this.dayEndTime
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
top: "0px",
|
top: "0px",
|
||||||
|
|||||||
@@ -105,6 +105,12 @@ export default {
|
|||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
timeInformation: {
|
||||||
|
type: Object,
|
||||||
|
default() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -268,6 +274,75 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
checkTimeLimits(eventTime, scheduleTime, timeType) {
|
||||||
|
if (timeType === "start")
|
||||||
|
return (
|
||||||
|
parseInt(eventTime.split(":")[0]) <
|
||||||
|
parseInt(scheduleTime.split(":")[0])
|
||||||
|
);
|
||||||
|
if (timeType === "end") {
|
||||||
|
let firstTime = eventTime.split(":").map((elem) => parseInt(elem));
|
||||||
|
let secondTime = scheduleTime.split(":").map((elem) => parseInt(elem));
|
||||||
|
if (firstTime[0] === secondTime[0]) return firstTime[1] > secondTime[1];
|
||||||
|
else return firstTime[0] > secondTime[0];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
checkTime() {
|
||||||
|
let counter = 0;
|
||||||
|
if (
|
||||||
|
this.checkTimeLimits(
|
||||||
|
this.startTime,
|
||||||
|
this.timeInformation.dayStartTime,
|
||||||
|
"start"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
this.addErrorNotification(
|
||||||
|
"Некорректное время начала события",
|
||||||
|
"Время начала события раньше начала рабочего дня"
|
||||||
|
);
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
this.checkTimeLimits(
|
||||||
|
this.endTime,
|
||||||
|
this.timeInformation.dayEndTime,
|
||||||
|
"end"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
this.addErrorNotification(
|
||||||
|
"Некорректное время окончания события",
|
||||||
|
"Время окончания события позже окончания рабочего дня"
|
||||||
|
);
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
this.checkTimeLimits(
|
||||||
|
this.endTime,
|
||||||
|
this.timeInformation.dayStartTime,
|
||||||
|
"start"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
this.addErrorNotification(
|
||||||
|
"Некорректное время окончания события",
|
||||||
|
"Время окончания события раньше начала рабочего дня"
|
||||||
|
);
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
this.checkTimeLimits(
|
||||||
|
this.startTime,
|
||||||
|
this.timeInformation.dayEndTime,
|
||||||
|
"end"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
this.addErrorNotification(
|
||||||
|
"Некорректное время начала события",
|
||||||
|
"Время начала события позже окончания рабочего дня"
|
||||||
|
);
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
return counter === 0;
|
||||||
|
},
|
||||||
trimOwnerName(lastName, firsName, patronymic) {
|
trimOwnerName(lastName, firsName, patronymic) {
|
||||||
return `${lastName} ${firsName[0]}.${patronymic[0]}.`;
|
return `${lastName} ${firsName[0]}.${patronymic[0]}.`;
|
||||||
},
|
},
|
||||||
@@ -275,6 +350,7 @@ export default {
|
|||||||
return `${lastName} ${firsName} ${patronymic}`;
|
return `${lastName} ${firsName} ${patronymic}`;
|
||||||
},
|
},
|
||||||
async sendEventData() {
|
async sendEventData() {
|
||||||
|
if (!this.checkTime()) return;
|
||||||
this.eventData = {
|
this.eventData = {
|
||||||
start: this.mergeDate(this.eventDate, this.startTime),
|
start: this.mergeDate(this.eventDate, this.startTime),
|
||||||
end: this.mergeDate(this.eventDate, this.endTime),
|
end: this.mergeDate(this.eventDate, this.endTime),
|
||||||
@@ -288,6 +364,7 @@ export default {
|
|||||||
this.eventData = {};
|
this.eventData = {};
|
||||||
},
|
},
|
||||||
async updateEventData() {
|
async updateEventData() {
|
||||||
|
if (!this.checkTime()) return;
|
||||||
if (
|
if (
|
||||||
Object.keys(
|
Object.keys(
|
||||||
this.findPerson(this.ownersData, this.employees, "employee")
|
this.findPerson(this.ownersData, this.employees, "employee")
|
||||||
@@ -384,7 +461,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
addErrorNotification(title, message) {
|
addErrorNotification(title, message) {
|
||||||
addNotification(new Date().getTime(), title, message, "error", 5000);
|
addNotification(title, title, message, "error", 5000);
|
||||||
},
|
},
|
||||||
addSuccessNotification(message) {
|
addSuccessNotification(message) {
|
||||||
addNotification(new Date().getTime(), message, "", "success", 5000);
|
addNotification(new Date().getTime(), message, "", "success", 5000);
|
||||||
|
|||||||
Reference in New Issue
Block a user