mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
feat: add display name defaultText
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ListSelect from "./ListSelect";
|
import intl from 'react-intl-universal';
|
||||||
|
import ListSelect from './ListSelect';
|
||||||
|
|
||||||
export default function DisplayNameList({
|
export default function DisplayNameList({
|
||||||
salutation,
|
salutation,
|
||||||
@@ -9,25 +10,32 @@ export default function DisplayNameList({
|
|||||||
...restProps
|
...restProps
|
||||||
}) {
|
}) {
|
||||||
const formats = [
|
const formats = [
|
||||||
{ format: '{1} {2} {3}', values: [salutation, firstName, lastName], required: [1] },
|
{
|
||||||
|
format: '{1} {2} {3}',
|
||||||
|
values: [salutation, firstName, lastName],
|
||||||
|
required: [1],
|
||||||
|
},
|
||||||
{ format: '{1} {2}', values: [firstName, lastName], required: [] },
|
{ format: '{1} {2}', values: [firstName, lastName], required: [] },
|
||||||
{ format: '{1}, {2}', values: [firstName, lastName], required: [1, 2] },
|
{ format: '{1}, {2}', values: [firstName, lastName], required: [1, 2] },
|
||||||
{ format: '{1}', values: [company], required: [1] }
|
{ format: '{1}', values: [company], required: [1] },
|
||||||
];
|
];
|
||||||
|
|
||||||
const formatOptions = formats
|
const formatOptions = formats
|
||||||
.filter((format) => !format.values.some((value, index) => {
|
.filter(
|
||||||
return !value && format.required.indexOf(index + 1) !== -1;
|
(format) =>
|
||||||
}))
|
!format.values.some((value, index) => {
|
||||||
|
return !value && format.required.indexOf(index + 1) !== -1;
|
||||||
|
}),
|
||||||
|
)
|
||||||
.map((formatOption) => {
|
.map((formatOption) => {
|
||||||
const { format, values } = formatOption;
|
const { format, values } = formatOption;
|
||||||
let label = format;
|
let label = format;
|
||||||
|
|
||||||
values.forEach((value, index) => {
|
values.forEach((value, index) => {
|
||||||
const replaceWith = (value || '');
|
const replaceWith = value || '';
|
||||||
label = label.replace(`{${index + 1}}`, replaceWith).trim();
|
label = label.replace(`{${index + 1}}`, replaceWith).trim();
|
||||||
});
|
});
|
||||||
return { label: label.replace(/\s+/g, " ") };
|
return { label: label.replace(/\s+/g, ' ') };
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -35,9 +43,9 @@ export default function DisplayNameList({
|
|||||||
items={formatOptions}
|
items={formatOptions}
|
||||||
selectedItemProp={'label'}
|
selectedItemProp={'label'}
|
||||||
textProp={'label'}
|
textProp={'label'}
|
||||||
defaultText={'Select display name as'}
|
defaultText={intl.get('select_display_name_as')}
|
||||||
filterable={false}
|
filterable={false}
|
||||||
{ ...restProps }
|
{...restProps}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user