From 13f37d00d48308f0e2e86ffd94ff43bf46055b05 Mon Sep 17 00:00:00 2001 From: labkey-martyp Date: Mon, 20 Nov 2023 14:23:17 -0800 Subject: [PATCH 1/2] React and npm updates --- snprc_scheduler/package-lock.json | 29 ++++++---- .../src/client/components/ProjectList.jsx | 8 +-- .../src/client/components/TimelineGrid.jsx | 31 ++++++---- .../components/dnd/DraggableContainer.jsx | 24 ++++---- .../components/dnd/html5DragDropContext.js | 4 -- .../components/dnd/html5DragDropContext.jsx | 11 ++++ .../domains/StudyDayNotes.java | 12 ++-- .../snprc_scheduler/domains/Timeline.java | 56 +++++++++---------- .../domains/TimelineAnimalJunction.java | 28 +++++----- .../snprc_scheduler/domains/TimelineItem.java | 23 ++++---- .../domains/TimelineProjectItem.java | 16 +++--- 11 files changed, 133 insertions(+), 109 deletions(-) delete mode 100644 snprc_scheduler/src/client/components/dnd/html5DragDropContext.js create mode 100644 snprc_scheduler/src/client/components/dnd/html5DragDropContext.jsx diff --git a/snprc_scheduler/package-lock.json b/snprc_scheduler/package-lock.json index c48950c64..f7b5020a5 100644 --- a/snprc_scheduler/package-lock.json +++ b/snprc_scheduler/package-lock.json @@ -2952,9 +2952,9 @@ "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" }, "node_modules/@types/cors": { - "version": "2.8.14", - "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.14.tgz", - "integrity": "sha512-RXHUvNWYICtbP6s18PnOCaqToK8y14DnLd75c6HfyKf228dxy7pHNOQkxPtvXKp/hINFMDjbYzsj63nnpPMSRQ==", + "version": "2.8.16", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.16.tgz", + "integrity": "sha512-Trx5or1Nyg1Fq138PCuWqoApzvoSLWzZ25ORBiHMbbUT42g578lH1GT4TwYDbiUOLFuDsCkfLneT2105fsFWGg==", "dependencies": { "@types/node": "*" } @@ -4314,9 +4314,9 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "node_modules/browser-sync-ui/node_modules/engine.io-client": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.2.tgz", - "integrity": "sha512-CQZqbrpEYnrpGqC07a9dJDz4gePZUgTPMU3NKJPSeQOyw27Tst4Pl3FemKoFGAlHzgZmKjoRmiJvbWfhCXUlIg==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz", + "integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==", "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1", @@ -11336,6 +11336,11 @@ "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz", "integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==" }, + "node_modules/react-data-grid-addons/node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, "node_modules/react-data-grid-addons/node_modules/react-dnd": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/react-dnd/-/react-dnd-2.6.0.tgz", @@ -12691,9 +12696,9 @@ } }, "node_modules/socket.io/node_modules/engine.io": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.3.tgz", - "integrity": "sha512-IML/R4eG/pUS5w7OfcDE0jKrljWS9nwnEfsxWCIJF5eO6AHo6+Hlv+lQbdlAYsiJPHzUthLm1RUjnBzWOs45cw==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.4.tgz", + "integrity": "sha512-KdVSDKhVKyOi+r5uEabrDLZw2qXStVvCsEB/LN3mw4WFi6Gx50jTyuxYVCwAAC0U46FdnzP/ScKRBTXb/NiEOg==", "dependencies": { "@types/cookie": "^0.4.1", "@types/cors": "^2.8.12", @@ -13448,9 +13453,9 @@ } }, "node_modules/ua-parser-js": { - "version": "1.0.36", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.36.tgz", - "integrity": "sha512-znuyCIXzl8ciS3+y3fHJI/2OhQIXbXw9MWC/o3qwyR+RGppjZHrM27CGFSKCJXi2Kctiz537iOu2KnXs1lMQhw==", + "version": "1.0.37", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.37.tgz", + "integrity": "sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==", "funding": [ { "type": "opencollective", diff --git a/snprc_scheduler/src/client/components/ProjectList.jsx b/snprc_scheduler/src/client/components/ProjectList.jsx index a2e62e051..b68fd121c 100644 --- a/snprc_scheduler/src/client/components/ProjectList.jsx +++ b/snprc_scheduler/src/client/components/ProjectList.jsx @@ -10,15 +10,13 @@ */ import React from 'react'; import PropTypes from 'prop-types' -import ReactDataGrid from 'react-data-grid'; import Glyphicon from 'react-bootstrap/lib/Glyphicon' import { selectProject, filterProjects, - sortProjects, - createAction, - PROJECT_SELECTED, - selectTimeline, TAB_TIMELINES, TAB_PROJECTS, setForceRerender + selectTimeline, + TAB_PROJECTS, + setForceRerender } from '../actions/dataActions'; import connect from "react-redux/es/connect/connect"; import {BootstrapTable, TableHeaderColumn} from "react-bootstrap-table"; diff --git a/snprc_scheduler/src/client/components/TimelineGrid.jsx b/snprc_scheduler/src/client/components/TimelineGrid.jsx index 03d0b639e..52eac1dd3 100644 --- a/snprc_scheduler/src/client/components/TimelineGrid.jsx +++ b/snprc_scheduler/src/client/components/TimelineGrid.jsx @@ -1,7 +1,7 @@ import React from "react"; import ReactDataGrid from "react-data-grid"; -import {Button, Modal, OverlayTrigger, Tooltip} from "react-bootstrap"; -// import DraggableContainer from "./dnd/DraggableContainer"; +import { Button, Modal, OverlayTrigger, Tooltip } from "react-bootstrap"; +import { DraggableContainer } from "./dnd/DraggableContainer"; import Moment from 'react-moment'; import { addTimelineItem, @@ -89,10 +89,15 @@ class TimelineGrid extends React.Component { procNote: "", rowId: undefined, revisionNum: undefined, - day0: "" + day0: "", + key: 0 } } + getGridKey = () => { + return Math.random(); + }; + CheckBoxFormatter = (colKey) => { return ((props) => { @@ -412,6 +417,7 @@ class TimelineGrid extends React.Component { allRows = newState.rows; newState.columns = sortedCols; + newState.key = this.getGridKey(); this.setState(Object.assign({}, this.state, newState)); } @@ -524,6 +530,7 @@ class TimelineGrid extends React.Component { this.setState(state => { state.rows = filteredRows; + state.key = this.getGridKey(); return state; }); @@ -563,8 +570,9 @@ class TimelineGrid extends React.Component { } state.rows = newRows; + state.key = this.getGridKey(); return state; - }) + }); this.props.onAssignTimelineProcedure({ Value: rowCopy[column.key], @@ -590,7 +598,7 @@ class TimelineGrid extends React.Component { this.props.onUpdateTimelineDayZero(selectedTimeline.StudyDay0, true, true); } - const stateCopy = {rows: [...rows]}; + const stateCopy = {rows: [...rows], key: this.getGridKey()}; this.setState(stateCopy); }; @@ -614,6 +622,7 @@ class TimelineGrid extends React.Component { this.props.onAddTimelineItem(newRow); stateCopy.rows.push(newRow); + stateCopy.key = this.getGridKey(); this.setState(stateCopy); @@ -645,7 +654,8 @@ class TimelineGrid extends React.Component { this.setState(emptyColumns); const reorderedColumns = Object.assign({}, this.state, { - columns: stateCopy.columns + columns: stateCopy.columns, + key: this.getGridKey() }); this.setState(reorderedColumns); @@ -668,7 +678,7 @@ class TimelineGrid extends React.Component { }; setSort = (sortColumn, sortDirection) => { - this.sortRows(this.state.rows, sortColumn, sortDirection, true); + this.sortRows(this.state.rows, sortColumn, undefined, sortDirection, true); }; sortRows = (initialRows, sortColumn, sortMinorColumn, sortDirection, setState) => { @@ -724,7 +734,8 @@ class TimelineGrid extends React.Component { this.setState(Object.assign({}, this.state, { rows: sortedRows, sortDirection: sortDirection, - sortColumn: sortColumn + sortColumn: sortColumn, + key: this.getGridKey() })); } @@ -778,7 +789,7 @@ class TimelineGrid extends React.Component {
- {/**/} + rows[i]} @@ -791,7 +802,7 @@ class TimelineGrid extends React.Component { onRowClick={this.onRowClick} emptyRowsView={this.EmptyRowsView} /> - {/**/} +
); diff --git a/snprc_scheduler/src/client/components/dnd/DraggableContainer.jsx b/snprc_scheduler/src/client/components/dnd/DraggableContainer.jsx index d830b02ce..a6af928ce 100644 --- a/snprc_scheduler/src/client/components/dnd/DraggableContainer.jsx +++ b/snprc_scheduler/src/client/components/dnd/DraggableContainer.jsx @@ -1,21 +1,25 @@ import React from 'react'; import PropTypes from 'prop-types'; -import html5DragDropContext from './html5DragDropContext'; +import { html5DragDropContext } from './html5DragDropContext'; import DraggableHeaderCell from './DraggableHeaderCell'; -class DraggableContainer extends React.Component { +class DraggableContainerImpl extends React.Component { + + child = React.Children.only(this.props.children); + render() { - return React.cloneElement( - React.Children.only(this.props.children), { - ...this.props, - draggableHeaderCell: DraggableHeaderCell - } - ); + return ( + <> + {React.cloneElement(this.child, {...this.props, draggableHeaderCell: DraggableHeaderCell})} + + ) } } -DraggableContainer.propTypes = { +DraggableContainerImpl.propTypes = { children: PropTypes.element.isRequired }; -export default html5DragDropContext(DraggableContainer); \ No newline at end of file +export const DraggableContainer = (props) => { + return html5DragDropContext(); +} \ No newline at end of file diff --git a/snprc_scheduler/src/client/components/dnd/html5DragDropContext.js b/snprc_scheduler/src/client/components/dnd/html5DragDropContext.js deleted file mode 100644 index c56ce6daf..000000000 --- a/snprc_scheduler/src/client/components/dnd/html5DragDropContext.js +++ /dev/null @@ -1,4 +0,0 @@ -import { DragDropContext } from 'react-dnd'; -import { HTML5Backend } from 'react-dnd-html5-backend'; - -export default DragDropContext(HTML5Backend); \ No newline at end of file diff --git a/snprc_scheduler/src/client/components/dnd/html5DragDropContext.jsx b/snprc_scheduler/src/client/components/dnd/html5DragDropContext.jsx new file mode 100644 index 000000000..c236c2a8b --- /dev/null +++ b/snprc_scheduler/src/client/components/dnd/html5DragDropContext.jsx @@ -0,0 +1,11 @@ +import React from 'react'; +import { DndProvider } from 'react-dnd'; +import { HTML5Backend } from 'react-dnd-html5-backend'; + +export const html5DragDropContext = (Component) => { + return ( + + {Component} + + ); +} \ No newline at end of file diff --git a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/StudyDayNotes.java b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/StudyDayNotes.java index 74d676288..fb86d62a2 100644 --- a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/StudyDayNotes.java +++ b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/StudyDayNotes.java @@ -37,12 +37,12 @@ public StudyDayNotes(JSONObject json) throws RuntimeException { try { - this.setTimelineObjectId(json.has(STUDYDAY_TIMELINE_OBJECT_ID) && !json.isNull(STUDYDAY_TIMELINE_OBJECT_ID) ? json.getString(STUDYDAY_TIMELINE_OBJECT_ID) : null); - this.setStudyDay(json.has(STUDYDAY_STUDY_DAY) && !json.isNull(STUDYDAY_STUDY_DAY) ? json.getInt(STUDYDAY_STUDY_DAY) : null); - this.setStudyDayNote(json.has(STUDYDAY_STUDY_DAY_NOTE) && !json.isNull(STUDYDAY_STUDY_DAY_NOTE) ? json.getString(STUDYDAY_STUDY_DAY_NOTE) : null); - this.setObjectId(json.has(STUDYDAY_OBJECT_ID) && !json.isNull(STUDYDAY_OBJECT_ID) ? json.getString(STUDYDAY_OBJECT_ID) : null); - this.setDeleted(json.has(STUDYDAY_IS_DELETED) && !json.isNull(STUDYDAY_IS_DELETED) && json.getBoolean(STUDYDAY_IS_DELETED)); - this.setDirty(json.has(STUDYDAY_IS_DIRTY) && !json.isNull(STUDYDAY_IS_DIRTY) && json.getBoolean(STUDYDAY_IS_DIRTY)); + this.setTimelineObjectId(json.optString(STUDYDAY_TIMELINE_OBJECT_ID, null)); + this.setStudyDay(json.isNull(STUDYDAY_STUDY_DAY) ? null : json.getInt(STUDYDAY_STUDY_DAY)); + this.setStudyDayNote(json.optString(STUDYDAY_STUDY_DAY_NOTE, null)); + this.setObjectId(json.optString(STUDYDAY_OBJECT_ID, null)); + this.setDeleted(!json.isNull(STUDYDAY_IS_DELETED) && json.getBoolean(STUDYDAY_IS_DELETED)); + this.setDirty(!json.isNull(STUDYDAY_IS_DIRTY) && json.getBoolean(STUDYDAY_IS_DIRTY)); } catch (Exception e) { diff --git a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/Timeline.java b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/Timeline.java index a0998d5e8..7ff9a7540 100644 --- a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/Timeline.java +++ b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/Timeline.java @@ -107,34 +107,34 @@ public Timeline(Container c, User u, JSONObject json) throws RuntimeException { try { - this.setTimelineId(json.has(TIMELINE_ID) && !json.isNull(TIMELINE_ID) ? json.getInt(TIMELINE_ID) : null); - this.setRevisionNum(json.has(TIMELINE_REVISION_NUM) && !json.isNull(TIMELINE_REVISION_NUM) ? json.getInt(TIMELINE_REVISION_NUM) : null); - this.setLeadTech(json.has(TIMELINE_LEAD_TECHS) && !json.isNull(TIMELINE_LEAD_TECHS) ? json.getString(TIMELINE_LEAD_TECHS) : null); - this.setNotes(json.has(TIMELINE_NOTES) && !json.isNull(TIMELINE_NOTES) ? json.getString(TIMELINE_NOTES) : null); - this.setSchedulerNotes(json.has(TIMELINE_SCHEDULER_NOTES) && !json.isNull(TIMELINE_SCHEDULER_NOTES) ? json.getString(TIMELINE_SCHEDULER_NOTES) : null); - this.setObjectId(json.has(TIMELINE_OBJECTID) && !json.isNull(TIMELINE_OBJECTID) ? json.getString(TIMELINE_OBJECTID) : null); - this.setCreatedBy(c, u, json.has(TIMELINE_CREATED_BY) && !json.isNull(TIMELINE_CREATED_BY) ? json.getInt(TIMELINE_CREATED_BY): null); - this.setModifiedBy(c, u, json.has(TIMELINE_MODIFIED_BY) && !json.isNull(TIMELINE_MODIFIED_BY) ? json.getInt(TIMELINE_MODIFIED_BY): null); - this.setCreatedByName(json.has(TIMELINE_CREATED_BY_NAME) && !json.isNull(TIMELINE_CREATED_BY_NAME) ? json.getString(TIMELINE_CREATED_BY_NAME): null); - this.setModifiedByName(json.has(TIMELINE_MODIFIED_BY_NAME) && !json.isNull(TIMELINE_MODIFIED_BY_NAME) ? json.getString(TIMELINE_MODIFIED_BY_NAME): null); - this.setDescription(json.has(TIMELINE_DESCRIPTION) && !json.isNull(TIMELINE_DESCRIPTION) ? json.getString(TIMELINE_DESCRIPTION) : null); - this.setQcState(json.has(TIMELINE_QCSTATE) && !json.isNull(TIMELINE_QCSTATE) ? json.getInt(TIMELINE_QCSTATE) : null); - this.setProjectObjectId(json.has(TIMELINE_PROJECT_OBJECT_ID) && !json.isNull(TIMELINE_PROJECT_OBJECT_ID) ? json.getString(TIMELINE_PROJECT_OBJECT_ID) : null); - this.setProjectId(json.has(TIMELINE_PROJECT_ID) && !json.isNull(TIMELINE_PROJECT_ID) ? json.getInt(TIMELINE_PROJECT_ID) : null); - this.setProjectRevisionNum(json.has(TIMELINE_PROJECT_REVISION_NUM) && !json.isNull(TIMELINE_PROJECT_REVISION_NUM) ? json.getInt(TIMELINE_PROJECT_REVISION_NUM) : null); - this.setDeleted(json.has(TIMELINE_IS_DELETED) && !json.isNull(TIMELINE_IS_DELETED) && json.getBoolean(TIMELINE_IS_DELETED)); - this.setDirty(json.has(TIMELINE_IS_DIRTY) && !json.isNull(TIMELINE_IS_DIRTY) && json.getBoolean(TIMELINE_IS_DIRTY)); - this.setInUse(json.has(TIMELINE_IS_IN_USE) && !json.isNull(TIMELINE_IS_IN_USE) && json.getBoolean(TIMELINE_IS_IN_USE)); - this.setRc(json.has(TIMELINE_RC) && !json.isNull(TIMELINE_RC) ? json.getString(TIMELINE_RC) : null); - this.setSpecies(json.has(TIMELINE_SPECIES) && !json.isNull(TIMELINE_SPECIES) ? json.getString(TIMELINE_SPECIES) : null); - this.setProtocol(json.has(TIMELINE_PROTOCOL) && !json.isNull(TIMELINE_PROTOCOL) ? json.getString(TIMELINE_PROTOCOL) : null); - this.setChargeId(json.has(TIMELINE_CHARGE_ID) && !json.isNull(TIMELINE_CHARGE_ID) ? json.getInt(TIMELINE_CHARGE_ID) : null); - this.setAnimalAccount(json.has(TIMELINE_ANIMAL_ACCOUNT) && !json.isNull(TIMELINE_ANIMAL_ACCOUNT) ? json.getString(TIMELINE_ANIMAL_ACCOUNT) : null); - - String startDateString = json.has(TIMELINE_STARTDATE) && !json.isNull(TIMELINE_STARTDATE) ? json.getString(TIMELINE_STARTDATE) : null; - String endDateString = json.has(TIMELINE_ENDDATE) && !json.isNull(TIMELINE_ENDDATE) ? json.getString(TIMELINE_ENDDATE) : null; - String createdDateString = json.has(TIMELINE_DATE_CREATED) && !json.isNull(TIMELINE_DATE_CREATED) ? json.getString(TIMELINE_DATE_CREATED) : null; - String modifiedDateString = json.has(TIMELINE_DATE_MODIFIED) && !json.isNull(TIMELINE_DATE_MODIFIED) ? json.getString(TIMELINE_DATE_MODIFIED) : null; + this.setTimelineId(json.isNull(TIMELINE_ID) ? null : json.getInt(TIMELINE_ID)); + this.setRevisionNum(json.isNull(TIMELINE_REVISION_NUM) ? null : json.getInt(TIMELINE_REVISION_NUM)); + this.setLeadTech(json.optString(TIMELINE_LEAD_TECHS, null)); + this.setNotes(json.optString(TIMELINE_NOTES, null)); + this.setSchedulerNotes(json.optString(TIMELINE_SCHEDULER_NOTES, null)); + this.setObjectId(json.optString(TIMELINE_OBJECTID, null)); + this.setCreatedBy(c, u, json.isNull(TIMELINE_CREATED_BY) ? null : json.getInt(TIMELINE_CREATED_BY)); + this.setModifiedBy(c, u, json.isNull(TIMELINE_MODIFIED_BY) ? null : json.getInt(TIMELINE_MODIFIED_BY)); + this.setCreatedByName(json.optString(TIMELINE_CREATED_BY_NAME, null)); + this.setModifiedByName(json.optString(TIMELINE_MODIFIED_BY_NAME, null)); + this.setDescription(json.optString(TIMELINE_DESCRIPTION, null)); + this.setQcState(json.isNull(TIMELINE_QCSTATE) ? null : json.getInt(TIMELINE_QCSTATE)); + this.setProjectObjectId(json.optString(TIMELINE_PROJECT_OBJECT_ID, null)); + this.setProjectId(json.isNull(TIMELINE_PROJECT_ID) ? null : json.getInt(TIMELINE_PROJECT_ID)); + this.setProjectRevisionNum(json.isNull(TIMELINE_PROJECT_REVISION_NUM) ? null : json.getInt(TIMELINE_PROJECT_REVISION_NUM)); + this.setDeleted(!json.isNull(TIMELINE_IS_DELETED) && json.getBoolean(TIMELINE_IS_DELETED)); + this.setDirty(!json.isNull(TIMELINE_IS_DIRTY) && json.getBoolean(TIMELINE_IS_DIRTY)); + this.setInUse(!json.isNull(TIMELINE_IS_IN_USE) && json.getBoolean(TIMELINE_IS_IN_USE)); + this.setRc(json.optString(TIMELINE_RC, null)); + this.setSpecies(json.optString(TIMELINE_SPECIES, null)); + this.setProtocol(json.optString(TIMELINE_PROTOCOL, null)); + this.setChargeId(json.isNull(TIMELINE_CHARGE_ID) ? null : json.getInt(TIMELINE_CHARGE_ID)); + this.setAnimalAccount(json.optString(TIMELINE_ANIMAL_ACCOUNT, null)); + + String startDateString = json.optString(TIMELINE_STARTDATE, null); + String endDateString = json.optString(TIMELINE_ENDDATE, null); + String createdDateString = json.optString(TIMELINE_DATE_CREATED, null); + String modifiedDateString = json.optString(TIMELINE_DATE_MODIFIED, null); try { diff --git a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineAnimalJunction.java b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineAnimalJunction.java index cd0d27e1e..b74e49d5b 100644 --- a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineAnimalJunction.java +++ b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineAnimalJunction.java @@ -57,20 +57,20 @@ public TimelineAnimalJunction(JSONObject json) throws RuntimeException try { // TODO: Update or remove commented out lines once we get to animal assignment - this.setRowId(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_ROW_ID) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_ROW_ID) ? json.getInt(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_ROW_ID) : null); - this.setTimelineObjectId(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_TIMELINE_OBJECT_ID) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_TIMELINE_OBJECT_ID) ? json.getString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_TIMELINE_OBJECT_ID) : null); - this.setAnimalId(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_ANIMAL_ID) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_ANIMAL_ID) ? json.getString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_ANIMAL_ID) : null); - this.setAssignmentStatus(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_ASSIGNMENT_STATUS) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_ASSIGNMENT_STATUS) ? json.getString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_ASSIGNMENT_STATUS) : null); - this.setGender(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_GENDER) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_GENDER) ? json.getString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_GENDER) : null); - this.setAge(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_AGE) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_AGE) ? json.getString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_AGE) : null); - this.setLocation(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_LOCATION) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_LOCATION) ? json.getString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_LOCATION) : null); - this.setCage(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_CAGE) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_CAGE) ? json.getString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_CAGE) : null); - this.setWeight(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_WEIGHT) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_WEIGHT) ? json.getDouble(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_WEIGHT) : null); - this.setObjectId(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_OBJECT_ID) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_OBJECT_ID) ? json.getString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_OBJECT_ID) : null); - this.setDeleted(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_IS_DELETED) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_IS_DELETED) && json.getBoolean(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_IS_DELETED)); - this.setDirty(json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_IS_DIRTY) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_IS_DIRTY) && json.getBoolean(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_IS_DIRTY)); - - String endDateString = json.has(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_END_DATE) && !json.isNull(TIMELINE_ANIMAL_JUNCTION_END_DATE) ? json.getString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_END_DATE) : null; + this.setRowId(json.isNull(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_ROW_ID) ? null : json.getInt(TIMELINE_ANIMAL_JUNCTION_ROW_ID)); + this.setTimelineObjectId(json.optString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_TIMELINE_OBJECT_ID, null)); + this.setAnimalId(json.optString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_ANIMAL_ID, null)); + this.setAssignmentStatus(json.optString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_ASSIGNMENT_STATUS, null)); + this.setGender(json.optString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_GENDER, null)); + this.setAge(json.optString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_AGE, null)); + this.setLocation(json.optString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_LOCATION, null)); + this.setCage(json.optString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_CAGE, null)); + this.setWeight(json.isNull(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_WEIGHT) ? null : json.getDouble(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_WEIGHT)); + this.setObjectId(json.optString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_OBJECT_ID, null)); + this.setDeleted(!json.isNull(TIMELINE_ANIMAL_JUNCTION_IS_DELETED) && json.getBoolean(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_IS_DELETED)); + this.setDirty(!json.isNull(TIMELINE_ANIMAL_JUNCTION_IS_DIRTY) && json.getBoolean(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_IS_DIRTY)); + + String endDateString = json.optString(TimelineAnimalJunction.TIMELINE_ANIMAL_JUNCTION_END_DATE, null); try { this.setEndDate(endDateString == null ? null : DateUtil.parseDateTime(endDateString, Timeline.TIMELINE_DATE_FORMAT)); diff --git a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineItem.java b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineItem.java index c01286bd4..d3828dd6a 100644 --- a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineItem.java +++ b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineItem.java @@ -53,17 +53,16 @@ public TimelineItem(JSONObject json) throws RuntimeException try { - this.setTimelineItemId(json.has(TIMELINEITEM_TIMELINE_ITEM_ID) && !json.isNull(TIMELINEITEM_TIMELINE_ITEM_ID) ? json.getInt(TIMELINEITEM_TIMELINE_ITEM_ID) : null); - this.setTimelineObjectId(json.has(TIMELINEITEM_TIMELINE_OBJECT_ID) && !json.isNull(TIMELINEITEM_TIMELINE_OBJECT_ID)? json.getString(TIMELINEITEM_TIMELINE_OBJECT_ID) : null); - this.setStudyDay(json.has(TIMELINEITEM_STUDY_DAY) && !json.isNull(TIMELINEITEM_STUDY_DAY) ? json.getInt(TIMELINEITEM_STUDY_DAY) : null); - this.setProjectItemId(json.has(TIMELINEITEM_PROJECT_ITEM_ID) && !json.isNull(TIMELINEITEM_PROJECT_ITEM_ID) - ? json.getInt(TIMELINEITEM_PROJECT_ITEM_ID) : null); - this.setObjectId(json.has(TIMELINEITEM_OBJECT_ID) && !json.isNull(TIMELINEITEM_OBJECT_ID) ? json.getString(TIMELINEITEM_OBJECT_ID) : null); - this.setDeleted(json.has(TIMELINEITEM_IS_DELETED) && !json.isNull(TIMELINEITEM_IS_DELETED) && json.getBoolean(TIMELINEITEM_IS_DELETED)); - this.setDirty(json.has(TIMELINEITEM_IS_DIRTY) && !json.isNull(TIMELINEITEM_IS_DIRTY) && json.getBoolean(TIMELINEITEM_IS_DIRTY)); - this.setPkgId(json.has(TIMELINEITEM_PKG_ID) && !json.isNull(TIMELINEITEM_PKG_ID) ? json.getInt(TIMELINEITEM_PKG_ID) : null); - - String scheduleDateString = json.has(TIMELINEITEM_SCHEDULE_DATE) && !json.isNull(TIMELINEITEM_SCHEDULE_DATE) ? json.getString(TIMELINEITEM_SCHEDULE_DATE) : null; + this.setTimelineItemId(json.isNull(TIMELINEITEM_TIMELINE_ITEM_ID) ? null : json.getInt(TIMELINEITEM_TIMELINE_ITEM_ID)); + this.setTimelineObjectId(json.optString(TIMELINEITEM_TIMELINE_OBJECT_ID, null)); + this.setStudyDay(json.isNull(TIMELINEITEM_STUDY_DAY) ? null : json.getInt(TIMELINEITEM_STUDY_DAY)); + this.setProjectItemId(json.isNull(TIMELINEITEM_PROJECT_ITEM_ID) ? null : json.getInt(TIMELINEITEM_PROJECT_ITEM_ID)); + this.setObjectId(json.optString(TIMELINEITEM_OBJECT_ID, null)); + this.setDeleted(!json.isNull(TIMELINEITEM_IS_DELETED) && json.getBoolean(TIMELINEITEM_IS_DELETED)); + this.setDirty(!json.isNull(TIMELINEITEM_IS_DIRTY) && json.getBoolean(TIMELINEITEM_IS_DIRTY)); + this.setPkgId(json.isNull(TIMELINEITEM_PKG_ID) ? null : json.getInt(TIMELINEITEM_PKG_ID)); + + String scheduleDateString = json.optString(TIMELINEITEM_SCHEDULE_DATE, null); try { @@ -91,7 +90,7 @@ public static boolean isValidTimelineItem(JSONObject json) // Find studyDay and projectItemId and parse as ints // Allow null value for projectItemId json.getInt(TIMELINEITEM_STUDY_DAY); - if (json.has(TIMELINEITEM_PROJECT_ITEM_ID) && !json.isNull(TIMELINEITEM_PROJECT_ITEM_ID)) + if (!json.isNull(TIMELINEITEM_PROJECT_ITEM_ID)) json.getInt(TIMELINEITEM_PROJECT_ITEM_ID); } catch (Exception e) diff --git a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineProjectItem.java b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineProjectItem.java index 60637d86e..689522c5f 100644 --- a/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineProjectItem.java +++ b/snprc_scheduler/src/org/labkey/snprc_scheduler/domains/TimelineProjectItem.java @@ -45,14 +45,14 @@ public TimelineProjectItem(JSONObject json) throws RuntimeException { try { - this.setProjectItemId(json.has(TimelineProjectItem.TIMELINE_PROJECT_ITEM_PROJECT_ITEM_ID) ? json.getInt(TimelineProjectItem.TIMELINE_PROJECT_ITEM_PROJECT_ITEM_ID) : null); - this.setTimelineObjectId(json.has(TimelineProjectItem.TIMELINE_PROJECT_ITEM_TIMELINE_OBJECT_ID) ? json.getString(TimelineProjectItem.TIMELINE_PROJECT_ITEM_TIMELINE_OBJECT_ID) : null); - this.setSortOrder(json.has(TimelineProjectItem.TIMELINE_PROJECT_ITEM_SORT_ORDER) ? json.getInt(TimelineProjectItem.TIMELINE_PROJECT_ITEM_SORT_ORDER) : null); - this.setObjectId(json.has(TimelineProjectItem.TIMELINE_PROJECT_ITEM_OBJECTID) ? json.getString(TimelineProjectItem.TIMELINE_PROJECT_ITEM_OBJECTID) : null); - this.setTimelineFootNotes(json.has(TimelineProjectItem.TIMELINE_PROJECT_ITEM_TIMELINE_FOOT_NOTES) ? json.getString(TimelineProjectItem.TIMELINE_PROJECT_ITEM_TIMELINE_FOOT_NOTES) : null); - this.setDeleted(json.has(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_DELETED) && json.getBoolean(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_DELETED) ); - this.setDirty(json.has(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_DIRTY) && json.getBoolean(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_DIRTY) ); - this.setActive(json.has(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_ACTIVE) && json.getBoolean(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_ACTIVE) ); + this.setProjectItemId(json.isNull(TimelineProjectItem.TIMELINE_PROJECT_ITEM_PROJECT_ITEM_ID) ? null : json.getInt(TimelineProjectItem.TIMELINE_PROJECT_ITEM_PROJECT_ITEM_ID)); + this.setTimelineObjectId(json.optString(TimelineProjectItem.TIMELINE_PROJECT_ITEM_TIMELINE_OBJECT_ID, null)); + this.setSortOrder(json.isNull(TimelineProjectItem.TIMELINE_PROJECT_ITEM_SORT_ORDER) ? null : json.getInt(TimelineProjectItem.TIMELINE_PROJECT_ITEM_SORT_ORDER)); + this.setObjectId(json.optString(TimelineProjectItem.TIMELINE_PROJECT_ITEM_OBJECTID, null)); + this.setTimelineFootNotes(json.optString(TimelineProjectItem.TIMELINE_PROJECT_ITEM_TIMELINE_FOOT_NOTES, null)); + this.setDeleted(!json.isNull(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_DELETED) && json.getBoolean(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_DELETED) ); + this.setDirty(!json.isNull(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_DIRTY) && json.getBoolean(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_DIRTY) ); + this.setActive(!json.isNull(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_ACTIVE) && json.getBoolean(TimelineProjectItem.TIMELINE_PROJECT_ITEM_IS_ACTIVE) ); } catch (Exception e) From 3cfcdd5abbdc6a80dfd382d8594824d724ef1676 Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Fri, 29 Dec 2023 14:30:13 -0800 Subject: [PATCH 2/2] render grid on study day and procedure note updates --- snprc_scheduler/src/client/components/TimelineGrid.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snprc_scheduler/src/client/components/TimelineGrid.jsx b/snprc_scheduler/src/client/components/TimelineGrid.jsx index 52eac1dd3..d576b289f 100644 --- a/snprc_scheduler/src/client/components/TimelineGrid.jsx +++ b/snprc_scheduler/src/client/components/TimelineGrid.jsx @@ -282,7 +282,8 @@ class TimelineGrid extends React.Component { }) this.setState(Object.assign({}, this.state, { - rows: newRows + rows: newRows, + key: this.getGridKey() })); this.props.selectedTimeline.forceReload = false; @@ -494,6 +495,7 @@ class TimelineGrid extends React.Component { stateCopy.showProcNote = false; stateCopy.procNoteName = ""; stateCopy.rows = newRows; + stateCopy.key = this.getGridKey(); this.setState(stateCopy);