mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Added confirmation dialog for user activation.
The IPA.user_status_widget has been modified such that it checks the facet dirty status and asks the admin to either Update or Reset the changes. Then the widget shows a dialog to confirm whether the admin wants to activate/deactivate the user. Ticket #1395
This commit is contained in:
@@ -15592,6 +15592,7 @@
|
||||
"dialogs": {
|
||||
"add_title": "Add ${entity}",
|
||||
"available": "Available",
|
||||
"confirmation": "Confirmation",
|
||||
"dirty_message": "This page has unsaved changes. Please save or revert.",
|
||||
"dirty_title": "Dirty",
|
||||
"hide_already_enrolled": "Hide already enrolled.",
|
||||
@@ -15665,9 +15666,7 @@
|
||||
"view_certificate": "Certificate for ${entity} ${primary_key}"
|
||||
},
|
||||
"config": {
|
||||
"cn": "Name",
|
||||
"group": "Group Options",
|
||||
"ipaserver": "Configuration",
|
||||
"search": "Search Options",
|
||||
"user": "User Options"
|
||||
},
|
||||
@@ -15816,10 +15815,13 @@
|
||||
},
|
||||
"user": {
|
||||
"account": "Account Settings",
|
||||
"activate": "Click to Activate",
|
||||
"account_status": "Account status",
|
||||
"activate": "Activate",
|
||||
"activation_link": "Click to ${action}",
|
||||
"activation_confirmation": "Are you sure you want to ${action} the user?<br/>The change will take effect immediately.",
|
||||
"active": "Active",
|
||||
"contact": "Contact Settings",
|
||||
"deactivate": "Click to Deactivate",
|
||||
"deactivate": "Deactivate",
|
||||
"employee": "Employee Information",
|
||||
"error_changing_status": "Error changing account status",
|
||||
"inactive": "Inactive",
|
||||
|
||||
@@ -62,7 +62,11 @@ IPA.entity_factories.user = function() {
|
||||
{
|
||||
name: 'account',
|
||||
fields: [
|
||||
{ factory: IPA.user_status_widget, name: 'nsaccountlock' },
|
||||
{
|
||||
factory: IPA.user_status_widget,
|
||||
name: 'nsaccountlock',
|
||||
label: IPA.messages.objects.user.account_status
|
||||
},
|
||||
'uid',
|
||||
{ factory: IPA.user_password_widget, name: 'userpassword' },
|
||||
'uidnumber',
|
||||
@@ -138,62 +142,126 @@ IPA.user_status_widget = function(spec) {
|
||||
|
||||
var that = IPA.widget(spec);
|
||||
|
||||
that.create = function(container) {
|
||||
|
||||
that.widget_create(container);
|
||||
|
||||
that.status_span = $('<span/>', {
|
||||
name: 'status'
|
||||
}).appendTo(container);
|
||||
|
||||
container.append(': ');
|
||||
|
||||
that.status_link = $('<a/>', {
|
||||
name: 'link',
|
||||
click: function() {
|
||||
|
||||
var entity = IPA.get_entity(that.entity_name);
|
||||
var facet_name = IPA.current_facet(entity);
|
||||
var facet = entity.get_facet(facet_name);
|
||||
|
||||
if (facet.is_dirty()) {
|
||||
var dialog = IPA.dirty_dialog({
|
||||
facet: facet
|
||||
});
|
||||
|
||||
dialog.callback = function() {
|
||||
that.show_activation_dialog();
|
||||
};
|
||||
|
||||
dialog.init();
|
||||
dialog.open(container);
|
||||
|
||||
} else {
|
||||
that.show_activation_dialog();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}).appendTo(container);
|
||||
};
|
||||
|
||||
that.update = function() {
|
||||
|
||||
if (!that.record) return;
|
||||
|
||||
that.container.empty();
|
||||
|
||||
var lock_field = 'nsaccountlock';
|
||||
|
||||
var locked = that.record[lock_field] &&
|
||||
var locked = that.record[lock_field] &&
|
||||
that.record[lock_field][0].toLowerCase() === 'true';
|
||||
var title = IPA.messages.objects.user.active;
|
||||
var text = title+": "+IPA.messages.objects.user.deactivate;
|
||||
|
||||
var status;
|
||||
var action;
|
||||
|
||||
if (locked) {
|
||||
title = IPA.messages.objects.user.inactive;
|
||||
text = title+": "+IPA.messages.objects.user.activate;
|
||||
status = IPA.messages.objects.user.inactive;
|
||||
action = 'activate';
|
||||
|
||||
} else {
|
||||
status = IPA.messages.objects.user.active;
|
||||
action = 'deactivate';
|
||||
}
|
||||
|
||||
function on_lock_win(data, textStatus, xhr){
|
||||
var entity = IPA.get_entity(that.entity_name);
|
||||
var facet = entity.get_facet('details');
|
||||
facet.refresh();
|
||||
return false;
|
||||
}
|
||||
that.status_span.html(status);
|
||||
that.status_link.attr('href', action);
|
||||
|
||||
function on_lock_fail(data, textStatus, xhr){
|
||||
$("#userstatuslink").text = IPA.messages.objects.user.error_changing_status;
|
||||
return false;
|
||||
}
|
||||
var message = IPA.messages.objects.user.activation_link;
|
||||
var action_label = IPA.messages.objects.user[action];
|
||||
message = message.replace('${action}', action_label);
|
||||
|
||||
var status_field =
|
||||
$('<a/>',
|
||||
{
|
||||
id: 'userstatuslink',
|
||||
title: title,
|
||||
href: "jslink",
|
||||
text: text,
|
||||
click: function() {
|
||||
var jobj = $(this);
|
||||
var val = jobj.attr('title');
|
||||
var pkey = IPA.nav.get_state('user-pkey');
|
||||
var method = 'enable';
|
||||
if (val == IPA.messages.objects.user.active) {
|
||||
method = 'disable';
|
||||
}
|
||||
IPA.command({
|
||||
entity: 'user',
|
||||
method: method,
|
||||
args: [pkey],
|
||||
on_success: on_lock_win,
|
||||
on_error: on_lock_fail
|
||||
}).execute();
|
||||
that.status_link.html(message);
|
||||
};
|
||||
|
||||
return (false);
|
||||
}
|
||||
});
|
||||
status_field.appendTo(that.container);
|
||||
that.show_activation_dialog = function() {
|
||||
|
||||
var action = that.status_link.attr('href');
|
||||
|
||||
var message = IPA.messages.objects.user.activation_confirmation;
|
||||
var action_label = IPA.messages.objects.user[action];
|
||||
message = message.replace('${action}', action_label.toLocaleLowerCase());
|
||||
|
||||
var dialog = IPA.dialog({
|
||||
'title': IPA.messages.dialogs.confirmation
|
||||
});
|
||||
|
||||
dialog.create = function() {
|
||||
dialog.container.append(message);
|
||||
};
|
||||
|
||||
dialog.add_button(action_label, function() {
|
||||
that.set_status(
|
||||
action == 'activate',
|
||||
function(data, textStatus, xhr) {
|
||||
var entity = IPA.get_entity(that.entity_name);
|
||||
var facet_name = IPA.current_facet(entity);
|
||||
var facet = entity.get_facet(facet_name);
|
||||
facet.refresh();
|
||||
dialog.close();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
dialog.add_button(IPA.messages.buttons.cancel, function() {
|
||||
dialog.close();
|
||||
});
|
||||
|
||||
dialog.init();
|
||||
|
||||
dialog.open(that.container);
|
||||
};
|
||||
|
||||
that.set_status = function(enabled, on_success, on_error) {
|
||||
|
||||
var pkey = IPA.nav.get_state('user-pkey');
|
||||
var method = enabled ? 'enable' : 'disable';
|
||||
|
||||
IPA.command({
|
||||
entity: 'user',
|
||||
method: method,
|
||||
args: [pkey],
|
||||
on_success: on_success,
|
||||
on_error: on_error
|
||||
}).execute();
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
@@ -148,8 +148,6 @@ class i18n_messages(Command):
|
||||
"restore_certificate":_("Restore Certificate for ${entity} ${primary_key}"),
|
||||
},
|
||||
"config": {
|
||||
"ipaserver":_("Configuration"),
|
||||
"cn":_("Name"),
|
||||
"user":_("User Options"),
|
||||
"search":_("Search Options"),
|
||||
"group":_("Group Options"),
|
||||
@@ -302,20 +300,23 @@ class i18n_messages(Command):
|
||||
},
|
||||
"user": {
|
||||
"account":_("Account Settings"),
|
||||
"contact":_("Contact Settings"),
|
||||
"mailing":_("Mailing Address"),
|
||||
"employee":_("Employee Information"),
|
||||
"misc":_("Misc. Information"),
|
||||
"account_status":_("Account Status"),
|
||||
"activate":_("Activate"),
|
||||
"activation_link":_("Click to ${action}"),
|
||||
"activation_confirmation":_("Are you sure you want to ${action} the user?<br/>The change will take effect immediately."),
|
||||
"active":_("Active"),
|
||||
"deactivate":_("Click to Deactivate"),
|
||||
"inactive":_("Inactive"),
|
||||
"activate":_("Click to Activate"),
|
||||
"contact":_("Contact Settings"),
|
||||
"deactivate":_("Deactivate"),
|
||||
"employee":_("Employee Information"),
|
||||
"error_changing_status":_("Error changing account status"),
|
||||
"reset_password":_("Reset Password"),
|
||||
"inactive":_("Inactive"),
|
||||
"mailing":_("Mailing Address"),
|
||||
"misc":_("Misc. Information"),
|
||||
"new_password":_("New Password"),
|
||||
"repeat_password":_("Repeat Password"),
|
||||
"password_change_complete":_("Password change complete"),
|
||||
"password_must_match":_("Passwords must match"),
|
||||
"repeat_password":_("Repeat Password"),
|
||||
"reset_password":_("Reset Password"),
|
||||
},
|
||||
},
|
||||
"buttons": {
|
||||
@@ -342,6 +343,7 @@ class i18n_messages(Command):
|
||||
"dialogs": {
|
||||
"add_title":_("Add ${entity}"),
|
||||
"available":_("Available"),
|
||||
"confirmation":_("Confirmation"),
|
||||
"dirty_message":_("This page has unsaved changes. Please save or revert."),
|
||||
"dirty_title":_("Dirty"),
|
||||
"hide_already_enrolled":_("Hide already enrolled."),
|
||||
|
||||
Reference in New Issue
Block a user