@k-int/address-plugins 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +249 -0
- package/es/address-plugin-british-isles/index.js +13 -0
- package/es/address-plugin-british-isles/src/AddressFieldsGBR.js +110 -0
- package/es/address-plugin-british-isles/src/backendToFields.js +45 -0
- package/es/address-plugin-british-isles/src/fieldOrder.js +16 -0
- package/es/address-plugin-british-isles/src/fieldsToBackend.js +101 -0
- package/es/address-plugin-british-isles/src/index.js +21 -0
- package/es/address-plugin-british-isles/src/listOfSupportedCountries.js +8 -0
- package/es/address-plugin-generic/index.js +13 -0
- package/es/address-plugin-generic/src/AddressFieldsGeneric.js +140 -0
- package/es/address-plugin-generic/src/backendToFields.js +53 -0
- package/es/address-plugin-generic/src/fieldOrder.js +19 -0
- package/es/address-plugin-generic/src/fieldsToBackend.js +140 -0
- package/es/address-plugin-generic/src/index.js +21 -0
- package/es/address-plugin-generic/src/listOfSupportedCountries.js +8 -0
- package/es/address-plugin-north-america/index.js +13 -0
- package/es/address-plugin-north-america/src/AddressFieldsUSA.js +106 -0
- package/es/address-plugin-north-america/src/backendToFields.js +41 -0
- package/es/address-plugin-north-america/src/fieldOrder.js +15 -0
- package/es/address-plugin-north-america/src/fieldsToBackend.js +98 -0
- package/es/address-plugin-north-america/src/index.js +21 -0
- package/es/address-plugin-north-america/src/listOfSupportedCountries.js +8 -0
- package/es/address-utils/index.js +16 -0
- package/es/address-utils/src/deleteFieldIfExists.js +17 -0
- package/es/address-utils/src/getExistingLineField.js +14 -0
- package/es/address-utils/src/index.js +27 -0
- package/es/address-utils/src/requiredValidator.js +20 -0
- package/es/index.js +31 -0
- package/package.json +65 -0
- package/src/address-plugin-british-isles/README.md +31 -0
- package/src/address-plugin-british-isles/index.js +1 -0
- package/src/address-plugin-british-isles/src/AddressFieldsGBR.js +88 -0
- package/src/address-plugin-british-isles/src/backendToFields.js +43 -0
- package/src/address-plugin-british-isles/src/fieldOrder.js +11 -0
- package/src/address-plugin-british-isles/src/fieldsToBackend.js +51 -0
- package/src/address-plugin-british-isles/src/index.js +9 -0
- package/src/address-plugin-british-isles/src/listOfSupportedCountries.js +3 -0
- package/src/address-plugin-generic/README.md +6 -0
- package/src/address-plugin-generic/index.js +1 -0
- package/src/address-plugin-generic/src/AddressFieldsGeneric.js +112 -0
- package/src/address-plugin-generic/src/backendToFields.js +51 -0
- package/src/address-plugin-generic/src/fieldOrder.js +14 -0
- package/src/address-plugin-generic/src/fieldsToBackend.js +68 -0
- package/src/address-plugin-generic/src/index.js +9 -0
- package/src/address-plugin-generic/src/listOfSupportedCountries.js +3 -0
- package/src/address-plugin-north-america/README.md +33 -0
- package/src/address-plugin-north-america/index.js +1 -0
- package/src/address-plugin-north-america/src/AddressFieldsUSA.js +85 -0
- package/src/address-plugin-north-america/src/backendToFields.js +40 -0
- package/src/address-plugin-north-america/src/fieldOrder.js +10 -0
- package/src/address-plugin-north-america/src/fieldsToBackend.js +50 -0
- package/src/address-plugin-north-america/src/index.js +8 -0
- package/src/address-plugin-north-america/src/listOfSupportedCountries.js +2 -0
- package/src/address-utils/README.md +40 -0
- package/src/address-utils/index.js +1 -0
- package/src/address-utils/src/deleteFieldIfExists.js +8 -0
- package/src/address-utils/src/getExistingLineField.js +8 -0
- package/src/address-utils/src/index.js +5 -0
- package/src/address-utils/src/requiredValidator.js +12 -0
- package/src/index.js +4 -0
- package/translations/ui-address-plugins/ar.json +38 -0
- package/translations/ui-address-plugins/ca.json +1 -0
- package/translations/ui-address-plugins/cs_CZ.json +38 -0
- package/translations/ui-address-plugins/da.json +38 -0
- package/translations/ui-address-plugins/de.json +38 -0
- package/translations/ui-address-plugins/en.json +44 -0
- package/translations/ui-address-plugins/en_US.json +1 -0
- package/translations/ui-address-plugins/es.json +38 -0
- package/translations/ui-address-plugins/fr.json +38 -0
- package/translations/ui-address-plugins/hi_IN.json +38 -0
- package/translations/ui-address-plugins/hu.json +38 -0
- package/translations/ui-address-plugins/it_IT.json +38 -0
- package/translations/ui-address-plugins/ja.json +38 -0
- package/translations/ui-address-plugins/ko.json +1 -0
- package/translations/ui-address-plugins/nb.json +1 -0
- package/translations/ui-address-plugins/nn.json +1 -0
- package/translations/ui-address-plugins/pl.json +38 -0
- package/translations/ui-address-plugins/pt_PT.json +38 -0
- package/translations/ui-address-plugins/ru.json +38 -0
- package/translations/ui-address-plugins/sv.json +38 -0
- package/translations/ui-address-plugins/ur.json +1 -0
- package/translations/ui-address-plugins/zh_CN.json +38 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { deleteFieldIfExists, getExistingLineField } from '../../address-utils';
|
|
2
|
+
|
|
3
|
+
const fieldsToBackend = (address) => {
|
|
4
|
+
const addressId = address.id || null;
|
|
5
|
+
const countryCode = address.countryCode || null;
|
|
6
|
+
const newAddress = {};
|
|
7
|
+
let lines = [];
|
|
8
|
+
|
|
9
|
+
if (address.department) {
|
|
10
|
+
const id = getExistingLineField(address.lines, 'department')?.id;
|
|
11
|
+
lines.push({ type: { value: 'Department' }, value: address.department, id });
|
|
12
|
+
} else {
|
|
13
|
+
lines.push(deleteFieldIfExists(address.lines, 'department'));
|
|
14
|
+
}
|
|
15
|
+
if (address.premise) {
|
|
16
|
+
const id = getExistingLineField(address.lines, 'premise')?.id;
|
|
17
|
+
lines.push({ type: { value: 'Premise' }, value: address.premise, id });
|
|
18
|
+
} else {
|
|
19
|
+
lines.push(deleteFieldIfExists(address.lines, 'premise'));
|
|
20
|
+
}
|
|
21
|
+
if (address.thoroughfare) {
|
|
22
|
+
const id = getExistingLineField(address.lines, 'thoroughfare')?.id;
|
|
23
|
+
lines.push({ type: { value: 'Thoroughfare' }, value: address.thoroughfare, id });
|
|
24
|
+
}
|
|
25
|
+
if (address.postalCodeOrTown) {
|
|
26
|
+
const id = getExistingLineField(address.lines, 'postalcodeortown')?.id;
|
|
27
|
+
lines.push({ type: { value: 'PostalCodeOrTown' }, value: address.postalCodeOrTown, id });
|
|
28
|
+
} else {
|
|
29
|
+
lines.push(deleteFieldIfExists(address.lines, 'postalcodeortown'));
|
|
30
|
+
}
|
|
31
|
+
if (address.locality) {
|
|
32
|
+
const id = getExistingLineField(address.lines, 'locality')?.id;
|
|
33
|
+
lines.push({ type: { value: 'Locality' }, value: address.locality, id });
|
|
34
|
+
}
|
|
35
|
+
if (address.administrativeArea) {
|
|
36
|
+
const id = getExistingLineField(address.lines, 'administrativearea')?.id;
|
|
37
|
+
lines.push({ type: { value: 'AdministrativeArea' }, value: address.administrativeArea, id });
|
|
38
|
+
}
|
|
39
|
+
if (address.postalCode) {
|
|
40
|
+
const id = getExistingLineField(address.lines, 'postalcode')?.id;
|
|
41
|
+
lines.push({ type: { value: 'PostalCode' }, value: address.postalCode, id });
|
|
42
|
+
}
|
|
43
|
+
if (address.postBox) {
|
|
44
|
+
const id = getExistingLineField(address.lines, 'postbox')?.id;
|
|
45
|
+
lines.push({ type: { value: 'PostBox' }, value: address.postBox, id });
|
|
46
|
+
} else {
|
|
47
|
+
lines.push(deleteFieldIfExists(address.lines, 'postbox'));
|
|
48
|
+
}
|
|
49
|
+
if (address.postOffice) {
|
|
50
|
+
const id = getExistingLineField(address.lines, 'postoffice')?.id;
|
|
51
|
+
lines.push({ type: { value: 'PostOffice' }, value: address.postOffice, id });
|
|
52
|
+
} else {
|
|
53
|
+
lines.push(deleteFieldIfExists(address.lines, 'postoffice'));
|
|
54
|
+
}
|
|
55
|
+
if (address.country) {
|
|
56
|
+
const id = getExistingLineField(address.lines, 'country')?.id;
|
|
57
|
+
lines.push({ type: { value: 'Country' }, value: address.country, id });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
lines = lines.filter(line => (line !== null));
|
|
61
|
+
newAddress.addressLabel = address.addressLabel;
|
|
62
|
+
newAddress.lines = lines;
|
|
63
|
+
newAddress.id = addressId;
|
|
64
|
+
newAddress.countryCode = countryCode;
|
|
65
|
+
return newAddress;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default fieldsToBackend;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import addressFields from './AddressFieldsGeneric';
|
|
2
|
+
import fieldsToBackend from './fieldsToBackend';
|
|
3
|
+
import backendToFields from './backendToFields';
|
|
4
|
+
import listOfSupportedCountries from './listOfSupportedCountries';
|
|
5
|
+
import fieldOrder from './fieldOrder';
|
|
6
|
+
|
|
7
|
+
const pluginName = 'address-plugin-generic';
|
|
8
|
+
|
|
9
|
+
export default { addressFields, fieldsToBackend, backendToFields, listOfSupportedCountries, fieldOrder, pluginName };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
# address-plugin-north-america
|
|
3
|
+
|
|
4
|
+
This is a plugin designed for use with `address-plugin-utils` as part of a general set of plugins. This plugin in particular refers to the US specific address form.
|
|
5
|
+
## Generic information
|
|
6
|
+
For the generic information about how these plugins operate, please see [here](https://gitlab.com/knowledge-integration/folio/addressplugins/-/blob/main/README.md). (I'd HIGHLY recommend starting there rather than trying to jump in blind here).
|
|
7
|
+
|
|
8
|
+
## plugin-specific details
|
|
9
|
+
The US form has some magic when it comes to the displayed `Address Line 1` and `AddressLine 2`. As per normal, it accepts data from the backend with `Premise` and `Thoroughfare`, and if both exists it will display those in `Address Line 1` and `AddressLine 2` respectively. However if just `Thoroughfare` exists, that will be displayed in `Address Line 1`, with `Address Line 2` left blank. This works in both directions, so you'd expect a user input of
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Address Line 1: "ABC Library",
|
|
13
|
+
Address Line 2: "123 Street"
|
|
14
|
+
```
|
|
15
|
+
to wind up as
|
|
16
|
+
```
|
|
17
|
+
Premise: "ABC Library",
|
|
18
|
+
Thoroughfare: "123 Street"
|
|
19
|
+
```
|
|
20
|
+
but an input without an Address Line 2:
|
|
21
|
+
```
|
|
22
|
+
Address Line 1: "123 Street"
|
|
23
|
+
```
|
|
24
|
+
to end up as
|
|
25
|
+
```
|
|
26
|
+
Thoroughfare: "123 Street"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This means that `Address Line 1` is listed as required.
|
|
30
|
+
`backendToFields` and `fieldsToBackend` should be able to do most of the lifting here.
|
|
31
|
+
|
|
32
|
+
## Supported countries
|
|
33
|
+
This plugin currently supports address forms for USA and Canada
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './src';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import { Row, Col } from 'react-flexbox-grid';
|
|
4
|
+
import { requiredValidator } from '../../address-utils';
|
|
5
|
+
|
|
6
|
+
const AddressFieldsUSA = ({ AddressTextField, country, name }) => {
|
|
7
|
+
return (
|
|
8
|
+
<>
|
|
9
|
+
<Row>
|
|
10
|
+
<Col xs={6}>
|
|
11
|
+
<AddressTextField
|
|
12
|
+
name={name ? `${name}.addressLineOne` : 'addressLineOne'}
|
|
13
|
+
label={<FormattedMessage id={`ui-address-plugins.NA.${country}.addressLineOne`} />}
|
|
14
|
+
required
|
|
15
|
+
validator={requiredValidator}
|
|
16
|
+
/>
|
|
17
|
+
</Col>
|
|
18
|
+
<Col xs={6}>
|
|
19
|
+
<AddressTextField
|
|
20
|
+
name={name ? `${name}.addressLineTwo` : 'addressLineTwo'}
|
|
21
|
+
label={<FormattedMessage id={`ui-address-plugins.NA.${country}.addressLineTwo`} />}
|
|
22
|
+
/>
|
|
23
|
+
</Col>
|
|
24
|
+
</Row>
|
|
25
|
+
<Row>
|
|
26
|
+
<Col xs={12}>
|
|
27
|
+
<AddressTextField
|
|
28
|
+
name={name ? `${name}.locality` : 'locality'}
|
|
29
|
+
label={<FormattedMessage id={`ui-address-plugins.NA.${country}.locality`} />}
|
|
30
|
+
required
|
|
31
|
+
validator={requiredValidator}
|
|
32
|
+
/>
|
|
33
|
+
</Col>
|
|
34
|
+
</Row>
|
|
35
|
+
<Row>
|
|
36
|
+
<Col xs={6}>
|
|
37
|
+
<AddressTextField
|
|
38
|
+
name={name ? `${name}.administrativeArea` : 'administrativeArea'}
|
|
39
|
+
label={<FormattedMessage id={`ui-address-plugins.NA.${country}.administrativeArea`} />}
|
|
40
|
+
required
|
|
41
|
+
validator={requiredValidator}
|
|
42
|
+
/>
|
|
43
|
+
</Col>
|
|
44
|
+
<Col xs={6}>
|
|
45
|
+
<AddressTextField
|
|
46
|
+
name={name ? `${name}.postalCode` : 'postalCode'}
|
|
47
|
+
label={<FormattedMessage id={`ui-address-plugins.NA.${country}.postalCode`} />}
|
|
48
|
+
required
|
|
49
|
+
validator={requiredValidator}
|
|
50
|
+
/>
|
|
51
|
+
</Col>
|
|
52
|
+
</Row>
|
|
53
|
+
<Row>
|
|
54
|
+
<Col xs={12}>
|
|
55
|
+
<AddressTextField
|
|
56
|
+
name={name ? `${name}.country` : 'country'}
|
|
57
|
+
label={<FormattedMessage id={`ui-address-plugins.NA.${country}.country`} />}
|
|
58
|
+
required
|
|
59
|
+
validator={requiredValidator}
|
|
60
|
+
/>
|
|
61
|
+
</Col>
|
|
62
|
+
</Row>
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
AddressFieldsUSA.propTypes = {
|
|
68
|
+
AddressTextField: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
69
|
+
country: PropTypes.string,
|
|
70
|
+
name: PropTypes.string,
|
|
71
|
+
savedAddress: PropTypes.shape({
|
|
72
|
+
addressLabel: PropTypes.string,
|
|
73
|
+
countryCode: PropTypes.string,
|
|
74
|
+
id: PropTypes.string,
|
|
75
|
+
lines: PropTypes.arrayOf(PropTypes.shape({
|
|
76
|
+
id: PropTypes.string.isRequired,
|
|
77
|
+
type: PropTypes.shape({
|
|
78
|
+
value: PropTypes.string.isRequired
|
|
79
|
+
}).isRequired,
|
|
80
|
+
value: PropTypes.string.isRequired
|
|
81
|
+
})),
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default AddressFieldsUSA;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getExistingLineField } from '../../address-utils';
|
|
2
|
+
|
|
3
|
+
const backendToFields = (address) => {
|
|
4
|
+
const addressFields = {};
|
|
5
|
+
|
|
6
|
+
const premise = getExistingLineField(address.lines, 'premise')?.value;
|
|
7
|
+
const thoroughfare = getExistingLineField(address.lines, 'thoroughfare')?.value;
|
|
8
|
+
const locality = getExistingLineField(address.lines, 'locality')?.value;
|
|
9
|
+
const postalCode = getExistingLineField(address.lines, 'postalcode')?.value;
|
|
10
|
+
const administrativeArea = getExistingLineField(address.lines, 'administrativearea')?.value;
|
|
11
|
+
const country = getExistingLineField(address.lines, 'country')?.value;
|
|
12
|
+
const countryCode = address?.countryCode;
|
|
13
|
+
|
|
14
|
+
if (premise && thoroughfare) {
|
|
15
|
+
addressFields.addressLineOne = premise;
|
|
16
|
+
addressFields.addressLineTwo = thoroughfare;
|
|
17
|
+
} else {
|
|
18
|
+
addressFields.addressLineOne = thoroughfare;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (locality) {
|
|
22
|
+
addressFields.locality = locality;
|
|
23
|
+
}
|
|
24
|
+
if (postalCode) {
|
|
25
|
+
addressFields.postalCode = postalCode;
|
|
26
|
+
}
|
|
27
|
+
if (administrativeArea) {
|
|
28
|
+
addressFields.administrativeArea = administrativeArea;
|
|
29
|
+
}
|
|
30
|
+
if (country) {
|
|
31
|
+
addressFields.country = country;
|
|
32
|
+
}
|
|
33
|
+
if (countryCode) {
|
|
34
|
+
addressFields.countryCode = countryCode;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return addressFields;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default backendToFields;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { deleteFieldIfExists, getExistingLineField } from '../../address-utils';
|
|
2
|
+
|
|
3
|
+
const fieldsToBackend = (address) => {
|
|
4
|
+
const addressId = address.id || null;
|
|
5
|
+
const countryCode = address.countryCode || null;
|
|
6
|
+
const newAddress = {};
|
|
7
|
+
let lines = [];
|
|
8
|
+
|
|
9
|
+
if (address.addressLineOne && address.addressLineTwo) {
|
|
10
|
+
// In this case we assume the first line is a premise, and the second is a thoroughfare
|
|
11
|
+
const premiseId = getExistingLineField(address.lines, 'premise')?.id;
|
|
12
|
+
const thoroughfareId = getExistingLineField(address.lines, 'thoroughfare')?.id;
|
|
13
|
+
|
|
14
|
+
lines.push({ type: { value: 'Premise' }, value: address.addressLineOne, id: premiseId });
|
|
15
|
+
lines.push({ type: { value: 'Thoroughfare' }, value: address.addressLineTwo, id: thoroughfareId });
|
|
16
|
+
} else {
|
|
17
|
+
// The only other scenario that should happen is a blank address line 2,
|
|
18
|
+
// in which case we assume that address line 1 was the thoroughfare.
|
|
19
|
+
const thoroughfareId = getExistingLineField(address.lines, 'thoroughfare')?.id;
|
|
20
|
+
lines.push({ type: { value: 'Thoroughfare' }, value: address.addressLineOne, id: thoroughfareId });
|
|
21
|
+
// In this case we can also check if there used to be a premise, and delete it if so
|
|
22
|
+
lines.push(deleteFieldIfExists(address.lines, 'premise'));
|
|
23
|
+
}
|
|
24
|
+
if (address.locality) {
|
|
25
|
+
const id = getExistingLineField(address.lines, 'locality')?.id;
|
|
26
|
+
lines.push({ type: { value: 'Locality' }, value: address.locality, id });
|
|
27
|
+
}
|
|
28
|
+
if (address.administrativeArea) {
|
|
29
|
+
const id = getExistingLineField(address.lines, 'administrativearea')?.id;
|
|
30
|
+
lines.push({ type: { value: 'AdministrativeArea' }, value: address.administrativeArea, id });
|
|
31
|
+
}
|
|
32
|
+
if (address.postalCode) {
|
|
33
|
+
const id = getExistingLineField(address.lines, 'postalcode')?.id;
|
|
34
|
+
lines.push({ type: { value: 'PostalCode' }, value: address.postalCode, id });
|
|
35
|
+
}
|
|
36
|
+
if (address.country) {
|
|
37
|
+
const id = getExistingLineField(address.lines, 'country')?.id;
|
|
38
|
+
lines.push({ type: { value: 'Country' }, value: address.country, id });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
lines = lines.filter(line => (line !== null));
|
|
42
|
+
newAddress.addressLabel = address.addressLabel;
|
|
43
|
+
newAddress.lines = lines;
|
|
44
|
+
newAddress.id = addressId;
|
|
45
|
+
newAddress.countryCode = countryCode;
|
|
46
|
+
|
|
47
|
+
return newAddress;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default fieldsToBackend;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import addressFields from './AddressFieldsUSA';
|
|
2
|
+
import fieldsToBackend from './fieldsToBackend';
|
|
3
|
+
import backendToFields from './backendToFields';
|
|
4
|
+
import listOfSupportedCountries from './listOfSupportedCountries';
|
|
5
|
+
import fieldOrder from './fieldOrder';
|
|
6
|
+
|
|
7
|
+
const pluginName = 'address-plugin-north-america';
|
|
8
|
+
export default { addressFields, fieldsToBackend, backendToFields, listOfSupportedCountries, fieldOrder, pluginName };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
# address-utils
|
|
3
|
+
|
|
4
|
+
This is a set of functions and components designed to work across many `address-plugins`. For the most part you shouldn't need to actually access any of these, but they're listed here for posterity.
|
|
5
|
+
|
|
6
|
+
## Generic information
|
|
7
|
+
For the generic information about how these plugins operate, please see [here](https://gitlab.com/knowledge-integration/folio/addressplugins/-/blob/main/README.md). (I'd HIGHLY recommend starting there rather than trying to jump in blind here).
|
|
8
|
+
|
|
9
|
+
## Functions
|
|
10
|
+
This set `address-utils` currently comprises of 2 functions and a component:
|
|
11
|
+
- getExistingLineField
|
|
12
|
+
- deleteFieldIfExists
|
|
13
|
+
- AddressTextField
|
|
14
|
+
|
|
15
|
+
We'll go over these one by one.
|
|
16
|
+
|
|
17
|
+
### getExistingLineField
|
|
18
|
+
This function accepts an array of `lines` (see the general documentation for more information about what those are) and a string containing the lowercase name of the field you're working on. Those follow the names set out by the general documentation, e.g. `"premise"`.
|
|
19
|
+
|
|
20
|
+
This function simply parses the array of lines, and returns the one whose `line.type?.value` matches the field `string`, or null if none exist.
|
|
21
|
+
|
|
22
|
+
(This is **NOT** set up to allow multiple lines of the same type. This function will just return the first one it finds. See the general docs for more information.)
|
|
23
|
+
|
|
24
|
+
### deleteFieldIfExists
|
|
25
|
+
This function accepts the same props as `getExistingLineField` above. It calls `getExistingLineField` in order to find the id of the saved line, and then returns an object `{id: "some_id", _delete:true}` In our backend setup this will delete the line saved with that id, but this may not be universal, and so you may need to write code to mimic this functionality for _your_ backend model wherever it is used.
|
|
26
|
+
|
|
27
|
+
### AddressTextField
|
|
28
|
+
This is a simple component which just returns a final-form `Field` with the props passed to it and `parse={v => v}`, which is simply there to allow "empty" inputs such as " " to be submitted. This component accepts props handed to it directly from `AddressFields` from each plugin. See the general documentation for the props expected by that component, as they are simply passed through to here.
|
|
29
|
+
|
|
30
|
+
## Release Procedure
|
|
31
|
+
|
|
32
|
+
* Check CHANGELOG.md
|
|
33
|
+
* Check correct version in package.json
|
|
34
|
+
* Check everything
|
|
35
|
+
* Re-Check everything
|
|
36
|
+
* Make preparatory commit
|
|
37
|
+
* Tag - git tag -a vn.n.n -m "Tagged version n.n.n"
|
|
38
|
+
* git push origin vn.n.n (Or your preferred variant)
|
|
39
|
+
* Jenkins does it's magic causing release artefacts to appear in nexus
|
|
40
|
+
* Update the version in package.json and open the new version in CHANGELOG.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import getExistingLineField from './getExistingLineField';
|
|
2
|
+
|
|
3
|
+
const deleteFieldIfExists = (incomingLines, field) => {
|
|
4
|
+
const id = getExistingLineField(incomingLines, field)?.id;
|
|
5
|
+
return (id ? { id, _delete: true } : null);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default deleteFieldIfExists;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This is essentially a clone of the validator found in https://github.com/folio-org/stripes-erm-components/blob/master/lib/validators.js
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
|
|
4
|
+
const required = value => {
|
|
5
|
+
const blankString = /^\s+$/;
|
|
6
|
+
if ((value && !blankString.test(value)) || value === false || value === 0) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return <FormattedMessage id="stripes-core.label.missingRequiredField" />;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { required as requiredValidator };
|
package/src/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"GBR.country": "البلد",
|
|
3
|
+
"GBR.premise": "اسم المبنى",
|
|
4
|
+
"GBR.locality": "المدينة",
|
|
5
|
+
"NA.US.country": "البلد",
|
|
6
|
+
"GBR.postalCode": "الرمز البريدي",
|
|
7
|
+
"NA.CA.locality": "المدينة",
|
|
8
|
+
"NA.US.locality": "المدينة",
|
|
9
|
+
"NA.sCA.country": "البلد",
|
|
10
|
+
"generic.country": "البلد",
|
|
11
|
+
"generic.postBox": "صندوق البريد",
|
|
12
|
+
"generic.premise": "الفرضية",
|
|
13
|
+
"GBR.thoroughfare": "عنوان الشارع",
|
|
14
|
+
"NA.CA.postalCode": "الرمز البريدي",
|
|
15
|
+
"NA.US.postalCode": "الرمز البريدي",
|
|
16
|
+
"generic.locality": "المنطقة المحلية",
|
|
17
|
+
"CA.countryCode": "كندا",
|
|
18
|
+
"US.countryCode": "الولايات المتحدة الأمريكية",
|
|
19
|
+
"GB-ENG.countryCode": "إنجلترا",
|
|
20
|
+
"GB-NIR.countryCode": "أيرلندا الشمالية",
|
|
21
|
+
"GB-SCT.countryCode": "اسكتلندا",
|
|
22
|
+
"GB-WLS.countryCode": "ويلز",
|
|
23
|
+
"generic.department": "القسم",
|
|
24
|
+
"generic.postOffice": "مكتب البريد",
|
|
25
|
+
"generic.postalCode": "الرمز البريدي",
|
|
26
|
+
"generic.countryCode": "عام",
|
|
27
|
+
"GBR.postalCodeOrTown": "المدينة",
|
|
28
|
+
"NA.CA.addressLineOne": "سطر العنوان 1",
|
|
29
|
+
"NA.CA.addressLineTwo": "سطر العنوان 2",
|
|
30
|
+
"NA.US.addressLineOne": "سطر العنوان 1",
|
|
31
|
+
"NA.US.addressLineTwo": "سطر العنوان 2",
|
|
32
|
+
"generic.thoroughfare": "الطريق السريع",
|
|
33
|
+
"GBR.administrativeArea": "المقاطعة",
|
|
34
|
+
"NA.CA.administrativeArea": "المقاطعات",
|
|
35
|
+
"NA.US.administrativeArea": "الولاية",
|
|
36
|
+
"generic.postalCodeOrTown": "المدينة",
|
|
37
|
+
"generic.administrativeArea": "المنطقة الإدارية"
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"GBR.country": "Země",
|
|
3
|
+
"GBR.premise": "Název budovy",
|
|
4
|
+
"GBR.locality": "Město",
|
|
5
|
+
"NA.US.country": "Země",
|
|
6
|
+
"GBR.postalCode": "Poštovní směrovací číslo",
|
|
7
|
+
"NA.CA.locality": "Město",
|
|
8
|
+
"NA.US.locality": "Město",
|
|
9
|
+
"NA.sCA.country": "Země",
|
|
10
|
+
"generic.country": "Země",
|
|
11
|
+
"generic.postBox": "Poštovní schránka",
|
|
12
|
+
"generic.premise": "Předpoklad",
|
|
13
|
+
"GBR.thoroughfare": "Adresa ulice",
|
|
14
|
+
"NA.CA.postalCode": "Poštovní směrovací číslo",
|
|
15
|
+
"NA.US.postalCode": "Poštovní směrovací číslo",
|
|
16
|
+
"generic.locality": "Lokalita",
|
|
17
|
+
"CA.countryCode": "Kanada",
|
|
18
|
+
"US.countryCode": "USA",
|
|
19
|
+
"GB-ENG.countryCode": "Anglie",
|
|
20
|
+
"GB-NIR.countryCode": "Severní Irsko",
|
|
21
|
+
"GB-SCT.countryCode": "Skotsko",
|
|
22
|
+
"GB-WLS.countryCode": "Wales",
|
|
23
|
+
"generic.department": "Oddělení",
|
|
24
|
+
"generic.postOffice": "Pošta",
|
|
25
|
+
"generic.postalCode": "Poštovní směrovací číslo",
|
|
26
|
+
"generic.countryCode": "Obecné",
|
|
27
|
+
"GBR.postalCodeOrTown": "Město",
|
|
28
|
+
"NA.CA.addressLineOne": "Adresní řádek 1",
|
|
29
|
+
"NA.CA.addressLineTwo": "Adresní řádek 2",
|
|
30
|
+
"NA.US.addressLineOne": "Adresní řádek 1",
|
|
31
|
+
"NA.US.addressLineTwo": "Adresní řádek 2",
|
|
32
|
+
"generic.thoroughfare": "Průjezdní komunikace",
|
|
33
|
+
"GBR.administrativeArea": "Okres",
|
|
34
|
+
"NA.CA.administrativeArea": "Provincie",
|
|
35
|
+
"NA.US.administrativeArea": "Stát",
|
|
36
|
+
"generic.postalCodeOrTown": "Město",
|
|
37
|
+
"generic.administrativeArea": "Správní oblast"
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"GBR.country": "Land",
|
|
3
|
+
"GBR.premise": "Bygningens navn",
|
|
4
|
+
"GBR.locality": "By",
|
|
5
|
+
"NA.US.country": "Land",
|
|
6
|
+
"GBR.postalCode": "Postnummer",
|
|
7
|
+
"NA.CA.locality": "By",
|
|
8
|
+
"NA.US.locality": "By",
|
|
9
|
+
"NA.sCA.country": "Land",
|
|
10
|
+
"generic.country": "Land",
|
|
11
|
+
"generic.postBox": "Postkasse",
|
|
12
|
+
"generic.premise": "Forudsætninger",
|
|
13
|
+
"GBR.thoroughfare": "Gadeadresse",
|
|
14
|
+
"NA.CA.postalCode": "Postnummer",
|
|
15
|
+
"NA.US.postalCode": "Postnummer",
|
|
16
|
+
"generic.locality": "Lokalitet",
|
|
17
|
+
"CA.countryCode": "Canada",
|
|
18
|
+
"US.countryCode": "USA",
|
|
19
|
+
"GB-ENG.countryCode": "England",
|
|
20
|
+
"GB-NIR.countryCode": "Nordirland",
|
|
21
|
+
"GB-SCT.countryCode": "Skotland",
|
|
22
|
+
"GB-WLS.countryCode": "Wales",
|
|
23
|
+
"generic.department": "Afdeling",
|
|
24
|
+
"generic.postOffice": "Posthus",
|
|
25
|
+
"generic.postalCode": "Postnummer",
|
|
26
|
+
"generic.countryCode": "Generisk",
|
|
27
|
+
"GBR.postalCodeOrTown": "By",
|
|
28
|
+
"NA.CA.addressLineOne": "Adresselinje 1",
|
|
29
|
+
"NA.CA.addressLineTwo": "Adresselinje 2",
|
|
30
|
+
"NA.US.addressLineOne": "Adresselinje 1",
|
|
31
|
+
"NA.US.addressLineTwo": "Adresselinje 2",
|
|
32
|
+
"generic.thoroughfare": "Gennemfartsvej",
|
|
33
|
+
"GBR.administrativeArea": "Amt",
|
|
34
|
+
"NA.CA.administrativeArea": "Provinser",
|
|
35
|
+
"NA.US.administrativeArea": "Stat",
|
|
36
|
+
"generic.postalCodeOrTown": "By",
|
|
37
|
+
"generic.administrativeArea": "Administrativt område"
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"GBR.country": "Land",
|
|
3
|
+
"GBR.premise": "Name des Gebäudes",
|
|
4
|
+
"GBR.locality": "Stadt",
|
|
5
|
+
"NA.US.country": "Land",
|
|
6
|
+
"GBR.postalCode": "Postleitzahl",
|
|
7
|
+
"NA.CA.locality": "Stadt",
|
|
8
|
+
"NA.US.locality": "Stadt",
|
|
9
|
+
"NA.sCA.country": "Land",
|
|
10
|
+
"generic.country": "Land",
|
|
11
|
+
"generic.postBox": "Briefkasten",
|
|
12
|
+
"generic.premise": "Premise",
|
|
13
|
+
"GBR.thoroughfare": "Straße und Hausnummer",
|
|
14
|
+
"NA.CA.postalCode": "Postleitzahl",
|
|
15
|
+
"NA.US.postalCode": "Postleitzahl",
|
|
16
|
+
"generic.locality": "Ortschaft",
|
|
17
|
+
"CA.countryCode": "Kanada",
|
|
18
|
+
"US.countryCode": "USA",
|
|
19
|
+
"GB-ENG.countryCode": "England",
|
|
20
|
+
"GB-NIR.countryCode": "Nordirland",
|
|
21
|
+
"GB-SCT.countryCode": "Schottland",
|
|
22
|
+
"GB-WLS.countryCode": "Wales",
|
|
23
|
+
"generic.department": "Abteilung",
|
|
24
|
+
"generic.postOffice": "Postamt",
|
|
25
|
+
"generic.postalCode": "Postleitzahl",
|
|
26
|
+
"generic.countryCode": "Allgemein",
|
|
27
|
+
"GBR.postalCodeOrTown": "Stadt",
|
|
28
|
+
"NA.CA.addressLineOne": "Anschrift Zeile 1",
|
|
29
|
+
"NA.CA.addressLineTwo": "Anschrift Zeile 2",
|
|
30
|
+
"NA.US.addressLineOne": "Anschrift Zeile 1",
|
|
31
|
+
"NA.US.addressLineTwo": "Anschrift Zeile 2",
|
|
32
|
+
"generic.thoroughfare": "Stadtviertel",
|
|
33
|
+
"GBR.administrativeArea": "Landkreis",
|
|
34
|
+
"NA.CA.administrativeArea": "Provinzen",
|
|
35
|
+
"NA.US.administrativeArea": "Staat",
|
|
36
|
+
"generic.postalCodeOrTown": "Stadt",
|
|
37
|
+
"generic.administrativeArea": "Verwaltungsbereich"
|
|
38
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generic.countryCode": "Generic",
|
|
3
|
+
|
|
4
|
+
"generic.department": "Department",
|
|
5
|
+
"generic.premise": "Premise",
|
|
6
|
+
"generic.thoroughfare": "Thoroughfare",
|
|
7
|
+
"generic.locality": "Locality",
|
|
8
|
+
"generic.administrativeArea": "Administrative Area",
|
|
9
|
+
"generic.postalCodeOrTown": "Town",
|
|
10
|
+
"generic.postBox" : "Post box",
|
|
11
|
+
"generic.postalCode": "Postal code",
|
|
12
|
+
"generic.postOffice": "Post office",
|
|
13
|
+
"generic.country": "Country",
|
|
14
|
+
|
|
15
|
+
"GB-ENG.countryCode": "England",
|
|
16
|
+
"GB-SCT.countryCode": "Scotland",
|
|
17
|
+
"GB-WLS.countryCode": "Wales",
|
|
18
|
+
"GB-NIR.countryCode": "Northern Ireland",
|
|
19
|
+
|
|
20
|
+
"GBR.premise": "Building name",
|
|
21
|
+
"GBR.thoroughfare": "Street address",
|
|
22
|
+
"GBR.postalCodeOrTown": "Town",
|
|
23
|
+
"GBR.locality": "City",
|
|
24
|
+
"GBR.administrativeArea": "County",
|
|
25
|
+
"GBR.postalCode": "Post code",
|
|
26
|
+
"GBR.country": "Country",
|
|
27
|
+
|
|
28
|
+
"US.countryCode": "USA",
|
|
29
|
+
"CA.countryCode": "Canada",
|
|
30
|
+
|
|
31
|
+
"NA.US.addressLineOne": "Address line 1",
|
|
32
|
+
"NA.US.addressLineTwo": "Address line 2",
|
|
33
|
+
"NA.US.locality": "City",
|
|
34
|
+
"NA.US.administrativeArea": "State",
|
|
35
|
+
"NA.US.postalCode": "Zip code",
|
|
36
|
+
"NA.US.country": "Country",
|
|
37
|
+
|
|
38
|
+
"NA.CA.addressLineOne": "Address line 1",
|
|
39
|
+
"NA.CA.addressLineTwo": "Address line 2",
|
|
40
|
+
"NA.CA.locality": "City",
|
|
41
|
+
"NA.CA.administrativeArea": "Province",
|
|
42
|
+
"NA.CA.postalCode": "Postal code",
|
|
43
|
+
"NA.CA.country": "Country"
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|