Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#358 - DrawTool - Grouping editing should only update changed templat… #359

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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