Skip to content

Commit c63eca4

Browse files
committed
Firefly-416: useFieldGroupConnector was not unmounting fields properly
- also enable wcs button to be turned off - added line to demonstrate removing wcs lock in gator - IRSA-3070 should use this example
1 parent 16fb3c9 commit c63eca4

File tree

6 files changed

+30
-12
lines changed

6 files changed

+30
-12
lines changed

src/firefly/html/test/template.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
},
6262
tables : {
6363
showInfoButton: false // info about table : title, table links, etc.
64-
}
64+
},
65+
MenuItemKeys: {matchLockDropDown:false}
6566
}
6667
}
6768
}

src/firefly/js/ui/FieldGroupConnector.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ export const useFieldGroupConnector= (props) => {
191191
if (fieldState !== gState.fields[fieldKey]) setFieldState(gState.fields[fieldKey]);
192192
});
193193
}, effectChangeAry);
194-
194+
195+
useEffect(() => { // only run on dismount
196+
return () => dispatchMountComponent( groupKey, fieldKey, false);
197+
}, []);
198+
195199
return {
196200
fireValueChange, viewProps: buildViewProps(fieldState,props,fieldKey,groupKey, value), fieldKey, groupKey
197201
};

src/firefly/js/visualize/MenuItemKeys.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export const MenuItemKeys= {
3232
restore : 'restore',
3333
overlayColorLock: 'overlayColorLock',
3434
fitsHeader: 'fitsHeader',
35-
panByTableRow: 'panByTableRow'
35+
panByTableRow: 'panByTableRow',
36+
matchLockDropDown: 'matchLockDropDown'
3637
};
3738

3839
const defaultOff = [MenuItemKeys.lockImage, MenuItemKeys.irsaCatalog, MenuItemKeys.maskOverlay];

src/firefly/js/visualize/ui/CatalogSelectViewPanel.jsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export class CatalogSelectViewPanel extends PureComponent {
8383
width='auto' height='auto'
8484
groupKey={[gkey, gkeySpacial]}
8585
onSubmit={(request) => onSearchSubmit(request)}
86+
onError={(request) => onSearchFail(request)}
87+
params={{hideOnInvalid: false}}
8688
onCancel={hideSearchPanel}>
8789
<CatalogSelectView fields={fields}/>
8890
</FormPanel>
@@ -104,17 +106,25 @@ export function validateConstraints(groupKey) {
104106
return true;
105107
}
106108

109+
function onSearchFail() {
110+
showInfoPopup('One or more fields are not valid');
111+
}
112+
107113
function onSearchSubmit(request) {
108-
// console.log('original request <br />' + JSON.stringify(request));
109114

115+
if (!catmaster) {
116+
showInfoPopup('Error: Master table was not loaded.');
117+
return false;
118+
}
110119
if (request[gkey].Tabs === 'catalog') {
111-
const {spatial} = request[gkeySpacial];
112-
const wp = parseWorldPt(request[gkeySpacial][ServerParams.USER_TARGET_WORLD_PT]);
120+
const spacPart= request[gkeySpacial] || {};
121+
const {spatial} = spacPart;
122+
const wp = parseWorldPt(spacPart[ServerParams.USER_TARGET_WORLD_PT]);
113123
if (!wp && (spatial === SpatialMethod.Cone.value
114124
|| spatial === SpatialMethod.Box.value
115125
|| spatial === SpatialMethod.Elliptical.value)) {
116126
showInfoPopup('Target is required');
117-
return;
127+
return false;
118128
}
119129
if (validateConstraints(gkey)) {
120130
doCatalog(request);
@@ -130,8 +140,10 @@ function onSearchSubmit(request) {
130140
doVoSearch(request[gkey], 'NED');
131141
}
132142
else {
133-
console.log('request no supported');
143+
showInfoPopup('Request not supported');
144+
return false;
134145
}
146+
return true;
135147
}
136148
function hideSearchPanel() {
137149
dispatchHideDropDown();
@@ -140,7 +152,7 @@ function hideSearchPanel() {
140152
function doCatalog(request) {
141153

142154
const catPart= request[gkey];
143-
const spacPart= request[gkeySpacial];
155+
const spacPart= request[gkeySpacial] || {};
144156
const {catalog, project, cattable}= catPart;
145157
const {spatial='AllSky'}= spacPart; // if there is no 'spatial' field (catalog with no position information case)
146158

src/firefly/js/visualize/ui/MatchLockDropDown.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const getCountWithTarget= (vr) =>
3434

3535

3636

37-
export function MatchLockDropDown({visRoot:vr, enabled}) {
37+
export function MatchLockDropDown({visRoot:vr, enabled, visible}) {
3838
const {wcsMatchType}= vr;
3939
const wcsCnt= getCountWithWCS(vr);
4040
const tCnt= getCountWithTarget(vr);
@@ -124,7 +124,7 @@ export function MatchLockDropDown({visRoot:vr, enabled}) {
124124
<DropDownToolbarButton icon={wcsMatchType?MATCH_LOCKED:MATCH_UNLOCKED }
125125
tip='Determine how to align images'
126126
enabled={enabled} horizontal={true}
127-
visible={true}
127+
visible={visible}
128128
hasHorizontalLayoutSep={false}
129129
useDropDownIndicator={true}
130130
dropDown={dropDown}/>

src/firefly/js/visualize/ui/VisToolbarView.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export class VisToolbarView extends PureComponent {
325325
onClick={() => toggleOverlayColorLock(pv,plotGroupAry)}
326326
/>
327327

328-
<MatchLockDropDown visRoot={visRoot} enabled={enabled} />
328+
<MatchLockDropDown visRoot={visRoot} enabled={enabled} visible={mi.matchLockDropDown} />
329329

330330

331331
<ToolbarButton icon={FITS_HEADER}

0 commit comments

Comments
 (0)