diff --git a/cvat/apps/engine/static/engine/js/annotationUI.js b/cvat/apps/engine/static/engine/js/annotationUI.js index 12e55fe48d3..eefd6ca0ab2 100644 --- a/cvat/apps/engine/static/engine/js/annotationUI.js +++ b/cvat/apps/engine/static/engine/js/annotationUI.js @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -/* exported callAnnotationUI translateSVGPos blurAllElements drawBoxSize */ +/* exported callAnnotationUI translateSVGPos blurAllElements drawBoxSize copyToClipboard */ "use strict"; function callAnnotationUI(jid) { @@ -221,20 +221,18 @@ function buildAnnotationUI(job, shapeData, loadJobEvent) { blurAllElements(); } }); +} - $('#copyLinkButton').on('click', (e) => { - let tempInput = $(""); - $("body").append(tempInput); - tempInput.prop('value', window.cvat.search.toString()).select(); - document.execCommand("copy"); - tempInput.remove(); - e.target.innerText = '\u2714'; - setTimeout(() => { - e.target.innerText = '\u270e'; - }, 1000); - }); + +function copyToClipboard(text) { + let tempInput = $(""); + $("body").append(tempInput); + tempInput.prop('value', text).select(); + document.execCommand("copy"); + tempInput.remove(); } + function setupFrameFilters() { let brightnessRange = $('#playerBrightnessRange'); let contrastRange = $('#playerContrastRange'); diff --git a/cvat/apps/engine/static/engine/js/player.js b/cvat/apps/engine/static/engine/js/player.js index cb0d21f03b1..7cf0821799b 100644 --- a/cvat/apps/engine/static/engine/js/player.js +++ b/cvat/apps/engine/static/engine/js/player.js @@ -647,6 +647,7 @@ class PlayerView { this._frameNumber = $('#frameNumber'); this._playerGridPattern = $('#playerGridPattern'); this._playerGridPath = $('#playerGridPath'); + this._contextMenuUI = $('#playerContextMenu'); $('*').on('mouseup', () => this._controller.frameMouseUp()); this._playerUI.on('wheel', (e) => this._controller.zoom(e)); @@ -763,6 +764,38 @@ class PlayerView { this._multiplePrevButtonUI.find('polygon').append($(document.createElementNS('http://www.w3.org/2000/svg', 'title')) .html(`${shortkeys['backward_frame'].view_value} - ${shortkeys['backward_frame'].description}`)); + + this._contextMenuUI.click((e) => { + $('.custom-menu').hide(100); + switch($(e.target).attr("action")) { + case "job_url": { + window.cvat.search.set('frame', null); + window.cvat.search.set('filter', null); + copyToClipboard(window.cvat.search.toString()); + break; + } + case "frame_url": + window.cvat.search.set('frame', window.cvat.player.frames.current); + window.cvat.search.set('filter', null); + copyToClipboard(window.cvat.search.toString()); + window.cvat.search.set('frame', null); + break; + } + }); + + this._playerContentUI.on('contextmenu.playerContextMenu', (e) => { + $('.custom-menu').hide(100); + this._contextMenuUI.finish().show(100).offset({ + top: e.pageY - 10, + left: e.pageX - 10, + }); + e.preventDefault(); + }); + + this._playerContentUI.on('mousedown.playerContextMenu', () => { + $('.custom-menu').hide(100); + }); + playerModel.subscribe(this); } diff --git a/cvat/apps/engine/static/engine/js/shapeCollection.js b/cvat/apps/engine/static/engine/js/shapeCollection.js index 28091b6b9d2..096298a9614 100644 --- a/cvat/apps/engine/static/engine/js/shapeCollection.js +++ b/cvat/apps/engine/static/engine/js/shapeCollection.js @@ -988,6 +988,10 @@ class ShapeCollectionController { get filterController() { return this._filterController; } + + get activeShape() { + return this._model.activeShape; + } } class ShapeCollectionView { @@ -1117,9 +1121,20 @@ class ShapeCollectionView { $('#shapeContextMenu li').click((e) => { let menu = $('#shapeContextMenu'); - menu.hide(100); + $('.custom-menu').hide(100); switch($(e.target).attr("action")) { + case "object_url": { + let active = this._controller.activeShape; + if (active) { + window.cvat.search.set('frame', window.cvat.player.frames.current); + window.cvat.search.set('filter', `*[id="${active.id}"]`); + copyToClipboard(window.cvat.search.toString()); + window.cvat.search.set('frame', null); + window.cvat.search.set('filter', null); + } + break; + } case "change_color": this._controller.switchActiveColor(); break; @@ -1162,7 +1177,7 @@ class ShapeCollectionView { $('#pointContextMenu li').click((e) => { let menu = $('#pointContextMenu'); let idx = +menu.attr('point_idx'); - menu.hide(100); + $('.custom-menu').hide(100); switch($(e.target).attr("action")) { case "remove_point": diff --git a/cvat/apps/engine/static/engine/js/shapes.js b/cvat/apps/engine/static/engine/js/shapes.js index 4207c5e584f..c78cc729962 100644 --- a/cvat/apps/engine/static/engine/js/shapes.js +++ b/cvat/apps/engine/static/engine/js/shapes.js @@ -1492,8 +1492,7 @@ class ShapeView extends Listener { // Setup context menu this._uis.shape.on('mousedown.contextMenu', (e) => { if (e.which === 1) { - this._shapeContextMenu.hide(100); - this._pointContextMenu.hide(100); + $('.custom-menu').hide(100); } if (e.which === 3) { e.stopPropagation(); @@ -1501,7 +1500,7 @@ class ShapeView extends Listener { }); this._uis.shape.on('contextmenu.contextMenu', (e) => { - this._pointContextMenu.hide(100); + $('.custom-menu').hide(100); let type = this._controller.type.split('_'); if (type[0] === 'interpolation') { this._shapeContextMenu.find('.interpolationItem').removeClass('hidden'); @@ -1553,8 +1552,7 @@ class ShapeView extends Listener { this._flags.editable = false; } - this._pointContextMenu.hide(100); - this._shapeContextMenu.hide(100); + $('.custom-menu').hide(100); } @@ -2829,7 +2827,7 @@ class PolyShapeView extends ShapeView { point = $(point); point.on('contextmenu.contextMenu', (e) => { - this._shapeContextMenu.hide(100); + $('.custom-menu').hide(100); this._pointContextMenu.attr('point_idx', point.index()); this._pointContextMenu.attr('dom_point_id', point.attr('id')); diff --git a/cvat/apps/engine/templates/engine/annotation.html b/cvat/apps/engine/templates/engine/annotation.html index 15938d4d187..67e6b1374fe 100644 --- a/cvat/apps/engine/templates/engine/annotation.html +++ b/cvat/apps/engine/templates/engine/annotation.html @@ -77,7 +77,9 @@ + + + @@ -135,7 +142,6 @@ -
diff --git a/tests/eslintrc.conf.js b/tests/eslintrc.conf.js index 7771a024f66..57614552f9b 100644 --- a/tests/eslintrc.conf.js +++ b/tests/eslintrc.conf.js @@ -44,6 +44,7 @@ module.exports = { 'translateSVGPos': true, 'blurAllElements': true, 'drawBoxSize': true, + 'copyToClipboard': true, // from base.js 'showMessage': true, 'showOverlay': true,