Skip to content

Commit 667daa8

Browse files
collins-selfcollins-self
authored andcommitted
rename modal handler and improve tooltip error display
1 parent 18eaad9 commit 667daa8

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/CommonComponents/LocationDrawingsButton.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ const LocationDrawingsButton: React.FC<LocationDrawingsButtonProps> = (props) =>
7979
const error = isValid(location, result);
8080
const option: DropDownOption = {
8181
Label: location.Name,
82-
Callback: () => handleShowDrawingsModal(location),
82+
Callback: () => handleClickDrawingsModal(location),
8383
Disabled: error != "",
84-
ToolTipContent: <p>{error}</p>,
84+
ToolTipContent: <p>{CrossMark} {error}</p>,
8585
ShowToolTip: error != "",
8686
ToolTipLocation: "left",
8787
Key: i
@@ -99,21 +99,25 @@ const LocationDrawingsButton: React.FC<LocationDrawingsButtonProps> = (props) =>
9999
return () => handles.forEach(handle => () => { if (handle != null && handle?.abort != null) handle.abort() });
100100
}, [props.Locations]);
101101

102-
const handleShowDrawingsModal = (loc) => {
102+
const handleClickDrawingsModal = (loc?: OpenXDA.Types.Location) => {
103+
if (showDrawingsModal) {
104+
setShowDrawingsModal(false);
105+
return;
106+
}
103107
if (loc == undefined) return;
104108
setSelectedLocation(loc);
105109
setShowDrawingsModal(true);
106110
};
107111

108112
return (
109-
<div>
113+
<>
110114
<LoadingScreen Show={pageState == 'loading' || props.IsLoadingLocations == true} />
111115
<ServerErrorIcon Show={pageState == 'error'} Size={40} Label={'A Server Error Occurred. Please Reload the Application.'} />
112116
{!multipleLocations
113117
? <>
114118
<button
115119
className={locationOptions[0]?.Disabled ? "btn btn-primary disabled" : "btn btn-primary"}
116-
onClick={() => locationOptions[0]?.Disabled ? null : handleShowDrawingsModal(props.Locations[0])}
120+
onClick={() => locationOptions[0]?.Disabled ? null : handleClickDrawingsModal(props.Locations[0])}
117121
onMouseEnter={() => setHover('drawings')}
118122
onMouseLeave={() => setHover('none')}
119123
>Open {props.Locations[0]?.Name} Drawings
@@ -129,7 +133,7 @@ const LocationDrawingsButton: React.FC<LocationDrawingsButtonProps> = (props) =>
129133
</>
130134
: <BtnDropdown
131135
Label={'Open ' + props.Locations[0]?.Name + ' Drawings'}
132-
Callback={() => handleShowDrawingsModal(props.Locations[0])}
136+
Callback={() => handleClickDrawingsModal(props.Locations[0])}
133137
TooltipContent={
134138
<p>{CrossMark} {locationOptions[0]?.Disabled}</p>
135139
}
@@ -155,7 +159,7 @@ const LocationDrawingsButton: React.FC<LocationDrawingsButtonProps> = (props) =>
155159
</div>
156160
</div>
157161
</Modal>
158-
</div>
162+
</>
159163
);
160164
};
161165

0 commit comments

Comments
 (0)