From 49f0df56048c26f48180479b4777065011d238dc Mon Sep 17 00:00:00 2001 From: Daria Golova Date: Tue, 20 Dec 2022 15:18:10 +0300 Subject: [PATCH] =?UTF-8?q?WIP=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20null=20=D0=BF=D1=80=D0=B8=20=D0=BE=D1=82?= =?UTF-8?q?=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B8=20=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8,=20=D0=BE=D1=82=D1=87=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit b6d4b46eed8704d840eb0ca8c6e9e44e9b21db3a) --- src/components/LoggedInLayout.vue | 6 +++-- .../calendar/components/CalendarColumn.vue | 19 +++++++++++---- .../calendar/components/CalendarEventCard.vue | 4 +++- .../CalendarEventDescriptionCard.vue | 4 +++- .../components/CalendarFormAddEvent.vue | 10 ++++---- .../components/CalendarSidebarTeammate.vue | 23 ++++++++++++------- 6 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/components/LoggedInLayout.vue b/src/components/LoggedInLayout.vue index 2db4834..92c6116 100644 --- a/src/components/LoggedInLayout.vue +++ b/src/components/LoggedInLayout.vue @@ -45,14 +45,16 @@ export default { this.isOpenForm = false; }, setUpdatedClients() { - this.updatedClients = true; + if (this.$router.currentRoute._value.path === "/clients") + this.updatedClients = true; }, resetUpdatedClients() { this.updatedClients = false; this.createdClientId = ""; }, writeCreatedClientId(id) { - this.createdClientId = id; + if (this.$router.currentRoute._value.path === "/clients") + this.createdClientId = id; }, }, }; diff --git a/src/pages/calendar/components/CalendarColumn.vue b/src/pages/calendar/components/CalendarColumn.vue index 3c034fb..6f648a0 100644 --- a/src/pages/calendar/components/CalendarColumn.vue +++ b/src/pages/calendar/components/CalendarColumn.vue @@ -65,15 +65,24 @@ export default { computed: { ownerName() { if (this.ownerData.id) { - return `${this.ownerData.last_name} ${this.ownerData.first_name.slice( - 0, - 1 - )}.${this.ownerData.patronymic.slice(0, 1)}.`; + let checkedFirstName = + this.ownerData.first_name !== null + ? this.ownerData.first_name[0] + "." + : ""; + let checkedPatronymic = + this.ownerData.patronymic !== null + ? this.ownerData.patronymic[0] + "." + : ""; + return `${this.ownerData.last_name} ${checkedFirstName}${checkedPatronymic}`; } return null; }, defaultAvatar() { - return `${this.ownerData.last_name[0]}${this.ownerData.first_name[0]}`; + let checkedFirstName = + this.ownerData.first_name !== null + ? this.ownerData.first_name[0] + : this.ownerData.last_name[1]; + return `${this.ownerData.last_name[0]}${checkedFirstName}`; }, pixelsPerMinute() { return this.pixelsPerHour / 60; diff --git a/src/pages/calendar/components/CalendarEventCard.vue b/src/pages/calendar/components/CalendarEventCard.vue index a8f7442..bbe0967 100644 --- a/src/pages/calendar/components/CalendarEventCard.vue +++ b/src/pages/calendar/components/CalendarEventCard.vue @@ -210,7 +210,9 @@ export default { return time.slice(11, -4); }, composeFullName(object) { - return `${object.last_name} ${object.first_name} ${object.patronymic}`; + return `${object.last_name} ${object.first_name ?? ""} ${ + object.patronymic ?? "" + }`; }, setActiveTheme() { this.isActive = true; diff --git a/src/pages/calendar/components/CalendarEventDescriptionCard.vue b/src/pages/calendar/components/CalendarEventDescriptionCard.vue index 492d095..a3de16b 100644 --- a/src/pages/calendar/components/CalendarEventDescriptionCard.vue +++ b/src/pages/calendar/components/CalendarEventDescriptionCard.vue @@ -140,7 +140,9 @@ export default { return time.slice(11, -4); }, composeFullName(object) { - return `${object.last_name} ${object.first_name} ${object.patronymic}`; + return `${object.last_name} ${object.first_name ?? ""} ${ + object.patronymic ?? "" + }`; }, }, mounted() { diff --git a/src/pages/calendar/components/CalendarFormAddEvent.vue b/src/pages/calendar/components/CalendarFormAddEvent.vue index 95eeb77..e864dca 100644 --- a/src/pages/calendar/components/CalendarFormAddEvent.vue +++ b/src/pages/calendar/components/CalendarFormAddEvent.vue @@ -357,11 +357,13 @@ export default { } return counter === 0; }, - trimOwnerName(lastName, firsName, patronymic) { - return `${lastName} ${firsName[0]}.${patronymic[0]}.`; + trimOwnerName(lastName, firstName, patronymic) { + let checkedFirstName = firstName !== null ? firstName[0] + "." : ""; + let checkedPatronymic = patronymic !== null ? patronymic[0] + "." : ""; + return `${lastName} ${checkedFirstName}${checkedPatronymic}`; }, - trimMemberName(lastName, firsName, patronymic) { - return `${lastName} ${firsName} ${patronymic}`; + trimMemberName(lastName, firstName, patronymic) { + return `${lastName} ${firstName ?? ""} ${patronymic ?? ""}`; }, async sendEventData() { if (!this.checkTime()) return; diff --git a/src/pages/calendar/components/CalendarSidebarTeammate.vue b/src/pages/calendar/components/CalendarSidebarTeammate.vue index c26ccb4..3f327e0 100644 --- a/src/pages/calendar/components/CalendarSidebarTeammate.vue +++ b/src/pages/calendar/components/CalendarSidebarTeammate.vue @@ -4,7 +4,7 @@ .team-card(v-for="teammate in teamData" :key="teammate.id") base-avatar(:size="32", :color="teammate.color") img.h-full.object-cover(:src="url + teammate.photo", alt="Team member", v-if="teammate.photo") - span(v-if="!teammate.photo") {{`${teammate.last_name[0]}${teammate.first_name[0]}`}} + span(v-if="!teammate.photo") {{teammateAvatar(teammate)}} .flex.flex-col.gap-y-4.w-full(v-else, :style="{ color: 'var(--font-dark-blue-color)' }") .flex.items-center.justify-between .flex.text-base.font-bold Команды @@ -17,7 +17,7 @@ .flex.items-center base-avatar(:size="32", :color="teammate.color") img.h-full.object-cover(:src="url + teammate.photo", alt="Team member", v-if="teammate.photo") - span(v-if="!teammate.photo") {{`${teammate.last_name[0]}${teammate.first_name[0]}`}} + span(v-if="!teammate.photo") {{teammateAvatar(teammate)}} .flex.ml-2.not-italic.font-medium.text-xxs {{ changeName(teammate.last_name, teammate.first_name, teammate.patronymic) }} span.icon-change-place.cursor-pointer.w-5.flex.items-center.justify-center.w-6.h-6 @@ -42,15 +42,22 @@ export default { }; }, methods: { - changeName(lastName, fitstName, patronymic) { + changeName(lastName, firstName, patronymic) { + let checkedFirstName = firstName !== null ? firstName[0] + "." : ""; + let checkedPatronymic = patronymic !== null ? patronymic[0] + "." : ""; return lastName.length > this.maxLengthLastName ? lastName.slice(0, this.maxLengthLastName) + "... " + - fitstName[0] + - "." + - patronymic[0] + - "." - : lastName + " " + fitstName[0] + "." + patronymic[0] + "."; + checkedFirstName + + checkedPatronymic + : lastName + " " + checkedFirstName + checkedPatronymic; + }, + teammateAvatar(teammate) { + let checkedFirstName = + teammate.first_name !== null + ? teammate.first_name[0] + : teammate.last_name[1]; + return `${teammate.last_name[0]}${checkedFirstName}`; }, }, };