in source/web-ui/src/views/overview/Overview.tsx [143:177]
handleUpdatedReferenceData(newRefData: IReferenceDataItem) {
if (!this._isMounted) { return; }
switch (newRefData.type) {
case ReferenceDataTypes.LOCATION:
this.addLocation(newRefData as ILocationReferenceDataItem);
break;
case ReferenceDataTypes.LINE:
this.addLine(newRefData as ILineReferenceDataItem);
break;
case ReferenceDataTypes.MACHINE:
this.addMachine(newRefData as IMachineReferenceDataItem);
break;
case ReferenceDataTypes.UI_REFERENCE_MAPPING:
this.addUIReferenceMapping(newRefData as IUIReferenceMappingItem);
break;
}
// Check if there are any machines not assigned to a location
const machines = this.state.machines;
const locations = this.state.locations;
if (machines.some(machine => !machine.locationId)) {
// Check if the list of locations has an item for unassigned machines. If not, create one
if (!locations.some(loc => loc.id === this.UNASSIGNED_MACHINES_LOCATION_ID)) {
locations.unshift({
id: this.UNASSIGNED_MACHINES_LOCATION_ID,
type: ReferenceDataTypes.LOCATION,
name: this.UNASSIGNED_MACHINES_LOCATION_NAME,
// Only select the location for unassigned machines if there is no previous location selected
isSelected: locations.find(loc => loc.isSelected) ? false : true
});
}
}
this.setState({ ...this.state, locations, machines });
}