Merge pull request #196 from dderbentsov/UC-157

WIP Анимация пагинации и загрузки клиентов, уведомление на попытку редактировать события с удаленным клиентом
This commit is contained in:
Daria Golova
2022-12-13 18:44:18 +03:00
committed by GitHub
9 changed files with 131 additions and 81 deletions

View File

@@ -1,6 +1,6 @@
<template lang="pug"> <template lang="pug">
.header-inputs-wrapper.flex.items-center.font-medium.text-base(:class="{ open: isOpen }") .header-inputs-wrapper.flex.items-center.font-medium.text-base(:class="{ open: isOpen }")
.select-container(@click="changeState") .select-container(@click="changeState", v-click-outside="closeOptions")
.select-wrapper.flex.items-center.cursor-pointer.mx-4.my-2 .select-wrapper.flex.items-center.cursor-pointer.mx-4.my-2
.icon-wrapper.icon-search.flex.text-lg.justify-center.items-center .icon-wrapper.icon-search.flex.text-lg.justify-center.items-center
span.custom-input.select-input.inline-block.box-border.align-middle.pl-2.pr-1 {{ selectedFilter }} span.custom-input.select-input.inline-block.box-border.align-middle.pl-2.pr-1 {{ selectedFilter }}
@@ -30,6 +30,9 @@ export default {
selectFilter(filter) { selectFilter(filter) {
this.selectedFilter = filter; this.selectedFilter = filter;
}, },
closeOptions() {
this.isOpen = false;
},
}, },
}; };
</script> </script>

View File

@@ -86,8 +86,8 @@ export default {
box-shadow: 1px 1px 8px rgba(37, 40, 80, 0.15) box-shadow: 1px 1px 8px rgba(37, 40, 80, 0.15)
border-radius: 4px border-radius: 4px
background-color: white background-color: white
max-height: 140px
overflow-y: auto overflow-y: auto
height: 140px
.placeholder .placeholder
color: #090A15 color: #090A15
opacity: 0.5 opacity: 0.5

View File

@@ -1,6 +1,6 @@
<template lang="pug"> <template lang="pug">
a(:href="path") a(:href="path")
button.button.cursor-pointer.text-4xl.py-3.pr-4.pl-3(:id="id" :class="{active:active}" @click="(e) => changeStylePage(e)") button.button.cursor-pointer.text-4xl.py-3.pr-4.pl-3.transition(:id="id" :class="{active:active}" @click="(e) => changeStylePage(e)")
slot slot
</template> </template>

View File

@@ -13,7 +13,7 @@
img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg") img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg")
column-header-checkbox column-header-checkbox
.body.pl-1 .body.pl-1
transition-group(name="card", tag="div") transition-group(name="card")
calendar-event-card( calendar-event-card(
v-for="event in dayEvents", v-for="event in dayEvents",
:key="event.id", :key="event.id",

View File

@@ -228,7 +228,7 @@ export default {
immediate: true, immediate: true,
handler(newValue) { handler(newValue) {
if (newValue === true) { if (newValue === true) {
this.setDefaultTheme(); this.isActive = false;
this.$emit("reset-change-form"); this.$emit("reset-change-form");
} }
}, },

View File

@@ -288,17 +288,29 @@ export default {
this.eventData = {}; this.eventData = {};
}, },
async updateEventData() { async updateEventData() {
this.eventData = { if (
start: this.mergeDate(this.eventDate, this.startTime), Object.keys(
end: this.mergeDate(this.eventDate, this.endTime), this.findPerson(this.ownersData, this.employees, "employee")
kind: this.kind.label, ).length > 0 &&
employees: [ Object.keys(this.findPerson(this.membersData, this.members, "person"))
this.findPerson(this.ownersData, this.employees, "employee"), .length > 0
], ) {
members: [this.findPerson(this.membersData, this.members, "person")], this.eventData = {
}; start: this.mergeDate(this.eventDate, this.startTime),
await this.postUpdateEvent(this.id, this.eventData); end: this.mergeDate(this.eventDate, this.endTime),
this.eventData = {}; kind: this.kind.label,
employees: [
this.findPerson(this.ownersData, this.employees, "employee"),
],
members: [this.findPerson(this.membersData, this.members, "person")],
};
await this.postUpdateEvent(this.id, this.eventData);
this.eventData = {};
} else
this.addErrorNotification(
"Событие не может быть изменено",
"Клиент был удален"
);
}, },
clearForm() { clearForm() {
if (this.selectedEventData.id) this.$emit("close-change-form"); if (this.selectedEventData.id) this.$emit("close-change-form");
@@ -310,23 +322,29 @@ export default {
}, },
findPerson(requestedList, object, field) { findPerson(requestedList, object, field) {
let foundPerson = requestedList.find(({ id }) => id === object[field].id); let foundPerson = requestedList.find(({ id }) => id === object[field].id);
let returnedData = { if (foundPerson) {
[field]: { let returnedData = {
id: foundPerson.id, [field]: {
last_name: foundPerson.last_name, id: foundPerson.id,
first_name: foundPerson.first_name, last_name: foundPerson.last_name,
patronymic: foundPerson.patronymic, first_name: foundPerson.first_name,
color: foundPerson.color, patronymic: foundPerson.patronymic,
}, color: foundPerson.color,
role: object.role, },
}; role: object.role,
if (object.id) returnedData.id = object.id; };
return returnedData; if (object.id) returnedData.id = object.id;
return returnedData;
}
return {};
}, },
async postCreateEvent(event) { async postCreateEvent(event) {
const response = await fetchWrapper.post("registry/event/create/", event); const response = await fetchWrapper.post("registry/event/create/", event);
if (response.type && response.type === "validation_error") { if (response.type && response.type === "validation_error") {
this.addErrorNotification(response); this.addErrorNotification(
response.errors[0].code,
response.errors[0].detail
);
} else { } else {
this.addSuccessNotification("Событие успешно создано"); this.addSuccessNotification("Событие успешно создано");
this.clearForm(); this.clearForm();
@@ -338,7 +356,10 @@ export default {
event event
); );
if (response.type && response.type === "validation_error") { if (response.type && response.type === "validation_error") {
this.addErrorNotification(response); this.addErrorNotification(
response.errors[0].code,
response.errors[0].detail
);
} else { } else {
this.addSuccessNotification("Изменения успешно сохранены"); this.addSuccessNotification("Изменения успешно сохранены");
this.clearForm(); this.clearForm();
@@ -362,14 +383,8 @@ export default {
return id; return id;
} }
}, },
addErrorNotification(error) { addErrorNotification(title, message) {
addNotification( addNotification(new Date().getTime(), title, message, "error", 5000);
new Date().getTime(),
error.errors[0].code,
error.errors[0].detail,
"error",
5000
);
}, },
addSuccessNotification(message) { addSuccessNotification(message) {
addNotification(new Date().getTime(), message, "", "success", 5000); addNotification(new Date().getTime(), message, "", "success", 5000);

View File

@@ -5,7 +5,7 @@
:disabled="disabledPreviousButton" :disabled="disabledPreviousButton"
) )
.icon-down-arrow.arrow-left .icon-down-arrow.arrow-left
button.item.flex.items-center.justify-center( button.item.flex.items-center.justify-center.transition.duration-100.ease-linear(
v-for="page, index in pageCount", v-for="page, index in pageCount",
:key="index", :key="index",
:id="page", :id="page",

View File

@@ -1,45 +1,52 @@
<template lang="pug"> <template lang="pug">
.wrapper-table.relative.flex.flex-col.px-6.py-6.h-full.w-full .wrapper-table.relative.flex.px-6.py-6.h-full.w-full
clients-table-hat( transition(name="table", mode="out-in")
:is-open-actions="marked.length", .flex.justify-center.items-center.w-full(v-if="dataClientsPresence")
:open-form="openForm", base-loader(
:clearing-text-search="clearingTextSearch", :width="60",
:change-clearing-text-search="changeClearingTextSearch", :height="60"
@search="filterDataClients",
)
.flex.flex-col.h-full.table-container.w-full.mt-8.mb-3
clients-table-header(:check="selectedCheck" :is-check="selectAll")
.flex.flex-col
clients-table-row(
v-for="client in dataClients",
:key="client.id",
:id="client.id",
:url="url",
:is-check="marked.includes(client.id)",
:check="selectedCheck",
:client="client",
:deleted-client-id="deletedRowId",
:update-data-client="updateDataClient",
:fetch-data-clients="fetchDataClients",
@delete-client="deleteClientHandler",
@recover-client="clearDeletedRowId",
) )
client-table-pagination( .relative.flex.flex-col.h-full.w-full(v-else)
v-if="paginationInfo.length > 1" clients-table-hat(
:pagination-info="paginationInfo" :is-open-actions="marked.length",
@previous-page="switchPreviousPage", :open-form="openForm",
@next-page="switchNextPage", :clearing-text-search="clearingTextSearch",
@set-current-page="changeCurrentTablePage" :change-clearing-text-search="changeClearingTextSearch",
) @search="filterDataClients",
base-modal( )
v-model="showModal", .flex.flex-col.h-full.table-container.w-full.mt-8.mb-3
title="Удалить клиента" clients-table-header(:check="selectedCheck" :is-check="selectAll")
) .flex.flex-col
client-table-delete-modal( clients-table-row(
:close-modal="closeModal", v-for="client in dataClients",
:deleted-client-id="deletedClientId", :key="client.id",
@delete-client="writeDeletedRowId" :id="client.id",
) :url="url",
:is-check="marked.includes(client.id)",
:check="selectedCheck",
:client="client",
:deleted-client-id="deletedRowId",
:update-data-client="updateDataClient",
:fetch-data-clients="fetchDataClients",
@delete-client="deleteClientHandler",
@recover-client="clearDeletedRowId",
)
client-table-pagination(
v-if="paginationInfo.length > 1"
:pagination-info="paginationInfo"
@previous-page="switchPreviousPage",
@next-page="switchNextPage",
@set-current-page="changeCurrentTablePage"
)
base-modal(
v-model="showModal",
title="Удалить клиента"
)
client-table-delete-modal(
:close-modal="closeModal",
:deleted-client-id="deletedClientId",
@delete-client="writeDeletedRowId"
)
</template> </template>
<script> <script>
@@ -52,6 +59,7 @@ import BaseClientFormCreate from "@/components/base/BaseClientFormCreate";
import ClientTablePagination from "./ClientTablePagination.vue"; import ClientTablePagination from "./ClientTablePagination.vue";
import BaseModal from "@/components/base/BaseModal.vue"; import BaseModal from "@/components/base/BaseModal.vue";
import ClientTableDeleteModal from "./ClientTableDeleteModal.vue"; import ClientTableDeleteModal from "./ClientTableDeleteModal.vue";
import BaseLoader from "@/components/Loader/BaseLoader.vue";
export default { export default {
name: "ClientsTable", name: "ClientsTable",
components: { components: {
@@ -63,6 +71,7 @@ export default {
ClientTablePagination, ClientTablePagination,
BaseModal, BaseModal,
ClientTableDeleteModal, ClientTableDeleteModal,
BaseLoader,
}, },
props: { props: {
openForm: Function, openForm: Function,
@@ -75,7 +84,11 @@ export default {
return { return {
selectAll: false, selectAll: false,
marked: [], marked: [],
dataClients: [], dataClients: [
{
initialization: true,
},
],
currentTablePage: 1, currentTablePage: 1,
limit: 14, limit: 14,
clientsCount: 0, clientsCount: 0,
@@ -91,6 +104,11 @@ export default {
clearingTextSearch: false, clearingTextSearch: false,
}; };
}, },
computed: {
dataClientsPresence() {
return this.dataClients[0]?.initialization;
},
},
methods: { methods: {
updateDataClient() { updateDataClient() {
if (this.textSearch) this.filteredClientsCount -= 1; if (this.textSearch) this.filteredClientsCount -= 1;
@@ -243,4 +261,18 @@ export default {
&::-webkit-scrollbar-thumb &::-webkit-scrollbar-thumb
border-radius: 8px border-radius: 8px
background-color: var(--btn-blue-color) background-color: var(--btn-blue-color)
.table-enter-from
opacity: 0
transform: translateY(0px)
pointer-events: none
.table-enter-active
transition: 0.3s ease
.table-leave-to
opacity: 0
transform: translateY(0px)
pointer-events: none
.table-leave-active
transition: 0.3s ease
.table-move
transition: 0.3s ease
</style> </style>

View File

@@ -350,7 +350,7 @@ export default {
}, },
async deleteClient() { async deleteClient() {
await fetchWrapper.del(`general/person/${this.client.id}/delete/`); await fetchWrapper.del(`general/person/${this.client.id}/delete/`);
this.addSuccessNotification("Клиент Успешно удален", ""); this.addSuccessNotification("Клиент успешно удален", "");
this.handleUnFocusPopup(); this.handleUnFocusPopup();
}, },
addSuccessNotification(title, message) { addSuccessNotification(title, message) {