Skip to content
Snippets Groups Projects
Commit 0e1b5458 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '686-plugins-not-properly-removed' into 'devel_12.2.x'

html nodes are removed from dom when plugin is removed

See merge request !669
parents 42448fea 0d2036e6
No related branches found
No related tags found
4 merge requests!678Merge 12.2.0 beta.2 into master,!67712.2.0~beta.2 into master,!676Devel 12.2.0~beta.2 into master,!669html nodes are removed from dom when plugin is removed
Pipeline #8994 passed
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 () {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment