Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNPRC Scheduler Fixes #654

Merged
merged 6 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions snprc_scheduler/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions snprc_scheduler/src/client/components/ProjectList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
35 changes: 24 additions & 11 deletions snprc_scheduler/src/client/components/TimelineGrid.jsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -277,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;
Expand Down Expand Up @@ -412,6 +418,7 @@ class TimelineGrid extends React.Component {
allRows = newState.rows;

newState.columns = sortedCols;
newState.key = this.getGridKey();
this.setState(Object.assign({}, this.state, newState));
}

Expand Down Expand Up @@ -488,6 +495,7 @@ class TimelineGrid extends React.Component {
stateCopy.showProcNote = false;
stateCopy.procNoteName = "";
stateCopy.rows = newRows;
stateCopy.key = this.getGridKey();

this.setState(stateCopy);

Expand Down Expand Up @@ -524,6 +532,7 @@ class TimelineGrid extends React.Component {

this.setState(state => {
state.rows = filteredRows;
state.key = this.getGridKey();
return state;
});

Expand Down Expand Up @@ -563,8 +572,9 @@ class TimelineGrid extends React.Component {
}

state.rows = newRows;
state.key = this.getGridKey();
return state;
})
});

this.props.onAssignTimelineProcedure({
Value: rowCopy[column.key],
Expand All @@ -590,7 +600,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);
};

Expand All @@ -614,6 +624,7 @@ class TimelineGrid extends React.Component {
this.props.onAddTimelineItem(newRow);

stateCopy.rows.push(newRow);
stateCopy.key = this.getGridKey();

this.setState(stateCopy);

Expand Down Expand Up @@ -645,7 +656,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);

Expand All @@ -668,7 +680,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) => {
Expand Down Expand Up @@ -724,7 +736,8 @@ class TimelineGrid extends React.Component {
this.setState(Object.assign({}, this.state, {
rows: sortedRows,
sortDirection: sortDirection,
sortColumn: sortColumn
sortColumn: sortColumn,
key: this.getGridKey()
}));
}

Expand Down Expand Up @@ -778,7 +791,7 @@ class TimelineGrid extends React.Component {
<div className='col-sm-10' />
</div>
<div className='col-sm-12 zero-side-padding'>
{/*<DraggableContainer onHeaderDrop={this.onHeaderDrop}>*/}
<DraggableContainer onHeaderDrop={this.onHeaderDrop} key={this.state.key}>
<ReactDataGrid
columns={columns}
rowGetter={i => rows[i]}
Expand All @@ -791,7 +804,7 @@ class TimelineGrid extends React.Component {
onRowClick={this.onRowClick}
emptyRowsView={this.EmptyRowsView}
/>
{/*</DraggableContainer>*/}
</DraggableContainer>
</div>
</div>
);
Expand Down
24 changes: 14 additions & 10 deletions snprc_scheduler/src/client/components/dnd/DraggableContainer.jsx
Original file line number Diff line number Diff line change
@@ -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);
export const DraggableContainer = (props) => {
return html5DragDropContext(<DraggableContainerImpl {...props}/>);
}

This file was deleted.

11 changes: 11 additions & 0 deletions snprc_scheduler/src/client/components/dnd/html5DragDropContext.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<DndProvider backend={HTML5Backend}>
{Component}
</DndProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading