diff --git a/install/ui/aci.js b/install/ui/aci.js index 336a965fc..d507e2d07 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -233,7 +233,7 @@ IPA.attributes_widget = function(spec) { click: function(){ $('.aci-attribute', that.table). attr('checked', $(this).attr('checked')); - that.show_undo(); + that.set_dirty(true); } }) })).append($('', { @@ -245,7 +245,6 @@ IPA.attributes_widget = function(spec) { that.create_undo(container); that.get_undo().click(function(){ that.reset(); - that.hide_undo(); }); } @@ -298,7 +297,7 @@ IPA.attributes_widget = function(spec) { value: value, 'class': 'aci-attribute', click: function() { - that.show_undo(); + that.set_dirty(true); } })); td = $('').appendTo(aci_tr); @@ -335,7 +334,7 @@ IPA.attributes_widget = function(spec) { value: value, 'class': 'aci-attribute', change: function() { - that.show_undo(); + that.set_dirty(true); } })); diff --git a/install/ui/associate.js b/install/ui/associate.js index 3ba510f10..5eb84260e 100644 --- a/install/ui/associate.js +++ b/install/ui/associate.js @@ -348,7 +348,6 @@ IPA.association_table_widget = function (spec) { that.create = function(container) { - var entity = IPA.get_entity(that.entity_name); var column; // create a column if none defined @@ -395,21 +394,6 @@ IPA.association_table_widget = function (spec) { that.table_setup(container); - var dialog = IPA.dialog({ - title: IPA.messages.dialogs.dirty_title, - width: '20em' - }); - - dialog.create = function() { - dialog.container.append(IPA.messages.dialogs.dirty_message); - }; - - dialog.add_button(IPA.messages.buttons.ok, function() { - dialog.close(); - }); - - dialog.init(); - var entity = IPA.get_entity(that.entity_name); var facet_name = IPA.current_facet(entity); var facet = entity.get_facet(facet_name); @@ -424,7 +408,17 @@ IPA.association_table_widget = function (spec) { } if (facet.is_dirty()) { + var dialog = IPA.dirty_dialog({ + facet: facet + }); + + dialog.callback = function() { + that.show_remove_dialog(); + }; + + dialog.init(); dialog.open(that.container); + } else { that.show_remove_dialog(); } @@ -443,7 +437,17 @@ IPA.association_table_widget = function (spec) { } if (facet.is_dirty()) { + var dialog = IPA.dirty_dialog({ + facet: facet + }); + + dialog.callback = function() { + that.show_add_dialog(); + }; + + dialog.init(); dialog.open(that.container); + } else { that.show_add_dialog(); } @@ -809,11 +813,6 @@ IPA.association_facet = function (spec) { that.table.init(); }; - that.is_dirty = function() { - var pkey = $.bbq.getState(that.entity_name+'-pkey'); - return pkey != that.pkey; - }; - that.create_header = function(container) { that.facet_create_header(container); diff --git a/install/ui/details.js b/install/ui/details.js index 4af837e8e..4aa864fed 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -496,14 +496,11 @@ IPA.details_facet = function(spec) { that.is_dirty = function() { - - var i; - for ( i =0; i < that.sections.length; i +=1 ){ - if (that.sections[i].is_dirty()){ + for (var i=0; i'}); }; + +IPA.dirty_dialog = function(spec) { + + spec = spec || {}; + spec.title = spec.title || IPA.messages.dialogs.dirty_title; + spec.width = spec.width || '25em'; + + var that = IPA.dialog(spec); + that.facet = spec.facet; + that.message = spec.message || IPA.messages.dialogs.dirty_message; + + that.create = function() { + that.container.append(that.message); + }; + + that.add_button(IPA.messages.buttons.update, function() { + that.facet.update(function() { + that.close(); + that.callback(); + }); + }); + + that.add_button(IPA.messages.buttons.reset, function() { + that.facet.reset(); + that.close(); + that.callback(); + }); + + that.add_button(IPA.messages.buttons.cancel, function() { + that.close(); + }); + + that.callback = function() { + }; + + return that; +}; \ No newline at end of file diff --git a/install/ui/navigation.js b/install/ui/navigation.js index 379573910..11520ff91 100644 --- a/install/ui/navigation.js +++ b/install/ui/navigation.js @@ -80,9 +80,27 @@ IPA.navigation = function(spec) { }; that.push_state = function(params) { - if (!IPA.test_dirty()) { - return false; + + if (IPA.current_entity) { + var facet_name = IPA.current_facet(IPA.current_entity); + var facet = IPA.current_entity.get_facet(facet_name); + + if (facet.is_dirty()) { + var dialog = IPA.dirty_dialog({ + facet: facet + }); + + dialog.callback = function() { + $.bbq.pushState(params); + }; + + dialog.init(); + dialog.open($('#navigation')); + + return false; + } } + $.bbq.pushState(params); return true; }; diff --git a/install/ui/sudo.js b/install/ui/sudo.js index 7bd6f4500..89b7101bd 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -454,7 +454,6 @@ IPA.sudorule_details_facet = function (spec) { for (var j=0; j= that.values.length) { // show undo/remove link for new value + that.set_dirty(true, index); if (that.undo) { - that.show_undo(index); - that.show_undo(); remove_link.css('display', 'none'); } else { remove_link.css('display', 'inline'); @@ -563,9 +539,8 @@ IPA.multivalued_text_widget = function(spec) { var index = that.row_index(row); // uncross removed value input.removeClass('strikethrough'); + that.set_dirty(true, index); if (that.undo) { - that.show_undo(index); - that.show_undo(); if (index < that.values.length) { remove_link.css('display', 'inline'); } @@ -579,10 +554,7 @@ IPA.multivalued_text_widget = function(spec) { // restore old value then cross it out that.update(index); input.addClass('strikethrough'); - if (that.undo) { - that.show_undo(index); - that.show_undo(); - } + that.set_dirty(true, index); remove_link.css('display', 'none'); } else { // remove new value @@ -623,7 +595,7 @@ IPA.multivalued_text_widget = function(spec) { }; that.reset = function(index) { - that.hide_undo(index); + that.set_dirty(false, index); that.update(index); }; @@ -685,7 +657,7 @@ IPA.checkbox_widget = function (spec) { var input = $('input[name="'+that.name+'"]', that.container); input.change(function() { - that.show_undo(); + that.set_dirty(true); }); var undo = that.get_undo(); @@ -759,7 +731,7 @@ IPA.checkboxes_widget = function (spec) { var input = $('input[name="'+that.name+'"]', that.container); input.change(function() { - that.show_undo(); + that.set_dirty(true); }); var undo = that.get_undo(); @@ -837,7 +809,7 @@ IPA.radio_widget = function(spec) { var input = $('input[name="'+that.name+'"]', that.container); input.change(function() { - that.show_undo(); + that.set_dirty(true); }); var undo = that.get_undo(); @@ -913,7 +885,7 @@ IPA.select_widget = function(spec) { that.select = $('select[name="'+that.name+'"]', that.container); that.select.change(function() { - that.show_undo(); + that.set_dirty(true); }); var undo = that.get_undo(); @@ -994,7 +966,7 @@ IPA.textarea_widget = function (spec) { var input = $('textarea[name="'+that.name+'"]', that.container); input.keyup(function() { - that.show_undo(); + that.set_dirty(true); that.validate(); }); @@ -1439,7 +1411,7 @@ IPA.entity_select_widget = function(spec) { that.entity_select = $('