Skip to content

Commit

Permalink
more filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ericjeangirard committed Mar 12, 2024
1 parent 553ad75 commit fe63a12
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/src/pages/datasetsView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
affiliationsTemplate,
allIdsTemplate,
authorsTemplate,
certaintyRowFilterTemplate,
datasourceTemplate,
frAuthorsTemplate,
linkedDOITemplate,
Expand All @@ -21,7 +22,10 @@ export default function DatasetsView({
setSelectedWorks,
works,
}) {
const [filters] = useState({ status: { value: null, matchMode: FilterMatchMode.IN } });
const [filters] = useState({
status: { value: null, matchMode: FilterMatchMode.IN },
levelCertainty: { value: null, matchMode: FilterMatchMode.IN },
});
return (
<DataTable
currentPageReportTemplate="{first} to {last} of {totalRecords}"
Expand Down Expand Up @@ -53,7 +57,7 @@ export default function DatasetsView({
<Column field="year" header="Year" style={{ maxWidth: '70px' }} />
<Column field="publisher" header="Publisher" style={{ maxWidth: '70px' }} />
<Column field="affiliationsHtml" header="Affiliations" body={affiliationsTemplate} style={{ maxWidth: '220px' }} />
<Column field="levelCertainty" header="Certainty" style={{ maxWidth: '90px' }} sortable />
<Column field="levelCertainty" header="Certainty" style={{ maxWidth: '90px' }} sortable showFilterMenu={false} filterMenuStyle={{ width: '7rem' }} filter filterElement={certaintyRowFilterTemplate}/>
<Column field="fr_publications_linked" header="Linked Article" body={linkedDOITemplate} style={{ maxWidth: '180px' }} />
<Column field="fr_authors_orcid" header="My institution author ORCID" body={linkedORCIDTemplate} style={{ maxWidth: '150px' }} />
<Column field="fr_authors_name" header="My institution author name" body={frAuthorsTemplate} style={{ maxWidth: '150px' }} />
Expand Down
15 changes: 15 additions & 0 deletions client/src/utils/templates.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ const statusRowFilterTemplate = (options) => (
/>
);

const certaintyRowFilterTemplate = (options) => (
<MultiSelect
value={options.value}
options={[{ name: '1.high', value: '1.high' }, { name: '2.medium', value: '2.medium' }, { name: '3.low', value: '3.low' }]}
itemTemplate={statusesItemTemplate}
onChange={(e) => options.filterApplyCallback(e.value)}
optionLabel="name"
placeholder="Any"
className="p-column-filter"
maxSelectedLabels={1}
style={{ minWidth: '7rem' }}
/>
);

const getIdsTemplate = (ids) => {
let html = '<ul>';
ids.forEach((id) => {
Expand Down Expand Up @@ -177,6 +191,7 @@ export {
allIdsTemplate,
authorsTemplate,
correctionTemplate,
certaintyRowFilterTemplate,
datasourceTemplate,
frAuthorsTemplate,
getAffiliationsHtmlField,
Expand Down

0 comments on commit fe63a12

Please sign in to comment.