From b068e18adad0d0086436b840e10085403d16a152 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Tue, 19 Feb 2019 14:37:11 +0000 Subject: [PATCH 1/4] Make suggest items clickable with the middle button. Clicking on an item with the middle button leads the user to the page for this item. This lets users inspect items without selecting them. Closes #1934. --- .../modules/core/externals/suggest/suggest-4_3.js | 14 ++++++++++++++ .../core/scripts/views/data-table/cell-ui.js | 3 +++ .../scripts/views/data-table/menu-reconcile.js | 3 +++ 3 files changed, 20 insertions(+) diff --git a/main/webapp/modules/core/externals/suggest/suggest-4_3.js b/main/webapp/modules/core/externals/suggest/suggest-4_3.js index bb10c3689..a630affc8 100644 --- a/main/webapp/modules/core/externals/suggest/suggest-4_3.js +++ b/main/webapp/modules/core/externals/suggest/suggest-4_3.js @@ -1299,6 +1299,20 @@ name.append($("").text(data.description)); } + // If we know of a view URL for this suggest service, + // clicking with the middle button sends the user to + // the view page. + if('view_url' in this.options && data.id) { + var view_url = this.options.view_url.replace('{{id}}', data.id); + li.on('mousedown', function(e) { + if (e.which == 2) { + var win = window.open(view_url, '_blank'); + win.focus(); + e.preventDefault(); + } + }); + } + //console.log("create_item", li); return li; }, diff --git a/main/webapp/modules/core/scripts/views/data-table/cell-ui.js b/main/webapp/modules/core/scripts/views/data-table/cell-ui.js index be5a9d29f..e399737e5 100644 --- a/main/webapp/modules/core/scripts/views/data-table/cell-ui.js +++ b/main/webapp/modules/core/scripts/views/data-table/cell-ui.js @@ -200,6 +200,9 @@ DataTableCellUI.prototype._render = function() { var addSuggest = false; if ((service) && (service.suggest) && (service.suggest.entity)) { suggestOptions = service.suggest.entity; + if ('view' in service && 'url' in service.view && !('view_url' in suggestOptions)) { + suggestOptions.view_url = service.view.url; + } addSuggest = true; } diff --git a/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js b/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js index 7845334fd..ffd021c3f 100644 --- a/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js +++ b/main/webapp/modules/core/scripts/views/data-table/menu-reconcile.js @@ -85,6 +85,9 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) { if (service && service.suggest && service.suggest.entity) { suggestOptions = $.extend({}, service.suggest.entity); suggestOptions.query_param_name = "prefix"; + if ('view' in service && 'url' in service.view && !('view_url' in suggestOptions)) { + suggestOptions.formatter_url = service.view.url; + } } var frame = DialogSystem.createDialog(); From 2f298b4093d75845452cd16a9febaf6bc085df5f Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Tue, 19 Feb 2019 14:42:04 +0000 Subject: [PATCH 2/4] Also make suggestions clickable in Wikidata extension --- .../module/scripts/dialogs/schema-alignment-dialog.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js b/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js index f9a1ebc8b..f6060957f 100644 --- a/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js +++ b/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js @@ -802,6 +802,10 @@ SchemaAlignmentDialog._initField = function(inputContainer, mode, initialValue, var suggestConfig = $.extend({}, endpoint); suggestConfig.key = null; suggestConfig.query_param_name = "prefix"; + if ('view' in this._reconService && 'url' in this._reconService.view && !('view_url' in endpoint)) { + suggestOptions.view_url = this._reconService.view.url; + } + input.suggestP(suggestConfig).bind("fb-select", function(evt, data) { inputContainer.data("jsonValue", { @@ -820,6 +824,9 @@ SchemaAlignmentDialog._initField = function(inputContainer, mode, initialValue, var suggestConfig = $.extend({}, endpoint); suggestConfig.key = null; suggestConfig.query_param_name = "prefix"; + if ('view' in this._reconService && 'url' in this._reconService.view && !('view_url' in endpoint)) { + suggestOptions.view_url = this._reconService.view.url; + } input.suggestP(suggestConfig).bind("fb-select", function(evt, data) { inputContainer.data("jsonValue", { From f9ef60e83955b853cc7cfbe264d826b0072bc4cf Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Tue, 19 Feb 2019 14:47:24 +0000 Subject: [PATCH 3/4] Also allow ${id} syntax for consistency with flyout --- main/webapp/modules/core/externals/suggest/suggest-4_3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/webapp/modules/core/externals/suggest/suggest-4_3.js b/main/webapp/modules/core/externals/suggest/suggest-4_3.js index a630affc8..605ad1ea6 100644 --- a/main/webapp/modules/core/externals/suggest/suggest-4_3.js +++ b/main/webapp/modules/core/externals/suggest/suggest-4_3.js @@ -1303,7 +1303,7 @@ // clicking with the middle button sends the user to // the view page. if('view_url' in this.options && data.id) { - var view_url = this.options.view_url.replace('{{id}}', data.id); + var view_url = this.options.view_url.replace('{{id}}', data.id).replace('${id}', data.id); li.on('mousedown', function(e) { if (e.which == 2) { var win = window.open(view_url, '_blank'); From ac07457306f772253ed7809229480be755aad5b4 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Mon, 25 Feb 2019 10:15:29 +0000 Subject: [PATCH 4/4] Fix suggest middle click in Wikidata schema --- .../module/scripts/dialogs/schema-alignment-dialog.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js b/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js index f6060957f..e5e730d67 100644 --- a/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js +++ b/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js @@ -803,11 +803,11 @@ SchemaAlignmentDialog._initField = function(inputContainer, mode, initialValue, suggestConfig.key = null; suggestConfig.query_param_name = "prefix"; if ('view' in this._reconService && 'url' in this._reconService.view && !('view_url' in endpoint)) { - suggestOptions.view_url = this._reconService.view.url; + suggestConfig.view_url = this._reconService.view.url; } - input.suggestP(suggestConfig).bind("fb-select", function(evt, data) { + input.suggest(suggestConfig).bind("fb-select", function(evt, data) { inputContainer.data("jsonValue", { type : "wbitemconstant", qid : data.id, @@ -824,9 +824,6 @@ SchemaAlignmentDialog._initField = function(inputContainer, mode, initialValue, var suggestConfig = $.extend({}, endpoint); suggestConfig.key = null; suggestConfig.query_param_name = "prefix"; - if ('view' in this._reconService && 'url' in this._reconService.view && !('view_url' in endpoint)) { - suggestOptions.view_url = this._reconService.view.url; - } input.suggestP(suggestConfig).bind("fb-select", function(evt, data) { inputContainer.data("jsonValue", {