diff --git a/client/src/config.js b/client/src/config.js index 0ec38b05..6ab0ed6d 100644 --- a/client/src/config.js +++ b/client/src/config.js @@ -33,7 +33,11 @@ const status = { const correction = { corrected: { badgeType: 'error', - label: 'CORRECTION', + label: 'MODIFIED', + }, + reset: { + badgeType: 'info', + label: 'CANCEL', }, notcorrected: { badgeType: 'info', diff --git a/client/src/pages/openalexView.jsx b/client/src/pages/openalexView.jsx index 12200013..dd4cd5e3 100644 --- a/client/src/pages/openalexView.jsx +++ b/client/src/pages/openalexView.jsx @@ -1,4 +1,4 @@ -import { Col, Row, Toggle } from '@dataesr/dsfr-plus'; +import { Button, Col, Row, Toggle } from '@dataesr/dsfr-plus'; import { Column } from 'primereact/column'; import { DataTable } from 'primereact/datatable'; import { InputTextarea } from 'primereact/inputtextarea'; @@ -25,11 +25,27 @@ export default function OpenalexView({ const [selectionPageOnly, setSelectionPageOnly] = useState(true); const cellEditor = (options) => ( - options.editorCallback(e.target.value)} - /> + + + options.editorCallback(e.target.value)} + /> + + + + + ); const { toast } = useToast(); @@ -51,7 +67,11 @@ export default function OpenalexView({ }); if (isValid) { data.rorsToCorrect = newValue; - data.hasCorrection = true; + if (data.rors.map((r) => r.rorId).join(';') !== newValue) { + data.hasCorrection = true; + } else { + data.hasCorrection = false; + } const newCorrections = getCorrections(allAffiliations); setAllOpenalexCorrections(newCorrections); } @@ -101,7 +121,7 @@ export default function OpenalexView({ paginatorLeft={paginatorLeft} paginatorPosition="top bottom" paginatorTemplate="RowsPerPageDropdown FirstPageLink PrevPageLink CurrentPageReport NextPageLink LastPageLink" - rows={100} + rows={50} rowsPerPageOptions={[50, 100, 200, 500]} scrollable selectionPageOnly={selectionPageOnly} @@ -121,39 +141,38 @@ export default function OpenalexView({ /> cellEditor(options)} /> - diff --git a/client/src/utils/templates.jsx b/client/src/utils/templates.jsx index e636ddd1..838e9bca 100644 --- a/client/src/utils/templates.jsx +++ b/client/src/utils/templates.jsx @@ -39,9 +39,13 @@ const statusRowFilterTemplate = (options) => ( const getIdsTemplate = (ids) => { let html = '
    '; ids.forEach((id) => { - html += `
  • ${id.id_type}: `; + html += `
  • `; const idLink = getIdLink(id.id_type, id.id_value); - html += idLink ? `${id.id_value}` : `${id.id_value}`; + let idValueDisplay = ''; + if (id.id_value.length > 18) { + idValueDisplay = id.id_value.slice(0, 18).concat('..'); + } + html += idLink ? `${idValueDisplay}` : `${id.id_value}`; html += '
  • '; }); html += '
'; @@ -118,16 +122,18 @@ const datasourceTemplate = (rowData) => { const correctionTemplate = (rowData) => { let html = ''; + html = html.concat('
    '); const rorsToCorrect = rowData.rorsToCorrect.split(';').map((item) => item.trim()).filter((item) => item.length > 0); if (rorsToCorrect.length > 0) { - html = html.concat('
      '); rorsToCorrect.forEach((ror) => { html = html.concat(`
    • ${ror}
    • `); }); - html = html.concat('
    '); - if (rowData.hasCorrection) { - html = `${ html }`; - } + } else { + html = html.concat('
  • '); + } + html = html.concat('
'); + if (rowData.hasCorrection) { + html = `${ html }`; } return ; }; @@ -136,8 +142,17 @@ const nameTemplate = (rowData) => {status[rowData?.status ?? rowData]?.label}; +const resetCorrection = (rowData, allAffiliations) => { + console.log('ttt', rowData); + const row = { rowData }; + row.rowData.hasCorrection = false; + row.rowData.rorsToCorrect = rowData.rors.map((e) => e.rorId).join(';'); +}; + const hasCorrectionTemplate = (rowData) => (rowData?.hasCorrection - ? {correction.corrected.label} + ? ( + {correction.corrected.label} + ) : ''); export { diff --git a/server/src/utils/works.js b/server/src/utils/works.js index 8368eb3b..f9c2b196 100644 --- a/server/src/utils/works.js +++ b/server/src/utils/works.js @@ -478,6 +478,7 @@ const groupByAffiliations = ({ options, works }) => { name: affiliation.rawAffiliation, nameHtml: toKeep[normalizedAffiliation].displayAffiliation, rors: affiliation.rors || [], + rorsNumber: affiliation.rors?.length || 0, rorsToCorrect: (affiliation.rorsToCorrect || []).join(';'), source: affiliation.source, status: 'tobedecided',