Merge pull request #191 from dderbentsov/UC-162

[WIP] Фикс апдейта данных клиента, убрал чекбоксы и на их место поставил кнопку редактирования
This commit is contained in:
frontgavrilin
2022-12-09 17:36:06 +03:00
committed by GitHub
6 changed files with 117 additions and 92 deletions

View File

@@ -1,17 +1,19 @@
<template lang="pug"> <template lang="pug">
.flex.box-border.container.items-center.cursor-pointer.justify-center.relative( .flex.box-border.container.items-center.cursor-pointer.justify-center.relative(
@click="changeSelect" @click="changeSelect",
v-click-outside="closeSelect",
:class="{border: styleBorder}" :class="{border: styleBorder}"
) )
.flex.select.cursor-pointer.w-full.text-xl.items-center.networks(:class="optionData, 'px-2.5'") .flex.select.cursor-pointer.w-full.text-xl.items-center.networks(:class="optionData, 'px-2.5'")
.absolute.options.top-11.left-0( .absolute.options.top-11.left-0(
v-show="isSelectOpen" v-show="isSelectOpen",
:id="id") :id="id"
)
.flex.option.justify-center.py-1.text-xl( .flex.option.justify-center.py-1.text-xl(
v-for="data in listData" v-for="data in listData",
@click="(e) => chooseOption(e)" @click="(e) => chooseOption(e)",
:key="data.network" :key="data.network",
:id="data.network" :id="data.network",
:class="data.icon" :class="data.icon"
) )
.select-form-separator.cursor-pointer.mr-6px(v-if="separator") .select-form-separator.cursor-pointer.mr-6px(v-if="separator")
@@ -45,6 +47,9 @@ export default {
changeSelect() { changeSelect() {
this.isSelectOpen = !this.isSelectOpen; this.isSelectOpen = !this.isSelectOpen;
}, },
closeSelect() {
this.isSelectOpen = false;
},
}, },
}; };
</script> </script>

View File

@@ -1,5 +1,5 @@
<template lang="pug"> <template lang="pug">
.flex.flex-col.items-end.absolute.right-2.top-5 .flex.flex-col.absolute.left-2.top-6
.corner .corner
.popup-wrapper.flex.flex-col.gap-y-3.w-10.h-10.p-4 .popup-wrapper.flex.flex-col.gap-y-3.w-10.h-10.p-4
.button.keep-redaction.flex.gap-x-3(@click="openChangeData") .button.keep-redaction.flex.gap-x-3(@click="openChangeData")
@@ -64,7 +64,7 @@ export default {
.corner .corner
width: 8px width: 8px
height: 8px height: 8px
border-top-left-radius: 100% border-top-right-radius: 100%
background-color: var(--default-white) background-color: var(--default-white)
z-index: 12 z-index: 12
overflow: hidden overflow: hidden

View File

@@ -11,14 +11,37 @@
@click="(e) => openDetailInfo(e)", @click="(e) => openDetailInfo(e)",
:class="{'row-overlay-color': rowOverlay}" :class="{'row-overlay-color': rowOverlay}"
) )
.check-box.flex.justify-center.items-center( .flex.items-center.px-2(
:class="{'row-opacity': rowOverlay}" v-show="!isOpenChange",
:tabindex="1",
@click="(e) => openPopup(e)",
@blur="handleUnFocusPopup"
) )
clients-table-checkbox( .relative.dots-button.icon-dots.cursor-pointer.leading-6.text-center
:id="id", clients-action-popup(
:check="check", v-if="isOpenPopup",
:is-check="isCheck" :open-change-data="openChangeData",
:disabled-delete="!!deletedClientId && !rowOverlay",
@delete-client="transmitDeleteClient"
) )
.dots.flex.justify-center.items-center(v-if="!rowOverlay")
.flex.pl-5.z-10(v-if="isOpenChange")
base-button(
@click="closeChangeData",
confirm,
rounded,
outlined,
:size="20"
)
.icon-ok.text-xsm(class="pt-[3px]")
//- .check-box.flex.justify-center.items-center(
//- :class="{'row-opacity': rowOverlay}"
//- )
//- clients-table-checkbox(
//- :id="id",
//- :check="check",
//- :is-check="isCheck"
//- )
table-cell-body-name( table-cell-body-name(
:class="{'row-opacity': rowOverlay}" :class="{'row-opacity': rowOverlay}"
:value="dataClient", :value="dataClient",
@@ -62,28 +85,6 @@
:is-open-change="isOpenChange", :is-open-change="isOpenChange",
:width="columnBody.find(el => el.name === 'networks').width" :width="columnBody.find(el => el.name === 'networks').width"
) )
.dots.flex.justify-center.items-center(v-if="!rowOverlay")
base-button(
v-if="isOpenChange",
@click="closeChangeData",
confirm,
rounded,
outlined,
:size="20"
)
.icon-ok.text-xsm(class="pt-[3px]")
.relative.dots-button.icon-dots.cursor-pointer.leading-6.text-center(
v-show="!isOpenChange",
:tabindex="1",
@click="(e) => openPopup(e)",
@blur="handleUnFocusPopup"
)
clients-action-popup(
v-if="isOpenPopup",
:open-change-data="openChangeData",
:disabled-delete="!!deletedClientId && !rowOverlay",
@delete-client="transmitDeleteClient"
)
client-detail-info-wrapper.detail.px-52px( client-detail-info-wrapper.detail.px-52px(
:class="{'pb-[30px] pt-4': isOpenDetailInfo}" :class="{'pb-[30px] pt-4': isOpenDetailInfo}"
:data-address="dataAddress", :data-address="dataAddress",
@@ -286,7 +287,9 @@ export default {
) )
updateContacts.push(this.dataClient.email); updateContacts.push(this.dataClient.email);
}); });
createContacts.forEach((el) => this.postCreateContact(el)); createContacts.forEach((el) => {
if (!el.id) this.postCreateContact(el);
});
deleteContacts.forEach((el) => this.postDeleteContact(el)); deleteContacts.forEach((el) => this.postDeleteContact(el));
updateContacts.forEach((el) => this.postUpdateContact(el)); updateContacts.forEach((el) => this.postUpdateContact(el));
}, },
@@ -300,11 +303,13 @@ export default {
.then(() => this.fetchDataClients()); .then(() => this.fetchDataClients());
}, },
postUpdateContact(contact) { postUpdateContact(contact) {
fetchWrapper.post(`general/contact/${contact.id}/update/`, { fetchWrapper
.post(`general/contact/${contact.id}/update/`, {
kind: contact.kind, kind: contact.kind,
username: contact.username, username: contact.username,
person_id: this.client.id, person_id: this.client.id,
}); })
.then(() => this.fetchDataClients());
}, },
postDeleteContact(contact) { postDeleteContact(contact) {
fetchWrapper.del(`general/contact/${contact.id}/delete/`); fetchWrapper.del(`general/contact/${contact.id}/delete/`);
@@ -555,7 +560,15 @@ export default {
}); });
}, },
}, },
created() { watch: {
rowOverlay() {
if (this.rowOverlay) this.startTimer();
},
client: {
deep: true,
immediate: true,
handler(newValue) {
if (newValue) {
this.dataClient = { this.dataClient = {
id: this.client.id, id: this.client.id,
fullName: `${this.client.last_name || ""} ${ fullName: `${this.client.last_name || ""} ${
@@ -564,21 +577,26 @@ export default {
age: this.client.birth_date || "", age: this.client.birth_date || "",
priority: this.prioritySettings.settings.find( priority: this.prioritySettings.settings.find(
(el) => (el) =>
el.priority === this.client.priority || this.client.priority === el.id el.priority === this.client.priority ||
this.client.priority === el.id
).text, ).text,
phone: { phone: {
id: this.client.contacts.find((el) => el.kind === "PHONE")?.id || "", id:
this.client.contacts.find((el) => el.kind === "PHONE")?.id ||
"",
kind: "PHONE", kind: "PHONE",
username: username:
this.client.contacts.find((el) => el.kind === "PHONE")?.username || this.client.contacts.find((el) => el.kind === "PHONE")
"", ?.username || "",
}, },
email: { email: {
id: this.client.contacts.find((el) => el.kind === "EMAIL")?.id || "", id:
this.client.contacts.find((el) => el.kind === "EMAIL")?.id ||
"",
kind: "EMAIL", kind: "EMAIL",
username: username:
this.client.contacts.find((el) => el.kind === "EMAIL")?.username || this.client.contacts.find((el) => el.kind === "EMAIL")
"", ?.username || "",
}, },
contacts: [...this.client.contacts], contacts: [...this.client.contacts],
avatar: this.client.first_name avatar: this.client.first_name
@@ -587,13 +605,10 @@ export default {
color: this.client.color, color: this.client.color,
photo: this.client.photo, photo: this.client.photo,
}; };
}, }
watch: { },
rowOverlay() {
if (this.rowOverlay) this.startTimer();
}, },
}, },
beforeUnmount() { beforeUnmount() {
if (this.timer) { if (this.timer) {
this.deleteClient(); this.deleteClient();
@@ -615,7 +630,7 @@ export default {
.check-box .check-box
min-width: 36px min-width: 36px
.dots .dots
min-width: 53px min-width: 14px
.dots-button .dots-button
width: 20px width: 20px
height: 20px height: 20px

View File

@@ -1,5 +1,8 @@
<template lang="pug"> <template lang="pug">
.flex.box-border.px-4.items-center.gap-x-3.w-full.text-sm(:style="{ minWidth : width + 'px' }") .flex.box-border.px-4.items-center.gap-x-3.w-full.text-sm(
:style="{ minWidth : width + 'px' }",
:class="{'open-change': isOpenChange}"
)
base-avatar(:size="36", :color="avatarColor", v-if="!photo") {{avatar}} base-avatar(:size="36", :color="avatarColor", v-if="!photo") {{avatar}}
base-avatar(:size="36", v-else) base-avatar(:size="36", v-else)
img.h-full.object-cover(:src="url + photo") img.h-full.object-cover(:src="url + photo")
@@ -39,4 +42,6 @@ export default {
border-radius: 50% border-radius: 50%
background-color: var(--font-grey-color) background-color: var(--font-grey-color)
color: var(--font-dark-blue-color) color: var(--font-dark-blue-color)
.open-change
padding-left: 52px
</style> </style>

View File

@@ -23,7 +23,7 @@
base-popup.right-3.top-6( base-popup.right-3.top-6(
v-if="isOpenPopupAdding", v-if="isOpenPopupAdding",
@click.stop, @click.stop,
v-click-outside="closePopup", v-click-outside.stop="closePopup",
:width="485" :width="485"
) )
base-adding-network( base-adding-network(

View File

@@ -1,8 +1,9 @@
export const column = [ export const column = [
{ {
name: "checkbox", name: "dots",
title: "Do",
iconHead: false, iconHead: false,
width: 36, width: 53,
}, },
{ {
name: "fullName", name: "fullName",
@@ -73,7 +74,7 @@ export const column = [
icon: "icon-tg", icon: "icon-tg",
}, },
{ {
network: "GOOGLE", network: "GMAIL",
icon: "icon-google", icon: "icon-google",
}, },
{ {
@@ -96,12 +97,11 @@ export const column = [
iconHead: false, iconHead: false,
width: 152, width: 152,
}, },
{ // {
name: "dots", // name: "checkbox",
title: "Do", // iconHead: false,
iconHead: false, // width: 36,
width: 53, // },
},
]; ];
export const detail = { export const detail = {