Skip to content

Commit 2c2b396

Browse files
committed
FIX: Footnote reference and content should be jumpable back and forth.
1 parent 4845e98 commit 2c2b396

File tree

11 files changed

+17
-18
lines changed

11 files changed

+17
-18
lines changed

frontend/scenarios/open_uri.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Scénario: d'un document
1313

1414
Scénario: d'un document en regard d'une de ses gloses
1515

16-
Quand j'essaie d'ouvrir l'URI "/c2b9f52285ce11edbd0aff9b25defbab#146e6e8442f0405b721b79357d00d0a1" reçue par courriel
16+
Quand j'essaie d'ouvrir l'URI "/c2b9f52285ce11edbd0aff9b25defbab/146e6e8442f0405b721b79357d00d0a1" reçue par courriel
1717
Alors "Analyse de l'entretien" est le document principal
1818
Et "Flux de l'Institut (diagramme d'activité)" est la glose ouverte
1919

2020
Scénario: d'un document avec une URI invalide
2121

22-
Quand j'essaie d'ouvrir l'URI "/document-inexistant#glose-inexistante" reçue par courriel
22+
Quand j'essaie d'ouvrir l'URI "/document-inexistant/glose-inexistante" reçue par courriel
2323
Alors je peux lire "Le document que vous cherchez a été supprimé par les co-éditeurs ou l'URI fournie est incorrecte"

frontend/src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function App() {
3737
<Routes>
3838
<Route path="/" element={<Bookshelf {...{backend, user}} />} />
3939
<Route path="/registration" element={<Registration {...{backend}}/>} />
40-
<Route path="/:id" element={<Lectern {...{backend, user}} />} />
40+
<Route path="/:id/:margin?" element={<Lectern {...{backend, user}} />} />
4141
</Routes>
4242
</TypesContext.Provider>
4343
</BrowserRouter>

frontend/src/components/BrowseTools.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function BrowseTools({id, closable, openable, editable, focusable = true}) {
1010
placement="top"
1111
overlay={<Tooltip id="tooltip-edit">Edit this document</Tooltip>}
1212
>
13-
<Link to={`../${id}#${id}`} className="icon edit">
13+
<Link to={id} className="icon edit">
1414
<PencilSquare />
1515
</Link>
1616
</OverlayTrigger>
@@ -21,7 +21,7 @@ function BrowseTools({id, closable, openable, editable, focusable = true}) {
2121
placement="top"
2222
overlay={<Tooltip id="tooltip-close">Close this document</Tooltip>}
2323
>
24-
<Link to="#" className="icon close">
24+
<Link to=".." relative="path" className="icon close">
2525
<ChevronBarDown />
2626
</Link>
2727
</OverlayTrigger>
@@ -32,7 +32,7 @@ function BrowseTools({id, closable, openable, editable, focusable = true}) {
3232
placement="top"
3333
overlay={<Tooltip id="tooltip-open">Open this document</Tooltip>}
3434
>
35-
<Link to={`#${id}`} className="icon open">
35+
<Link to={id} className="icon open">
3636
<ChevronExpand />
3737
</Link>
3838
</OverlayTrigger>
@@ -43,7 +43,7 @@ function BrowseTools({id, closable, openable, editable, focusable = true}) {
4343
placement="top"
4444
overlay={<Tooltip id="tooltip-focus">Focus on this document</Tooltip>}
4545
>
46-
<Link to={`../${id}`} className="icon focus">
46+
<Link to={`/${id}`} className="icon focus">
4747
<Bookmark />
4848
</Link>
4949
</OverlayTrigger>

frontend/src/components/ExistingDocument.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function ExistingDocument({ document, relatedTo, verb, setLastUpdate, backend })
2929
.then(x => Promise.all(x))
3030
.then(() => {
3131
setLastUpdate(document._id);
32-
navigate('#' + document._id);
32+
navigate(document._id);
3333
})
3434
.catch(console.error);
3535
};

frontend/src/components/FutureDocument.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const FutureDocument = ({ relatedTo, setLastUpdate, backend, user }) => {
6666
: relatedTo.map((object) => ({ verb, object }))
6767
});
6868
setLastUpdate(_id);
69-
navigate((relatedTo.length ? '#' : `/${_id}#`) + _id);
69+
navigate((relatedTo.length ? '' : `/${_id}/`) + _id);
7070
} catch (error) {
7171
console.error('Error creating document:', error);
7272
}

frontend/src/menu-items/DeleteDocumentAction.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function DeleteDocumentAction({metadata, isFromScratch, backend, setLastUpdate})
1010
const handleClick = () => {
1111
backend.deleteDocument(metadata)
1212
.then(x => setLastUpdate(x.rev))
13-
.then(() => navigate(isFromScratch ? '/' : '#'));
13+
.then(() => navigate(isFromScratch ? '/' : '..', {relative: 'path'}));
1414
};
1515

1616
return (

frontend/src/menu-items/DeleteReferenceToDocumentAction.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function DeleteReferenceToDocumentAction({id, margin, backend, metadata, content
1111
metadata.links = metadata.links.filter(link => ![id, ...new Set([...content.filter((row) => row.value.isPartOf === id).map(({id, value}) => value._id || id)])].includes(link.object));
1212
backend.putDocument({...metadata})
1313
.then(x => setLastUpdate(x.rev))
14-
.then(() => navigate('/' + margin + '#' + margin))
14+
.then(() => navigate('/' + margin + '/' + margin))
1515
.catch(console.error);
1616
};
1717

frontend/src/routes/Lectern.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Container from 'react-bootstrap/Container';
55
import Row from 'react-bootstrap/Row';
66
import Col from 'react-bootstrap/Col';
77
import { useState, useEffect } from 'react';
8-
import { useParams, useLocation } from 'react-router';
8+
import { useParams } from 'react-router';
99
import Context from '../context';
1010
import ParallelDocuments from '../parallelDocuments';
1111
import OpenedDocuments from '../components/OpenedDocuments';
@@ -19,8 +19,7 @@ function Lectern({backend, user}) {
1919
const [lastUpdate, setLastUpdate] = useState();
2020
const [rawEditMode, setRawEditMode] = useState(false);
2121
const [loading, setLoading] = useState(true);
22-
let {id} = useParams();
23-
let margin = useLocation().hash.slice(1);
22+
let {id, margin} = useParams();
2423
const getCaption = ({dc_title, dc_spatial}) => [dc_title, dc_spatial].filter(Boolean).join(', ');
2524

2625
if (metadata) {

frontend/tests/context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Soit("un document sans champ {string} affiché comme document principal", (field
172172
cy.sign_in('alice', '/');
173173
cy.create_document_from_scratch();
174174
cy.url().then((url) => {
175-
const id = url.split('#')[1];
175+
const id = url.split('/').pop();
176176
cy.request(`/api/${id}`)
177177
.then(({ body: doc }) => {
178178
delete doc[field];

frontend/tests/support.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Cypress.Commands.add('click_on_text', (type, text) => {
3434

3535
Cypress.Commands.add('create_glose', (random = false) => {
3636
cy.get('.create-document').click();
37-
cy.url().should('contain', '#');
37+
cy.url().should('match', /[0-9a-f]+\/[0-9a-f]+$/);
3838
if (random) {
3939
cy.set_random_name();
4040
}
@@ -43,7 +43,7 @@ Cypress.Commands.add('create_glose', (random = false) => {
4343
Cypress.Commands.add('create_glose_of_type', (random = false, option = "Adaptation") => {
4444
cy.get('#select-dropdown').select(option);
4545
cy.get('.create-document').click();
46-
cy.url().should('contain', '#');
46+
cy.url().should('match', /[0-9a-f]+\/[0-9a-f]+$/);
4747
if (random) {
4848
cy.set_random_name();
4949
}

0 commit comments

Comments
 (0)