mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Merge pull request #604 from nowcommunity/change-button-text-2
change button text from author to proper type in references
This commit is contained in:
@@ -15,6 +15,16 @@ interface AuthorTabProps {
|
||||
tab_name?: string | null
|
||||
}
|
||||
|
||||
const tabNameToButtonText: { [tabName: string]: string } = {
|
||||
Authors: 'author',
|
||||
Editors: 'editor',
|
||||
'Series Editors': 'editor',
|
||||
'Editors of Issue': 'editor',
|
||||
Sender: 'sender',
|
||||
Recipient: 'recipient',
|
||||
Recipients: 'recipient',
|
||||
}
|
||||
|
||||
function checkIndexes(editData: EditDataType<ReferenceDetailsType>): boolean {
|
||||
let needsUpdate = false
|
||||
// First, check if any index is incorrect
|
||||
@@ -74,15 +84,21 @@ export const AuthorTab: React.FC<AuthorTabProps> = ({ field_num_param, tab_name
|
||||
},
|
||||
]
|
||||
|
||||
let buttonText = 'Author'
|
||||
if (tab_name && tabNameToButtonText[tab_name]) {
|
||||
buttonText = tabNameToButtonText[tab_name]
|
||||
}
|
||||
|
||||
let title = tab_name ? tab_name : 'Authors'
|
||||
if (hasError) title = title.concat(' (Required)')
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Grouped error={hasError} title={title}>
|
||||
{!mode.read && (
|
||||
<Box display="flex" gap={1}>
|
||||
<EditingForm<ReferenceAuthorType, ReferenceDetailsType>
|
||||
buttonText="Add new author"
|
||||
buttonText={`Add new ${buttonText}`}
|
||||
formFields={formFields}
|
||||
editAction={(newAuthor: ReferenceAuthorType) => {
|
||||
const updatedAuthors = [
|
||||
@@ -106,7 +122,7 @@ export const AuthorTab: React.FC<AuthorTabProps> = ({ field_num_param, tab_name
|
||||
}}
|
||||
/>
|
||||
<SelectingTable<ReferenceAuthorType, ReferenceDetailsType>
|
||||
buttonText="Select Author"
|
||||
buttonText={`Select ${buttonText}`}
|
||||
data={authorData}
|
||||
isError={isError}
|
||||
columns={authorColumns}
|
||||
|
||||
Reference in New Issue
Block a user