Save changes before modifying association.

In a details page, usually any changes done to the fields will not be
applied until the user clicks the Update button. However, if the page
contains an association table, any addition/deletion to the table will
be applied immediately.

To avoid any confusion, the user is now required to save or reset all
changes to the page before modifying the association. A dialog box will
appear if the page contains any unsaved changes.
This commit is contained in:
Endi S. Dewata 2011-02-23 12:35:45 -06:00 committed by Adam Young
parent d37bb6f925
commit 697af3e1f8
5 changed files with 49 additions and 10 deletions

View File

@ -351,6 +351,28 @@ IPA.association_table_widget = function (spec) {
that.table_setup(container); that.table_setup(container);
var dialog = $('<div/>', {
html: IPA.messages.dialogs.dirty_message
}).appendTo(container);
var buttons = {};
buttons[IPA.messages.buttons.ok] = function() {
dialog.dialog('close');
};
dialog.dialog({
autoOpen: false,
title: IPA.messages.dialogs.dirty_title,
modal: true,
width: '20em',
buttons: buttons
});
var entity = IPA.get_entity(that.entity_name);
var facet_name = IPA.current_facet(entity);
var facet = entity.get_facet(facet_name);
var button = $('input[name=remove]', container); var button = $('input[name=remove]', container);
button.replaceWith(IPA.action_button({ button.replaceWith(IPA.action_button({
'label': button.val(), 'label': button.val(),
@ -359,7 +381,13 @@ IPA.association_table_widget = function (spec) {
if ($(this).hasClass('action-button-disabled')) { if ($(this).hasClass('action-button-disabled')) {
return false; return false;
} }
that.show_remove_dialog();
if (facet.is_dirty()) {
dialog.dialog('open');
} else {
that.show_remove_dialog();
}
return false; return false;
} }
})); }));
@ -369,8 +397,16 @@ IPA.association_table_widget = function (spec) {
'label': button.val(), 'label': button.val(),
'icon': 'ui-icon-plus', 'icon': 'ui-icon-plus',
'click': function() { 'click': function() {
if ($(this).hasClass('action-button-disabled')) return false; if ($(this).hasClass('action-button-disabled')) {
that.show_add_dialog(); return false;
}
if (facet.is_dirty()) {
dialog.dialog('open');
} else {
that.show_add_dialog();
}
return false; return false;
} }
})); }));

View File

@ -137,7 +137,7 @@ var IPA = ( function () {
var facet = IPA.current_entity.facets_by_name[facet_name]; var facet = IPA.current_entity.facets_by_name[facet_name];
if (facet.is_dirty()){ if (facet.is_dirty()){
var message_box = $("<div/>",{ var message_box = $("<div/>",{
html: IPA.messages.dirty html: IPA.messages.dialogs.dirty_message
}). }).
appendTo($("#navigation")); appendTo($("#navigation"));
@ -148,7 +148,7 @@ var IPA = ( function () {
}; };
message_box.dialog({ message_box.dialog({
title: 'Dirty', title: IPA.messages.dialogs.dirty_title,
modal:true, modal:true,
width: '20em', width: '20em',
buttons: buttons buttons: buttons

View File

@ -42,12 +42,13 @@
}, },
"dialogs": { "dialogs": {
"available": "Available", "available": "Available",
"dirty_message": "This page has unsaved changes. Please save or revert.",
"dirty_title": "Dirty",
"hide_already_enrolled": "Hide already enrolled.", "hide_already_enrolled": "Hide already enrolled.",
"prospective": "Prospective", "prospective": "Prospective",
"remove_empty": "Select ${entity} to be removed.", "remove_empty": "Select ${entity} to be removed.",
"remove_title": "Remove ${entity}." "remove_title": "Remove ${entity}."
}, },
"dirty": "This page has unsaved changes. Please save or revert.",
"facets": { "facets": {
"details": "Settings", "details": "Settings",
"search": "Search" "search": "Search"

View File

@ -9505,12 +9505,13 @@
}, },
"dialogs": { "dialogs": {
"available": "Available", "available": "Available",
"dirty_message": "This page has unsaved changes. Please save or revert.",
"dirty_title": "Dirty",
"hide_already_enrolled": "Hide already enrolled.", "hide_already_enrolled": "Hide already enrolled.",
"prospective": "Prospective", "prospective": "Prospective",
"remove_empty": "Select ${entity} to be removed.", "remove_empty": "Select ${entity} to be removed.",
"remove_title": "Remove ${entity}." "remove_title": "Remove ${entity}."
}, },
"dirty": "This page has unsaved changes. Please save or revert.",
"facets": { "facets": {
"details": "Settings", "details": "Settings",
"search": "Search" "search": "Search"

View File

@ -332,10 +332,12 @@ class i18n_messages(Command):
"view":_("View"), "view":_("View"),
}, },
"dialogs":{ "dialogs":{
"available":_("Available"),
"dirty_message":_("This page has unsaved changes. Please save or revert."),
"dirty_title":_("Dirty"),
"hide_already_enrolled":_("Hide already enrolled."),
"remove_empty":_("Select ${entity} to be removed."), "remove_empty":_("Select ${entity} to be removed."),
"remove_title":_("Remove ${entity}."), "remove_title":_("Remove ${entity}."),
"hide_already_enrolled":_("Hide already enrolled."),
"available":_("Available"),
"prospective":_("Prospective"), "prospective":_("Prospective"),
}, },
"facets":{ "facets":{
@ -377,7 +379,6 @@ class i18n_messages(Command):
"ajax":{ "ajax":{
"401":_("Your kerberos ticket is no longer valid. Please run kinit and then click 'Retry'. If this is your first time running the IPA Web UI <a href='/ipa/config/unauthorized.html'>follow these directions</a> to configure your browser.") "401":_("Your kerberos ticket is no longer valid. Please run kinit and then click 'Retry'. If this is your first time running the IPA Web UI <a href='/ipa/config/unauthorized.html'>follow these directions</a> to configure your browser.")
}, },
"dirty":_("This page has unsaved changes. Please save or revert."),
} }
has_output = ( has_output = (
Output('messages', dict, doc=_('Dict of I18N messages')), Output('messages', dict, doc=_('Dict of I18N messages')),