Skip to content

Commit

Permalink
feat(openAlex): add buttons to change view of results
Browse files Browse the repository at this point in the history
  • Loading branch information
jerem1508 committed Nov 14, 2024
1 parent f46c38e commit f191119
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions client/src/pages/openalex-ror/openalexView.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -26,6 +26,8 @@ export default function OpenalexView({
undo,
}) {
const [selectionPageOnly, setSelectionPageOnly] = useState(true);
const urlParams = new URLSearchParams(window.location.search);
const view = urlParams.get('view') || 'table';

const cellEditor = (options) => (
<InputTextarea
Expand All @@ -37,6 +39,12 @@ export default function OpenalexView({
);
const { toast } = useToast();

const changeView = (_view) => {
const url = new URL(window.location);
url.searchParams.set('view', _view);
window.history.pushState({}, '', url);
};

const onRowEditComplete = async (edit) => {
const { data, newData } = edit;
let isValid = true;
Expand Down Expand Up @@ -96,7 +104,9 @@ export default function OpenalexView({
return (
<>
<div className="wm-internal-actions">
actions relatives au tableau du dessous
<Button onClick={() => changeView('table')} icon="table-line" size="sm" color="beige-gris-galet" />
<Button onClick={() => changeView('list')} icon="list-unordered" size="sm" color="beige-gris-galet" />
{view}
</div>
<DataTable
currentPageReportTemplate="{first} to {last} of {totalRecords}"
Expand Down

0 comments on commit f191119

Please sign in to comment.