From 4b2d20a1f95edd2982fbb1901287f2bb2194c9db Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Tue, 20 May 2014 12:57:28 +0200 Subject: webui: display only dialogs which belong to current facet Dialog instances no longer directly call IPA.opened_dialog methods. It's handled through events (decoupled from dialog's POV). IPA.open_dialogs with assistance of ApplicationController makes sure that there is only one dialog opened at the same time. It also makes sure to hide all dialogs, which are not global dialogs and did not originate from current facet, when switching facets. https://fedorahosted.org/freeipa/ticket/4348 Reviewed-By: Endi Sukma Dewata --- install/ui/src/freeipa/Application_controller.js | 7 +- install/ui/src/freeipa/dialog.js | 152 ++++++++++++++++++++--- 2 files changed, 144 insertions(+), 15 deletions(-) diff --git a/install/ui/src/freeipa/Application_controller.js b/install/ui/src/freeipa/Application_controller.js index c166e36ee..f38a60dc3 100644 --- a/install/ui/src/freeipa/Application_controller.js +++ b/install/ui/src/freeipa/Application_controller.js @@ -116,6 +116,7 @@ define([ simple_container.hide(); var load_facet = reg.facet.get('load'); this.show_facet(load_facet); + IPA.opened_dialogs.start_handling(this); }, /** @@ -320,9 +321,14 @@ define([ on(facet, 'facet-state-change', lang.hitch(this, this.on_facet_state_changed)); } + if (this.current_facet !== facet) { + IPA.opened_dialogs.hide(); + } + this.hide_facet(); this.current_facet = facet; facet.show(); + IPA.opened_dialogs.focus_top(); }, hide_facet: function() { @@ -455,7 +461,6 @@ define([ } topic.publish('auth-successful'); }); - this.show_facet(login_facet); } } diff --git a/install/ui/src/freeipa/dialog.js b/install/ui/src/freeipa/dialog.js index 082d6699a..7e72c4e60 100644 --- a/install/ui/src/freeipa/dialog.js +++ b/install/ui/src/freeipa/dialog.js @@ -21,7 +21,10 @@ */ define([ + 'dojo/_base/lang', 'dojo/keys', + 'dojo/topic', + 'dojo/Evented', './builder', './ipa', './jquery', @@ -30,11 +33,15 @@ define([ './text', './field', './widget'], - function(keys, builder, IPA, $, phases, reg, text, field_mod, widget_mod) { + function(lang, keys, topic, Evented, builder, IPA, $, phases, reg, text, + field_mod, widget_mod) { + /** * Opened dialogs * + * For proper functionality requires started application(`app_container.app`) + * * @class * @singleton */ @@ -43,23 +50,65 @@ IPA.opened_dialogs = { /** Opened dialogs */ dialogs: [], - /** Get top dialog */ + /** + * Show only one dialog at a time + * @property {Boolean} + */ + show_only_one: true, + + /** + * Dialog topic handlers + * @property {Array} + * @protected + */ + handlers: [], + + /** + * Object which contains `current_facet` + * @property {ApplicationController} + */ + app: null, + + /** + * Get top dialog of target facet or a global one + * @return {IPA.dialog} + */ top_dialog: function() { var top = null; - if (this.dialogs.length) top = this.dialogs[this.dialogs.length - 1]; + for (var i=0,l=this.dialogs.length; i -1) this.dialogs.splice(index, 1); + + this.focus_top(); + }, + + /** + * Hide all dialogs or only the ones belonging to specific facet + * @param {facet.facet|facets.Facet} [facet] Target facet + */ + hide: function(facet) { + for (var i=0,l=this.dialogs.length; i