WIP Сделала ошибку на измение события
This commit is contained in:
@@ -75,7 +75,7 @@ export default {
|
||||
showModal: false,
|
||||
timeInformation: {
|
||||
dayStartTime: "08:00",
|
||||
dayEndTime: "20:00",
|
||||
dayEndTime: "24:00",
|
||||
},
|
||||
eventsData: [],
|
||||
employeesData: [],
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg")
|
||||
column-header-checkbox
|
||||
.body.pl-1
|
||||
transition-group(name="card", tag="div")
|
||||
transition-group(name="card")
|
||||
calendar-event-card(
|
||||
v-for="event in dayEvents",
|
||||
:key="event.id",
|
||||
|
||||
@@ -228,7 +228,7 @@ export default {
|
||||
immediate: true,
|
||||
handler(newValue) {
|
||||
if (newValue === true) {
|
||||
this.setDefaultTheme();
|
||||
this.isActive = false;
|
||||
this.$emit("reset-change-form");
|
||||
}
|
||||
},
|
||||
|
||||
@@ -288,6 +288,13 @@ export default {
|
||||
this.eventData = {};
|
||||
},
|
||||
async updateEventData() {
|
||||
if (
|
||||
Object.keys(
|
||||
this.findPerson(this.ownersData, this.employees, "employee")
|
||||
).length > 0 &&
|
||||
Object.keys(this.findPerson(this.membersData, this.members, "person"))
|
||||
.length > 0
|
||||
) {
|
||||
this.eventData = {
|
||||
start: this.mergeDate(this.eventDate, this.startTime),
|
||||
end: this.mergeDate(this.eventDate, this.endTime),
|
||||
@@ -299,6 +306,11 @@ export default {
|
||||
};
|
||||
await this.postUpdateEvent(this.id, this.eventData);
|
||||
this.eventData = {};
|
||||
} else
|
||||
this.addErrorNotification(
|
||||
"Событие не может быть изменено",
|
||||
"Клиент был удален"
|
||||
);
|
||||
},
|
||||
clearForm() {
|
||||
if (this.selectedEventData.id) this.$emit("close-change-form");
|
||||
@@ -310,6 +322,7 @@ export default {
|
||||
},
|
||||
findPerson(requestedList, object, field) {
|
||||
let foundPerson = requestedList.find(({ id }) => id === object[field].id);
|
||||
if (foundPerson) {
|
||||
let returnedData = {
|
||||
[field]: {
|
||||
id: foundPerson.id,
|
||||
@@ -322,11 +335,16 @@ export default {
|
||||
};
|
||||
if (object.id) returnedData.id = object.id;
|
||||
return returnedData;
|
||||
}
|
||||
return {};
|
||||
},
|
||||
async postCreateEvent(event) {
|
||||
const response = await fetchWrapper.post("registry/event/create/", event);
|
||||
if (response.type && response.type === "validation_error") {
|
||||
this.addErrorNotification(response);
|
||||
this.addErrorNotification(
|
||||
response.errors[0].code,
|
||||
response.errors[0].detail
|
||||
);
|
||||
} else {
|
||||
this.addSuccessNotification("Событие успешно создано");
|
||||
this.clearForm();
|
||||
@@ -338,7 +356,10 @@ export default {
|
||||
event
|
||||
);
|
||||
if (response.type && response.type === "validation_error") {
|
||||
this.addErrorNotification(response);
|
||||
this.addErrorNotification(
|
||||
response.errors[0].code,
|
||||
response.errors[0].detail
|
||||
);
|
||||
} else {
|
||||
this.addSuccessNotification("Изменения успешно сохранены");
|
||||
this.clearForm();
|
||||
@@ -362,14 +383,8 @@ export default {
|
||||
return id;
|
||||
}
|
||||
},
|
||||
addErrorNotification(error) {
|
||||
addNotification(
|
||||
new Date().getTime(),
|
||||
error.errors[0].code,
|
||||
error.errors[0].detail,
|
||||
"error",
|
||||
5000
|
||||
);
|
||||
addErrorNotification(title, message) {
|
||||
addNotification(new Date().getTime(), title, message, "error", 5000);
|
||||
},
|
||||
addSuccessNotification(message) {
|
||||
addNotification(new Date().getTime(), message, "", "success", 5000);
|
||||
|
||||
Reference in New Issue
Block a user