From 66601ed3464eb81eb97bb508962808feefaa74a8 Mon Sep 17 00:00:00 2001 From: Fernando Terra <79578735+fterra-encora@users.noreply.github.com> Date: Tue, 7 Jan 2025 19:20:59 -0300 Subject: [PATCH] feat(fe:FSADT1-1682): CLIENT_VIEWER Client Location/Contact accordion title style (#1376) * fix style for accordion's title * adjust contact data * test: fix description --- .../cypress/e2e/pages/ClientDetailsPage.cy.ts | 28 +++++++-------- frontend/src/assets/styles/global.scss | 11 +++++- frontend/src/dto/CommonTypesDto.ts | 4 +-- frontend/src/pages/ClientDetailsPage.vue | 21 ++++++------ .../src/pages/client-details/ContactView.vue | 27 ++++++--------- .../__files/response-clients-details-G.json | 3 -- .../__files/response-clients-details-S.json | 1 - .../pages/client-details/ContactView.cy.ts | 34 +++++++++---------- 8 files changed, 64 insertions(+), 65 deletions(-) diff --git a/frontend/cypress/e2e/pages/ClientDetailsPage.cy.ts b/frontend/cypress/e2e/pages/ClientDetailsPage.cy.ts index 87968512a..a13015f69 100644 --- a/frontend/cypress/e2e/pages/ClientDetailsPage.cy.ts +++ b/frontend/cypress/e2e/pages/ClientDetailsPage.cy.ts @@ -231,16 +231,16 @@ describe("Client Details Page", () => { }); }); - it("displays the contact name on the accordion's title", () => { - cy.get("#contact-00 [slot='title']").contains("Cheryl Bibby"); - cy.get("#contact-01 [slot='title']").contains("Edward Burns"); - cy.get("#contact-02 [slot='title']").contains("Christoffer Stewart"); + it("displays the contacts names on the accordions' titles sorted by contact name", () => { + cy.get("#contact-0 [slot='title']").contains("Cheryl Bibby"); + cy.get("#contact-1 [slot='title']").contains("Christoffer Stewart"); + cy.get("#contact-2 [slot='title']").contains("Edward Burns"); }); it("displays the associated locations on the accordion's title while it's collapsed", () => { - cy.get("#contact-00-title-locations").should("be.visible"); - cy.get("#contact-01-title-locations").should("be.visible"); - cy.get("#contact-02-title-locations").should("be.visible"); + cy.get("#contact-0-title-locations").should("be.visible"); + cy.get("#contact-1-title-locations").should("be.visible"); + cy.get("#contact-2-title-locations").should("be.visible"); }); }); @@ -259,14 +259,14 @@ describe("Client Details Page", () => { it("hides the associated locations on the accordion's title when it's expanded", () => { // Clicks to expand the accordion - cy.get("#contact-00 [slot='title']").click(); - cy.get("#contact-00-title-locations").should("not.be.visible"); + cy.get("#contact-0 [slot='title']").click(); + cy.get("#contact-0-title-locations").should("not.be.visible"); }); it("keeps accordions' states while tabs are switched", () => { // Expand first and third contacts, leave second one collapsed - cy.get("#contact-00 [slot='title']").click(); - cy.get("#contact-02 [slot='title']").click(); + cy.get("#contact-0 [slot='title']").click(); + cy.get("#contact-2 [slot='title']").click(); // Switch to another tab (Locations) cy.get("#tab-locations").click(); // Make sure the current tab panel was effectively switched @@ -275,11 +275,11 @@ describe("Client Details Page", () => { // Switch back to tab Contacts cy.get("#tab-contacts").click(); // First contact is still open - cy.get("#contact-00 cds-accordion-item").should("have.attr", "open"); + cy.get("#contact-0 cds-accordion-item").should("have.attr", "open"); // Second contact is still closed - cy.get("#contact-01 cds-accordion-item").should("not.have.attr", "open"); + cy.get("#contact-1 cds-accordion-item").should("not.have.attr", "open"); // Third contact is still open - cy.get("#contact-02 cds-accordion-item").should("have.attr", "open"); + cy.get("#contact-2 cds-accordion-item").should("have.attr", "open"); }); }); describe("no contacts", () => { diff --git a/frontend/src/assets/styles/global.scss b/frontend/src/assets/styles/global.scss index 27af3f317..f8eea97e8 100644 --- a/frontend/src/assets/styles/global.scss +++ b/frontend/src/assets/styles/global.scss @@ -956,7 +956,8 @@ cds-actionable-notification * { align-self: stretch; display: flex; flex-direction: column; - gap: 2.5rem; + gap: 1rem; + border-radius: 0 0 0.5rem 0.5rem; background: #fff; padding: 1rem; } @@ -1033,6 +1034,10 @@ cds-actionable-notification * { gap: 2rem; } +cds-accordion-item:not([open]) { + gap: 0; // removes unwanted extra space when accordion item is closed. +} + .grouping-13 { align-self: stretch; display: flex; @@ -1468,6 +1473,10 @@ cds-side-nav { width: 100%; } +cds-accordion-item::part(expando) { + min-block-size: 3rem; +} + cds-accordion-item[open]:not([disabled])::part(content), :host(cds-accordion-item[open]:not([disabled])) .cds-ce--accordion__content--md { diff --git a/frontend/src/dto/CommonTypesDto.ts b/frontend/src/dto/CommonTypesDto.ts index a164f9d40..42042cf9b 100644 --- a/frontend/src/dto/CommonTypesDto.ts +++ b/frontend/src/dto/CommonTypesDto.ts @@ -282,8 +282,8 @@ export interface ClientLocation { export interface ClientContact { clientNumber: string; - clientLocnCode: string[]; - contactCode: string; + clientLocnCode: string; + locationCode: string[]; contactName: string; contactTypeCode: string; contactTypeDesc: string; diff --git a/frontend/src/pages/ClientDetailsPage.vue b/frontend/src/pages/ClientDetailsPage.vue index 106c3047f..e40b7af47 100644 --- a/frontend/src/pages/ClientDetailsPage.vue +++ b/frontend/src/pages/ClientDetailsPage.vue @@ -97,7 +97,7 @@ const sortedLocations = computed(() => ); const sortedContacts = computed(() => - data.value.contacts?.toSorted((a, b) => compareString(a.contactCode, b.contactCode)), + data.value.contacts?.toSorted((a, b) => compareString(a.contactName, b.contactName)), ); const formatLocations = ( @@ -116,8 +116,8 @@ const formatLocations = ( const associatedLocationsRecord = computed(() => { const result: Record = {}; - sortedContacts.value?.forEach((contact) => { - result[contact.contactCode] = formatLocations(contact.locationCode); + sortedContacts.value?.forEach((contact, index) => { + result[index] = formatLocations(contact.locationCode); }); return result; }); @@ -281,26 +281,27 @@ const toolsSvg = useSvg(tools); {{ pluralize("contact", data.contacts?.length) }}
- {{ contact.contactCode }} - {{ contact.contactName }} + {{ contact.contactName }} - {{ associatedLocationsRecord[contact.contactCode] }} + {{ associatedLocationsRecord[index] }}
diff --git a/frontend/src/pages/client-details/ContactView.vue b/frontend/src/pages/client-details/ContactView.vue index 669d6968c..90b782b6e 100644 --- a/frontend/src/pages/client-details/ContactView.vue +++ b/frontend/src/pages/client-details/ContactView.vue @@ -1,31 +1,24 @@