Merge pull request #1958 from OpenRefine/issue1934

Make suggest items clickable with the middle button.
This commit is contained in:
Antonin Delpeuch 2019-02-25 10:30:31 +00:00 committed by GitHub
commit 70094f68b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View File

@ -802,8 +802,12 @@ 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)) {
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,

View File

@ -1299,6 +1299,20 @@
name.append($("<span></span>").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).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;
},

View File

@ -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;
}

View File

@ -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();