From b6903f0b1615a5d907370362cf4b1d9e38ab00b7 Mon Sep 17 00:00:00 2001 From: Jim Thomason Date: Fri, 27 Jan 2017 13:25:42 -0600 Subject: [PATCH] refactors buildObjectIdentity in various widgets into a single method way up in kbwidget. Needs further testing. --- kbase-extension/static/kbase/js/kbwidget.js | 22 ++++++++ .../function_output/kbaseDomainAnnotation.js | 22 -------- .../kbaseExpressionConditionsetBaseWidget.js | 56 ++++++------------- .../kbaseExpressionEstimateK.js | 22 -------- .../kbaseExpressionFeatureClusters.js | 22 -------- .../kbaseExpressionGenesetBaseWidget.js | 27 +-------- .../function_output/kbaseExpressionMatrix.js | 21 ------- .../function_output/kbaseFeatureSet.js | 22 -------- .../js/widgets/function_output/kbaseMSA.js | 22 -------- .../function_output/kbaseMatrix2DAbstract.js | 22 -------- .../function_output/kbaseReportView.js | 40 ++++--------- .../js/widgets/function_output/kbaseTree.js | 44 ++++----------- 12 files changed, 63 insertions(+), 279 deletions(-) diff --git a/kbase-extension/static/kbase/js/kbwidget.js b/kbase-extension/static/kbase/js/kbwidget.js index 4b9f3e3ff6..76ff250ad3 100644 --- a/kbase-extension/static/kbase/js/kbwidget.js +++ b/kbase-extension/static/kbase/js/kbwidget.js @@ -923,6 +923,28 @@ define ( return 'uuid-' + result; }, + buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) { + var obj = {}; + if (wsRef) { + obj['ref'] = wsRef; + } else { + if (/^\d+$/.exec(workspaceID)) + obj['wsid'] = workspaceID; + else + obj['workspace'] = workspaceID; + + // same for the id + if (/^\d+$/.exec(objectID)) + obj['objid'] = objectID; + else + obj['name'] = objectID; + + if (objectVer) + obj['ver'] = objectVer; + } + return obj; + }, + } ); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseDomainAnnotation.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseDomainAnnotation.js index 2625ad6dde..f7c27a7eeb 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseDomainAnnotation.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseDomainAnnotation.js @@ -461,28 +461,6 @@ define ( }); }, - buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) { - var obj = {}; - if (wsRef) { - obj['ref'] = wsRef; - } else { - if (/^\d+$/.exec(workspaceID)) - obj['wsid'] = workspaceID; - else - obj['workspace'] = workspaceID; - - // same for the id - if (/^\d+$/.exec(objectID)) - obj['objid'] = objectID; - else - obj['name'] = objectID; - - if (objectVer) - obj['ver'] = objectVer; - } - return obj; - }, - clientError: function(error){ this.loading(false); this.showMessage(error.error.error); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionConditionsetBaseWidget.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionConditionsetBaseWidget.js index 7287c801a2..7e4a3e98eb 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionConditionsetBaseWidget.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionConditionsetBaseWidget.js @@ -1,11 +1,11 @@ /** * Base class for viewers visualizaing expression of a set of conditions from various aspects - * + * * The descendant classes should override: * 1. getSubmtrixParams - to set params for get_submatrix_stat method from the KBaseFeatureValues service * 2. buildWidget - to create a custom visuzualization * - * + * * * * Pavel Novichkov @@ -73,7 +73,7 @@ define([ // Create a message pane this.$messagePane = $("
").addClass("kbwidget-message-pane kbwidget-hide-message"); - this.$elem.append(this.$messagePane); + this.$elem.append(this.$messagePane); return this; }, @@ -86,12 +86,12 @@ define([ "service_wizard"); this.genericClient = new GenericClient(serviceWizardURL, auth); } else { - this.featureValueClient = new KBaseFeatureValues(this.options.featureValueURL, auth); + this.featureValueClient = new KBaseFeatureValues(this.options.featureValueURL, auth); } - this.ws = new Workspace(this.options.wsURL, auth); + this.ws = new Workspace(this.options.wsURL, auth); // Let's go... - this.loadAndRender(); + this.loadAndRender(); return this; }, @@ -198,7 +198,7 @@ define([ var $vizContainer = $("
"); this.$elem.append( $vizContainer ); - this.buildWidget( $vizContainer ); + this.buildWidget( $vizContainer ); }, buildOverviewDiv: function($containerDiv){ @@ -229,22 +229,22 @@ define([ { sTitle: "Name", mData: "id"}, // { sTitle: "Function", mData: "function"}, { sTitle: "Min", mData:"min" }, - { sTitle: "Max", mData:"max" }, - { sTitle: "Avg", mData:"avg" }, + { sTitle: "Max", mData:"max" }, + { sTitle: "Avg", mData:"avg" }, { sTitle: "Std", mData:"std"}, { sTitle: "Missing", mData:"missing_values" } ], "oLanguage": { "sEmptyTable": "No conditions found!", "sSearch": "Search: " - } + } } ); $overviewSwitch.click(function(){ $overvewContainer.toggle(); }); }, - + buildConditionsTableData: function(){ var submatrixStat = this.submatrixStat; var tableData = []; @@ -278,12 +278,12 @@ define([ .append($("").append(value)); return $row; }, - + loading: function(isLoading) { if (isLoading) this.showMessage(""); else - this.hideMessage(); + this.hideMessage(); }, showMessage: function(message) { @@ -318,44 +318,22 @@ define([ "and will be fixed shortly." } } - + var $errorDiv = $("
") .addClass("alert alert-danger") .append("Error:") .append("
" + errString); this.$elem.empty(); this.$elem.append($errorDiv); - }, + }, uuid: function() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); return v.toString(16); }); }, - buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) { - var obj = {}; - if (wsRef) { - obj['ref'] = wsRef; - } else { - if (/^\d+$/.exec(workspaceID)) - obj['wsid'] = workspaceID; - else - obj['workspace'] = workspaceID; - - // same for the id - if (/^\d+$/.exec(objectID)) - obj['objid'] = objectID; - else - obj['name'] = objectID; - - if (objectVer) - obj['ver'] = objectVer; - } - return obj; - } - }); -}); \ No newline at end of file +}); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionEstimateK.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionEstimateK.js index 2326e7b57b..60fbe6d7df 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionEstimateK.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionEstimateK.js @@ -240,28 +240,6 @@ define ( }); }, - buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) { - var obj = {}; - if (wsRef) { - obj['ref'] = wsRef; - } else { - if (/^\d+$/.exec(workspaceID)) - obj['wsid'] = workspaceID; - else - obj['workspace'] = workspaceID; - - // same for the id - if (/^\d+$/.exec(objectID)) - obj['objid'] = objectID; - else - obj['name'] = objectID; - - if (objectVer) - obj['ver'] = objectVer; - } - return obj; - }, - clientError: function(error){ this.loading(false); this.showMessage(error.error.error); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionFeatureClusters.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionFeatureClusters.js index 2e37a4f622..6d1ff49681 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionFeatureClusters.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionFeatureClusters.js @@ -504,28 +504,6 @@ define ( this.$messagePane.empty(); }, - buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) { - var obj = {}; - if (wsRef) { - obj['ref'] = wsRef; - } else { - if (/^\d+$/.exec(workspaceID)) - obj['wsid'] = workspaceID; - else - obj['workspace'] = workspaceID; - - // same for the id - if (/^\d+$/.exec(objectID)) - obj['objid'] = objectID; - else - obj['name'] = objectID; - - if (objectVer) - obj['ver'] = objectVer; - } - return obj; - }, - clientError: function(error){ this.loading(false); this.showMessage(error.error.error); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionGenesetBaseWidget.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionGenesetBaseWidget.js index 3fe240c20b..786efaa8d9 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionGenesetBaseWidget.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionGenesetBaseWidget.js @@ -1,11 +1,11 @@ /** * Base class for viewers visualizaing expression of a set of genes from various aspects - * + * * The descendant classes should override: * 1. getSubmtrixParams - to set params for get_submatrix_stat method from the KBaseFeatureValues service * 2. buildWidget - to create a custom visuzualization * - * + * * * * Pavel Novichkov @@ -315,27 +315,6 @@ define([ return v.toString(16); }); }, - buildObjectIdentity: function (workspaceID, objectID, objectVer, wsRef) { - var obj = {}; - if (wsRef) { - obj['ref'] = wsRef; - } else { - if (/^\d+$/.exec(workspaceID)) - obj['wsid'] = workspaceID; - else - obj['workspace'] = workspaceID; - - // same for the id - if (/^\d+$/.exec(objectID)) - obj['objid'] = objectID; - else - obj['name'] = objectID; - - if (objectVer) - obj['ver'] = objectVer; - } - return obj; - } }); -}); \ No newline at end of file +}); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionMatrix.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionMatrix.js index c5c19ebc0b..1b1174e491 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionMatrix.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseExpressionMatrix.js @@ -323,27 +323,6 @@ define ( }); }, - buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) { - var obj = {}; - if (wsRef) { - obj['ref'] = wsRef; - } else { - if (/^\d+$/.exec(workspaceID)) - obj['wsid'] = workspaceID; - else - obj['workspace'] = workspaceID; - - // same for the id - if (/^\d+$/.exec(objectID)) - obj['objid'] = objectID; - else - obj['name'] = objectID; - - if (objectVer) - obj['ver'] = objectVer; - } - return obj; - }, clientError: function(error){ this.loading(false); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseFeatureSet.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseFeatureSet.js index c0e89d3fad..79f587ea5a 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseFeatureSet.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseFeatureSet.js @@ -248,28 +248,6 @@ define ( this.$elem.append($errorDiv); }, - buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) { - var obj = {}; - if (wsRef) { - obj['ref'] = wsRef; - } else { - if (/^\d+$/.exec(workspaceID)) - obj['wsid'] = workspaceID; - else - obj['workspace'] = workspaceID; - - // same for the id - if (/^\d+$/.exec(objectID)) - obj['objid'] = objectID; - else - obj['name'] = objectID; - - if (objectVer) - obj['ver'] = objectVer; - } - return obj; - }, - loading: function(doneLoading) { if (doneLoading) this.hideMessage(); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseMSA.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseMSA.js index 1c8401fad1..b29f551451 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseMSA.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseMSA.js @@ -207,28 +207,6 @@ define ( }; }, - buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) { - var obj = {}; - if (wsRef) { - obj['ref'] = wsRef; - } else { - if (/^\d+$/.exec(workspaceID)) - obj['wsid'] = workspaceID; - else - obj['workspace'] = workspaceID; - - // same for the id - if (/^\d+$/.exec(objectID)) - obj['objid'] = objectID; - else - obj['name'] = objectID; - - if (objectVer) - obj['ver'] = objectVer; - } - return obj; - }, - loading: function(doneLoading) { if (doneLoading) this.hideMessage(); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseMatrix2DAbstract.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseMatrix2DAbstract.js index 52bb6c18fe..f1e9a02227 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseMatrix2DAbstract.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseMatrix2DAbstract.js @@ -489,28 +489,6 @@ define ( }); }, - buildObjectIdentity: function(workspaceID, objectID, objectVer, wsRef) { - var obj = {}; - if (wsRef) { - obj['ref'] = wsRef; - } else { - if (/^\d+$/.exec(workspaceID)) - obj['wsid'] = workspaceID; - else - obj['workspace'] = workspaceID; - - // same for the id - if (/^\d+$/.exec(objectID)) - obj['objid'] = objectID; - else - obj['name'] = objectID; - - if (objectVer) - obj['ver'] = objectVer; - } - return obj; - } - }); }); diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbaseReportView.js b/kbase-extension/static/kbase/js/widgets/function_output/kbaseReportView.js index 4f4df4f5c6..29c5721b69 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbaseReportView.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbaseReportView.js @@ -242,8 +242,8 @@ define([ }; }, - // preserved for a minute. The approach below blocks off the report and presents a - // translucent layer and link on top of the report area. The premise is that the + // preserved for a minute. The approach below blocks off the report and presents a + // translucent layer and link on top of the report area. The premise is that the // content is nearly useless, so don't encourage users to try to use it. // openReportWindow: function (arg) { @@ -473,7 +473,7 @@ define([ // We may receive this if a 'ready' was received // from another cell. Perhaps there is a better // way of filtering messages before getting here! - // TODO: implement an address feature to allow a + // TODO: implement an address feature to allow a // message bus to ignore messages not sent to it. // we use the frame id for this, but it should actually // be a feature of the message bus itself. @@ -712,7 +712,7 @@ define([ // REPORT SECTION /* - The "inline" report can come from either the direct_html property or the direct_html_link_index. + The "inline" report can come from either the direct_html property or the direct_html_link_index. The direct_html_link_index will take precedence since it offers a better method for referencing content within an iframe. Generally the app developer should use either method, not both */ @@ -722,7 +722,7 @@ define([ if (report.direct_html && report.direct_html.length > 0) { hasDirectHtml = true; } - if (typeof report.direct_html_link_index === 'number' && + if (typeof report.direct_html_link_index === 'number' && report.direct_html_link_index >= 0) { hasDirectHtmlIndex = true; } @@ -761,7 +761,7 @@ define([ }; } } else { - // If the direct_html is a full document we cannot (yet?) insert + // If the direct_html is a full document we cannot (yet?) insert // the necessary code to gracefully handle resizing and click-passthrough. if (/