Skip to content

Commit ce5b21c

Browse files
committed
Create a document as a glose of multiple documents (see#404)
Fix checkbox bug
1 parent ac693c6 commit ce5b21c

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

frontend/src/components/DocumentsCards.jsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import BrowseTools from './BrowseTools';
77
import FutureDocument from './FutureDocument';
88
import { TypeBadge } from './Type';
99

10-
function DocumentsCards({docs, expandable, byRow, createOn, setLastUpdate, backend, user, selectedDocs, setSelectedDocs}) {
10+
function DocumentsCards({docs, expandable, byRow, createOn, setLastUpdate, backend, user, selectedDocs, setSelectedDocs, showCheckboxes}) {
1111
return (
1212
<Row className="gy-4">
1313
{docs.map(x => x?._id && x?.dc_title &&
@@ -17,6 +17,7 @@ function DocumentsCards({docs, expandable, byRow, createOn, setLastUpdate, backe
1717
expandable={expandable}
1818
selectedDocs={selectedDocs}
1919
setSelectedDocs={setSelectedDocs}
20+
showCheckboxes={showCheckboxes}
2021
/>
2122
</Col>
2223
)}
@@ -33,7 +34,7 @@ function DocumentsCards({docs, expandable, byRow, createOn, setLastUpdate, backe
3334
);
3435
}
3536

36-
function DocumentCard({doc, expandable, selectedDocs, setSelectedDocs}) {
37+
function DocumentCard({doc, expandable, selectedDocs, setSelectedDocs, showCheckboxes}) {
3738
const handleCheck = (e) => {
3839
if (e.target.checked) {
3940
setSelectedDocs(prev => [...prev, doc._id]);
@@ -46,14 +47,17 @@ function DocumentCard({doc, expandable, selectedDocs, setSelectedDocs}) {
4647
<Card className="h-100 position-relative">
4748
<Card.Body>
4849
<div className="d-flex align-items-start gap-2 mb-2">
49-
<Form.Check
50-
type="checkbox"
51-
id={`check-${doc._id}`}
52-
className="me-1"
53-
style={{ cursor: 'pointer' }}
54-
checked={selectedDocs?.includes(doc._id) || false}
55-
onChange={handleCheck}
56-
/>
50+
{/* La checkbox s'affiche uniquement si showCheckboxes est vrai */}
51+
{showCheckboxes && (
52+
<Form.Check
53+
type="checkbox"
54+
id={`check-${doc._id}`}
55+
className="me-1"
56+
style={{ cursor: 'pointer' }}
57+
checked={selectedDocs?.includes(doc._id) || false}
58+
onChange={handleCheck}
59+
/>
60+
)}
5761
<div className="flex-grow-1">
5862
<BrowseTools id={doc._id} openable={expandable} />
5963
</div>

frontend/src/routes/Bookshelf.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function Bookshelf({ backend, user }) {
8181
{selectedDocs.length > 0 && (
8282
<div className="card p-3 mb-4 justify-content-between align-items-center flex-direction-row">
8383
<div>Create a new quotation with the <strong>{selectedDocs.length}</strong> selected document(s)</div>
84-
<Button variant="danger" onClick={handleCreateQuotation}>
84+
<Button variant="outline-danger" onClick={handleCreateQuotation}>
8585
Create Quotation
8686
</Button>
8787
</div>
@@ -92,6 +92,7 @@ function Bookshelf({ backend, user }) {
9292
createOn={[]}
9393
selectedDocs={selectedDocs}
9494
setSelectedDocs={setSelectedDocs}
95+
showCheckboxes={true}
9596
{...{setLastUpdate, backend, user}}
9697
/>
9798
</>

0 commit comments

Comments
 (0)