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