Skip to content

Commit

Permalink
Merge branch 'master' of github.com:folio-org/ui-organizations into f…
Browse files Browse the repository at this point in the history
…eat/number_generator
  • Loading branch information
EthanFreestone committed Mar 1, 2024
2 parents d618b90 + fc155d5 commit 28d2d16
Show file tree
Hide file tree
Showing 56 changed files with 570 additions and 313 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
* Search organization on bank account number. Refs UIORGS-392.
* Enable "Hourly" and "Monthly" EDI export scheduling frequency options. Refs UIORGS-415.
* Create Privileged donor information accordion in organization record. Refs UIORGS-397.
* Factor away from unsupported `color()` function. Refs UIORGS-416.
* Suppress banking information management for unauthorized user. Refs UIORGS-418.
* Add validation for `Day` field in `Monthly` scheduler for export method. Refs UIORGS-417.
* Support `data-export-spring` interface `v2.0`. Refs UXPROD-3903.

## [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
31 changes: 24 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"okapiInterfaces": {
"acquisition-methods": "1.0",
"banking-information": "1.0",
"data-export-spring": "1.0",
"data-export-spring": "1.0 2.0",
"configuration": "2.0",
"organizations.organizations": "1.0",
"organizations-storage.addresses": "1.1",
Expand Down Expand Up @@ -80,6 +80,7 @@
"module.organizations.enabled",
"data-export.config.collection.get",
"data-export.config.item.get",
"erm.agreements.collection.get",
"orders.acquisition-methods.collection.get",
"orders.acquisition-method.item.get",
"organizations.organizations.collection.get",
Expand All @@ -97,8 +98,6 @@
"organizations-storage.interfaces.collection.get",
"organizations-storage.phone-numbers.collection.get",
"organizations-storage.phone-numbers.item.get",
"organizations-storage.privileged-contacts.collection.get",
"organizations-storage.privileged-contacts.item.get",
"organizations-storage.settings.collection.get",
"organizations-storage.urls.collection.get",
"organizations-storage.urls.item.get",
Expand All @@ -121,9 +120,6 @@
"organizations-storage.contacts.item.post",
"organizations-storage.contacts.item.put",
"organizations-storage.contacts.item.delete",
"organizations-storage.privileged-contacts.item.post",
"organizations-storage.privileged-contacts.item.put",
"organizations-storage.privileged-contacts.item.delete",
"organizations-storage.interfaces.item.post",
"organizations-storage.interfaces.item.put",
"organizations-storage.interfaces.item.delete",
Expand Down Expand Up @@ -156,13 +152,34 @@
"ui-organizations.edit"
]
},
{
"permissionName": "ui-organizations.privileged-contacts.view",
"displayName": "Organizations: can view privileged donor information",
"visible": true,
"subPermissions": [
"organizations-storage.privileged-contacts.collection.get",
"organizations-storage.privileged-contacts.item.get"
]
},
{
"permissionName": "ui-organizations.privileged-contacts.edit",
"displayName": "Organizations: can view, create, edit, delete privileged donor information",
"visible": true,
"subPermissions": [
"ui-organizations.privileged-contacts.view",
"organizations-storage.privileged-contacts.item.post",
"organizations-storage.privileged-contacts.item.put",
"organizations-storage.privileged-contacts.item.delete"
]
},
{
"permissionName": "ui-organizations.banking-information.view",
"displayName": "Organizations: View banking information",
"visible": true,
"subPermissions": [
"organizations.banking-information.collection.get",
"organizations.banking-information.item.get"
"organizations.banking-information.item.get",
"organizations-storage.banking-account-types.collection.get"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

.contactPersonItemContent {
padding: 14px;
background-color: color(var(--bg) blend(var(--bg-hover) 20%));
background-color: color-mix(in oklch, var(--bg), var(--bg-hover) 20%);
width: 100%;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,16 @@ import {
SCHEDULE_PERIODS,
WEEKDAYS,
} from '../../constants';

const ALLOWED_SCHEDULE_PERIODS = [
SCHEDULE_PERIODS.none,
SCHEDULE_PERIODS.hours,
SCHEDULE_PERIODS.days,
SCHEDULE_PERIODS.weeks,
SCHEDULE_PERIODS.months,
];

const normalizeNumber = value => {
if (!value && value !== 0) return value;

return Number(value);
};

const validatePeriod = (value) => {
return value !== SCHEDULE_PERIODS.none
? undefined
: <FormattedMessage id="stripes-acq-components.validation.required" />;
};
import {
ALLOWED_SCHEDULE_PERIODS,
MAX_DAYS_OF_MONTHLY_SCHEDULE,
MIN_REQUIRED_NUMBER,
} from './constants';
import {
validateRequiredMinAndMaxNumber,
normalizeNumber,
validatePeriod,
} from './utils';

export const SchedulingForm = () => {
const { formatMessage } = useIntl();
Expand Down Expand Up @@ -135,7 +125,7 @@ export const SchedulingForm = () => {
label={<FormattedMessage id="ui-organizations.integration.scheduling.scheduleFrequency" />}
name="exportTypeSpecificParameters.vendorEdiOrdersExportConfig.ediSchedule.scheduleParameters.scheduleFrequency"
type="number"
min={1}
min={MIN_REQUIRED_NUMBER}
hasClearIcon={false}
required
validate={validateRequiredPositiveNumber}
Expand Down Expand Up @@ -167,7 +157,7 @@ export const SchedulingForm = () => {
label={<FormattedMessage id="ui-organizations.integration.scheduling.scheduleFrequency" />}
name="exportTypeSpecificParameters.vendorEdiOrdersExportConfig.ediSchedule.scheduleParameters.scheduleFrequency"
type="number"
min={1}
min={MIN_REQUIRED_NUMBER}
hasClearIcon={false}
required
validate={validateRequiredPositiveNumber}
Expand Down Expand Up @@ -207,7 +197,7 @@ export const SchedulingForm = () => {
label={<FormattedMessage id="ui-organizations.integration.scheduling.scheduleFrequency" />}
name="exportTypeSpecificParameters.vendorEdiOrdersExportConfig.ediSchedule.scheduleParameters.scheduleFrequency"
type="number"
min={1}
min={MIN_REQUIRED_NUMBER}
hasClearIcon={false}
required
validate={validateRequiredPositiveNumber}
Expand Down Expand Up @@ -259,11 +249,11 @@ export const SchedulingForm = () => {
label={<FormattedMessage id="ui-organizations.integration.scheduling.scheduleDay" />}
name="exportTypeSpecificParameters.vendorEdiOrdersExportConfig.ediSchedule.scheduleParameters.scheduleDay"
type="number"
min={1}
max={31}
min={MIN_REQUIRED_NUMBER}
max={MAX_DAYS_OF_MONTHLY_SCHEDULE}
hasClearIcon={false}
required
validate={validateRequiredPositiveNumber}
validate={validateRequiredMinAndMaxNumber}
parse={normalizeNumber}
/>
</Col>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { SCHEDULE_PERIODS } from '../../constants';

export const ALLOWED_SCHEDULE_PERIODS = [
SCHEDULE_PERIODS.none,
SCHEDULE_PERIODS.hours,
SCHEDULE_PERIODS.days,
SCHEDULE_PERIODS.weeks,
SCHEDULE_PERIODS.months,
];

export const MIN_REQUIRED_NUMBER = 1;
export const MAX_DAYS_OF_MONTHLY_SCHEDULE = 31;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { FormattedMessage } from 'react-intl';

import {
validateRequiredMinNumber,
validateRequiredMaxNumber,
validateRequiredNumber,
} from '@folio/stripes-acq-components';

import { SCHEDULE_PERIODS } from '../../constants';
import {
MAX_DAYS_OF_MONTHLY_SCHEDULE,
MIN_REQUIRED_NUMBER,
} from './constants';

export const normalizeNumber = value => {
if (!value && value !== 0) return value;

return Number(value);
};

export const validatePeriod = (value) => {
return value !== SCHEDULE_PERIODS.none
? undefined
: <FormattedMessage id="stripes-acq-components.validation.required" />;
};

export const validateRequiredMinAndMaxNumber = (value) => {
return (
validateRequiredNumber(value)
|| validateRequiredMinNumber({ minNumber: MIN_REQUIRED_NUMBER, value })
|| validateRequiredMaxNumber({ maxNumber: MAX_DAYS_OF_MONTHLY_SCHEDULE, value })
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { SCHEDULE_PERIODS } from '../../constants';
import {
validateRequiredMinAndMaxNumber,
normalizeNumber,
validatePeriod,
} from './utils';

jest.mock('@folio/stripes-acq-components', () => ({
...jest.requireActual('@folio/stripes-acq-components'),
validateRequiredMinNumber: jest.fn(({ minNumber, value }) => (minNumber <= value ? undefined : 'min error')),
validateRequiredMaxNumber: jest.fn(({ maxNumber, value }) => (maxNumber >= value ? undefined : 'max error')),
}));

describe('OrganizationIntegrationForm utils', () => {
describe('normalizeNumber', () => {
it('should return number', () => {
expect(normalizeNumber(0)).toBe(0);
});

it('should return number', () => {
expect(normalizeNumber('0')).toBe(0);
});

it('should return undefined', () => {
expect(normalizeNumber('')).toBe('');
});
});

describe('validatePeriod', () => {
it('should return undefined', () => {
expect(validatePeriod(SCHEDULE_PERIODS.monthly)).toBe(undefined);
});

it('should return error message', () => {
expect(validatePeriod(SCHEDULE_PERIODS.none)).toBeDefined();
});
});

describe('validateRequiredMinAndMaxNumber', () => {
it('should return undefined', () => {
expect(validateRequiredMinAndMaxNumber(0)).toBeTruthy();
expect(validateRequiredMinAndMaxNumber('')).toBeTruthy();
expect(validateRequiredMinAndMaxNumber(-1)).toBeTruthy();
expect(validateRequiredMinAndMaxNumber(1)).toBe(undefined);
expect(validateRequiredMinAndMaxNumber(2)).toBe(undefined);
expect(validateRequiredMinAndMaxNumber(34)).toBeTruthy();
});
});
});
Loading

0 comments on commit 28d2d16

Please sign in to comment.