Skip to content
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
5 changes: 4 additions & 1 deletion CageUI/src/client/components/layoutEditor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const Editor: FC<EditorProps> = ({roomSize}) => {
const [showRoomSelectorTemplateLoad, setShowRoomSelectorTemplateLoad] = useState<boolean>(false);
const [showSaveResult, setShowSaveResult] = useState<LayoutSaveResult>(null);
const [templateOptions, setTemplateOptions] = useState<boolean>(false);
const [templateRename, setTemplateRename] = useState<string>(null);

// number of cells in grid width/height, based off scale
const gridWidth = Math.ceil(SVG_WIDTH / roomSize.scale / CELL_SIZE);
Expand Down Expand Up @@ -762,7 +763,8 @@ const Editor: FC<EditorProps> = ({roomSize}) => {
}

const handleSave = async () => {
const result = await saveRoom();

const result = await saveRoom(templateRename);
setShowSaveResult(result);
}

Expand Down Expand Up @@ -937,6 +939,7 @@ const Editor: FC<EditorProps> = ({roomSize}) => {
<RoomSelectorPopup
setRoom={setLocalRoom}
template={templateOptions}
templateRename={setTemplateRename}
onConfirm={() => {setShowRoomSelector(false);setShowSaveConfirm(true);}}
onCancel={() => {setTemplateOptions(false);setShowRoomSelector(false);}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ interface RoomSelectorPopup {
setRoom: React.Dispatch<React.SetStateAction<Room>>;
template: boolean;
templateLoad?: boolean;
templateRename?: React.Dispatch<React.SetStateAction<string>>;
}

// For saving and loading in the layout editor, this is a room selector component
export const RoomSelectorPopup: FC<RoomSelectorPopup> = (props) => {
const { onConfirm, onCancel, setRoom, template,templateLoad } = props;
const { onConfirm, onCancel, setRoom, template,templateLoad, templateRename } = props;
const [selectedRoom, setSelectedRoom] = useState<string>(null);
const [options, setOptions] = useState<Option<number>[]>(null);
const [templateName, setTemplateName] = useState<string>('');
Expand Down Expand Up @@ -76,11 +77,12 @@ export const RoomSelectorPopup: FC<RoomSelectorPopup> = (props) => {
onCancel();
return;
}
// if template, save old name and new name together to parse later in submission
// if template, save old template name for later
setRoom(prevState => ({
...prevState,
name: templateName
}));
templateRename(selectedRoom);
}else{
setRoom(prevState => ({
...prevState,
Expand Down
6 changes: 4 additions & 2 deletions CageUI/src/client/context/LayoutEditorContextManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1117,12 +1117,14 @@ export const LayoutEditorContextProvider: FC<LayoutContextProps> = ({children, p
setNextAvailGroup('rack-group-1');
}

const saveRoom = async (): Promise<LayoutSaveResult> => {
const saveRoom = async (oldTemplateName?: string): Promise<LayoutSaveResult> => {
const commands: Command[] = [];
const dataToSave: LayoutHistoryData[] = [];

// if template parse room name, 1 is the new name, 0 is the old name

const roomName = localRoom.name;
const oldRoomName: string = ActionURL.getParameter('room');
const oldRoomName: string = oldTemplateName ? oldTemplateName : ActionURL.getParameter('room');
const savingTemplate: boolean = roomName.toLowerCase().includes("template");
const newEndDate = new Date();
const newStartDate = new Date();
Expand Down
2 changes: 1 addition & 1 deletion CageUI/src/client/types/layoutEditorContextTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface LayoutContextProps {
export interface LayoutContextType {
room: Room;
setRoom: React.Dispatch<React.SetStateAction<Room>>;
saveRoom: () => Promise<LayoutSaveResult>;
saveRoom: (oldTemplateName?: string) => Promise<LayoutSaveResult>;
layoutSvg: d3.Selection<SVGElement, {}, HTMLElement, any>;
setLayoutSvg: React.Dispatch<React.SetStateAction<d3.Selection<SVGElement, {}, HTMLElement, any>>>;
unitLocs: UnitLocations;
Expand Down
13 changes: 13 additions & 0 deletions WNPRC_EHR/resources/data/cageui_item_types.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Value Title Category Description Sort Order Date Disabled
0 Default Cage Caging 4
1 Default Pen Caging 8
2 Default Temp Cage Caging 4
3 Default Play Cage Caging 8
4 Cage Caging 4
5 Pen Caging 8
6 Temp Cage Caging 4
7 Play Cage Caging 8
100 Room Divider Room Object
101 Drain Room Object
102 Door Room Object
103 Gate Room Object
6 changes: 6 additions & 0 deletions WNPRC_EHR/resources/data/cageui_rack_manufacturers.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Value Title Category Description Sort Order Date Disabled
at Allentown
sb Suburban
lk Lenderking
wnprc WNPRC
uk Unknown
6 changes: 3 additions & 3 deletions WNPRC_EHR/resources/data/lookup_sets.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ biopsy_type Biopsy Type Field Values value
birth_condition Birth Condition Field Values value value
birth_type Birth Type Field Values value title
blood_billed_by Blood Billed By Field Values value title
blood_code_prefixes Blood Code Prefix Field Values value
cageui_item_types Room Item Type Field Values value title
cageui_rack_manufacturers Rack Manufacturer Field Values value title
blood_code_prefixes Blood Code Prefix Field Values value
cageui_item_types Room Item Type Field Values value
cageui_rack_manufacturers Rack Manufacturer Field Values value
chemistry_method Chemistry Method Field Values value
chow_types Chow Types Field Values value
clinpath_collection_method Clinpath Collection Method Field Values value
Expand Down
14 changes: 14 additions & 0 deletions WNPRC_EHR/resources/views/populateInitialData.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@
queryName: 'husbandry_assigned',
module: 'wnprc_ehr',
pk: 'rowid'
},{
label: 'Room Item Type Field Values',
populateFn: 'populateFromFile',
schemaName: 'ehr_lookups',
queryName: 'cageui_item_types',
module: 'wnprc_ehr',
pk: 'value'
},{
label: 'Rack Manufacturer Field Values',
populateFn: 'populateFromFile',
schemaName: 'ehr_lookups',
queryName: 'cageui_rack_manufacturers',
module: 'wnprc_ehr',
pk: 'value'
}];

tables.sort(function(a, b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4701,7 +4701,7 @@ private void importRacks() throws IOException, CommandException
Map<String, Object> responseMap = new HashMap<>();

List<Map<String, Object>> tsv = loadTsv(TestFileUtils.getSampleData("wnprc_ehr/cageui/racks.tsv"));
insertTsvData(connection, "cageUI", "racks", tsv, EHR_FOLDER_PATH)
insertTsvData(connection, "cageui", "racks", tsv, EHR_FOLDER_PATH)
.forEach(row -> responseMap.put(row.get("rowid").toString(),row));
}
// Imports rack types data for cage ui testing
Expand All @@ -4711,7 +4711,7 @@ private void importRackTypes() throws IOException, CommandException
Map<String, Object> responseMap = new HashMap<>();

List<Map<String, Object>> tsv = loadTsv(TestFileUtils.getSampleData("wnprc_ehr/cageui/rackTypes.tsv"));
insertTsvData(connection, "cageUI", "rack_types", tsv, EHR_FOLDER_PATH)
insertTsvData(connection, "cageui", "rack_types", tsv, EHR_FOLDER_PATH)
.forEach(row -> responseMap.put(row.get("rowid").toString(),row));
}

Expand Down