Skip to content

Commit

Permalink
CHI-2453 fix edit sections (duplicate PR) (#1929)
Browse files Browse the repository at this point in the history
* fix: corrections to bug causing labels; chore:add cl prfileForm Sections

* fix: edit page use of form details

* translation: add profile translations

* fix: corrections to bug causing labels; chore:add cl prfileForm Sections

* cleanup: update nz form defintions

* fix: clean up translations file

* update cl profile section definition

---------

Co-authored-by: Robert Bo Davis <bo@interrobang.consulting>
  • Loading branch information
mythilytm and robert-bo-davis authored Dec 8, 2023
1 parent 836fabb commit f901544
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
[
{
"name": "summary",
"label": "Summary ",
"label": "Summary",
"editLabel": "Edit Summary",
"type": "textarea",
"rows": 20,
"width": 300,
"placeholder": "Enter a summary of the case"
"width": 500,
"placeholder": "Enter a summary of the client"
},
{
"name": "recommended approach",
"name": "recommendedApproach",
"label": "Recommended Approach",
"editLabel": "Edit Recommended Approach",
"type": "textarea",
"rows": 20,
"width": 300,
"placeholder": "Enter recommended approach "
"width": 500,
"placeholder": "Enter recommended approach"
},
{
"name": "details",
"label": "Details",
"editLabel": "Edit Details",
"type": "textarea",
"rows": 20,
"width": 300,
"width": 500,
"placeholder": "Enter Details"
}
]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"name": "summary",
"label": "Summary",
"editLabel": "Edit Summary",
"type": "textarea",
"rows": 20,
"width": 500,
"placeholder": "Ingrese un resumen del cliente"
}
]
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
[
{
"name": "summary",
"label": "Summary ",
"label": "Summary",
"editLabel": "Edit Summary",
"type": "textarea",
"rows": 20,
"width": 300,
"placeholder": "Enter a summary of the case"
"width": 500,
"placeholder": "Enter a summary of the client"
},
{
"name": "recommended approach",
"name": "recommendedApproach",
"label": "Recommended Approach",
"editLabel": "Edit Recommended Approach",
"type": "textarea",
"rows": 20,
"width": 300,
"placeholder": "Enter recommended approach "
"width": 500,
"placeholder": "Enter recommended approach"
},
{
"name": "details",
"label": "Details",
"editLabel": "Edit Details",
"type": "textarea",
"rows": 20,
"width": 300,
"width": 500,
"placeholder": "Enter Details"
}
]
]
4 changes: 2 additions & 2 deletions hrm-form-definitions/src/formDefinition/loadDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
isSelectDefinitionWithReferenceOptions,
LayoutVersion,
CategoriesDefinition,
ProfileSection,
ProfileSectionDefinition,
} from './types';
import { OneToManyConfigSpecs, OneToOneConfigSpec } from './insightsConfig';

Expand Down Expand Up @@ -197,7 +197,7 @@ export async function loadDefinition(baseUrl: string): Promise<DefinitionVersion
),
fetchDefinition<Record<string, any>>('ReferenceData.json', {}),
fetchDefinition<string[]>('BlockedEmojis.json', []),
fetchDefinition<ProfileSection[]>('profileForms/Sections.json', []),
fetchDefinition<ProfileSectionDefinition[]>('profileForms/Sections.json', []),
]);

const { helplines } = helplineInformation;
Expand Down
5 changes: 3 additions & 2 deletions hrm-form-definitions/src/formDefinition/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ type CustomContactComponentDefinition = ItemBase &
props?: Record<string, boolean | number | string>;
};

export declare type ProfileSection = {
export declare type ProfileSectionDefinition = {
name: string;
label: string;
editLabel: string;
type: string;
rows: number;
placeholder: string;
Expand Down Expand Up @@ -338,5 +339,5 @@ export type DefinitionVersion = {
};
referenceData?: Record<string, any>;
blockedEmojis: string[];
profileForms?: { Sections: ProfileSection[] };
profileForms?: { Sections: ProfileSectionDefinition[] };
};
17 changes: 9 additions & 8 deletions plugin-hrm-form/src/components/profile/ProfileDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import React from 'react';
import { connect, ConnectedProps } from 'react-redux';
import { Icon, Template } from '@twilio/flex-ui';
import { ProfileSection } from 'hrm-form-definitions';
import { ProfileSectionDefinition } from 'hrm-form-definitions';

import { Box, HiddenText, Row, HorizontalLine } from '../../styles/HrmStyles';
import { newOpenModalAction } from '../../states/routing/actions';
Expand All @@ -37,8 +37,7 @@ import ProfileSectionView from './section/ProfileSectionView';
type OwnProps = ProfileCommonProps;

type Section = {
titleCode?: string;
title?: string;
titleCode: string;
renderComponent: () => React.ReactNode;
handleEdit?: () => void;
inInlineEditMode?: boolean;
Expand Down Expand Up @@ -66,12 +65,12 @@ const ProfileDetails: React.FC<Props> = ({ profileId, task, openSectionEditModal
},
];

const sectionTypesForms: ProfileSection[] = useProfileSectionTypes();
const sectionTypesForms = useProfileSectionTypes();

const sectionSections: Section[] = sectionTypesForms.map(sectionType => ({
title: `${sectionType.name}`,
titleCode: sectionType.label,
renderComponent: () => <ProfileSectionView profileId={profileId} task={task} sectionType={sectionType} />,
handleEdit: () => openSectionEditModal(sectionType.label),
handleEdit: () => openSectionEditModal(sectionType.name),
}));

const renderEditButton = section => {
Expand All @@ -86,7 +85,9 @@ const ProfileDetails: React.FC<Props> = ({ profileId, task, openSectionEditModal
<ProfileSectionEditButton onClick={section.handleEdit}>
{icon && <Icon icon={icon} />}
{!icon && <Template code="Profile-EditButton" />}
<HiddenText>{section.title}</HiddenText>
<HiddenText>
<Template code={section.titleCode} />{' '}
</HiddenText>
</ProfileSectionEditButton>
);
};
Expand All @@ -95,7 +96,7 @@ const ProfileDetails: React.FC<Props> = ({ profileId, task, openSectionEditModal
if (!section) return null;

return (
<div key={section.title}>
<div key={section.titleCode}>
<ProfileSectionWrapper>
<Box marginBottom="5px">
<Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import React, { useState } from 'react';
import { connect, ConnectedProps } from 'react-redux';
import startCase from 'lodash/startCase';

import { ProfileSection } from '../../../types/types';
import NavigableContainer from '../../NavigableContainer';
Expand Down Expand Up @@ -59,7 +58,7 @@ const ProfileSectionEdit = ({ task, profileId, sectionType, closeModal }: Props)
};

return (
<NavigableContainer titleCode={`Edit ${startCase(sectionType)}`} task={task}>
<NavigableContainer titleCode={sectionTypesForm.editLabel} task={task}>
<Container>
<Box>
<ColumnarBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/

import React from 'react';
import { ProfileSection } from 'hrm-form-definitions';
import { ProfileSectionDefinition } from 'hrm-form-definitions';

import { ProfileCommonProps } from '../types';
import { useProfileSectionByType } from '../../../states/profile/hooks/useProfileSection';
import { ProfileSectionTextContent, SectionText } from '../styles';

type OwnProps = ProfileCommonProps & {
sectionType: ProfileSection;
sectionType: ProfileSectionDefinition;
};

const ProfileSectionView = ({ profileId, sectionType }: OwnProps) => {
Expand All @@ -34,7 +34,7 @@ const ProfileSectionView = ({ profileId, sectionType }: OwnProps) => {

return (
<ProfileSectionTextContent hasContent={Boolean(section?.content)}>
{section?.content?.length > 0 ? section?.content : `No ${sectionType.name}`}
{section?.content?.length > 0 ? section?.content : `No ${sectionType.label}`}
</ProfileSectionTextContent>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import { useSelector } from 'react-redux';
import * as ConfigurationSelectors from '../selectors';

import { RootState } from '../..';
import { ProfileSection } from 'hrm-form-definitions';
import { ProfileSectionDefinition } from 'hrm-form-definitions';

const useProfileSectionTypes = () =>
useSelector(
(state: RootState): ProfileSection[] =>
(state: RootState): ProfileSectionDefinition[] =>
ConfigurationSelectors.selectDefinitionVersionProperty(state, 'profileForms')?.Sections,
);

Expand Down
1 change: 1 addition & 0 deletions plugin-hrm-form/src/translations/en-NZ/flexUI.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
"PreviousContacts-TwitterUser": "Twitter user",
"PreviousContacts-ViewRecords": "View Records",
"PreviousContacts-WhatsappNumber": "WhatsApp number",

"QueueCard-LessThanMinute": "less than a minute",
"QueueCard-Minutes": "&nbsp;minutes",
"QueueCard-Name": "Queue name:",
Expand Down
14 changes: 7 additions & 7 deletions plugin-hrm-form/src/translations/en-US/flexUI.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"CallTypeButtons-Or": "Or was this contact…",
"ConnectDialog-Child": "Copy child information from this record to new contact?",
"ConnectDialog-Caller": "Copy caller information from this record to new contact?",
"Profile-Title": "Client Profile",
"QueueCard-WaitLabel": "Longest wait time:",
"QueueCard-None": "none",
"QueueCard-LessThanMinute": "less than a minute",
Expand Down Expand Up @@ -60,11 +59,11 @@
"SearchResultsIndex-ViewContacts": "View Contacts",
"SearchResultsIndex-ViewCases": "View Cases",
"Contact-ViewButton": "View",
"SearchResultsIndex-SelectCase":"Select Case",
"SearchResultsIndex-NoCasesFound":"No {{type}} Found",
"SearchResultsIndex-SearchAgainForCase":"Search again for a {{type}}",
"SearchResultsIndex-SaveToNewCase":"save this contact to a new case",
"SearchResultsIndex-Or":"or",
"SearchResultsIndex-SelectCase": "Select Case",
"SearchResultsIndex-NoCasesFound": "No {{type}}s Found",
"SearchResultsIndex-SearchAgainForCase": "Search again for a {{type}}",
"SearchResultsIndex-SaveToNewCase": "save this contact to a new case",
"SearchResultsIndex-Or": "or",

"StandaloneSearch-SideNav": "Search",
"CaseHeader-Opened": "Opened",
Expand Down Expand Up @@ -386,6 +385,7 @@
"PreviousContacts-ViewRecords": "View Records",
"PreviousContacts-OnlyShowRecordsFrom": "Only show records from",

"Profile-Title": "Client Profile",
"Profile-DetailsHeader-Overview": "Overview",
"Profile-DetailsHeader-Notes": "Notes",
"Profile-IdentifiersHeader": "Identifiers",
Expand All @@ -398,7 +398,7 @@
"Profile-FlagEditHeader": "Edit Status and Blocking",
"Profile-NoContactsFound": "No Contacts Found",
"Profile-NoCasesFound": "No Cases Found",

"UploadFile-ButtonText": "Upload File",
"DownloadFile-ButtonText": "Download File",
"CSAMReportForm-Header": "File a Report: Child Sexual Abuse Material",
Expand Down
4 changes: 3 additions & 1 deletion plugin-hrm-form/src/translations/es-CL/flexUI.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,5 +512,7 @@
"CaseMerging-RemoveFromCase": "Quitar del caso",
"CaseMerging-ContactRemovedFromCase": "Contacto eliminado del caso",
"CaseMerging-CaseCreatedAndContactAdded": "Caso #{{caseId}} creado y contacto agregado",
"CaseMerging-CancelCase": "Cancelar Caso"
"CaseMerging-CancelCase": "Cancelar Caso",

"Something Else": "Enfoque Recomendado"
}

0 comments on commit f901544

Please sign in to comment.