Skip to content

Commit 2a4628c

Browse files
collins-selfcollins-self
authored andcommitted
fixed error handling and DBSearch, organized AssetConnection changes
1 parent b029f77 commit 2a4628c

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Asset/AssetConnection.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,17 @@ function AssetConnectionWindow(props: { Name: string, ID: number, TypeID: number
111111
}, [props.ID, trigger])
112112

113113
React.useEffect(() => {
114-
const h = getLocations();
115-
return () => { if (h!= null && h.abort != null) h.abort(); }
116-
}, [assetConnections])
117-
118-
function getLocations() {
119114
setIsLoadingLocations(true);
120-
const h = $.ajax({
115+
const h = $.ajax({
121116
type: "GET",
122117
url: `${homePath}api/OpenXDA/Asset/${props.ID}/Locations`,
123118
contentType: "application/json; charset=utf-8",
124119
dataType: 'json',
125120
cache: true,
126121
async: true
127-
});
128-
h.done(data => { setLocations(data); setIsLoadingLocations(false); });
129-
return h;
130-
}
122+
}).done(data => { setLocations(data); setIsLoadingLocations(false); });
123+
return () => { if (h!= null && h.abort != null) h.abort(); }
124+
}, [assetConnections])
131125

132126
function getAssetConnections(): JQuery.jqXHR<OpenXDA.Types.AssetConnection> {
133127
setStatus('loading');

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { OpenXDA } from '@gpa-gemstone/application-typings';
2626
import { CrossMark } from '@gpa-gemstone/gpa-symbols';
2727
import LocationDrawingsTable from '../Location/LocationDrawingsTable';
2828

29+
const LocationDrawingController = new GenericController(`${homePath}api/LocationDrawing`, "Name", true);
2930
interface LocationDrawingsButtonProps {
3031
Locations: OpenXDA.Types.Location[];
3132
IsLoadingLocations?: boolean;
@@ -53,7 +54,7 @@ const isValid = (location: OpenXDA.Types.Location, drawingData) => {
5354
&& location.Longitude == null
5455
&& location.Name === ""))
5556
e = 'No location(s) have been set.';
56-
else if (drawingData.TotalRecords == 0)
57+
else if (drawingData.length == 0)
5758
e = 'No drawing(s) associated with location.';
5859
return e;
5960
}
@@ -65,7 +66,6 @@ const LocationDrawingsButton: React.FC<LocationDrawingsButtonProps> = (props) =>
6566
const multipleLocations = React.useMemo(() => props.Locations.length > 1, [props.Locations]);
6667
const [showDrawingsModal, setShowDrawingsModal] = React.useState<boolean>(false);
6768
const [locationOptions, setLocationOptions] = React.useState<DropDownOption[]>([]);
68-
const LocationDrawingController = new GenericController(`${homePath}api/LocationDrawing`, "Name", true);
6969

7070
React.useEffect(() => { // Generates the map of errors for each location
7171
setPageState('loading');
@@ -74,7 +74,7 @@ const LocationDrawingsButton: React.FC<LocationDrawingsButtonProps> = (props) =>
7474
const handles = props.Locations.map((location, i) => {
7575
if (location == null)
7676
return null;
77-
const handle = LocationDrawingController.PagedSearch([], 'Name', true, 1, location.ID)
77+
const handle = LocationDrawingController.DBSearch([], 'Name', true, location.ID)
7878
.done((result) => {
7979
const error = isValid(location, result);
8080
const option: DropDownOption = {

0 commit comments

Comments
 (0)