Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIORGS-383: add donor info for organization summary #574

Merged
merged 6 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 5.1.0 (IN PROGRESS)

* Designate Organization as donor. Refs UIORGS-383.

## [5.0.0](https://github.com/folio-org/ui-organizations/tree/v5.0.0) (2023-10-12)
[Full Changelog](https://github.com/folio-org/ui-organizations/compare/v4.0.0...v5.0.0)

Expand Down
1 change: 1 addition & 0 deletions src/Organizations/OrganizationCreate/OrganizationCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const INITIAL_VALUES = {
interfaces: [],
contacts: [],
isVendor: false,
isDonor: false,
edi: {
vendorEdiType: '31B/US-SAN',
libEdiType: '31B/US-SAN',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ const OrganizationDetails = ({
description={organization.description}
erpCode={organization.erpCode}
isVendor={organization.isVendor}
isDonor={organization.isDonor}
language={organization.language}
metadata={organization.metadata}
name={organization.name}
Expand Down
alisher-epam marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import React, { useMemo } from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';

import {
Checkbox,
Col,
KeyValue,
MultiColumnList,
NoValue,
Row,
} from '@folio/stripes/components';
Expand All @@ -18,26 +17,22 @@ import {

import { ORGANIZATION_SECTIONS } from '../../constants';

const aliasesColumnMapping = {
value: <FormattedMessage id="ui-organizations.summary.alias" />,
description: <FormattedMessage id="ui-organizations.summary.description" />,
};
const aliasesVisibleColumns = ['value', 'description'];

const OrganizationSummary = ({
acqUnitIds,
aliases,
code,
description,
erpCode,
isVendor,
isDonor,
language,
metadata,
name,
status,
organizationTypes,
}) => {
const defaultLanguageValue = LANG_LABEL_BY_CODE[language] || language;
const alternativeNames = useMemo(() => aliases.map(({ value }) => value).join(', '), [aliases]);

return (
<>
Expand All @@ -53,87 +48,89 @@ const OrganizationSummary = ({
</Row>

<Row>
<Col xs={4}>
<Col xs={3}>
<KeyValue
data-testid="name"
label={<FormattedMessage id="ui-organizations.summary.name" />}
value={name}
/>
</Col>

<Col xs={4}>
<Col xs={3}>
<KeyValue
label={<FormattedMessage id="ui-organizations.summary.code" />}
value={code}
/>
</Col>

<Col xs={4}>
<Col xs={3}>
<KeyValue
data-testid="accountingCode"
label={<FormattedMessage id="ui-organizations.summary.accountingCode" />}
value={erpCode || <NoValue />}
/>
</Col>

<Col xs={4}>
<Col xs={3}>
<KeyValue
label={<FormattedMessage id="ui-organizations.summary.organizationStatus" />}
>
{status && <FormattedMessage id={`ui-organizations.organizationStatus.${status.toLowerCase()}`} />}
</KeyValue>
</Col>

<Col xs={4}>
<Col xs={3}>
<KeyValue
data-testid="defaultLanguage"
label={<FormattedMessage id="ui-organizations.summary.defaultLanguage" />}
value={defaultLanguageValue || <NoValue />}
/>
</Col>

<Col xs={4}>
<Checkbox
checked={isVendor}
disabled
label={<FormattedMessage id="ui-organizations.summary.isVendor" />}
vertical
/>
</Col>

<Col xs={4}>
<Col xs={3}>
<KeyValue
data-testid="type"
label={<FormattedMessage id="ui-organizations.summary.type" />}
value={organizationTypes.join(', ') || <NoValue />}
/>
</Col>

<Col xs={4}>
<Col xs={3}>
<AcqUnitsView units={acqUnitIds} />
</Col>

<Col xs={12}>
<Col xs={3}>
<KeyValue
data-testid="description"
label={<FormattedMessage id="ui-organizations.summary.description" />}
value={description || <NoValue />}
/>
</Col>
</Row>

<Row>
<Col xs={12}>
<Col xs={3}>
<Checkbox
checked={isDonor}
disabled
label={<FormattedMessage id="ui-organizations.summary.isDonor" />}
vertical
/>
</Col>

<Col xs={3}>
<Checkbox
checked={isVendor}
disabled
label={<FormattedMessage id="ui-organizations.summary.isVendor" />}
vertical
/>
</Col>

<Col xs={3}>
<KeyValue
data-testid="alternativeNames"
label={<FormattedMessage id="ui-organizations.summary.alternativeNames" />}
>
<MultiColumnList
contentData={aliases}
columnMapping={aliasesColumnMapping}
interactive={false}
visibleColumns={aliasesVisibleColumns}
/>
</KeyValue>
value={alternativeNames || <NoValue />}
/>
</Col>
</Row>
</>
Expand All @@ -150,6 +147,7 @@ OrganizationSummary.propTypes = {
description: PropTypes.string,
erpCode: PropTypes.string,
isVendor: PropTypes.bool,
isDonor: PropTypes.bool,
language: PropTypes.string,
metadata: PropTypes.object,
name: PropTypes.string,
Expand Down
14 changes: 8 additions & 6 deletions src/Organizations/OrganizationForm/OrganizationForm.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import React from 'react';
import { render, screen, act } from '@folio/jest-config-stripes/testing-library/react';
import { queryHelpers } from '@folio/jest-config-stripes/testing-library/dom';
import user from '@folio/jest-config-stripes/testing-library/user-event';
import { MemoryRouter } from 'react-router-dom';
import { useHistory } from 'react-router';

Expand All @@ -10,12 +6,18 @@ import {
expandAllSections,
collapseAllSections,
} from '@folio/stripes/components';
import { organizationTypes } from 'fixtures';
import {
render,
screen,
act,
} from '@folio/jest-config-stripes/testing-library/react';
import { queryHelpers } from '@folio/jest-config-stripes/testing-library/dom';
import user from '@folio/jest-config-stripes/testing-library/user-event';

import { organizationTypes } from 'fixtures';
import { ORGANIZATIONS_ROUTE } from '../../common/constants';
import OrganizationForm from './OrganizationForm';


jest.mock('react-router', () => ({
...jest.requireActual('react-router'),
useHistory: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function OrganizationSummaryForm({ initialValues }) {
onResetVendorFields();
}, [onResetVendorFields]);

const onChangeIsVendor = useCallback(({ target: { checked } }) => {
change('isVendor', checked);
const handleCheckbox = useCallback(({ target: { checked, name } }) => {
change(name, checked);

if (initialValues.id && !checked) setVendorUncheckConfirm(true);
alisher-epam marked this conversation as resolved.
Show resolved Hide resolved
}, [initialValues.id, change]);
Expand Down Expand Up @@ -159,20 +159,6 @@ function OrganizationSummaryForm({ initialValues }) {
name="language"
/>
</Col>
<Col
xs={6}
md={3}
>
<Field
component={Checkbox}
label={<FormattedMessage id="ui-organizations.summary.isVendor" />}
name="isVendor"
type="checkbox"
onChange={onChangeIsVendor}
vertical
validateFields={[]}
/>
</Col>
<Col
xs={6}
md={3}
Expand All @@ -197,6 +183,34 @@ function OrganizationSummaryForm({ initialValues }) {
validateFields={[]}
/>
</Col>
<Col
xs={6}
md={3}
>
<Field
component={Checkbox}
label={<FormattedMessage id="ui-organizations.summary.isDonor" />}
name="isDonor"
type="checkbox"
onChange={handleCheckbox}
vertical
validateFields={[]}
/>
</Col>
<Col
xs={6}
md={3}
>
<Field
component={Checkbox}
label={<FormattedMessage id="ui-organizations.summary.isVendor" />}
name="isVendor"
type="checkbox"
onChange={handleCheckbox}
vertical
validateFields={[]}
/>
</Col>
<Col xs={6}>
<FieldArray
addLabel={<FormattedMessage id="ui-organizations.summary.add" />}
Expand Down
Loading
Loading