Commit 0d2036e6 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

html nodes are removed from dom when plugin is removed

parent 42448fea
Pipeline #8993 passed with stage
in 9 minutes and 30 seconds
minerva (12.2.0~beta.2) unstable; urgency=medium
* Bug fix: when plugin is removed the html elements associated with it are
removed as well (#686)
* Bug fix: when creating new user default privileges are set properly (#692)
* Bug fix: import from SBML issue - reaction with product and modifier being
the same element caused exception (#703)
......
......@@ -1140,6 +1140,23 @@ GuiUtils.prototype.hideTab = function (abstractGuiElement, panel) {
}
};
/**
*
* @param {AbstractGuiElement} abstractGuiElement
* @param {Panel|HTMLElement} panel
*/
GuiUtils.prototype.removeTab = function (abstractGuiElement, panel) {
var panelId = getPanelId(panel);
var liElement = $("li:has(a[href='#" + panelId + "'])", $(abstractGuiElement.getElement()))[0];
var contentElement = $("#" + panelId, $(abstractGuiElement.getElement()))[0];
if (liElement !== undefined && contentElement !==undefined) {
liElement.parentElement.removeChild(liElement);
contentElement.parentElement.removeChild(contentElement);
} else {
logger.warn("Cannot find tab for panel: " + panel);
}
};
/**
*
* @param {AbstractGuiElement} abstractGuiElement
......
......@@ -97,10 +97,7 @@ PluginManager.prototype.addPlugin = function (options) {
serverConnector: self.getServerConnector()
});
plugin.addListener("onUnload", function () {
self.getGuiUtils().hideTab(self, element);
if ($("li", self.getElement()).children(':visible').length === 0) {
$(self.getElement()).hide();
}
self.getGuiUtils().removeTab(self, element);
});
if (!self.isValidUrl(options.url)) {
return Promise.reject(new InvalidArgumentError("url: '" + options.url + "' is invalid"));
......@@ -189,6 +186,7 @@ PluginManager.prototype.removePlugin = function (plugin) {
GuiConnector.removeWindowResizeEvent(self._pluginOnResizeHandlers[plugin.getPluginId()]);
return plugin.unload().then(function () {
if (self._plugins.length === 0) {
$(self.getElement()).hide();
return self.getMap().getMapCanvas().triggerListeners("resize");
} else {
return self.adjustMinWidth();
......
......@@ -122,6 +122,7 @@ describe('PluginManager', function () {
return manager.removePlugin(plugin);
}).then(function () {
assert.equal(0, manager.getPlugins().length);
assert.equal(-1, testDiv.innerHTML.indexOf("tab-pane"));
});
});
it('removing non existing plugin', function () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment