Skip to content

Commit ddbe207

Browse files
Merge pull request #164 from SingularityNET-Archive:development
150-autosave-feature-date-2025-01-23
2 parents 3a9e7d4 + 755cbc0 commit ddbe207

File tree

11 files changed

+1833
-1086
lines changed

11 files changed

+1833
-1086
lines changed

components/SummaryAgendaItems.tsx

Lines changed: 313 additions & 200 deletions
Large diffs are not rendered by default.

components/SummaryMeetingInfo.tsx

Lines changed: 371 additions & 329 deletions
Large diffs are not rendered by default.

components/SummaryTemplate.tsx

Lines changed: 293 additions & 285 deletions
Large diffs are not rendered by default.

components/WorkingDocs.tsx

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,91 @@
11
import styles from '../styles/workingDocsTable.module.css';
22

3-
const WorkingDocs = ({ handleChange, addNewDoc, docs, removeDoc, originalDocsCount, updateMyVariable }: any) => {
3+
type Doc = {
4+
title?: string;
5+
link?: string;
6+
};
7+
8+
type WorkingDocsProps = {
9+
/** The complete array of docs, both old + newly added. */
10+
docs: Doc[];
11+
/**
12+
* Number of docs that existed in the DB before.
13+
* If `index < originalDocsCount`, we treat it as an “existing doc”.
14+
* Otherwise, it's a newly added doc.
15+
*/
16+
originalDocsCount: number;
17+
18+
/** Called when a NEW doc changes (indexes >= originalDocsCount). */
19+
handleChange: (e: any, newDocIndex: number) => void;
20+
21+
/** Called when the user clicks “Add New Working Document”. */
22+
addNewDoc: () => void;
23+
24+
/** Called to remove a NEW doc from the parent's state. */
25+
removeDoc: (newDocIndex: number) => void;
26+
27+
/**
28+
* Called to update an OLD doc (i.e. in DB).
29+
* If `e === null`, it means remove. Otherwise it’s a change event.
30+
*/
31+
updateMyVariable: (e: any | null, oldDocIndex: number) => void;
32+
};
33+
34+
const WorkingDocs = ({
35+
docs,
36+
originalDocsCount,
37+
handleChange,
38+
addNewDoc,
39+
removeDoc,
40+
updateMyVariable
41+
}: WorkingDocsProps) => {
42+
43+
/**
44+
* Called whenever an input changes in the table row.
45+
* If it's an existing doc (index < originalDocsCount),
46+
* we call `updateMyVariable`. Otherwise, we call `handleChange`.
47+
*/
448
const handleDocChange = (e: any, index: number) => {
549
if (index < originalDocsCount) {
50+
// This is an existing doc from the DB
651
updateMyVariable(e, index);
752
} else {
53+
// This is a newly added doc
854
handleChange(e, index - originalDocsCount);
955
}
1056
};
1157

58+
/**
59+
* Called when the user clicks the “X” to remove a doc row.
60+
* If it’s an existing doc, call `updateMyVariable(null, index)`.
61+
* If it’s a new doc, call `removeDoc(...)`.
62+
*/
1263
const handleDocRemove = (index: number) => {
1364
if (index < originalDocsCount) {
65+
// Remove an existing doc from DB or mark it removed
1466
updateMyVariable(null, index);
1567
} else {
68+
// Remove a new doc from local state
1669
removeDoc(index - originalDocsCount);
1770
}
1871
};
1972

73+
/**
74+
* Called when the user clicks “Add New Working Document”.
75+
* If we currently have 0 docs, we initialize the first doc as empty.
76+
* Otherwise, we call `addNewDoc()` to push another blank doc to local.
77+
*/
2078
const handleAddNewDoc = () => {
2179
if (docs.length === 0) {
22-
// Add the first document
80+
// Force-initialize the very first doc
2381
handleChange({ target: { name: 'title', value: '' } }, 0);
2482
handleChange({ target: { name: 'link', value: '' } }, 0);
2583
} else {
26-
// Add a new document
2784
addNewDoc();
2885
}
2986
};
3087

88+
/** Utility function to ensure links have a protocol. */
3189
const formatUrl = (url: string) => {
3290
if (!url?.startsWith('http://') && !url?.startsWith('https://')) {
3391
return `http://${url}`;
@@ -47,8 +105,9 @@ const WorkingDocs = ({ handleChange, addNewDoc, docs, removeDoc, originalDocsCou
47105
</tr>
48106
</thead>
49107
<tbody>
50-
{docs.map((doc: any, index: number) => (
108+
{docs.map((doc: Doc, index: number) => (
51109
<tr className={styles.tr} key={index}>
110+
{/* TITLE */}
52111
<td className={styles.td}>
53112
<input
54113
className={styles.input}
@@ -59,8 +118,10 @@ const WorkingDocs = ({ handleChange, addNewDoc, docs, removeDoc, originalDocsCou
59118
onChange={(e) => handleDocChange(e, index)}
60119
/>
61120
</td>
121+
122+
{/* LINK */}
62123
<td className={`${styles.td} ${styles.centerAligned} ${styles.linkCell}`}>
63-
{/* Change here: Always show input fields if there's only one row */}
124+
{/* If there's only 1 row total, or if it's a newly added doc, show the text input. */}
64125
{(docs.length === 1 || index >= originalDocsCount) ? (
65126
<input
66127
className={styles.input}
@@ -71,17 +132,31 @@ const WorkingDocs = ({ handleChange, addNewDoc, docs, removeDoc, originalDocsCou
71132
onChange={(e) => handleDocChange(e, index)}
72133
/>
73134
) : (
74-
<a href={formatUrl(doc.link)} target="_blank" rel="noopener noreferrer">Link</a>
135+
// Otherwise, for older docs, show a clickable link
136+
<a href={formatUrl(doc.link || '')} target="_blank" rel="noopener noreferrer">
137+
Link
138+
</a>
75139
)}
76140
</td>
141+
142+
{/* REMOVE BUTTON */}
77143
<td className={`${styles.td} ${styles.centerAligned} ${styles.removeButtonColumn}`}>
78-
<button className={styles.removeButton} type="button" onClick={() => handleDocRemove(index)}>X</button>
144+
<button
145+
className={styles.removeButton}
146+
type="button"
147+
onClick={() => handleDocRemove(index)}
148+
>
149+
X
150+
</button>
79151
</td>
80152
</tr>
81153
))}
82154
</tbody>
83155
</table>
84-
<button className={styles.button} type="button" onClick={handleAddNewDoc}>Add New Working Document</button>
156+
157+
<button className={styles.button} type="button" onClick={handleAddNewDoc}>
158+
Add New Working Document
159+
</button>
85160
</>
86161
);
87162
};

package-lock.json

Lines changed: 54 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@
2121
"eslint-config-next": "13.4.6",
2222
"google-auth-library": "^9.14.1",
2323
"googleapis": "^144.0.0",
24+
"lodash": "^4.17.21",
2425
"next": "^14.2.8",
2526
"react": "18.2.0",
2627
"react-dom": "18.2.0",
2728
"react-markdown": "^9.0.0",
29+
"react-modal": "^3.16.3",
2830
"react-select": "^5.7.7",
2931
"typescript": "5.1.3"
3032
},
3133
"devDependencies": {
32-
"@netlify/plugin-nextjs": "^5.9.4"
34+
"@netlify/plugin-nextjs": "^5.9.4",
35+
"@types/lodash": "^4.17.14"
3336
}
3437
}

pages/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ const Home: NextPage = () => {
4242
<div>
4343
<ul>
4444
<li className={styles.listItem}>When you hover over input fields it will give you a tip on what is needed or how it works</li>
45-
<li className={styles.listItem}>When you select your workgroup to submit a meeting summary, it will load all the data from the previous meeting</li>
46-
<li className={styles.listItem}>{`Please select the date the meeting happened in the "Meeting Date:" dropdown`}</li>
47-
<li className={styles.listItem}>{`Any changes you save will be saved to the date you selected in the "Meeting Date:" dropdown`}</li>
48-
<li className={styles.listItem}>Please remember to click the save button when you are done</li>
45+
<li className={styles.listItem}>When you select your workgroup it will ask how you want to proceed in creating the meeting summary</li>
46+
<li className={styles.listItem}>It will give you the following options - Edit existing summary, New clean summary or New prefilled Summary</li>
47+
<li className={styles.listItem}>For each of these options you need to select a date</li>
48+
<li className={styles.listItem}>The tool now autosaves</li>
4949
<li className={styles.listItem}>Bottom left of the save button you will find the date and time the summary was last saved</li>
5050
<li className={styles.listItem}>Meeting summaries will be reviewed by an Archive member</li>
5151
<li className={styles.listItem}>When the Archive member approves the data, the GitBook and database will be updated</li>

0 commit comments

Comments
 (0)