From 59fe9e35bdcb67b3c818e975113b712a90a54391 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Mon, 28 Jun 2010 22:42:53 +0000 Subject: [PATCH] Property suggest and type suggest widgets in standard recon service panel now use the service's suggest settings, including custom service URLs. git-svn-id: http://google-refine.googlecode.com/svn/trunk@1049 7d457c2a-affb-35e4-300a-418c747d4874 --- .../webapp/modules/core/MOD-INF/controller.js | 3 +- .../dialogs/extend-data-preview-dialog.js | 4 +- main/webapp/modules/core/scripts/project.js | 2 +- .../protograph/schema-alignment-ui-link.js | 4 +- .../scripts/reconciliation/recon-manager.js | 16 ++- .../reconciliation/standard-service-panel.js | 10 +- .../core/scripts/util/custom-suggest.js | 126 ++++-------------- 7 files changed, 48 insertions(+), 117 deletions(-) diff --git a/main/webapp/modules/core/MOD-INF/controller.js b/main/webapp/modules/core/MOD-INF/controller.js index 3fc3b243c..279831673 100644 --- a/main/webapp/modules/core/MOD-INF/controller.js +++ b/main/webapp/modules/core/MOD-INF/controller.js @@ -27,6 +27,8 @@ function init() { "externals/imgareaselect/jquery.imgareaselect.js", "externals/date.js", + "scripts/project.js", + "scripts/util/misc.js", "scripts/util/url.js", "scripts/util/string.js", @@ -43,7 +45,6 @@ function init() { "scripts/widgets/histogram-widget.js", "scripts/widgets/slider-widget.js", - "scripts/project.js", "scripts/project/menu-bar.js", "scripts/project/browsing-engine.js", "scripts/project/scripting.js", diff --git a/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js b/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js index a5a8323fd..71a264ec7 100644 --- a/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js +++ b/main/webapp/modules/core/scripts/dialogs/extend-data-preview-dialog.js @@ -39,7 +39,7 @@ ExtendDataPreviewDialog.getAllProperties = function(typeID, onDone) { var done = false; $.getJSON( - Gridworks.gridworksHelperService + "get_properties_of_type?type=" + typeID + "&callback=?", + Gridworks.gridworksHelperService + "/get_properties_of_type?type=" + typeID + "&callback=?", null, function(data) { if (done) return; @@ -109,7 +109,7 @@ ExtendDataPreviewDialog.prototype._show = function(properties) { type: '/type/property' }; if ("reconConfig" in this._column && "type" in this._column.reconConfig) { - suggestConfig.schema = this._column.reconConfig.type.id; + suggestConfig.ac_param = { schema: this._column.reconConfig.type.id }; } this._elmts.addPropertyInput.suggestP(suggestConfig).bind("fb-select", function(evt, data) { diff --git a/main/webapp/modules/core/scripts/project.js b/main/webapp/modules/core/scripts/project.js index f2f206592..56edb5f74 100644 --- a/main/webapp/modules/core/scripts/project.js +++ b/main/webapp/modules/core/scripts/project.js @@ -2,7 +2,7 @@ var theProject; var ui = {}; var Gridworks = { - gridworksHelperService: "http://1-0.gridworks-helper.dfhuynh.user.dev.freebaseapps.com/" + gridworksHelperService: "http://6.gridworks-helper.dfhuynh.user.dev.freebaseapps.com" }; Gridworks.reportException = function(e) { diff --git a/main/webapp/modules/core/scripts/protograph/schema-alignment-ui-link.js b/main/webapp/modules/core/scripts/protograph/schema-alignment-ui-link.js index c43f943df..b9e08da88 100644 --- a/main/webapp/modules/core/scripts/protograph/schema-alignment-ui-link.js +++ b/main/webapp/modules/core/scripts/protograph/schema-alignment-ui-link.js @@ -141,7 +141,7 @@ SchemaAlignmentDialog.UILink._getPropertiesOfType = function(typeID, targetTypeI } $.getJSON( - Gridworks.gridworksHelperService + "get_properties_of_type?" + $.param(params) + "&callback=?", + Gridworks.gridworksHelperService + "/get_properties_of_type?" + $.param(params) + "&callback=?", null, function(data) { if (done) return; @@ -246,7 +246,7 @@ SchemaAlignmentDialog.UILink.prototype._showPropertySuggestPopup = function(elmt } else { var sourceTypeID = this._parentUINode.getExpectedType(); if (sourceTypeID !== null) { - suggestOptions.schema = sourceTypeID; + suggestOptions.ac_param = { schema: sourceTypeID }; } } input.suggestP(suggestOptions).bind("fb-select", function(e, data) { commitProperty(data); }); diff --git a/main/webapp/modules/core/scripts/reconciliation/recon-manager.js b/main/webapp/modules/core/scripts/reconciliation/recon-manager.js index b69dddf17..98e722601 100644 --- a/main/webapp/modules/core/scripts/reconciliation/recon-manager.js +++ b/main/webapp/modules/core/scripts/reconciliation/recon-manager.js @@ -34,10 +34,12 @@ ReconciliationManager.registerService = function(service) { }; ReconciliationManager.registerStandardService = function(url, f) { - $.ajax({ - async: false, - url: url + (url.contains("?") ? "&" : "?") + "callback=?", - success: function(data) { + var dismissBusy = DialogSystem.showBusy(); + + $.getJSON( + url + (url.contains("?") ? "&" : "?") + "callback=?", + null, + function(data) { data.url = url; data.ui = { "handler" : "ReconStandardServicePanel" }; @@ -49,12 +51,14 @@ ReconciliationManager.registerStandardService = function(url, f) { ReconciliationManager.save(); + dismissBusy(); + if (f) { f(index); } }, - dataType: "jsonp" - }); + "jsonp" + ); }; ReconciliationManager.unregisterService = function(service, f) { diff --git a/main/webapp/modules/core/scripts/reconciliation/standard-service-panel.js b/main/webapp/modules/core/scripts/reconciliation/standard-service-panel.js index e0a9a80ab..74f8e1849 100644 --- a/main/webapp/modules/core/scripts/reconciliation/standard-service-panel.js +++ b/main/webapp/modules/core/scripts/reconciliation/standard-service-panel.js @@ -131,7 +131,7 @@ ReconStandardServicePanel.prototype._populatePanel = function() { .find('input[name="type-choice"][value=""]') .attr("checked", "true"); - this._panel.typeInput.focus(); + this._elmts.typeInput.focus(); } /* @@ -197,16 +197,18 @@ ReconStandardServicePanel.prototype._rewirePropertySuggests = function(type) { .find('input[name="property"]') .unbind(); - if ("property" in this._service && "property" in this._service.suggest) { + if ("suggest" in this._service && "property" in this._service.suggest) { var suggestOptions = $.extend({}, this._service.suggest.property); if (type) { - suggestOptions.schema = typeof type == "string" ? type : type.id; + suggestOptions.ac_param = { schema: typeof type == "string" ? type : type.id }; } inputs.suggestP(suggestOptions); } else if (this._isInFreebaseSchemaSpace()) { inputs.suggestP({ type: '/type/property', - schema: (type) ? (typeof type == "string" ? type : type.id) : "/common/topic" + ac_param: { + schema: (type) ? (typeof type == "string" ? type : type.id) : "/common/topic" + } }); } }; diff --git a/main/webapp/modules/core/scripts/util/custom-suggest.js b/main/webapp/modules/core/scripts/util/custom-suggest.js index a77aea7f0..cd6032d53 100644 --- a/main/webapp/modules/core/scripts/util/custom-suggest.js +++ b/main/webapp/modules/core/scripts/util/custom-suggest.js @@ -1,40 +1,4 @@ (function() { - var oldResponse = $.suggest.suggest.prototype.response; - var typeToIncludedTypes = {}; - var resortByType = function(data, type) { - var schemaPrefixes = [ type + "/" ]; - - var includedTypes = typeToIncludedTypes[type]; - for (var i = 0; i < includedTypes.length; i++) { - schemaPrefixes.push(includedTypes[i] + "/"); - } - - var results = "result" in data ? data.result : []; - var entries1 = []; - var entries2 = []; - - for (var i = 0; i < results.length; i++) { - var result = results[i]; - - var matched = false; - for (var j = 0; j < schemaPrefixes.length; j++) { - var schemaPrefix = schemaPrefixes[j]; - if (result.id.substring(0, schemaPrefix.length) == schemaPrefix) { - matched = true; - break; - } - } - - if (matched) { - entries1.push(result); - } else { - entries2.push(result); - } - } - - data.result = entries1.concat(entries2); - }; - /* * Property suggest */ @@ -45,80 +9,24 @@ {}, $.suggest.suggest.prototype, { - request: function(val, start) { - if (this.ac_xhr) { - this.ac_xhr.abort(); - this.ac_xhr = null; - } - - var self = this; - var o = this.options; - - var data = { - query: val - }; - if (start) { - data.start = start; - } - if ("schema" in o) { - data.schema = o.schema; - } - - $.extend(data, o.ac_param); - - var baseUrl = Gridworks.gridworksHelperService + "suggest_property"; - var url = baseUrl + "?" + $.param(data), - - cached = $.suggest.cache[url]; - if (cached) { - this.response(cached, start ? start : -1, true); - return; - } - - clearTimeout(this.request.timeout); - this.request.timeout = - setTimeout(function() { - self.ac_xhr = $.ajax({ - url: baseUrl, - data: data, - beforeSend: function() { - var calls = self.input.data("request.count.suggest") || 0; - if (!calls) { - self.trackEvent(self.name, "start_session"); - } - calls += 1; - self.trackEvent(self.name, "request", "count", calls); - self.input.data("request.count.suggest", calls); - }, - success: function(data) { - self.response(data, start ? start : -1); - }, - error: function(xhr) { - self.trackEvent(self.name, "request", "error", {url:this.url, response: xhr ? xhr.responseText : ''}); - }, - complete: function(xhr) { - if (xhr) { - self.trackEvent(self.name, "request", "tid", xhr.getResponseHeader("X-Metaweb-TID")); - } - }, - dataType: "jsonp", - cache: true - }); - }, o.xhr_delay); - }, create_item: function(data, response_data) { var css = this.options.css; - + var li = $("
  • ").addClass(css.item); - + var name = $("
    ") .addClass(css.item_name) .append( - $("