Skip to content

Commit

Permalink
Merge branch 'UIORGS-356' of https://github.com/folio-org/ui-organiza…
Browse files Browse the repository at this point in the history
…tions into UIORGS-356
  • Loading branch information
usavkov-epam committed Nov 26, 2024
2 parents 570e7f4 + e7581fd commit a9433a8
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export const OrganizationVersionView = ({ version }) => {
},
];

console.log('version', version);

return (
<HasCommand
commands={shortcuts}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,8 @@ export const OrganizationContactInfoVersionView = ({ version: currentVersion })
>
<ContactAddressesVersionView addresses={data[category.id].addresses} />
<ContactPersonPhonesVersionView phones={data[category.id].phoneNumbers} />
<ContactPersonEmailsVersionView
name="emails"
emails={data[category.id].emails}
/>
<ContactPersonURLsVersionView
name="urls"
urls={data[category.id].urls}
/>
<ContactPersonEmailsVersionView emails={data[category.id].emails} />
<ContactPersonURLsVersionView urls={data[category.id].urls} />
</Accordion>
))}
</Layout>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
import PropTypes from 'prop-types';
import { useContext } from 'react';
import { FormattedMessage } from 'react-intl';

import {
Card,
Col,
Row,
} from '@folio/stripes/components';
import {
VersionKeyValue,
VersionViewContext,
} from '@folio/stripes-acq-components';
import { VersionKeyValue } from '@folio/stripes-acq-components';

export const ContactAddressesVersionView = ({ addresses }) => {
const versionContext = useContext(VersionViewContext);
import { ContactCardHeaderVersionView } from './ContactCardHeaderVersionView';

export const ContactAddressesVersionView = ({ addresses }) => {
return (
<Row>
<Col xs={12}>
{addresses?.map((address) => {
const isPrimaryValue = (
<h4 style={{ margin: 0 }}>
<FormattedMessage id={`ui-organizations.${address?.isPrimary ? 'primaryItem' : 'alternateItem'}`} />
</h4>
);
const headerStart = versionContext?.paths?.includes(`${address?._initialFieldPath}.isPrimary`)
? <mark>{isPrimaryValue}</mark>
: isPrimaryValue;

return (
<Card headerStart={headerStart}>
<Card
headerStart={(
<ContactCardHeaderVersionView
name={`${address?._initialFieldPath}.isPrimary`}
isPrimary={address?.isPrimary}
/>
)}
>
<Row>
<Col xs={3}>
<VersionKeyValue
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.cardHeader {
margin: 0;

& .mark {
background-color: mark;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import PropTypes from 'prop-types';
import { useContext } from 'react';
import { FormattedMessage } from 'react-intl';

import { VersionViewContext } from '@folio/stripes-acq-components';

import css from './ContactCardHeaderVersionView.css';

export const ContactCardHeaderVersionView = ({ isPrimary, name }) => {
const versionContext = useContext(VersionViewContext);

const isUpdated = versionContext?.paths?.includes(name);

const headerStart = (
<h4 className={css.cardHeader}>
<span className={isUpdated ? css.mark : ''}><FormattedMessage id={`ui-organizations.${isPrimary ? 'primaryItem' : 'alternateItem'}`} /></span>
</h4>
);

return headerStart;
};

ContactCardHeaderVersionView.propTypes = {
isPrimary: PropTypes.bool.isRequired,
name: PropTypes.string.isRequired,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ContactCardHeaderVersionView } from './ContactCardHeaderVersionView';
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import PropTypes from 'prop-types';
import { useContext } from 'react';
import { FormattedMessage } from 'react-intl';

import {
Expand All @@ -10,31 +9,27 @@ import {
import {
LANG_LABEL_BY_CODE,
VersionKeyValue,
VersionViewContext,
} from '@folio/stripes-acq-components';

import { ContactPersonSection } from '../../../../../ContactPeople/ContactPerson';
import { ContactCardHeaderVersionView } from './ContactCardHeaderVersionView';

export const ContactPersonEmailsVersionView = ({ emails }) => {
const versionContext = useContext(VersionViewContext);

if (!emails?.length) return null;

const renderBody = () => (
<Row>
<Col xs={12}>
{emails?.map((email) => {
const isPrimaryValue = (
<h4 style={{ margin: 0 }}>
<FormattedMessage id={`ui-organizations.${email?.isPrimary ? 'primaryItem' : 'alternateItem'}`} />
</h4>
);
const headerStart = versionContext?.paths?.includes(`${email?._initialFieldPath}.isPrimary`)
? <span><mark>{isPrimaryValue}</mark></span>
: isPrimaryValue;

return (
<Card headerStart={headerStart}>
<Card
headerStart={(
<ContactCardHeaderVersionView
name={`${email?._initialFieldPath}.isPrimary`}
isPrimary={email?.isPrimary}
/>
)}
>
<Row>
<Col xs={3}>
<VersionKeyValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import PropTypes from 'prop-types';
import { useContext } from 'react';
import { FormattedMessage } from 'react-intl';

import {
Expand All @@ -10,32 +9,28 @@ import {
import {
LANG_LABEL_BY_CODE,
VersionKeyValue,
VersionViewContext,
} from '@folio/stripes-acq-components';

import { ContactPersonSection } from '../../../../../ContactPeople/ContactPerson';
import { ContactCardHeaderVersionView } from './ContactCardHeaderVersionView';

export const ContactPersonPhonesVersionView = ({ phones }) => {
const versionContext = useContext(VersionViewContext);

if (!phones?.length) return null;

const renderBody = () => (
(
<Row>
<Col xs={12}>
{phones?.map((phone) => {
const isPrimaryValue = (
<h4 style={{ margin: 0 }}>
<FormattedMessage id={`ui-organizations.${phone?.isPrimary ? 'primaryItem' : 'alternateItem'}`} />
</h4>
);
const headerStart = versionContext?.paths?.includes(`${phone?._initialFieldPath}.isPrimary`)
? <mark>{isPrimaryValue}</mark>
: isPrimaryValue;

return (
<Card headerStart={headerStart}>
<Card
headerStart={(
<ContactCardHeaderVersionView
name={`${phone?._initialFieldPath}.isPrimary`}
isPrimary={phone?.isPrimary}
/>
)}
>
<Row>
<Col xs={3}>
<VersionKeyValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import PropTypes from 'prop-types';
import { useContext } from 'react';
import { FormattedMessage } from 'react-intl';

import {
Expand All @@ -11,31 +10,27 @@ import {
import {
LANG_LABEL_BY_CODE,
VersionKeyValue,
VersionViewContext,
} from '@folio/stripes-acq-components';

import { ContactPersonSection } from '../../../../../ContactPeople/ContactPerson';
import { ContactCardHeaderVersionView } from './ContactCardHeaderVersionView';

export const ContactPersonURLsVersionView = ({ urls }) => {
const versionContext = useContext(VersionViewContext);

if (!urls?.length) return null;

const renderBody = () => (
<Row>
<Col xs={12}>
{urls?.map((url) => {
const isPrimaryValue = (
<h4 style={{ margin: 0 }}>
<FormattedMessage id={`ui-organizations.${url?.isPrimary ? 'primaryItem' : 'alternateItem'}`} />
</h4>
);
const headerStart = versionContext?.paths?.includes(`${url?._initialFieldPath}.isPrimary`)
? <mark>{isPrimaryValue}</mark>
: isPrimaryValue;

return (
<Card headerStart={headerStart}>
<Card
headerStart={(
<ContactCardHeaderVersionView
name={`${url?._initialFieldPath}.isPrimary`}
isPrimary={url?.isPrimary}
/>
)}
>
<Row>
<Col xs={3}>
<VersionKeyValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,44 @@ export const getOrganizationFieldsLabelMap = () => {
'addresses[\\d].stateRegion': 'ui-organizations.contactPeople.stateRegion',
'addresses[\\d].zipCode': 'ui-organizations.contactPeople.zipCode',
'addresses[\\d].country': 'ui-organizations.contactPeople.country',
'addresses[\\d].isPrimary': 'ui-organizations.primaryItem',
'addresses[\\d].categories': 'ui-organizations.contactPeople.categories',
'addresses[\\d].categories[\\d]': 'ui-organizations.contactPeople.categories',
'addresses[\\d].language': 'ui-organizations.contactPeople.language',
'addresses[\\d].isPrimary': 'ui-organizations.versionHistory.field.address.isPrimary',
'addresses[\\d].categories': 'ui-organizations.versionHistory.field.address.categories',
'addresses[\\d].categories[\\d]': 'ui-organizations.versionHistory.field.address.categories',
'addresses[\\d].language': 'ui-organizations.versionHistory.field.address.language',
'phoneNumbers': 'ui-organizations.contactPeople.phoneNumbers',
'phoneNumbers[\\d]': 'ui-organizations.contactPeople.phoneNumbers',
'phoneNumbers[\\d].phoneNumber': 'ui-organizations.contactPeople.phoneNumber',
'phoneNumbers[\\d].categories': 'ui-organizations.contactPeople.categories',
'phoneNumbers[\\d].categories[\\d]': 'ui-organizations.contactPeople.categories',
'phoneNumbers[\\d].type': 'ui-organizations.contactPeople.type',
'phoneNumbers[\\d].isPrimary': 'ui-organizations.primaryItem',
'phoneNumbers[\\d].categories': 'ui-organizations.versionHistory.field.phoneNumbers.categories',
'phoneNumbers[\\d].categories[\\d]': 'ui-organizations.versionHistory.field.phoneNumbers.categories',
'phoneNumbers[\\d].type': 'ui-organizations.versionHistory.field.phoneNumbers.type',
'phoneNumbers[\\d].isPrimary': 'ui-organizations.versionHistory.field.phoneNumbers.isPrimary',
'phoneNumbers[\\d].language': 'ui-organizations.contactPeople.language',
'emails': 'ui-organizations.contactPeople.emails',
'emails[\\d]': 'ui-organizations.contactPeople.emails',
'emails[\\d].value': 'ui-organizations.contactPeople.emailAddress',
'emails[\\d].description': 'ui-organizations.contactPeople.description',
'emails[\\d].isPrimary': 'ui-organizations.primaryItem',
'emails[\\d].categories': 'ui-organizations.contactPeople.categories',
'emails[\\d].categories[\\d]': 'ui-organizations.contactPeople.categories',
'emails[\\d].language': 'ui-organizations.contactPeople.language',
'emails[\\d].description': 'ui-organizations.versionHistory.field.emails.description',
'emails[\\d].isPrimary': 'ui-organizations.versionHistory.field.emails.isPrimary',
'emails[\\d].categories': 'ui-organizations.versionHistory.field.emails.categories',
'emails[\\d].categories[\\d]': 'ui-organizations.versionHistory.field.emails.categories',
'emails[\\d].language': 'ui-organizations.versionHistory.field.emails.language',
'urls': 'ui-organizations.contactPeople.urls',
'urls[\\d]': 'ui-organizations.contactPeople.urls',
'urls[\\d].value': 'ui-organizations.contactPeople.url',
'urls[\\d].description': 'ui-organizations.contactPeople.description',
'urls[\\d].language': 'ui-organizations.contactPeople.language',
'urls[\\d].isPrimary': 'ui-organizations.primaryItem',
'urls[\\d].categories': 'ui-organizations.contactPeople.categories',
'urls[\\d].categories[\\d]': 'ui-organizations.contactPeople.categories',
'urls[\\d].description': 'ui-organizations.versionHistory.field.urls.description',
'urls[\\d].language': 'ui-organizations.versionHistory.field.urls.language',
'urls[\\d].isPrimary': 'ui-organizations.versionHistory.field.urls.isPrimary',
'urls[\\d].categories': 'ui-organizations.versionHistory.field.urls.categories',
'urls[\\d].categories[\\d]': 'ui-organizations.versionHistory.field.urls.categories',

'contacts': 'ui-organizations.contactPeople',
'contacts[\\d]': 'ui-organizations.contactPeople',
'privilegedContacts': 'ui-organizations.privilegedDonorInformation',
'agreements': 'ui-organizations.linkedAgreements.section',
'agreements[\\d]': 'ui-organizations.linkedAgreements.section',
'agreements[\\d].name': 'ui-organizations.agreement.name',
'agreements[\\d].name': 'ui-organizations.versionHistory.field.agreements.name',
'agreements[\\d].discount': 'ui-organizations.agreement.discount',
'agreements[\\d].referenceUrl': 'ui-organizations.agreement.referenceUrl',
'agreements[\\d].notes': 'ui-organizations.agreement.notes',
'agreements[\\d].notes': 'ui-organizations.versionHistory.field.agreements.notes',
'erpCode': 'ui-organizations.summary.accountingCode',
'paymentMethod': 'ui-organizations.accounts.paymentMethod',
'accessProvider': 'ui-organizations.versionHistory.field.accessProvider',
Expand Down Expand Up @@ -100,7 +100,7 @@ export const getOrganizationFieldsLabelMap = () => {
'edi.sendAcctNum': 'integration.edi.sendAccountNumber',
'edi.supportOrder': 'ui-organizations.integration.edi.orders',
'edi.supportInvoice': 'ui-organizations.integration.edi.invoices',
'edi.notes': 'ui-organizations.integration.edi.notes',
'edi.notes': 'ui-organizations.versionHistory.field.edi.notes',
'edi.ediFtp': 'ui-organizations.integration.ftp',
'edi.ediFtp.ftpFormat': 'ui-organizations.integration.ftp.ftpFormat',
'edi.ediFtp.serverAddress': 'ui-organizations.integration.ftp.serverAddress',
Expand Down
21 changes: 21 additions & 0 deletions translations/ui-organizations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,34 @@
"versionHistory.field.accessProvider": "Access provider",
"versionHistory.field.governmental": "Governmental",
"versionHistory.field.licensor": "Licensor",
"versionHistory.field.edi.notes": "Notes (EDI)",
"versionHistory.field.edi.prorateTax": "Prorate tax",
"versionHistory.field.edi.prorateFees": "Prorate fees",
"versionHistory.field.edi.ediJob.sendToEmails": "Send to emails",
"versionHistory.field.edi.ediJob.notifyAllEdi": "Notify all",
"versionHistory.field.edi.ediJob.notifyInvoiceOnly": "Notify invoice only",
"versionHistory.field.edi.ediJob.notifyErrorOnly": "Notify error only",
"versionHistory.field.edi.ediJob.schedulingNotes": "Scheduling notes",
"versionHistory.field.address.isPrimary": "Primary (Address)",
"versionHistory.field.address.categories": "Categories (Address)",
"versionHistory.field.address.language": "Language (Address)",
"versionHistory.field.phoneNumbers.isPrimary": "Primary (Phone number)",
"versionHistory.field.phoneNumbers.categories": "Categories (Phone number)",
"versionHistory.field.phoneNumbers.language": "Language (Phone number)",
"versionHistory.field.phoneNumbers.type": "Type (Phone number)",
"versionHistory.field.emails.description": "Description (Email)",
"versionHistory.field.emails.isPrimary": "Primary (Email)",
"versionHistory.field.emails.categories": "Categories (Email)",
"versionHistory.field.emails.language": "Language (Email)",
"versionHistory.field.urls.description": "Description (URL)",
"versionHistory.field.urls.language": "Language (URL)",
"versionHistory.field.urls.isPrimary": "Primary (URL)",
"versionHistory.field.urls.categories": "Categories (URL)",
"versionHistory.field.agreements.name": "Name (Agreement)",
"versionHistory.field.agreements.notes": "Notes (Agreement)",
"versionHistory.field.accounts.name": "Name (Account)",
"versionHistory.field.accounts.description": "Description (Account)",
"versionHistory.field.accounts.notes": "Notes (Account)",

"settings.categories": "Categories",
"settings.categories.cannotDeleteTermHeader": "Cannot delete category",
Expand Down

0 comments on commit a9433a8

Please sign in to comment.