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
2 changes: 1 addition & 1 deletion CageUI/ios-webpack/watch.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const constants = require('./constants');
const path = require('path');
// relative to the <lk_module>/node_modules/@labkey/build/webpack dir
const entryPoints = require('../src/client/entryPoints.js');
const host = require("host");
const host = require("./host");


const devServer = {
Expand Down
67 changes: 10 additions & 57 deletions CageUI/resources/web/CageUI/static/legend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 39 additions & 2 deletions CageUI/src/client/components/layoutEditor/EditorContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const EditorContextMenu: FC<EditorContextMenuProps> = (props) => {
type
} = props;

const menuRef = useRef(null);
const menuRef = useRef<HTMLDivElement>(null);

// Delete object for room objects
const handleDeleteObject = (e: React.MouseEvent<HTMLElement>) => {
Expand Down Expand Up @@ -97,7 +97,44 @@ export const EditorContextMenu: FC<EditorContextMenuProps> = (props) => {
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, [menuRef]);
}, [closeMenu]);

// Handle dynamic positioning
useEffect(() => {
if (!menuRef.current || ctxMenuStyle.display !== 'block') return;

const menu = menuRef.current;
const { top, left } = ctxMenuStyle;
const topValue = parseInt(top, 10);
const leftValue = parseInt(left, 10);

const windowWidth = window.innerWidth;
const windowHeight = window.innerHeight;
const menuWidth = menu.offsetWidth;
const menuHeight = menu.offsetHeight;

let adjustedTop = topValue;
let adjustedLeft = leftValue;

// Prevent overflow to the right
if (leftValue + menuWidth > windowWidth) {
adjustedLeft = windowWidth - menuWidth - 10;
}

// Prevent overflow to the bottom
if (topValue + menuHeight > windowHeight) {
adjustedTop = windowHeight - menuHeight - 10;
}

// Prevent overflow to the left
if (adjustedLeft < 10) adjustedLeft = 10;

// Prevent overflow to the top
if (adjustedTop < 10) adjustedTop = 10;

menu.style.left = `${adjustedLeft}px`;
menu.style.top = `${adjustedTop}px`;
}, [ctxMenuStyle.display, ctxMenuStyle.left, ctxMenuStyle.top]);

return (
<div id="contextMenu" className="context-menu" ref={menuRef} style={{
Expand Down
10 changes: 3 additions & 7 deletions CageUI/src/client/components/layoutEditor/RoomSelectorPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,11 @@ export const RoomSelectorPopup: FC<RoomSelectorPopup> = (props) => {
}

if (templateName.length > 0) {
//return if new name doesn't have word template in it
if (!templateName.includes('template')) {
onCancel();
return;
}
const newTemplateName = "template-" + templateName;
// if template, save old template name for later
setRoom(prevState => ({
...prevState,
name: templateName
name: newTemplateName
}));
templateRename(selectedRoom);
} else {
Expand Down Expand Up @@ -109,7 +105,7 @@ export const RoomSelectorPopup: FC<RoomSelectorPopup> = (props) => {
</label>
<input
value={templateName}
onChange={(e) => setTemplateName("template-" + e.target.value)}
onChange={(e) => setTemplateName(e.target.value)}
/>
</div>
}
Expand Down
15 changes: 8 additions & 7 deletions CageUI/src/client/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -758,20 +758,21 @@ export const buildNewLocalRoom = async (prevRoom: PrevRoom): Promise<[Room, Unit
cageNumType = roomItemToString(defaultTypeToRackType(rackItem.objectType as DefaultRackTypes));
}

let cageMods: CageModificationsType = {
[ModLocations.Top]: [],
[ModLocations.Bottom]: [],
[ModLocations.Left]: [],
[ModLocations.Right]: [],
[ModLocations.Direct]: []
};
let cageMods: CageModificationsType;
if (rackItem.extraContext) {
extraContext = JSON.parse(rackItem.extraContext);
}
const svgSize = await getSvgSize(rack.type.type);

// This is where mods are loaded into state for the room
if (loadMods && !rack.type.isDefault) {
cageMods = {
[ModLocations.Top]: [],
[ModLocations.Bottom]: [],
[ModLocations.Left]: [],
[ModLocations.Right]: [],
[ModLocations.Direct]: []
};

const modReturnData = await cageModLookup([], []);
const availMods = modReturnData.map(row => ({value: row.value, label: row.title}));
Expand Down
Loading