From 348d734c59432a740b52924ac18ff47b30dad54e Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Thu, 3 Feb 2011 21:42:50 -0600 Subject: Restructuring details page. Previously the IPA.details_list_section can only be used with widgets that generates
tag because it uses the following structure:
Telephone Number:
111-1111
222-2222
The
tag was previously used to handle multi-valued attributes. Since multi-valued attributes are now handled by the recently added IPA.multivalued_text_widget, the structure can be changed as follows:
Telephone Number:
111-1111
222-2222
This allows IPA.details_list_section to be used with any widgets without requiring the
tag. --- install/ui/user.js | 141 +++++++++++++++++++++++++---------------------------- 1 file changed, 67 insertions(+), 74 deletions(-) (limited to 'install/ui/user.js') diff --git a/install/ui/user.js b/install/ui/user.js index 663aab92..c30836c5 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -55,9 +55,9 @@ IPA.entity_factories.user = function (){ input({name:'initials'})). section( IPA.stanza({name: 'account', label: IPA.messages.details.account}). - custom_input(user_status_widget({name:'nsaccountlock'})). + custom_input(IPA.user_status_widget({name:'nsaccountlock'})). input({name:'uid'}). - input({name:'userpassword', load: user_password_load}). + custom_input(IPA.user_password_widget({name:'userpassword'})). input({name:'uidnumber'}). input({name:'gidnumber'}). input({name:'loginshell'}). @@ -96,7 +96,7 @@ IPA.entity_factories.user = function (){ /* ATTRIBUTE CALLBACKS */ -function user_status_widget(spec) { +IPA.user_status_widget = function(spec) { spec = spec || {}; @@ -106,10 +106,7 @@ function user_status_widget(spec) { if (!that.record) return; - $('dd', that.container).remove(); - - var dd = IPA.create_first_dd(this.name); - dd.appendTo(that.container); + that.container.empty(); var lock_field = 'nsaccountlock'; @@ -154,81 +151,77 @@ function user_status_widget(spec) { return (false); } }); - status_field.appendTo(dd); + status_field.appendTo(that.container); }; return that; -} - -function resetpwd_on_click(){ - - function reset_password(new_password){ - var dialog = resetpwd_dialog; - - var user_pkey = $.bbq.getState('user-pkey'); - var pw_pkey; - if (user_pkey === IPA.whoami.uid[0]){ - pw_pkey = []; - }else{ - pw_pkey = [user_pkey]; - } - - IPA.cmd('passwd', - pw_pkey, {"password":new_password}, - function(){ - alert("Password change complete"); - dialog.dialog("close"); - }, - function(){}); - } - - - var resetpwd_dialog = - $('
'); - resetpwd_dialog.dialog( - { modal: true, - minWidth:400, - buttons: { - 'Reset Password': function(){ - var p1 = $("#password_1").val(); - var p2 = $("#password_2").val(); - if (p1 != p2){ - alert("passwords must match"); - return; - } - reset_password(p1); - }, - 'Cancel':function(){ - resetpwd_dialog.dialog('close'); - } - }}); - return false; -} +}; -function user_password_load(result) { +IPA.user_password_widget = function(spec) { - var that = this; + spec = spec || {}; - $('dd', that.container).remove(); + var that = IPA.widget(spec); - var dd = IPA.create_first_dd(this.name); - dd.appendTo(that.container); + that.create = function(container) { + $('', { + href: 'jslink', + title: 'userpassword', + text: 'reset password', + click: resetpwd_on_click + }).appendTo(container); + }; - var link = $('',{ - href:"jslink", - click:resetpwd_on_click, - title:'userpassword', - text: 'reset password' - }); - link.appendTo(dd); + function resetpwd_on_click() { + + function reset_password(new_password) { + + var user_pkey = $.bbq.getState('user-pkey'); + var pw_pkey; + if (user_pkey === IPA.whoami.uid[0]){ + pw_pkey = []; + }else{ + pw_pkey = [user_pkey]; + } + + IPA.cmd('passwd', + pw_pkey, {"password":new_password}, + function(){ + alert("Password change complete"); + dialog.dialog("close"); + }, + function(){}); + } -} + var dialog = + $('
'); + + dialog.dialog({ + modal: true, + minWidth:400, + buttons: { + 'Reset Password': function(){ + var p1 = $("#password_1").val(); + var p2 = $("#password_2").val(); + if (p1 != p2){ + alert("passwords must match"); + return; + } + reset_password(p1); + }, + 'Cancel':function(){ + dialog.dialog('close'); + } + } + }); -var select_temp = ''; -var option_temp = ''; + return false; + } + return that; +}; -- cgit