Make confirm_dialog a base class for deleter dialog

https://fedorahosted.org/freeipa/ticket/3035
This commit is contained in:
Petr Vobornik
2012-09-13 11:23:35 +02:00
parent 16663cb215
commit c23dd23219
6 changed files with 9 additions and 43 deletions

View File

@@ -632,12 +632,10 @@ IPA.association_table_widget = function (spec) {
selected_values,
function() {
that.refresh();
dialog.close();
IPA.notify_success(IPA.messages.association.removed);
},
function() {
that.refresh();
dialog.close();
}
);
};
@@ -1051,12 +1049,10 @@ IPA.association_facet = function (spec, no_init) {
method: that.remove_method,
on_success: function() {
that.refresh();
dialog.close();
IPA.notify_success(IPA.messages.association.removed);
},
on_error: function() {
that.refresh();
dialog.close();
}
});
@@ -1311,12 +1307,10 @@ IPA.attribute_facet = function(spec, no_init) {
function(data) {
that.load(data);
that.show_content();
dialog.close();
IPA.notify_success(IPA.messages.association.removed);
},
function() {
that.refresh();
dialog.close();
}
);
};

View File

@@ -569,13 +569,17 @@ IPA.adder_dialog = function(spec) {
IPA.deleter_dialog = function (spec) {
spec = spec || {};
spec.title = spec.title || IPA.messages.buttons.remove;
spec.name = spec.name || 'deleter_dialog';
spec.message = spec.message || IPA.messages.search.delete_confirm;
spec.ok_label = spec.ok_label || IPA.messages.buttons.remove;
var that = IPA.dialog(spec);
that.title = spec.title || IPA.messages.buttons.remove;
var that = IPA.confirm_dialog(spec);
that.values = spec.values || [];
that.on_ok = spec.on_ok || function() {
that.execute();
};
that.add_value = function(value) {
that.values.push(value);
@@ -588,7 +592,7 @@ IPA.deleter_dialog = function (spec) {
that.create = function() {
$('<p/>', {
'text': IPA.messages.search.delete_confirm
'text': that.message
}).appendTo(that.container);
var div = $('<div/>', {
@@ -621,30 +625,6 @@ IPA.deleter_dialog = function (spec) {
}
};
that.open = function(container) {
that.create_button({
name: 'remove',
label: IPA.messages.buttons.remove,
click: function() {
that.execute();
}
});
that.create_button({
name: 'cancel',
label: IPA.messages.buttons.cancel,
click: function() {
that.close();
}
});
that.dialog_open(container);
};
that.execute = function() {
};
that.deleter_dialog_create = that.create;
return that;

View File

@@ -1816,13 +1816,11 @@ IPA.dns.record_type_table_widget = function(spec) {
that.idnsname[0],
function(data) {
that.reload_facet(data);
dialog.close();
that.notify_facet_update();
that.facet.nofify_update_success();
},
function() {
that.refresh_facet();
dialog.close();
}
);
};

View File

@@ -311,13 +311,11 @@ IPA.search_deleter_dialog = function(spec) {
batch.on_success = function(data, text_status, xhr) {
that.facet.refresh();
that.facet.on_update.notify([],that.facet);
that.close();
IPA.notify_success(IPA.messages.search.deleted);
};
batch.on_error = function() {
that.facet.refresh();
that.close();
};
batch.execute();

View File

@@ -881,12 +881,10 @@ IPA.sudo.options_section = function(spec) {
that.reload();
}
dialog.close();
IPA.notify_success(IPA.messages.objects.sudorule.option_removed);
},
on_error: function(data) {
that.reload();
dialog.close();
}
});

View File

@@ -1903,12 +1903,10 @@ IPA.attribute_table_widget = function(spec) {
function(data, text_status, xhr) {
var handler = that.on_remove || that.on_command_success;
handler.call(this, data, text_status, xhr);
dialog.close();
},
function(xhr, text_status, error_thrown) {
var handler = that.on_remove_error || that.on_command_error;
handler.call(this, xhr, text_status, error_thrown);
dialog.close();
}
);
command.execute();