[PATCH] [Wok] Issue #79: All error messages should keep on UI until user dismiss it

From: Samuel Guimarães <sguimaraes943@gmail.com> This commit makes all messages closeable by default, removing the fade animation after 10 seconds. A parameter to allow a custom ID for each alert was also added to wok.message function. Samuel Guimarães (1): Issue #79: All error messages should keep on UI until user dismiss it ui/js/src/wok.message.js | 53 +++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 25 deletions(-) -- 1.8.3.1

From: Samuel Guimarães <sguimaraes943@gmail.com> Signed-off-by: Samuel Guimarães <sguimaraes943@gmail.com> --- ui/js/src/wok.message.js | 53 +++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/ui/js/src/wok.message.js b/ui/js/src/wok.message.js index e4c2ebd..cf682d2 100644 --- a/ui/js/src/wok.message.js +++ b/ui/js/src/wok.message.js @@ -18,34 +18,37 @@ * limitations under the License. */ -wok.message = function(msg, level, node, closeable, onclick) { +wok.message = function(msg, level, node, closeable, onclick, alertId) { "use strict"; + var close = closeable || true; var container = node || $('#alert-fields'); - if ($(container).size() < 1) { - container = $('<div id="alert-fields"/>').appendTo($('#alert-container')); - } - var message = '<div role="alert" class="alert ' + (level || '') + ' alert-dismissible fade in" style="display: none;">'; - if(!node || closeable) { - message += '<button type="button" class="close" data-dismiss="alert" aria-label="Close" onclick="' + (onclick || '') + '"><span aria-hidden="true"><i class="fa fa-times-circle"></i></span></button>'; - } - message += msg; - message += '</div>'; - var $message = $(message); - $(container).show(); - $(container).append($message); - $message.alert(); - $message.fadeIn(100); + if($("#" + alertId).length === 0) { + if ($(container).size() < 1) { + container = $('<div id="alert-fields"/>').appendTo($('#alert-container')); + } + var message = '<div '+( alertId ? 'id="'+alertId+'"' : '')+' role="alert" class="alert ' + (level || '') + ' alert-dismissible fade in" style="display: none;">'; + if(!node || closeable) { + message += '<button type="button" class="close" data-dismiss="alert" aria-label="Close" onclick="' + (onclick || '') + '"><span aria-hidden="true"><i class="fa fa-times-circle"></i></span></button>'; + } + message += msg; + message += '</div>'; + var $message = $(message); + $(container).show(); + $(container).append($message); + $message.alert(); + $message.fadeIn(100); - if(!closeable){ - var timeout = setTimeout(function() { - $message.delay(4000).fadeOut(100, function() { - $message.alert('close'); - $(this).remove(); - if ($(container).children().length < 1) { - $(container).hide(); - } - }); - }, 10000); + if(!close){ + var timeout = setTimeout(function() { + $message.delay(4000).fadeOut(100, function() { + $message.alert('close'); + $(this).remove(); + if ($(container).children().length < 1) { + $(container).hide(); + } + }); + }, 10000); + } } }; -- 1.8.3.1

Hi Samuel, I noticed the following in Kimchi after applying your patch with some of the scenarios I ran: Click on Add a Storage, enter any invalid info and click on Create button: Error shows on parent panel, not main panel although the error does not disappear on its own which is the intent. I think we've encountered this problem before where the error shows on parent panel instead of main panel. Click on Add Template, enter any path in File Path, click on Create button: Error shows on main panel, but no X (and it doesn't disappear either which is the intent) In both cases, prior to your patch the error messages would disappear after a few seconds and with your patch now the messages stay until user closes them so that part seems to work. Thanks -Socorro On 06/22/2016 08:45 AM, sguimaraes943@gmail.com wrote:
From: Samuel Guimarães <sguimaraes943@gmail.com>
This commit makes all messages closeable by default, removing the fade animation after 10 seconds. A parameter to allow a custom ID for each alert was also added to wok.message function.
Samuel Guimarães (1): Issue #79: All error messages should keep on UI until user dismiss it
ui/js/src/wok.message.js | 53 +++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 25 deletions(-)

Hi Socorro, I think this is happening because I've added a new parameter to wok.message but not for wok.message.error or wok.message.warn. I'll take a look and maybe send a v2 for this or send new patches for Kimchi. -----Original Message----- From: kimchi-devel-bounces@ovirt.org [mailto:kimchi-devel-bounces@ovirt.org] On Behalf Of Socorro Stoppler Sent: quarta-feira, 22 de junho de 2016 20:41 To: sguimaraes943@gmail.com; Kimchi Devel <kimchi-devel@ovirt.org> Subject: Re: [Kimchi-devel] [PATCH] [Wok] Issue #79: All error messages should keep on UI until user dismiss it Hi Samuel, I noticed the following in Kimchi after applying your patch with some of the scenarios I ran: Click on Add a Storage, enter any invalid info and click on Create button: Error shows on parent panel, not main panel although the error does not disappear on its own which is the intent. I think we've encountered this problem before where the error shows on parent panel instead of main panel. Click on Add Template, enter any path in File Path, click on Create button: Error shows on main panel, but no X (and it doesn't disappear either which is the intent) In both cases, prior to your patch the error messages would disappear after a few seconds and with your patch now the messages stay until user closes them so that part seems to work. Thanks -Socorro On 06/22/2016 08:45 AM, sguimaraes943@gmail.com wrote:
From: Samuel Guimarães <sguimaraes943@gmail.com>
This commit makes all messages closeable by default, removing the fade animation after 10 seconds. A parameter to allow a custom ID for each alert was also added to wok.message function.
Samuel Guimarães (1): Issue #79: All error messages should keep on UI until user dismiss it
ui/js/src/wok.message.js | 53 +++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 25 deletions(-)
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
participants (3)
-
Samuel Henrique De Oliveira Guimaraes
-
sguimaraes943@gmail.com
-
Socorro Stoppler