forked from geoserver/geoserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GEOS-11488: MapML Double click to copy attributes to feature caption …
…template (geoserver#7813) * GEOS-11488: MapML Double click to copy attributes to feature caption template Co-authored-by: Andrea Aime <[email protected]>
- Loading branch information
1 parent
5744888
commit 8e2f4e8
Showing
6 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.6 KB
doc/en/user/source/extensions/mapml/images/mapml_feature_captions_wfs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/extension/mapml/src/main/resources/org/geoserver/mapml/feature-caption-selector.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function insertTextAtCaret(text) { | ||
var template = $('#featureCaptionTemplate'); | ||
var start = template[0].selectionStart; | ||
var end = template[0].selectionEnd; | ||
|
||
// Get the text before and after the caret position | ||
var beforeText = template.val().substring(0, start); | ||
var afterText = template.val().substring(end); | ||
|
||
// Insert the text at the caret position | ||
template.val(beforeText + text + afterText); | ||
|
||
// Move the caret to the end of the inserted text | ||
var newCaretPosition = start + text.length; | ||
template[0].selectionStart = template[0].selectionEnd = newCaretPosition; | ||
|
||
// Set focus back to the textarea | ||
template.focus(); | ||
} | ||
|
||
$(document).ready(function() { | ||
$(this).on('dblclick', 'option', function() { | ||
var selectedAttribute = $(this).text(); | ||
var formattedAttribute = '${' + selectedAttribute + '}'; | ||
insertTextAtCaret(formattedAttribute); | ||
}); | ||
}); | ||
|