Skip to content

Commit 9bfcf8b

Browse files
authored
CageUI Test Fix (#838)
* Fix for incorrect grid snapping due to chrome version update 137 * Fix for objects to jump away from the cursor in larger scaled rooms * Fix for clear layout not removing everything correctly * Fix for the large amount of empty space in the object toolbar * Fix for test failing due to lookup tables not being populated * Fix for templates not being able to be saved while renamed
1 parent 6651dc5 commit 9bfcf8b

9 files changed

Lines changed: 51 additions & 11 deletions

File tree

CageUI/src/client/components/layoutEditor/Editor.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ const Editor: FC<EditorProps> = ({roomSize}) => {
107107
const [showRoomSelectorTemplateLoad, setShowRoomSelectorTemplateLoad] = useState<boolean>(false);
108108
const [showSaveResult, setShowSaveResult] = useState<LayoutSaveResult>(null);
109109
const [templateOptions, setTemplateOptions] = useState<boolean>(false);
110+
const [templateRename, setTemplateRename] = useState<string>(null);
110111

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

764765
const handleSave = async () => {
765-
const result = await saveRoom();
766+
767+
const result = await saveRoom(templateRename);
766768
setShowSaveResult(result);
767769
}
768770

@@ -937,6 +939,7 @@ const Editor: FC<EditorProps> = ({roomSize}) => {
937939
<RoomSelectorPopup
938940
setRoom={setLocalRoom}
939941
template={templateOptions}
942+
templateRename={setTemplateRename}
940943
onConfirm={() => {setShowRoomSelector(false);setShowSaveConfirm(true);}}
941944
onCancel={() => {setTemplateOptions(false);setShowRoomSelector(false);}}
942945
/>

CageUI/src/client/components/layoutEditor/RoomSelectorPopup.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ interface RoomSelectorPopup {
3232
setRoom: React.Dispatch<React.SetStateAction<Room>>;
3333
template: boolean;
3434
templateLoad?: boolean;
35+
templateRename?: React.Dispatch<React.SetStateAction<string>>;
3536
}
3637

3738
// For saving and loading in the layout editor, this is a room selector component
3839
export const RoomSelectorPopup: FC<RoomSelectorPopup> = (props) => {
39-
const { onConfirm, onCancel, setRoom, template,templateLoad } = props;
40+
const { onConfirm, onCancel, setRoom, template,templateLoad, templateRename } = props;
4041
const [selectedRoom, setSelectedRoom] = useState<string>(null);
4142
const [options, setOptions] = useState<Option<number>[]>(null);
4243
const [templateName, setTemplateName] = useState<string>('');
@@ -76,11 +77,12 @@ export const RoomSelectorPopup: FC<RoomSelectorPopup> = (props) => {
7677
onCancel();
7778
return;
7879
}
79-
// if template, save old name and new name together to parse later in submission
80+
// if template, save old template name for later
8081
setRoom(prevState => ({
8182
...prevState,
8283
name: templateName
8384
}));
85+
templateRename(selectedRoom);
8486
}else{
8587
setRoom(prevState => ({
8688
...prevState,

CageUI/src/client/context/LayoutEditorContextManager.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,12 +1117,14 @@ export const LayoutEditorContextProvider: FC<LayoutContextProps> = ({children, p
11171117
setNextAvailGroup('rack-group-1');
11181118
}
11191119

1120-
const saveRoom = async (): Promise<LayoutSaveResult> => {
1120+
const saveRoom = async (oldTemplateName?: string): Promise<LayoutSaveResult> => {
11211121
const commands: Command[] = [];
11221122
const dataToSave: LayoutHistoryData[] = [];
1123+
11231124
// if template parse room name, 1 is the new name, 0 is the old name
1125+
11241126
const roomName = localRoom.name;
1125-
const oldRoomName: string = ActionURL.getParameter('room');
1127+
const oldRoomName: string = oldTemplateName ? oldTemplateName : ActionURL.getParameter('room');
11261128
const savingTemplate: boolean = roomName.toLowerCase().includes("template");
11271129
const newEndDate = new Date();
11281130
const newStartDate = new Date();

CageUI/src/client/types/layoutEditorContextTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface LayoutContextProps {
4747
export interface LayoutContextType {
4848
room: Room;
4949
setRoom: React.Dispatch<React.SetStateAction<Room>>;
50-
saveRoom: () => Promise<LayoutSaveResult>;
50+
saveRoom: (oldTemplateName?: string) => Promise<LayoutSaveResult>;
5151
layoutSvg: d3.Selection<SVGElement, {}, HTMLElement, any>;
5252
setLayoutSvg: React.Dispatch<React.SetStateAction<d3.Selection<SVGElement, {}, HTMLElement, any>>>;
5353
unitLocs: UnitLocations;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Value Title Category Description Sort Order Date Disabled
2+
0 Default Cage Caging 4
3+
1 Default Pen Caging 8
4+
2 Default Temp Cage Caging 4
5+
3 Default Play Cage Caging 8
6+
4 Cage Caging 4
7+
5 Pen Caging 8
8+
6 Temp Cage Caging 4
9+
7 Play Cage Caging 8
10+
100 Room Divider Room Object
11+
101 Drain Room Object
12+
102 Door Room Object
13+
103 Gate Room Object
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Value Title Category Description Sort Order Date Disabled
2+
at Allentown
3+
sb Suburban
4+
lk Lenderking
5+
wnprc WNPRC
6+
uk Unknown

WNPRC_EHR/resources/data/lookup_sets.tsv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ biopsy_type Biopsy Type Field Values value
1111
birth_condition Birth Condition Field Values value value
1212
birth_type Birth Type Field Values value title
1313
blood_billed_by Blood Billed By Field Values value title
14-
blood_code_prefixes Blood Code Prefix Field Values value
15-
cageui_item_types Room Item Type Field Values value title
16-
cageui_rack_manufacturers Rack Manufacturer Field Values value title
14+
blood_code_prefixes Blood Code Prefix Field Values value
15+
cageui_item_types Room Item Type Field Values value
16+
cageui_rack_manufacturers Rack Manufacturer Field Values value
1717
chemistry_method Chemistry Method Field Values value
1818
chow_types Chow Types Field Values value
1919
clinpath_collection_method Clinpath Collection Method Field Values value

WNPRC_EHR/resources/views/populateInitialData.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,20 @@
269269
queryName: 'husbandry_assigned',
270270
module: 'wnprc_ehr',
271271
pk: 'rowid'
272+
},{
273+
label: 'Room Item Type Field Values',
274+
populateFn: 'populateFromFile',
275+
schemaName: 'ehr_lookups',
276+
queryName: 'cageui_item_types',
277+
module: 'wnprc_ehr',
278+
pk: 'value'
279+
},{
280+
label: 'Rack Manufacturer Field Values',
281+
populateFn: 'populateFromFile',
282+
schemaName: 'ehr_lookups',
283+
queryName: 'cageui_rack_manufacturers',
284+
module: 'wnprc_ehr',
285+
pk: 'value'
272286
}];
273287

274288
tables.sort(function(a, b) {

WNPRC_EHR/test/src/org/labkey/test/tests/wnprc_ehr/WNPRC_EHRTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4701,7 +4701,7 @@ private void importRacks() throws IOException, CommandException
47014701
Map<String, Object> responseMap = new HashMap<>();
47024702

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

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

0 commit comments

Comments
 (0)