From 9f670e39c03269a73ccd01dc243d55f6bd460410 Mon Sep 17 00:00:00 2001 From: Bill Riehl Date: Thu, 14 Dec 2017 16:02:05 -0800 Subject: [PATCH] Fix pangenome viewer to handle a case where an UPA is passed instead of a name. --- .../static/kbase/js/kbaseNarrative.js | 4 +- .../widgets/function_output/kbasePanGenome.js | 6 +- .../narrative_core/kbaseNarrativeWorkspace.js | 62 ++++++------------- 3 files changed, 24 insertions(+), 48 deletions(-) diff --git a/kbase-extension/static/kbase/js/kbaseNarrative.js b/kbase-extension/static/kbase/js/kbaseNarrative.js index b70662c749..f6f2ceeaf2 100644 --- a/kbase-extension/static/kbase/js/kbaseNarrative.js +++ b/kbase-extension/static/kbase/js/kbaseNarrative.js @@ -837,8 +837,6 @@ define([ nearIdx = 0; if (cell) { nearIdx = Jupyter.notebook.find_cell_index(cell); - $(cell.element).off('dblclick'); - $(cell.element).off('keydown'); } var objInfo = {}; // If a string, expect a ref, and fetch the info. @@ -846,7 +844,7 @@ define([ objInfo = this.sidePanel.$dataWidget.getDataObjectByRef(obj, true); } // If an array, expect it to be an array of the info, and convert it. - else if (obj instanceof Array) { + else if (Array.isArray(obj)) { objInfo = ServiceUtils.objectInfoToObject(obj); } // If not an array or a string, it's our object already. diff --git a/kbase-extension/static/kbase/js/widgets/function_output/kbasePanGenome.js b/kbase-extension/static/kbase/js/widgets/function_output/kbasePanGenome.js index f5e131fb82..dfe4244254 100644 --- a/kbase-extension/static/kbase/js/widgets/function_output/kbasePanGenome.js +++ b/kbase-extension/static/kbase/js/widgets/function_output/kbasePanGenome.js @@ -36,7 +36,11 @@ define([ init: function(options) { this._super(options); - this.objRef = this.options.ws + '/' + this.options.name; + if (this.options.name.indexOf('/') > -1) { + this.objRef = this.options.name; + } else { + this.objRef = this.options.ws + '/' + this.options.name; + } if (!ApiUtil.checkObjectRef(this.objRef)) { this.$elem.append(Display.createError('Bad object.', 'PanGenome Object Unavailable.')); this.isError = true; diff --git a/kbase-extension/static/kbase/js/widgets/narrative_core/kbaseNarrativeWorkspace.js b/kbase-extension/static/kbase/js/widgets/narrative_core/kbaseNarrativeWorkspace.js index 0d30bf1ee2..0fb7870ca4 100644 --- a/kbase-extension/static/kbase/js/widgets/narrative_core/kbaseNarrativeWorkspace.js +++ b/kbase-extension/static/kbase/js/widgets/narrative_core/kbaseNarrativeWorkspace.js @@ -130,10 +130,10 @@ define([ // This property is only set in accordance with the Jupyter.notebook.writable property. // It is set here, at the outset, and also in a listener for the // 'updateReadOnlyMode.Narrative' jquery event, which, as far as I can tell - // is not issued anywhere in the system. The effect of this would be to + // is not issued anywhere in the system. The effect of this would be to // cause a narrative to flip from edit->view or view->edit while a user is - // engaged with the narrative. This seems like a jarring experience, and would - // certainly need some ui mechanism like a dialog to explain what is happening + // engaged with the narrative. This seems like a jarring experience, and would + // certainly need some ui mechanism like a dialog to explain what is happening // to the user. // So, effectively, this is a constant. this.narrativeIsReadOnly = !Jupyter.notebook.writable; @@ -147,21 +147,21 @@ define([ // The "inReadOnlyMode" is the user-configurable setting for this. // TODO: it should be renamed to something else. It is confusing to have - // the permanent "not writable == narrativeIsReadOnly == readonly" setting, - // which reflects the (during this runtime session) permanent state of the + // the permanent "not writable == narrativeIsReadOnly == readonly" setting, + // which reflects the (during this runtime session) permanent state of the // narrative. // this.inReadOnlyMode = false; // isViewMode is really a cheap way of representing edit mode. // If false, the mode is 'edit', if true the mode is 'view'. - // If there were more than two modes, we would need to store this as + // If there were more than two modes, we would need to store this as // another type of value -- string or number. // this.isViewMode = false; // uiMode is one of 'edit', view'. - // A string enum, because although we have two ui states now, - // edit, which basically follows read-write + // A string enum, because although we have two ui states now, + // edit, which basically follows read-write // view, which shadows read-only - // we may have additional modes (as has been discussed) - + // we may have additional modes (as has been discussed) - this.uiMode = this.narrativeIsReadOnly ? 'view' : 'edit'; Jupyter.narrative.uiMode = this.uiMode; @@ -764,11 +764,11 @@ define([ // within these enter... calls above. // In true read-only (non-writable) mode, the view-mode toggle button - // is not available. Interestingly, this function can only be called + // is not available. Interestingly, this function can only be called // from the toggle button itself..., so I've disabled that logic and it // should just be removed... // If this narrative became read-only after the toggle button was rendered, - // then simply disabling the class-switching is not enough, the entire + // then simply disabling the class-switching is not enough, the entire // mechanism should be disabled (and the button hidden as well.) // if (!this.narrativeIsReadOnly) { var icon = $('#kb-view-mode span'); @@ -779,7 +779,7 @@ define([ // Warning, do not look for the code for this ... it will burn your // eyes out to their bare sockets. - // Note also, there is code in this module which supposdly does the same thing + // Note also, there is code in this module which supposdly does the same thing // (see readOnlyMode, readWriteMode), but doesn't seem to work. Jupyter.CellToolbar.rebuild_all(); this.runtime.bus().emit('read-only-changed', { @@ -972,10 +972,10 @@ define([ * This is called during initialization and by the view-mode toggle. * Note that this is for the view-only ui mode, and thus the narrative * itself may be writable (read-write). This crossover of terminology is - * a bit confusing to follow, and thus I've attempted to introduct the - * ui view/edit mode as orthgonal to narrative + * a bit confusing to follow, and thus I've attempted to introduct the + * ui view/edit mode as orthgonal to narrative * permission (read-only/read-write/read-write-share). - * + * * TODO: probably a better design to set the read / view only flags * and thsn simply render everything that is interested in this. * Otherwise, we just have to propogate the state that _will_ be true when @@ -1039,7 +1039,7 @@ define([ /** * Set narrative from read-only mode to read-write mode - * This is only called in the context of an editable Narrative + * This is only called in the context of an editable Narrative * in which the user is togging between view/edit mode in order * to evaluate how the narrative appears on view-only mode. * @@ -1979,9 +1979,8 @@ define([ }, - createViewerCell: function (cellIndex, data, widget) { + createViewerCell: function (cellIndex, data) { var placement = data.placement || 'below'; - var cell; var cellData = { type: 'data', objectInfo: data.info @@ -1991,31 +1990,6 @@ define([ } else { Jupyter.notebook.insert_cell_below('code', cellIndex, cellData); } - // var title = (data.info && data.info.name) ? data.info.name : 'Data Viewer'; - // var type = 'viewer'; - // $(cell.element).trigger('toggleCodeArea.cell'); - - - // var meta = { - // 'kbase': { - // 'attributes': { - // 'status': 'new', - // 'title': title - // }, - // 'type': 'output', - // 'subtype': 'data' - // } - // }; - // cell.metadata = meta; - // cell.execute(); - // $([Jupyter.events]).trigger('inserted.Cell', { - // cell: cell, - // kbase: { - // type: 'data' - // }, - // objectInfo: data.info - // }); - }, /** @@ -2539,4 +2513,4 @@ define([ return color; } }); -}); \ No newline at end of file +});