Skip to content

Commit 124e020

Browse files
committed
#788 Fix Recompute Template should only recompute time and intersected fields
1 parent e12fc8a commit 124e020

6 files changed

Lines changed: 105 additions & 58 deletions

File tree

src/essence/Basics/Layers_/LayerCapturer.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => {
115115
: null,
116116
}
117117

118-
if (layerData.time?.enabled === true && layerData.time?.type === 'requery') {
118+
if (
119+
layerData.time?.enabled === true &&
120+
layerData.time?.type === 'requery'
121+
) {
119122
body.starttime = layerData.time.start
120123
body.startProp = layerData.time.startProp
121124
body.endtime = layerData.time.end
@@ -257,7 +260,10 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => {
257260
zoom: zoom,
258261
}
259262

260-
if (layerData.time?.enabled === true && layerData.time?.type === 'requery') {
263+
if (
264+
layerData.time?.enabled === true &&
265+
layerData.time?.type === 'requery'
266+
) {
261267
body.starttime = layerData.time.start
262268
body.startProp = layerData.time.startProp
263269
body.endtime = layerData.time.end
@@ -400,7 +406,10 @@ export const captureVector = (layerObj, options, cb, dynamicCb) => {
400406
layer: urlSplitRaw[1],
401407
type: 'geojson',
402408
}
403-
if (layerData.time?.enabled === true && layerData.time?.type === 'requery') {
409+
if (
410+
layerData.time?.enabled === true &&
411+
layerData.time?.type === 'requery'
412+
) {
404413
body.starttime = layerData.time.start
405414
body.endtime = layerData.time.end
406415
}

src/essence/Basics/Layers_/Layers_.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,11 @@ const L_ = {
277277
//Takes in config layer obj
278278
//Toggles a layer on and off and accounts for sublayers
279279
//Takes in a config layer object
280-
toggleLayer: async function (s, skipOrderedBringToFront) {
280+
toggleLayer: async function (
281+
s,
282+
skipOrderedBringToFront,
283+
ignoreToggleStateChange
284+
) {
281285
if (s == null) return
282286

283287
const wasNeverOn = L_.layers.layer[s.name] === false
@@ -286,7 +290,13 @@ const L_ = {
286290
if (L_.layers.on[s.name] === true) on = true
287291
else on = false
288292

289-
await L_.toggleLayerHelper(s, on, null, null, skipOrderedBringToFront)
293+
await L_.toggleLayerHelper(
294+
s,
295+
on,
296+
ignoreToggleStateChange,
297+
null,
298+
skipOrderedBringToFront
299+
)
290300

291301
Object.keys(L_._onLayerToggleSubscriptions).forEach((k) => {
292302
L_._onLayerToggleSubscriptions[k](s.name, !on)
@@ -338,9 +348,12 @@ const L_ = {
338348
L_.Map_.map.hasLayer(L_.layers.layer[s.name]) &&
339349
globeOnly != true
340350
) {
341-
try {
342-
$('.drawToolContextMenuHeaderClose').click()
343-
} catch (err) {}
351+
// Only close DrawTool Edit Panel if this is a user-initiated toggle, not a refresh
352+
if (!ignoreToggleStateChange) {
353+
try {
354+
$('.drawToolContextMenuHeaderClose').click()
355+
} catch (err) {}
356+
}
344357
L_.Map_.rmNotNull(L_.layers.layer[s.name])
345358
if (L_.layers.attachments[s.name]) {
346359
for (let sub in L_.layers.attachments[s.name]) {
@@ -3665,7 +3678,8 @@ async function parseConfig(configData, urlOnLayers) {
36653678
L_.mission = L_.configData._dbMissionName || L_.configData.msv.mission
36663679
L_.recentMissions.unshift(L_.mission)
36673680
// Use missionFolderName if available, otherwise fallback to msv.mission
3668-
L_.missionFolderName = L_.configData.msv.missionFolderName || L_.configData.msv.mission
3681+
L_.missionFolderName =
3682+
L_.configData.msv.missionFolderName || L_.configData.msv.mission
36693683
L_.missionPath = 'Missions/' + L_.missionFolderName + '/'
36703684
L_.site = L_.configData.msv.site
36713685

src/essence/Basics/Map_/Map_.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -954,15 +954,15 @@ async function makeVectorLayer(
954954
L_.Map_.map.hasLayer(L_.layers.layer[layerObj.name])
955955
) {
956956
wasOnForRefresh = true
957-
L_.toggleLayer(L_.layers.data[layerObj.name], true)
957+
L_.toggleLayer(L_.layers.data[layerObj.name], true, true)
958958
}
959959

960960
L_.layers.attachments[layerObj.name] = vl.sublayers
961961
L_.layers.layer[layerObj.name] = vl.layer
962962

963963
// For refresh operations, turn the new layer back on if the old one was on
964964
if (isRefresh && wasOnForRefresh) {
965-
L_.toggleLayer(L_.layers.data[layerObj.name], true)
965+
L_.toggleLayer(L_.layers.data[layerObj.name], false, true)
966966
}
967967

968968
d3.selectAll('.' + F_.getSafeName(layerObj.name)).data(
@@ -1185,7 +1185,10 @@ async function makeTileLayer(layerObj) {
11851185
let bandsParamStac = ''
11861186

11871187
// Only add bands if no expression exists (expression takes precedence)
1188-
if (!layerObj.cogExpression || layerObj.cogExpression.trim() === '') {
1188+
if (
1189+
!layerObj.cogExpression ||
1190+
layerObj.cogExpression.trim() === ''
1191+
) {
11891192
b = layerObj.cogBands
11901193
if (b != null) {
11911194
b.forEach((band) => {
@@ -1216,7 +1219,10 @@ async function makeTileLayer(layerObj) {
12161219
bandsParam = ''
12171220

12181221
// Only add bands if no expression exists (expression takes precedence)
1219-
if (!layerObj.cogExpression || layerObj.cogExpression.trim() === '') {
1222+
if (
1223+
!layerObj.cogExpression ||
1224+
layerObj.cogExpression.trim() === ''
1225+
) {
12201226
b = layerObj.cogBands
12211227
if (b != null) {
12221228
b.forEach((band) => {

src/essence/Tools/Draw/DrawTool.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,6 @@
23712371
}
23722372

23732373
.drawToolContextMenuPropertiesTitle {
2374-
height: 30px;
23752374
line-height: 30px;
23762375
color: #91c676;
23772376
}

src/essence/Tools/Draw/DrawTool_Editing.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,8 @@ var Editing = {
913913
geometry: JSON.stringify(
914914
DrawTool.contextMenuLayer?.feature?.geometry
915915
),
916-
}
916+
},
917+
true // recomputeOnly: only update time and intersected fields
917918
)
918919

919920
$('#drawToolContextMenuPropertiesTemplate').empty()

src/essence/Tools/Draw/DrawTool_Templater.js

Lines changed: 61 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,12 @@ const DrawTool_Templater = {
15571557
}
15581558
return true
15591559
},
1560-
getTemplateDefaults: async function (template, layer, toAdd) {
1560+
getTemplateDefaults: async function (
1561+
template,
1562+
layer,
1563+
toAdd,
1564+
recomputeOnly = false
1565+
) {
15611566
return new Promise(async (resolve, reject) => {
15621567
let defaultHasBeenSet = false
15631568
const intersectedGeodatasets = {}
@@ -1745,70 +1750,83 @@ const DrawTool_Templater = {
17451750
) {
17461751
let f = t.field
17471752
let v = t.default
1753+
let overrideRecomputeOnlyHere = false
17481754
switch (t.type) {
17491755
case 'incrementer':
1750-
const nextIncrement =
1751-
DrawTool_Templater._validateIncrement(
1752-
t.default,
1753-
t,
1754-
layer
1755-
)
1756-
v = nextIncrement.newValue
1756+
if (recomputeOnly != true) {
1757+
const nextIncrement =
1758+
DrawTool_Templater._validateIncrement(
1759+
t.default,
1760+
t,
1761+
layer
1762+
)
1763+
v = nextIncrement.newValue
1764+
}
17571765
break
17581766
case 'date':
1759-
if (v === 'NOW')
1767+
if (v === 'NOW') {
17601768
v = moment
17611769
.utc(new Date().getTime())
17621770
.format(t.format || 'YYYY-MM-DDTHH:mm:ss')
1763-
else if (v === 'STARTTIME')
1771+
overrideRecomputeOnlyHere = true
1772+
} else if (v === 'STARTTIME') {
17641773
v = moment
17651774
.utc(TimeControl.getStartTime())
17661775
.format(t.format || 'YYYY-MM-DDTHH:mm:ss')
1767-
else if (v === 'ENDTIME')
1776+
overrideRecomputeOnlyHere = true
1777+
} else if (v === 'ENDTIME') {
17681778
v = moment
17691779
.utc(TimeControl.getEndTime())
17701780
.format(t.format || 'YYYY-MM-DDTHH:mm:ss')
1781+
overrideRecomputeOnlyHere = true
1782+
}
17711783
break
17721784
default:
17731785
}
1774-
defaultProps[f] = v
1786+
if (
1787+
recomputeOnly != true ||
1788+
overrideRecomputeOnlyHere === true
1789+
) {
1790+
defaultProps[f] = v
1791+
}
17751792
}
17761793

17771794
// Last check to cast all non-bool checkbox values to bools
1778-
if (
1779-
t.field != null &&
1780-
t.type === 'checkbox' &&
1781-
typeof defaultProps[t.field] !== 'boolean'
1782-
)
1783-
defaultProps[t.field] = Boolean(defaultProps[t.field])
1784-
else if (
1785-
t.field != null &&
1786-
t.type === 'number' &&
1787-
t.min != null &&
1788-
t.max != null &&
1789-
!isNaN(parseFloat(defaultProps[t.field])) &&
1790-
(parseFloat(defaultProps[t.field]) > t.max ||
1791-
parseFloat(defaultProps[t.field]) < t.min)
1792-
)
1793-
defaultProps[t.field] = Math.min(
1794-
Math.max(parseFloat(defaultProps[t.field]), t.min),
1795-
t.max
1795+
if (recomputeOnly != true) {
1796+
if (
1797+
t.field != null &&
1798+
t.type === 'checkbox' &&
1799+
typeof defaultProps[t.field] !== 'boolean'
17961800
)
1797-
else if (
1798-
t.field != null &&
1799-
t.type === 'slider' &&
1800-
t.min != null &&
1801-
t.max != null &&
1802-
!isNaN(parseFloat(defaultProps[t.field])) &&
1803-
(parseFloat(defaultProps[t.field]) > t.max ||
1804-
parseFloat(defaultProps[t.field]) < t.min)
1805-
)
1806-
defaultProps[t.field] = Math.min(
1807-
Math.max(parseFloat(defaultProps[t.field]), t.min),
1808-
t.max
1801+
defaultProps[t.field] = Boolean(defaultProps[t.field])
1802+
else if (
1803+
t.field != null &&
1804+
t.type === 'number' &&
1805+
t.min != null &&
1806+
t.max != null &&
1807+
!isNaN(parseFloat(defaultProps[t.field])) &&
1808+
(parseFloat(defaultProps[t.field]) > t.max ||
1809+
parseFloat(defaultProps[t.field]) < t.min)
1810+
)
1811+
defaultProps[t.field] = Math.min(
1812+
Math.max(parseFloat(defaultProps[t.field]), t.min),
1813+
t.max
1814+
)
1815+
else if (
1816+
t.field != null &&
1817+
t.type === 'slider' &&
1818+
t.min != null &&
1819+
t.max != null &&
1820+
!isNaN(parseFloat(defaultProps[t.field])) &&
1821+
(parseFloat(defaultProps[t.field]) > t.max ||
1822+
parseFloat(defaultProps[t.field]) < t.min)
18091823
)
1824+
defaultProps[t.field] = Math.min(
1825+
Math.max(parseFloat(defaultProps[t.field]), t.min),
1826+
t.max
1827+
)
1828+
}
18101829
}
1811-
18121830
resolve(defaultProps)
18131831
})
18141832
},

0 commit comments

Comments
 (0)