From 65bd82eaa1a0d8e377b58ebc6b5d96ea9364c993 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Thu, 19 Jul 2012 14:47:48 +0200 Subject: IDs and names for dialogs It's hard to detect if or which type dialog is displayed becouse not all dialogs have IDs. On dialog open, it's id or name (if id is not set) is used for containing element id. Many of dialog types were missing id or name so name was added to each dialog type. In HTML, element's id should be unique. Our framework allows opening two dialogs with the same id. It may lead to state where getElementById method may have unpredicted behaviour. Therefore attribute 'data-name' with dialog's name was added to dialog's containing element. Automation framework can search more reliable by using this attribute instead of id. https://fedorahosted.org/freeipa/ticket/2853 --- install/ui/dialog.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'install/ui/dialog.js') diff --git a/install/ui/dialog.js b/install/ui/dialog.js index 2af9ee33..87821841 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -61,7 +61,7 @@ IPA.dialog = function(spec) { var that = {}; that.entity = IPA.get_entity(spec.entity); - that.name = spec.name; + that.name = spec.name || 'dialog'; that.id = spec.id; that.title = spec.title; that.width = spec.width || 500; @@ -107,6 +107,12 @@ IPA.dialog = function(spec) { return valid; }; + that.get_id = function() { + if (that.id) return that.id; + if (that.name) return that.name; + return null; + }; + /** * Create content layout @@ -147,7 +153,11 @@ IPA.dialog = function(spec) { */ that.open = function(container) { - that.container = $('
', { id : that.id }); + that.container = $('
', { + id : that.get_id(), + 'data-name': that.name + }); + if (container) { container.append(that.container); } @@ -286,6 +296,8 @@ IPA.adder_dialog = function(spec) { spec = spec || {}; + spec.name = spec.name || 'adder_dialog'; + var that = IPA.dialog(spec); that.external = spec.external; @@ -557,6 +569,7 @@ IPA.adder_dialog = function(spec) { IPA.deleter_dialog = function (spec) { spec = spec || {}; + spec.name = spec.name || 'deleter_dialog'; var that = IPA.dialog(spec); @@ -639,13 +652,13 @@ IPA.deleter_dialog = function (spec) { IPA.message_dialog = function(spec) { - var that = IPA.dialog(spec); + spec = spec || {}; - var init = function() { - spec = spec || {}; - that.message = spec.message || ''; - that.on_ok = spec.on_ok; - }; + spec.name = spec.name || 'message_dialog'; + + var that = IPA.dialog(spec); + that.message = spec.message || ''; + that.on_ok = spec.on_ok; that.create = function() { $('

', { @@ -664,8 +677,6 @@ IPA.message_dialog = function(spec) { } }); - init(); - that.message_dialog_create = that.create; return that; -- cgit