Skip to content

Commit

Permalink
#358 - DrawTool - Grouping editing should only update changed templat…
Browse files Browse the repository at this point in the history
…e fields (#359)
  • Loading branch information
tariqksoliman authored Apr 13, 2023
1 parent 0b75b14 commit af11505
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/css/mmgisUI.css
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,7 @@ input::-webkit-inner-spin-button {
position: fixed !important;
bottom: 40px !important;
right: 5px !important;
z-index: 1001 !important;
}
.mmgisToast {
z-index: 1000;
Expand Down
5 changes: 2 additions & 3 deletions src/essence/Tools/Draw/DrawTool_Editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ var Editing = {
)
)
}
//console.log( JSON.parse(JSON.stringify(DrawTool.contextMenuLayer.feature)) );

if (
reenableEdit &&
Expand Down Expand Up @@ -2259,7 +2258,6 @@ var Editing = {
{}
DrawTool.contextMenuLayer.snapediting.enable()
} catch (e) {
console.log(e)
DrawTool.contextMenuLayer.enableEdit()
}
} else {
Expand Down Expand Up @@ -2352,7 +2350,8 @@ var Editing = {

const templaterProperties = templater.getValues(
L_.layers.layer[DrawTool.lastContextLayerIndexFileId.layer],
properties
properties,
grouping ? true : false
)
if (templaterProperties === false) return

Expand Down
19 changes: 17 additions & 2 deletions src/essence/Tools/Draw/DrawTool_Templater.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const DrawTool_Templater = {
})

return {
getValues: (layer, existingProperties) => {
getValues: (layer, existingProperties, onlyIfChanged) => {
const values = {}
const invalids = {}

Expand Down Expand Up @@ -424,7 +424,19 @@ const DrawTool_Templater = {
'black'
)
return false
} else return values
} else {
if (onlyIfChanged === true) {
const changedValues = {}
Object.keys(values).forEach((k) => {
if (
!existingProperties.hasOwnProperty(k) ||
values[k] !== existingProperties[k]
)
changedValues[k] = values[k]
})
return changedValues
} else return values
}
},
}
},
Expand Down Expand Up @@ -460,6 +472,7 @@ const DrawTool_Templater = {
const split = (t._default || t.default).split('#')
const start = split[0]
const end = split[1]

for (var i = 0; i < layer.length; i++) {
if (layer[i] == null) continue
let geojson =
Expand All @@ -476,6 +489,7 @@ const DrawTool_Templater = {
}
}
}

if ((response.newValue || '').indexOf('#') !== -1) {
// Actually increment the incrementer for the first time
let bestVal = 0
Expand Down Expand Up @@ -512,6 +526,7 @@ const DrawTool_Templater = {
if (incRegex.test(response.newValue) == false) {
response.error = `Incrementing field: '${t.field}' must follow syntax: '${start}{#}${end}'`
}

return response
},
_templateInDesignIdx: 0,
Expand Down

0 comments on commit af11505

Please sign in to comment.