Skip to content

Commit

Permalink
ERM-3332
Browse files Browse the repository at this point in the history
  • Loading branch information
MonireRasouli committed Oct 21, 2024
1 parent 78c03a7 commit bd1658e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/DocumentFilter/DocumentFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {

import DocumentFilterForm from './DocumentFilterForm';

const DocumentFilter = ({ activeFilters, atTypeValues = [], filterHandlers }) => {
const DocumentFilter = ({ activeFilters, atTypeValues = [], filterHandlers, filterName = }) => {
// atTypeValues are only passed for SupplementaryDocumentFilter
const filterType = atTypeValues.length > 0 ? 'supplementaryDocuments' : 'documents';
const [editingFilters, setEditingFilters] = useState(false);
Expand Down
4 changes: 3 additions & 1 deletion lib/DocumentFilter/DocumentFilterRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const DocumentFilterRule = ({
}) => {
const intl = useIntl();

const { operators, attributes } = DocumentFilterRuleConstants(atTypeValues.length > 0);
const { operators, attributes } = DocumentFilterRuleConstants({
filterName: atTypeValues.length > 0 ? 'supplementaryDocs' : 'docs'
});
return (
<Row key={name}>
<Col xs={2}>
Expand Down
17 changes: 8 additions & 9 deletions lib/DocumentFilter/DocumentFilterRuleConstants.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useIntl } from 'react-intl';

const DocumentFilterRuleConstants = (useSupplementaryDocs) => {
const DocumentFilterRuleConstants = ({filterName = 'docs'}) => {

Check failure on line 3 in lib/DocumentFilter/DocumentFilterRuleConstants.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

A space is required after '{'

Check failure on line 3 in lib/DocumentFilter/DocumentFilterRuleConstants.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

A space is required before '}'
const intl = useIntl();
const docType = useSupplementaryDocs ? 'supplementaryDocs' : 'docs';

const operators = [
{ label: '', value: '' },
Expand All @@ -24,35 +23,35 @@ const DocumentFilterRuleConstants = (useSupplementaryDocs) => {
{ label: '', value: '' },
{
label: intl.formatMessage({ id: 'stripes-erm-components.doc.name' }),
value: `${docType}.name`,
value: `${filterName}.name`,
},
{
label: intl.formatMessage({ id: 'stripes-erm-components.doc.note' }),
value: `${docType}.note`,
value: `${filterName}.note`,
},
{
label: intl.formatMessage({ id: 'stripes-erm-components.doc.location' }),
value: `${docType}.location`,
value: `${filterName}.location`,
},
{
label: intl.formatMessage({ id: 'stripes-erm-components.doc.url' }),
value: `${docType}.url`,
value: `${filterName}.url`,
},
{
label: intl.formatMessage({ id: 'stripes-erm-components.contentType' }),
value: `${docType}.fileUpload.fileContentType`,
value: `${filterName}.fileUpload.fileContentType`,
},
{
label: intl.formatMessage({ id: 'stripes-erm-components.fuf.filename' }),
value: `${docType}.fileUpload.fileName`,
value: `${filterName}.fileUpload.fileName`,
},
];

// Include additional line specific to supplementaryDocs
if (useSupplementaryDocs) {

Check failure on line 51 in lib/DocumentFilter/DocumentFilterRuleConstants.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

'useSupplementaryDocs' is not defined
attributes.splice(3, 0, {
label: intl.formatMessage({ id: 'stripes-erm-components.doc.category' }),
value: `${docType}.atType.value`,
value: `${filterName}.atType.value`,
});
}

Expand Down

0 comments on commit bd1658e

Please sign in to comment.