webui: proper alerts in dialogs

Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
This commit is contained in:
Petr Vobornik 2014-05-28 17:51:08 +02:00
parent 0fadb14ec7
commit bedd128de0
3 changed files with 11 additions and 6 deletions

View File

@ -85,7 +85,7 @@ IPA.entity_adder_dialog = function(spec) {
that.add( that.add(
function(data, text_status, xhr) { function(data, text_status, xhr) {
that.added.notify([data], that); that.added.notify([data], that);
that.show_message(that.get_success_message(data)); that.show_message(that.get_success_message(data), 'success');
that.reset(); that.reset();
that.focus_first_element(); that.focus_first_element();
}, },

View File

@ -30,7 +30,7 @@ define([
'./text', './text',
'./field', './field',
'./widget'], './widget'],
function(keys, builder, IPA, $, phases, reg, text) { function(keys, builder, IPA, $, phases, reg, text, field_mod, widget_mod) {
/** /**
* Opened dialogs * Opened dialogs
@ -331,7 +331,7 @@ IPA.dialog = function(spec) {
that.message_container = $('<div/>', { that.message_container = $('<div/>', {
style: 'display: none', style: 'display: none',
'class': 'dialog-message alert' 'class': 'dialog-message col-sm-12'
}).appendTo(that.body_node); }).appendTo(that.body_node);
var widgets = that.widgets.get_widgets(); var widgets = that.widgets.get_widgets();
@ -433,14 +433,19 @@ IPA.dialog = function(spec) {
* Show message in dialog's message container * Show message in dialog's message container
* @param {string} message * @param {string} message
*/ */
that.show_message = function(message) { that.show_message = function(message, type) {
that.message_container.text(message);
var ah = widget_mod.alert_helper;
var alert = ah.create_alert('msg', message, type);
var el = ah.render_alert(alert);
that.message_container.append(el);
that.message_container.css('display', ''); that.message_container.css('display', '');
}; };
/** Hide dialog message */ /** Hide dialog message */
that.hide_message = function() { that.hide_message = function() {
that.message_container.css('display', 'none'); that.message_container.css('display', 'none');
that.message_container.empty();
}; };
/** /**

View File

@ -1884,7 +1884,7 @@ IPA.dns.record_type_table_widget = function(spec) {
dialog.add( dialog.add(
function(data, text_status, xhr) { function(data, text_status, xhr) {
dialog.show_message(dialog.get_add_message()); dialog.show_message(dialog.get_add_message(), 'success');
if (data.result.result.dnsrecords) { if (data.result.result.dnsrecords) {
that.reload_facet(data); that.reload_facet(data);