mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-25 15:46:30 -06:00
Account activation adjustment
The user details facet has been modified such that when the account is activated/deactivated the page will be reloaded. Some methods in the framework have been changed: - The ipa_widget.clear() has been removed because it can be replaced by existing reset(). - The ipa_widget.set_values() has been renamed into update().
This commit is contained in:
parent
e0a39234f7
commit
cec6703da3
@ -57,7 +57,7 @@ function ipa_add_dialog(spec) {
|
|||||||
var facet = entity.get_facet('search');
|
var facet = entity.get_facet('search');
|
||||||
var table = facet.table;
|
var table = facet.table;
|
||||||
table.refresh();
|
table.refresh();
|
||||||
that.clear();
|
that.reset();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -364,7 +364,7 @@ function ipa_association_table_widget(spec) {
|
|||||||
that.reset();
|
that.reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
that.set_values = function(values) {
|
that.update = function() {
|
||||||
|
|
||||||
that.empty();
|
that.empty();
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ function ipa_details_field(spec) {
|
|||||||
that.load = spec.load || load;
|
that.load = spec.load || load;
|
||||||
that.save = spec.save || save;
|
that.save = spec.save || save;
|
||||||
|
|
||||||
function load(result) {
|
function load(record) {
|
||||||
that.record = result;
|
that.record = record;
|
||||||
that.values = result[that.name];
|
that.values = record[that.name];
|
||||||
that.reset();
|
that.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
that.set_values = function(values) {
|
that.update = function() {
|
||||||
|
|
||||||
if (!that.record) return;
|
if (!that.record) return;
|
||||||
|
|
||||||
@ -335,20 +335,28 @@ function ipa_details_list_section(spec){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is to allow declarative style programming for details
|
|
||||||
function input(spec){
|
|
||||||
that.create_field(spec);
|
|
||||||
return that;
|
|
||||||
}
|
|
||||||
|
|
||||||
that.input = input;
|
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
// shorthand notation used for declarative definitions of details pages
|
// shorthand notation used for declarative definitions of details pages
|
||||||
function ipa_stanza(spec) {
|
function ipa_stanza(spec) {
|
||||||
return ipa_details_list_section(spec);
|
|
||||||
|
spec = spec || {};
|
||||||
|
|
||||||
|
var that = ipa_details_list_section(spec);
|
||||||
|
|
||||||
|
// This is to allow declarative style programming for details
|
||||||
|
that.input = function(spec) {
|
||||||
|
that.create_field(spec);
|
||||||
|
return that;
|
||||||
|
};
|
||||||
|
|
||||||
|
that.custom_input = function(input) {
|
||||||
|
that.add_field(input);
|
||||||
|
return that;
|
||||||
|
};
|
||||||
|
|
||||||
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipa_details_facet(spec) {
|
function ipa_details_facet(spec) {
|
||||||
|
@ -806,25 +806,25 @@ function ipa_hbac_accesstime_widget(spec) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
that.load = function(result) {
|
that.load = function(record) {
|
||||||
|
|
||||||
that.values = result[that.name] || [];
|
that.values = record[that.name] || [];
|
||||||
that.reset();
|
that.reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
that.set_values = function(values) {
|
that.update = function() {
|
||||||
|
|
||||||
that.set_radio_value(that.container, values && values.length ? '' : 'all');
|
that.set_category(that.container, that.values && that.values.length ? '' : 'all');
|
||||||
|
|
||||||
that.table.tbody.empty();
|
that.table.tbody.empty();
|
||||||
for (var i=0; values && i<values.length; i++) {
|
for (var i=0; that.values && i<that.values.length; i++) {
|
||||||
var record = {};
|
var record = {};
|
||||||
record[that.name] = values[i];
|
record[that.name] = that.values[i];
|
||||||
that.table.add_record(record);
|
that.table.add_record(record);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
that.set_radio_value = function(container, value) {
|
that.set_category = function(container, value) {
|
||||||
$('input[name="'+that.name+'"][value="'+value+'"]', that.container).get(0).checked = true;
|
$('input[name="'+that.name+'"][value="'+value+'"]', that.container).get(0).checked = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -903,7 +903,7 @@ function ipa_hbac_accesstime_widget(spec) {
|
|||||||
|
|
||||||
dialog.add_button('Add', function() {
|
dialog.add_button('Add', function() {
|
||||||
add(
|
add(
|
||||||
function() { dialog.clear(); }
|
function() { dialog.reset(); }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ test("Testing ipa_details_section.create().", function() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var section = ipa_details_list_section({name:'IDIDID', label:'NAMENAMENAME'}).
|
var section = ipa_stanza({name:'IDIDID', label:'NAMENAMENAME'}).
|
||||||
input({name:'cn'}).
|
input({name:'cn'}).
|
||||||
input({name:'description'}).
|
input({name:'description'}).
|
||||||
input({name:'number'});
|
input({name:'number'});
|
||||||
@ -270,7 +270,7 @@ test("Testing _ipa_create_text_input() read only .", function(){
|
|||||||
|
|
||||||
test("Testing ipa_details_section_setup again()",function(){
|
test("Testing ipa_details_section_setup again()",function(){
|
||||||
|
|
||||||
var section = ipa_details_list_section({name: 'IDIDID', label: 'NAMENAMENAME'}).
|
var section = ipa_stanza({name: 'IDIDID', label: 'NAMENAMENAME'}).
|
||||||
input({name:'cn', label:'Entity Name'}).
|
input({name:'cn', label:'Entity Name'}).
|
||||||
input({name:'description', label:'Description'}).
|
input({name:'description', label:'Description'}).
|
||||||
input({name:'number', label:'Entity ID'});
|
input({name:'number', label:'Entity ID'});
|
||||||
|
@ -21,23 +21,36 @@
|
|||||||
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
|
/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
|
||||||
|
|
||||||
function ipa_user(){
|
function ipa_user(){
|
||||||
|
|
||||||
var that = ipa_entity({
|
var that = ipa_entity({
|
||||||
name: 'user'
|
name: 'user'
|
||||||
});
|
});
|
||||||
|
|
||||||
that.init = function() {
|
that.init = function() {
|
||||||
|
|
||||||
|
that.create_association({
|
||||||
|
'name': 'group',
|
||||||
|
'associator': 'serial'
|
||||||
|
});
|
||||||
|
|
||||||
|
that.create_association({
|
||||||
|
'name': 'netgroup',
|
||||||
|
'associator': 'serial'
|
||||||
|
});
|
||||||
|
|
||||||
var search_facet = ipa_search_facet({
|
var search_facet = ipa_search_facet({
|
||||||
'name': 'search',
|
'name': 'search',
|
||||||
'label': 'Search',
|
'label': 'Search',
|
||||||
entity_name: that.name
|
entity_name: that.name
|
||||||
});
|
});
|
||||||
|
that.add_facet(search_facet);
|
||||||
|
|
||||||
search_facet.create_column({name:'cn'});
|
search_facet.create_column({name:'cn'});
|
||||||
search_facet.create_column({name:'uid'});
|
search_facet.create_column({name:'uid'});
|
||||||
search_facet.create_column({name:'uidnumber'});
|
search_facet.create_column({name:'uidnumber'});
|
||||||
search_facet.create_column({name:'mail'});
|
search_facet.create_column({name:'mail'});
|
||||||
search_facet.create_column({name:'telephonenumber'});
|
search_facet.create_column({name:'telephonenumber'});
|
||||||
search_facet.create_column({name:'title'});
|
search_facet.create_column({name:'title'});
|
||||||
that.add_facet(search_facet);
|
|
||||||
|
|
||||||
|
|
||||||
that.add_facet(details_facet({name:'details',label:'Details'}));
|
that.add_facet(details_facet({name:'details',label:'Details'}));
|
||||||
|
|
||||||
@ -74,7 +87,7 @@ function ipa_user(){
|
|||||||
input({name:'displayname'}).
|
input({name:'displayname'}).
|
||||||
input({name:'initials'}),
|
input({name:'initials'}),
|
||||||
ipa_stanza({name:'account', label:'Account Details'}).
|
ipa_stanza({name:'account', label:'Account Details'}).
|
||||||
input({name:'nsaccountlock', load:user_status_load}).
|
custom_input(user_status_widget({name:'nsaccountlock'})).
|
||||||
input({name:'uid'}).
|
input({name:'uid'}).
|
||||||
input({name:'userpassword', load: user_password_load}).
|
input({name:'userpassword', load: user_password_load}).
|
||||||
input({name:'uidnumber'}).
|
input({name:'uidnumber'}).
|
||||||
@ -107,70 +120,73 @@ function ipa_user(){
|
|||||||
}
|
}
|
||||||
IPA.add_entity(ipa_user());
|
IPA.add_entity(ipa_user());
|
||||||
|
|
||||||
ipa_entity_set_association_definition('user', {
|
|
||||||
'group': { associator: 'serial' },
|
|
||||||
'netgroup': { associator: 'serial' }
|
|
||||||
});
|
|
||||||
|
|
||||||
/* ATTRIBUTE CALLBACKS */
|
/* ATTRIBUTE CALLBACKS */
|
||||||
|
|
||||||
|
|
||||||
function user_status_load(result) {
|
function user_status_widget(spec) {
|
||||||
|
|
||||||
var that = this;
|
spec = spec || {};
|
||||||
|
|
||||||
$('dd', that.container).remove();
|
var that = ipa_widget(spec);
|
||||||
|
|
||||||
var dd = ipa_create_first_dd(this.name);
|
that.update = function() {
|
||||||
dd.appendTo(that.container);
|
|
||||||
|
|
||||||
var lock_field = 'nsaccountlock';
|
if (!that.record) return;
|
||||||
|
|
||||||
var locked = result[lock_field] &&
|
$('dd', that.container).remove();
|
||||||
result[lock_field][0].toLowerCase() === 'true';
|
|
||||||
var title = "Active";
|
|
||||||
var text = "Active: Click to Deactivate";
|
|
||||||
if (locked) {
|
|
||||||
title = "Inactive";
|
|
||||||
text = "Inactive: Click to Activate";
|
|
||||||
}
|
|
||||||
|
|
||||||
function on_lock_win(data, textStatus, xhr){
|
var dd = ipa_create_first_dd(this.name);
|
||||||
alert(data.result.summary);
|
dd.appendTo(that.container);
|
||||||
$.bbq.pushState('user-facet','search');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function on_lock_fail(data, textStatus, xhr){
|
var lock_field = 'nsaccountlock';
|
||||||
$("#userstatuslink").text = "Error changing account status";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var status_field =
|
var locked = that.record[lock_field] &&
|
||||||
$('<a/>',
|
that.record[lock_field][0].toLowerCase() === 'true';
|
||||||
{
|
var title = "Active";
|
||||||
id: 'userstatuslink',
|
var text = "Active: Click to Deactivate";
|
||||||
title: title,
|
if (locked) {
|
||||||
href: "jslink",
|
title = "Inactive";
|
||||||
text: text,
|
text = "Inactive: Click to Activate";
|
||||||
click: function() {
|
}
|
||||||
var jobj = $(this);
|
|
||||||
var val = jobj.attr('title');
|
function on_lock_win(data, textStatus, xhr){
|
||||||
var pkey = $.bbq.getState('user-pkey');
|
var entity = IPA.get_entity(that.entity_name);
|
||||||
var command = 'user_enable';
|
var facet = entity.get_facet('details');
|
||||||
if (val == 'Active') {
|
facet.refresh();
|
||||||
command = 'user_disable';
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_lock_fail(data, textStatus, xhr){
|
||||||
|
$("#userstatuslink").text = "Error changing account status";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var status_field =
|
||||||
|
$('<a/>',
|
||||||
|
{
|
||||||
|
id: 'userstatuslink',
|
||||||
|
title: title,
|
||||||
|
href: "jslink",
|
||||||
|
text: text,
|
||||||
|
click: function() {
|
||||||
|
var jobj = $(this);
|
||||||
|
var val = jobj.attr('title');
|
||||||
|
var pkey = $.bbq.getState('user-pkey');
|
||||||
|
var command = 'user_enable';
|
||||||
|
if (val == 'Active') {
|
||||||
|
command = 'user_disable';
|
||||||
|
}
|
||||||
|
ipa_cmd(command, [pkey], {}, on_lock_win,on_lock_fail);
|
||||||
|
|
||||||
|
return (false);
|
||||||
}
|
}
|
||||||
ipa_cmd(command, [pkey], {}, on_lock_win,on_lock_fail);
|
});
|
||||||
|
status_field.appendTo(dd);
|
||||||
|
};
|
||||||
|
|
||||||
return (false);
|
return that;
|
||||||
}
|
|
||||||
});
|
|
||||||
status_field.appendTo(dd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function resetpwd_on_click(){
|
function resetpwd_on_click(){
|
||||||
|
|
||||||
function reset_password(new_password){
|
function reset_password(new_password){
|
||||||
|
@ -42,7 +42,7 @@ function ipa_widget(spec) {
|
|||||||
that.setup = spec.setup || setup;
|
that.setup = spec.setup || setup;
|
||||||
that.load = spec.load || load;
|
that.load = spec.load || load;
|
||||||
that.save = spec.save || save;
|
that.save = spec.save || save;
|
||||||
that.clear = spec.clear || clear;
|
that.update = spec.update || update;
|
||||||
|
|
||||||
that.__defineGetter__("entity_name", function(){
|
that.__defineGetter__("entity_name", function(){
|
||||||
return that._entity_name;
|
return that._entity_name;
|
||||||
@ -67,15 +67,22 @@ function ipa_widget(spec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function load(record) {
|
function load(record) {
|
||||||
|
that.record = record;
|
||||||
|
that.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
that.reset = function() {
|
||||||
|
that.hide_undo();
|
||||||
|
that.update();
|
||||||
|
};
|
||||||
|
|
||||||
|
function update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear() {
|
|
||||||
}
|
|
||||||
|
|
||||||
that.is_dirty = function() {
|
that.is_dirty = function() {
|
||||||
|
|
||||||
var values = that.save();
|
var values = that.save();
|
||||||
@ -90,14 +97,6 @@ function ipa_widget(spec) {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.set_values = function(values) {
|
|
||||||
};
|
|
||||||
|
|
||||||
that.reset = function() {
|
|
||||||
that.hide_undo();
|
|
||||||
that.set_values(that.values);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.get_undo = function() {
|
that.get_undo = function() {
|
||||||
return $('span[name="undo"]', that.container);
|
return $('span[name="undo"]', that.container);
|
||||||
};
|
};
|
||||||
@ -189,18 +188,15 @@ function ipa_text_widget(spec) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
that.set_values = function(values) {
|
that.update = function() {
|
||||||
|
var value = that.values && that.values.length ? that.values[0] : '';
|
||||||
if (that.read_only) {
|
if (that.read_only) {
|
||||||
$('label[name="'+that.name+'"]', that.container).val(values[0]);
|
$('label[name="'+that.name+'"]', that.container).val(value);
|
||||||
} else {
|
} else {
|
||||||
$('input[name="'+that.name+'"]', that.container).val(values[0]);
|
$('input[name="'+that.name+'"]', that.container).val(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
that.clear = function() {
|
|
||||||
that.set_values(['']);
|
|
||||||
};
|
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,15 +247,11 @@ function ipa_checkbox_widget(spec) {
|
|||||||
return [value];
|
return [value];
|
||||||
};
|
};
|
||||||
|
|
||||||
that.set_values = function(values) {
|
that.update = function() {
|
||||||
var value = values && values.length ? values[0] : false;
|
var value = that.values && that.values.length ? that.values[0] : false;
|
||||||
$('input[name="'+that.name+'"]', that.container).get(0).checked = value;
|
$('input[name="'+that.name+'"]', that.container).get(0).checked = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
that.clear = function() {
|
|
||||||
$('input[name="'+that.name+'"]', that.container).get(0).checked = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,20 +312,15 @@ function ipa_radio_widget(spec) {
|
|||||||
return [input.val()];
|
return [input.val()];
|
||||||
};
|
};
|
||||||
|
|
||||||
that.set_values = function(values) {
|
that.update = function() {
|
||||||
if (values.length) {
|
if (that.values && that.values.length) {
|
||||||
var input = $('input[name="'+that.name+'"][value="'+values[0]+'"]', that.container);
|
var input = $('input[name="'+that.name+'"][value="'+that.values[0]+'"]', that.container);
|
||||||
if (input.length) {
|
if (input.length) {
|
||||||
input.get(0).checked = true;
|
input.get(0).checked = true;
|
||||||
} else {
|
return;
|
||||||
that.clear();
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
that.clear();
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
that.clear = function() {
|
|
||||||
$('input[name="'+that.name+'"]', that.container).each(function() {
|
$('input[name="'+that.name+'"]', that.container).each(function() {
|
||||||
var input = this;
|
var input = this;
|
||||||
input.checked = false;
|
input.checked = false;
|
||||||
@ -397,12 +384,9 @@ function ipa_textarea_widget(spec) {
|
|||||||
return [value];
|
return [value];
|
||||||
};
|
};
|
||||||
|
|
||||||
that.set_values = function(values) {
|
that.update = function() {
|
||||||
$('textarea[name="'+that.name+'"]', that.container).val(values[0]);
|
var value = that.values && that.values.length ? that.values[0] : '';
|
||||||
};
|
$('textarea[name="'+that.name+'"]', that.container).val(value);
|
||||||
|
|
||||||
that.clear = function() {
|
|
||||||
that.set_values(['']);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
@ -930,10 +914,10 @@ function ipa_dialog(spec) {
|
|||||||
that.container.remove();
|
that.container.remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
that.clear = function() {
|
that.reset = function() {
|
||||||
for (var i=0; i<that.fields.length; i++) {
|
for (var i=0; i<that.fields.length; i++) {
|
||||||
var field = that.fields[i];
|
var field = that.fields[i];
|
||||||
field.clear();
|
field.reset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user