Skip to content

Commit

Permalink
#127 DrawTool - enable panning around without dropping points while d… (
Browse files Browse the repository at this point in the history
#128)

* #127 DrawTool - enable panning around without dropping points while drawing

* DrawTool - make active layer deselectable

* DrawTool - Fix uploaded file edit panel
  • Loading branch information
tariqksoliman authored Jan 18, 2022
1 parent 4efc848 commit 8f512df
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/essence/Basics/Formulae_/Formulae_.js
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,7 @@ var Formulae_ = {
return uniqueArray
},
sanitize(str) {
if (str == null) return ''
return str.replace(/[<>;{}]/g, '')
},
doBoundingBoxesIntersect(a, b) {
Expand Down
4 changes: 0 additions & 4 deletions src/essence/Tools/Draw/DrawTool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1714,10 +1714,6 @@ var Test = {
name: 'Lead can draw ROIs',
subtests: 2,
test: function (c) {
$(
'#drawToolDrawFilesListMaster .drawToolDrawFilesListElem[file_id="1"] .drawToolFileSelector'
).click()

c(
'Starts on polygon drawing',
$('.drawToolDrawingTypePolygon').hasClass('active')
Expand Down
10 changes: 10 additions & 0 deletions src/essence/Tools/Draw/DrawTool_Drawing.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var Drawing = {
DrawTool.setDrawingType = Drawing.setDrawingType
DrawTool.switchDrawingType = Drawing.switchDrawingType
DrawTool.setDrawing = Drawing.setDrawing

L.Draw.Polyline.prototype._onTouch = L.Util.falseFn
},
drawOver: function (d, clip, callback) {
var file_id =
Expand Down Expand Up @@ -254,6 +256,8 @@ var Drawing = {
case 'arrow':
DrawTool.drawing.arrow.begin(type)
break
default:
break
}
},
switchDrawingType: function (type) {
Expand Down Expand Up @@ -294,6 +298,12 @@ var Drawing = {
DrawTool.switchDrawingType('Polygon')
DrawTool.drawing.polygon.begin('polygon')
break
default:
DrawTool.drawing.polygon.end()
DrawTool.drawing.point.end()
DrawTool.drawing.line.end()
DrawTool.drawing.annotation.end()
break
}

if (DrawTool.intentType != null) {
Expand Down
35 changes: 22 additions & 13 deletions src/essence/Tools/Draw/DrawTool_Files.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,8 @@ var Files = {
$('.drawToolFileSelector').off('click')
$('.drawToolFileSelector').on('click', function () {
//Only select files you own
var fileFromId = DrawTool.getFileObjectWithId(
$(this).attr('file_id')
)
const fileId = $(this).attr('file_id')
var fileFromId = DrawTool.getFileObjectWithId(fileId)
if (
mmgisglobal.user !== $(this).attr('file_owner') &&
fileFromId &&
Expand All @@ -1099,20 +1098,30 @@ var Files = {
return

var checkbox = $(this).parent().find('.drawToolFileCheckbox')
const wasOn = $(this).parent().parent().hasClass('checked')
$('.drawToolFileCheckbox').removeClass('checked')
$('.drawToolDrawFilesListElem').removeClass('checked')
checkbox.addClass('checked')
checkbox.parent().parent().parent().addClass('checked')

var intent = $(this).attr('file_intent')
if (DrawTool.intentType != intent) {
DrawTool.intentType = intent
DrawTool.setDrawing(true)
}
if (!wasOn) {
checkbox.addClass('checked')
checkbox.parent().parent().parent().addClass('checked')

DrawTool.currentFileId = parseInt(checkbox.attr('file_id'))
if (DrawTool.filesOn.indexOf(DrawTool.currentFileId) == -1)
checkbox.click()
var intent = $(this).attr('file_intent')
if (DrawTool.intentType != intent) {
DrawTool.intentType = intent
DrawTool.setDrawing(true)
}

DrawTool.currentFileId = parseInt(checkbox.attr('file_id'))
if (DrawTool.filesOn.indexOf(DrawTool.currentFileId) == -1)
checkbox.click()
} else {
DrawTool.intentType = null
DrawTool.switchDrawingType(null)
DrawTool.setDrawing(false)
DrawTool.currentFileId = null
DrawTool.toggleFile(fileId, 'off')
}
})

//Visible File
Expand Down
14 changes: 7 additions & 7 deletions src/essence/Tools/Draw/DrawTool_SetOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ var SetOperations = {
for (var i = 0; i < DrawTool.contextMenuLayers.length; i++) {
// prettier-ignore
lis.push(
[
"<li shape_id='" + DrawTool.contextMenuLayers[i].properties._.id + "'>",
"<div>" + F_.sanitize(DrawTool.contextMenuLayers[i].properties.name) + "</div>",
"<div class='drawToolContextMenuTabSOMergeCheckbox'></div>",
"</li>"
].join('\n')
)
[
"<li shape_id='" + DrawTool.contextMenuLayers[i].properties._.id + "'>",
"<div>" + F_.sanitize(DrawTool.contextMenuLayers[i].properties.name || 'No Name') + "</div>",
"<div class='drawToolContextMenuTabSOMergeCheckbox'></div>",
"</li>"
].join('\n')
)
}
return lis.join('\n')
},
Expand Down

0 comments on commit 8f512df

Please sign in to comment.