Skip to content

Commit

Permalink
UIQM-611: Add tooltips for LDR positions. (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro-Melnyshyn authored Mar 15, 2024
1 parent 093dbd4 commit 4f26a39
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* [UIQM-627](https://issues.folio.org/browse/UIQM-627) Add `shared` text to the title when editing a shared authority record.
* [UIQM-471](https://issues.folio.org/browse/UIQM-471) Added Dropdowns for fixed field 008 bib records.
* [UIQM-610](https://issues.folio.org/browse/UIQM-610) Split LDR by position & add dropdowns for create/edit/derive.
* [UIQM-611](https://issues.folio.org/browse/UIQM-611) Add tooltips for LDR positions.

## [7.0.5](https://github.com/folio-org/ui-quick-marc/tree/v7.0.5) (2023-12-11)

Expand Down
69 changes: 39 additions & 30 deletions src/QuickMarcEditor/QuickMarcEditorRows/BytesField/BytesField.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Field } from 'react-final-form';
import { FieldArray } from 'react-final-form-arrays';
import { FormattedMessage } from 'react-intl';
import {
FormattedMessage,
useIntl,
} from 'react-intl';
import classNames from 'classnames';

import {
Expand All @@ -24,7 +27,7 @@ export const SUBFIELD_TYPES = {
SELECTS: 'Selects',
};

const renderSubField = (name, config) => {
const renderSubField = (name, config, intl) => {
const fieldName = `${name}.${config.name}`;
const label = config.noLabel ? null : <FormattedMessage id={`ui-quick-marc.record.fixedField.${config.name}`} />;
const hint = config.hint ? config.hint : config.name;
Expand Down Expand Up @@ -231,38 +234,44 @@ const renderSubField = (name, config) => {
},
);

const getTextField = (textFieldProps = {}) => (
<Field
dirty={false}
name={fieldName}
label={label}
ariaLabel={intl.formatMessage({ id: `ui-quick-marc.record.fixedField.${config.name}` })}
component={TextField}
disabled={config.disabled}
maxLength={getMaxLengthByType}
className={textFieldClasses}
hasClearIcon={false}
data-testid={`fixed-field-${config.type}`}
defaultValue={defaultValue}
{...textFieldProps}
/>
);

if (config.noLabel) {
return getTextField();
}

return (
<FormattedMessage id={`ui-quick-marc.record.fixedField.${config.name}`}>
{([ariaLabel]) => (
<Tooltip
id={`ui-quick-marc.record.fixedField-${config.name}`}
text={labelHint}
placement="bottom-start"
>
{({ ref, ariaIds }) => (
<Field
inputRef={ref}
dirty={false}
ariaLabel={ariaLabel}
aria-labelledby={ariaIds.text}
name={fieldName}
label={label}
component={TextField}
disabled={config.disabled}
maxLength={getMaxLengthByType}
className={textFieldClasses}
hasClearIcon={false}
data-testid={`fixed-field-${config.type}`}
defaultValue={defaultValue}
/>
)}
</Tooltip>
)}
</FormattedMessage>
<Tooltip
id={`ui-quick-marc.record.fixedField-${config.name}`}
text={labelHint}
placement="bottom-start"
>
{({ ref, ariaIds }) => getTextField({
inputRef: ref,
'aria-labelledby': ariaIds.text,
})}
</Tooltip>
);
};

export const BytesField = ({ config, name, id }) => {
const intl = useIntl();

return (
<div
className={styles.bytesFieldRow}
Expand All @@ -275,7 +284,7 @@ export const BytesField = ({ config, name, id }) => {
key={fieldIdx}
data-testid="bytes-field-col"
>
{renderSubField(name, field)}
{renderSubField(name, field, intl)}
</div>
);
})
Expand Down
18 changes: 16 additions & 2 deletions translations/ui-quick-marc/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,13 @@
"record.fixedField.MultiLvl": "MultiLvl",
"record.fixedField.Punct": "Punct",
"record.fixedField.Item": "Item",
"record.fixedField.20-23 positions": "20-23 positions",
"record.fixedField.19-23 positions": "19-23 positions",
"record.fixedField.19-16 positions": "19-16 positions",
"record.fixedField.7-16 positions": "7-16 positions",
"record.fixedField.9-16 positions": "9-16 positions",
"record.fixedField.Record length": "Record length",

"record.fixedField.tip.Type": "Type",
"record.fixedField.tip.Date entered on file": "Date entered on file",
"record.fixedField.tip.Type of date/Publication status": "Type of date/Publication status",
"record.fixedField.tip.Start date": "Date 1",
Expand Down Expand Up @@ -292,6 +297,15 @@
"record.fixedField.tip.Deterioration stage": "Deterioration stage",
"record.fixedField.tip.Kind of color stock or print": "Kind of color stock or print",
"record.fixedField.tip.Refined categories of color": "Refined categories of color",
"record.fixedField.tip.Status": "Record status",
"record.fixedField.tip.Type": "Type of record",
"record.fixedField.tip.BLvl": "Bibliographic level",
"record.fixedField.tip.Ctrl": "Type of control",
"record.fixedField.tip.ELvl": "Encoding level",
"record.fixedField.tip.Desc": "Descriptive cataloging form",
"record.fixedField.tip.MultiLvl": "Multipart resource record level",
"record.fixedField.tip.Punct": "Punctuation policy",
"record.fixedField.tip.Item": "Item information in record",

"record.fixedField.No attempt to code": "No attempt to code",
"record.fixedField.No dates given; B.C. date involved": "No dates given; B.C. date involved",
Expand Down Expand Up @@ -819,8 +833,8 @@
"leader.Manuscript cartographic material": "Manuscript cartographic material",
"leader.Projected medium": "Projected medium",
"leader.Nonmusical sound recording": "Nonmusical sound recording",
"leader.Two-dimensional nonprojectable graphic": "Two-dimensional nonprojectable graphic",
"leader.Musical sound recording": "Musical sound recording",
"leader.Two-dimensional nonprojectable graphic": "Two-dimensional nonprojectable graphic",
"leader.Computer file": "Computer file",
"leader.Kit": "Kit",
"leader.Mixed materials": "Mixed materials",
Expand Down

0 comments on commit 4f26a39

Please sign in to comment.