diff --git a/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/NewMeterWizard/AssetPage.tsx b/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/NewMeterWizard/AssetPage.tsx index 8dfeaf042..f8e4496ae 100644 --- a/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/NewMeterWizard/AssetPage.tsx +++ b/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/NewMeterWizard/AssetPage.tsx @@ -71,15 +71,16 @@ export default function AssetPage(props: IProps) { const aStatus = useAppSelector(SelectAssetStatus); const byAssetStatus = useAppSelector(ByAssetSlice.Status); const detailedAssets = useAppSelector(ByAssetSlice.Data); - + const [newEditAsset, setNewEditAsset] = React.useState(AssetAttributes.getNewAsset('Line')); const [editAssetKey, setEditAssetKey] = React.useState(''); const allAssetKeys = React.useMemo(() => detailedAssets.filter(a => a.ID !== newEditAsset.ID).map(a => a.AssetKey).concat(props.Assets.filter((a) => a.AssetKey !== editAssetKey).map(a => a.AssetKey)), [detailedAssets, props.Assets, newEditAsset.ID, editAssetKey]) const filterChannels = React.useMemo(() => { - return props.Channels.filter(ch => - !(ch.Asset.length > 0) - ); - }, [props.Channels]); + const chans = props.Channels.filter(ch => { + return (ch.Asset === editAssetKey) || (ch.Asset === ""); + }); + return chans; + }, [props.Channels, editAssetKey]); const [newEdit, setNewEdit] = React.useState<'New' | 'Edit'>('New'); const [showAssetModal, setShowAssetModal] = React.useState(false); @@ -453,12 +454,12 @@ export default function AssetPage(props: IProps) { Size={'xlg'} CallBack={(confirm) => { setShowAssetModal(false); - + if (!confirm) { setNewEditAsset(AssetAttributes.getNewAsset('Line')); return; } - + let record: OpenXDA.Types.Asset = _.clone(newEditAsset); let list = _.clone(props.Assets); let channels: Array = _.clone(props.Channels); @@ -480,7 +481,7 @@ export default function AssetPage(props: IProps) { props.UpdateChannels(channels); props.UpdateAssets(list); - setNewEditAsset(AssetAttributes.getNewAsset('Line')); + setNewEditAsset(AssetAttributes.getNewAsset('Line')); }} DisableConfirm={(AssetAttributes.AssetError(newEditAsset, newEditAsset.AssetType, allAssetKeys).length > 0) } ConfirmShowToolTip={AssetAttributes.AssetError(newEditAsset, newEditAsset.AssetType, allAssetKeys).length > 0} @@ -521,7 +522,7 @@ export default function AssetPage(props: IProps) {
{ setNewEditAsset((prev) => ({ ...prev, Channels: c })); @@ -538,7 +539,7 @@ export default function AssetPage(props: IProps) {
ch.ConnectionPriority == 0)} UpdateChannels={(c) => { let asset = _.clone(newEditAsset as OpenXDA.Types.Asset); @@ -556,7 +557,7 @@ export default function AssetPage(props: IProps) {
ch.ConnectionPriority == 1)} UpdateChannels={(c) => { let asset = _.clone(newEditAsset as OpenXDA.Types.Asset); @@ -569,7 +570,7 @@ export default function AssetPage(props: IProps) { channels = channels.map(ch => ({ ...ch, ConnectionPriority: c.find(d => d.ID == ch.ID) == null ? ch.ConnectionPriority : 1 })); props.UpdateChannels(channels); }} - /> + />
: null} {newEditAsset.AssetType === 'Transformer' ? (
@@ -577,7 +578,7 @@ export default function AssetPage(props: IProps) {
ch.ConnectionPriority == 0)} UpdateChannels={(c) => { let asset = _.clone(newEditAsset as OpenXDA.Types.Asset); @@ -595,7 +596,7 @@ export default function AssetPage(props: IProps) {
ch.ConnectionPriority == 1)} UpdateChannels={(c) => { let asset = _.clone(newEditAsset as OpenXDA.Types.Asset); @@ -613,7 +614,7 @@ export default function AssetPage(props: IProps) {
ch.ConnectionPriority == 2)} UpdateChannels={(c) => { let asset = _.clone(newEditAsset as OpenXDA.Types.Asset); @@ -626,7 +627,7 @@ export default function AssetPage(props: IProps) { channels = channels.map(ch => ({ ...ch, ConnectionPriority: c.find(d => d.ID == ch.ID) == null ? ch.ConnectionPriority : 2})); props.UpdateChannels(channels); }} - /> + />