A new IPA.dialog_button class has been added to encapsulate the buttons in the dialog box so they can be managed more easily.
The adder dialog has been modified to disable the enroll button if there is no entries selected. Ticket #1856 -- Endi S. Dewata
From 0b94a6059fdb02161169413df34439f670c15107 Mon Sep 17 00:00:00 2001 From: Endi S. Dewata <edew...@redhat.com> Date: Wed, 28 Sep 2011 15:56:25 -0500 Subject: [PATCH] Disable enroll button if nothing selected. A new IPA.dialog_button class has been added to encapsulate the buttons in the dialog box so they can be managed more easily. The adder dialog has been modified to disable the enroll button if there is no entries selected. Ticket #1856 --- install/ui/add.js | 72 ++++++++++++++--------- install/ui/certificate.js | 96 ++++++++++++++++++++---------- install/ui/dialog.js | 137 ++++++++++++++++++++++++++++++++++++++------ install/ui/dns.js | 10 ++- install/ui/entitle.js | 140 +++++++++++++++++++++++++++----------------- install/ui/hbac.js | 18 ++++-- install/ui/host.js | 84 ++++++++++++++++----------- install/ui/ipa.js | 58 +++++++++++++------ install/ui/service.js | 32 ++++++----- install/ui/sudo.js | 52 ++++++++++------- install/ui/user.js | 80 +++++++++++++++---------- 11 files changed, 520 insertions(+), 259 deletions(-) diff --git a/install/ui/add.js b/install/ui/add.js index 21707df13a553586e7610a42fd038aecdad344ff..5a4537ba3c310d27e60a588645dcd49add66f7c2 100644 --- a/install/ui/add.js +++ b/install/ui/add.js @@ -111,40 +111,56 @@ IPA.add_dialog = function (spec) { }; /*dialog initialization*/ - that.add_button(IPA.messages.buttons.add, function() { - that.add( - function(data, text_status, xhr) { - var facet = IPA.current_entity.get_facet(); - var table = facet.table; - table.refresh(); - that.close(); - }, - that.on_error); + that.create_button({ + name: 'add', + label: IPA.messages.buttons.add, + click: function() { + that.add( + function(data, text_status, xhr) { + var facet = IPA.current_entity.get_facet(); + var table = facet.table; + table.refresh(); + that.close(); + }, + that.on_error); + } }); - that.add_button(IPA.messages.buttons.add_and_add_another, function() { - that.add( - function(data, text_status, xhr) { - var facet = IPA.current_entity.get_facet(); - var table = facet.table; - table.refresh(); - that.reset(); - }, - that.on_error); + that.create_button({ + name: 'add_and_add_another', + label: IPA.messages.buttons.add_and_add_another, + click: function() { + that.add( + function(data, text_status, xhr) { + var facet = IPA.current_entity.get_facet(); + var table = facet.table; + table.refresh(); + that.reset(); + }, + that.on_error); + } }); - that.add_button(IPA.messages.buttons.add_and_edit, function() { - that.add( - function(data, text_status, xhr) { - that.close(); - var result = data.result.result; - that.show_edit_page(that.entity, result); - }, - that.on_error); + that.create_button({ + name: 'add_and_edit', + label: IPA.messages.buttons.add_and_edit, + click: function() { + that.add( + function(data, text_status, xhr) { + that.close(); + var result = data.result.result; + that.show_edit_page(that.entity, result); + }, + that.on_error); + } }); - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } }); return that; diff --git a/install/ui/certificate.js b/install/ui/certificate.js index 15789fc1af8768d9326a5904456d7e6d97142953..9334ad037a1bd2913401286ba9bf701b3c49aa70 100755 --- a/install/ui/certificate.js +++ b/install/ui/certificate.js @@ -86,8 +86,12 @@ IPA.cert.download_dialog = function(spec) { that.certificate = spec.certificate || ''; - that.add_button(IPA.messages.buttons.close, function() { - that.close(); + that.create_button({ + name: 'close', + label: IPA.messages.buttons.close, + click: function() { + that.close(); + } }); that.create = function() { @@ -121,17 +125,25 @@ IPA.cert.revoke_dialog = function(spec) { that.revoke = spec.revoke; - that.add_button(IPA.messages.buttons.revoke, function() { - var values = {}; - values['reason'] = that.select.val(); - if (that.revoke) { - that.revoke(values); + that.create_button({ + name: 'revoke', + label: IPA.messages.buttons.revoke, + click: function() { + var values = {}; + values['reason'] = that.select.val(); + if (that.revoke) { + that.revoke(values); + } + that.close(); } - that.close(); }); - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } }); that.create = function() { @@ -178,16 +190,24 @@ IPA.cert.restore_dialog = function(spec) { that.restore = spec.restore; - that.add_button(IPA.messages.buttons.restore, function() { - var values = {}; - if (that.restore) { - that.restore(values); + that.create_button({ + name: 'restore', + label: IPA.messages.buttons.restore, + click: function() { + var values = {}; + if (that.restore) { + that.restore(values); + } + that.close(); } - that.close(); }); - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } }); that.create = function() { @@ -215,8 +235,12 @@ IPA.cert.view_dialog = function(spec) { that.md5_fingerprint = spec.md5_fingerprint || ''; that.sha1_fingerprint = spec.sha1_fingerprint || ''; - that.add_button(IPA.messages.buttons.close, function() { - that.close(); + that.create_button({ + name: 'close', + label: IPA.messages.buttons.close, + click: function() { + that.close(); + } }); that.create = function() { @@ -328,22 +352,30 @@ IPA.cert.request_dialog = function(spec) { that.request = spec.request; - that.add_button(IPA.messages.buttons.issue, function() { - var values = {}; - var request = that.textarea.val(); - request = - IPA.cert.BEGIN_CERTIFICATE_REQUEST+'\n'+ - $.trim(request)+'\n'+ - IPA.cert.END_CERTIFICATE_REQUEST+'\n'; - values['request'] = request; - if (that.request) { - that.request(values); + that.create_button({ + name: 'issue', + label: IPA.messages.buttons.issue, + click: function() { + var values = {}; + var request = that.textarea.val(); + request = + IPA.cert.BEGIN_CERTIFICATE_REQUEST+'\n'+ + $.trim(request)+'\n'+ + IPA.cert.END_CERTIFICATE_REQUEST+'\n'; + values['request'] = request; + if (that.request) { + that.request(values); + } + that.close(); } - that.close(); }); - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } }); that.create = function() { diff --git a/install/ui/dialog.js b/install/ui/dialog.js index 50bb194b3e42df12449c9920d089bae6a6f16a1d..d291120eadfb4057f5afe356639bee5994d96649 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -21,6 +21,34 @@ /* REQUIRES: widget.js */ +IPA.dialog_button = function(spec) { + + spec = spec || {}; + + var that = {}; + + that.name = spec.name; + that.label = spec.label || spec.name; + that.click = spec.click || click; + + function click() { + } + + that.set_enabled = function(enabled) { + if (enabled) { + that.element.removeClass('ui-state-disabled'); + } else { + that.element.addClass('ui-state-disabled'); + } + }; + + that.is_enabled = function() { + return !that.element.hasClass('ui-state-disabled'); + }; + + return that; +}; + /** * This is a base class for dialog boxes. */ @@ -37,7 +65,7 @@ IPA.dialog = function(spec) { that.width = spec.width || 500; that.height = spec.height; - that.buttons = {}; + that.buttons = $.ordered_map(); that.sections = $.ordered_map(); @@ -57,8 +85,19 @@ IPA.dialog = function(spec) { section.add_fields(fields); }; - that.add_button = function(name, handler) { - that.buttons[name] = handler; + that.create_button = function(spec) { + var factory = spec.factory || IPA.dialog_button; + var button = factory(spec); + that.add_button(button); + return button; + }; + + that.add_button = function(button) { + that.buttons.put(button.name, button); + }; + + that.get_button = function(name) { + return that.buttons.get(name); }; that.get_field = function(name) { @@ -173,6 +212,13 @@ IPA.dialog = function(spec) { that.create(); that.reset(); + // create a map of button labels and handlers + var dialog_buttons = {}; + for (var i=0; i<that.buttons.values.length; i++) { + var button = that.buttons.values[i]; + dialog_buttons[button.label] = button.click; + } + that.container.dialog({ title: that.title, modal: true, @@ -180,11 +226,20 @@ IPA.dialog = function(spec) { minWidth: that.width, height: that.height, minHeight: that.height, - buttons: that.buttons, + buttons: dialog_buttons, close: function(event, ui) { that.close(); } }); + + // find button elements + var parent = that.container.parent(); + var buttons = $('.ui-dialog-buttonpane .ui-dialog-buttonset button', parent); + + buttons.each(function(index) { + var button = that.buttons.values[index]; + button.element = $(this); + }); }; that.option = function(name, value) { @@ -231,6 +286,7 @@ IPA.adder_dialog = function(spec) { spec = spec || {}; var that = IPA.dialog(spec); + that.external = spec.external; that.width = spec.width || 600; that.height = spec.height || 360; @@ -373,21 +429,23 @@ IPA.adder_dialog = function(spec) { }).appendTo(container); var p = $('<p/>').appendTo(buttons_panel); - that.add_button = IPA.button({ + IPA.button({ name: 'add', label: '>>', click: function() { that.add(); + that.update_buttons(); return false; } }).appendTo(p); p = $('<p/>').appendTo(buttons_panel); - that.remove_button = IPA.button({ + IPA.button({ name: 'remove', label: '<<', click: function() { that.remove(); + that.update_buttons(); return false; } }).appendTo(p); @@ -422,10 +480,26 @@ IPA.adder_dialog = function(spec) { that.open = function(container) { - that.buttons[IPA.messages.buttons.enroll] = that.execute; - that.buttons[IPA.messages.buttons.cancel] = that.close; + var add_button = that.create_button({ + name: 'add', + label: IPA.messages.buttons.enroll, + click: function() { + if (!add_button.is_enabled()) return; + that.execute(); + } + }); + + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } + }); that.dialog_open(container); + + that.update_buttons(); }; that.add = function() { @@ -438,14 +512,18 @@ IPA.adder_dialog = function(spec) { that.available_table.add_rows(rows); }; + that.update_buttons = function() { + + var values = that.selected_table.save(); + + var button = that.get_button('add'); + button.set_enabled(values && values.length); + }; + that.get_filter = function() { return that.filter_field.val(); }; - that.get_hide_checkbox = function() { - return that.hide_checkbox.checked; - }; - that.clear_available_values = function() { that.available_table.empty(); }; @@ -462,6 +540,9 @@ IPA.adder_dialog = function(spec) { return that.selected_table.save(); }; + that.execute = function() { + }; + init(); that.adder_dialog_create = that.create; @@ -528,12 +609,28 @@ IPA.deleter_dialog = function (spec) { that.open = function(container) { - that.buttons[IPA.messages.buttons.remove] = that.execute; - that.buttons[IPA.messages.buttons.cancel] = that.close; + 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; @@ -555,10 +652,14 @@ IPA.message_dialog = function(spec) { }).appendTo(that.container); }; - that.add_button(IPA.messages.buttons.ok, function() { - that.close(); - if(that.on_ok) { - that.on_ok(); + that.create_button({ + name: 'ok', + label: IPA.messages.buttons.ok, + click: function() { + that.close(); + if(that.on_ok) { + that.on_ok(); + } } }); diff --git a/install/ui/dns.js b/install/ui/dns.js index f5f617383e6e35db22e0accb0653949d28f2bc75..18468519d472a26297efc40586299c3ac1a55800 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -621,9 +621,13 @@ IPA.dnsrecord_redirection_dialog = function(spec) { }).appendTo(that.container); }; - that.add_button(IPA.messages.buttons.ok, function() { - that.close(); - IPA.nav.show_page('dnszone','default'); + that.create_button({ + name: 'ok', + label: IPA.messages.buttons.ok, + click: function() { + that.close(); + IPA.nav.show_page('dnszone','default'); + } }); return that; }; diff --git a/install/ui/entitle.js b/install/ui/entitle.js index b8cff6ee2b04a9b3bd4884ecfa8bf0a1bf238a9c..eaa96069381cd3c393520f566ca9956665c163da 100644 --- a/install/ui/entitle.js +++ b/install/ui/entitle.js @@ -569,24 +569,32 @@ IPA.entitle.register_online_dialog = function(spec) { var that = IPA.dialog(spec); - that.add_button(IPA.messages.objects.entitle.register, function() { - var record = {}; - that.save(record); + that.create_button({ + name: 'register', + label: IPA.messages.objects.entitle.register, + click: function() { + var record = {}; + that.save(record); - that.entity.register_online( - record.username[0], - record.password[0], - record.ipaentitlementid[0], - function() { - var facet = that.entity.get_facet(); - facet.refresh(); - that.close(); - } - ); + that.entity.register_online( + record.username[0], + record.password[0], + record.ipaentitlementid[0], + function() { + var facet = that.entity.get_facet(); + facet.refresh(); + that.close(); + } + ); + } }); - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } }); return that; @@ -598,19 +606,27 @@ IPA.entitle.register_offline_dialog = function(spec) { var that = IPA.entitle.certificate_dialog(spec); - that.add_button(that.label, function() { - that.entity.register_offline( - that.get_certificate(), - function() { - var facet = that.entity.get_facet(); - facet.refresh(); - that.close(); - } - ); + that.create_button({ + name: 'register', + label: that.label, + click: function() { + that.entity.register_offline( + that.get_certificate(), + function() { + var facet = that.entity.get_facet(); + facet.refresh(); + that.close(); + } + ); + } }); - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } }); return that; @@ -622,27 +638,35 @@ IPA.entitle.consume_dialog = function(spec) { var that = IPA.dialog(spec); - that.add_button(IPA.messages.objects.entitle.consume, function() { + that.create_button({ + name: 'consume', + label: IPA.messages.objects.entitle.consume, + click: function() { - if (!that.is_valid()) { - return; - } - - var record = {}; - that.save(record); - - that.entity.consume( - record.quantity[0], - function() { - var facet = that.entity.get_facet(); - facet.refresh(); - that.close(); + if (!that.is_valid()) { + return; } - ); + + var record = {}; + that.save(record); + + that.entity.consume( + record.quantity[0], + function() { + var facet = that.entity.get_facet(); + facet.refresh(); + that.close(); + } + ); + } }); - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } }); return that; @@ -654,19 +678,27 @@ IPA.entitle.import_dialog = function(spec) { var that = IPA.entitle.certificate_dialog(spec); - that.add_button(IPA.messages.objects.entitle.import_button, function() { - that.entity.import_certificate( - that.get_certificate(), - function() { - var facet = that.entity.get_facet(); - facet.refresh(); - that.close(); - } - ); + that.create_button({ + name: 'import', + label: IPA.messages.objects.entitle.import_button, + click: function() { + that.entity.import_certificate( + that.get_certificate(), + function() { + var facet = that.entity.get_facet(); + facet.refresh(); + that.close(); + } + ); + } }); - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } }); return that; diff --git a/install/ui/hbac.js b/install/ui/hbac.js index 52cb5d6f9d262d2408b2e0e124e86ed1e9164fb8..d777861ad3969da3db3c4bc4ac5a99735423212a 100644 --- a/install/ui/hbac.js +++ b/install/ui/hbac.js @@ -557,13 +557,21 @@ IPA.hbac_deny_warning_dialog = function(container) { })).appendTo(dialog.container); }; - dialog.add_button('Edit HBAC Rules', function() { - dialog.close(); - IPA.nav.show_page('hbacrule', 'search'); + dialog.create_button({ + name: 'edit', + label: 'Edit HBAC Rules', + click: function() { + dialog.close(); + IPA.nav.show_page('hbacrule', 'search'); + } }); - dialog.add_button('Ignore for now', function() { - dialog.close(); + dialog.create_button({ + name: 'ignore', + label: 'Ignore for now', + click: function() { + dialog.close(); + } }); dialog.open(); diff --git a/install/ui/host.js b/install/ui/host.js index a74ad5e48855d6fc23af13fa5da796f0bf482770..99cf1ac6648987a8eb3bb2f44349b876506898b6 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -505,20 +505,28 @@ IPA.host_keytab_widget = function(spec) { dialog.container.append(IPA.messages.objects.host.unprovision_confirmation); }; - dialog.add_button(IPA.messages.objects.host.unprovision, function() { - that.unprovision( - function(data, text_status, xhr) { - set_status('missing'); - dialog.close(); - }, - function(xhr, text_status, error_thrown) { - dialog.close(); - } - ); + dialog.create_button({ + name: 'unprovision', + label: IPA.messages.objects.host.unprovision, + click: function() { + that.unprovision( + function(data, text_status, xhr) { + set_status('missing'); + dialog.close(); + }, + function(xhr, text_status, error_thrown) { + dialog.close(); + } + ); + } }); - dialog.add_button(IPA.messages.buttons.cancel, function() { - dialog.close(); + dialog.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + dialog.close(); + } }); dialog.open(that.container); @@ -634,34 +642,42 @@ IPA.host_password_widget = function(spec) { type: 'password' })); - dialog.add_button(label, function() { + dialog.create_button({ + name: 'set_password', + label: label, + click: function() { - var record = {}; - dialog.save(record); + var record = {}; + dialog.save(record); - var new_password = record.password1[0]; - var repeat_password = record.password2[0]; + var new_password = record.password1[0]; + var repeat_password = record.password2[0]; - if (new_password != repeat_password) { - alert(IPA.messages.password.password_must_match); - return; - } - - that.set_password( - new_password, - function(data, text_status, xhr) { - that.load(data.result.result); - dialog.close(); - }, - function(xhr, text_status, error_thrown) { - dialog.close(); + if (new_password != repeat_password) { + alert(IPA.messages.password.password_must_match); + return; } - ); - dialog.close(); + + that.set_password( + new_password, + function(data, text_status, xhr) { + that.load(data.result.result); + dialog.close(); + }, + function(xhr, text_status, error_thrown) { + dialog.close(); + } + ); + dialog.close(); + } }); - dialog.add_button(IPA.messages.buttons.cancel, function() { - dialog.close(); + dialog.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + dialog.close(); + } }); dialog.open(that.container); diff --git a/install/ui/ipa.js b/install/ui/ipa.js index ca081dc0de68ede3aa2d1adb9332d3dd86033c4a..a4fef6018e95d5d2497910f35b5494795e0f497e 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -714,21 +714,33 @@ IPA.dirty_dialog = function(spec) { that.container.append(that.message); }; - that.add_button(IPA.messages.buttons.update, function() { - that.facet.update(function() { + that.create_button({ + name: 'update', + label: IPA.messages.buttons.update, + click: function() { + that.facet.update(function() { + that.close(); + that.callback(); + }); + } + }); + + that.create_button({ + name: 'reset', + label: IPA.messages.buttons.reset, + click: function() { + that.facet.reset(); that.close(); that.callback(); - }); + } }); - that.add_button(IPA.messages.buttons.reset, function() { - that.facet.reset(); - that.close(); - that.callback(); - }); - - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); + that.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + that.close(); + } }); that.callback = function() { @@ -824,22 +836,34 @@ IPA.error_dialog = function(spec) { if(that.visible_buttons.indexOf('retry') > -1) { label = IPA.get_message('buttons.retry', 'Retry'); - that.add_button(label, function() { - that.on_retry(); + that.create_button({ + name: 'retry', + label: label, + click: function() { + that.on_retry(); + } }); } if(that.visible_buttons.indexOf('ok') > -1) { label = IPA.get_message('buttons.ok', 'OK'); - that.add_button(label, function() { - that.on_ok(); + that.create_button({ + name: 'ok', + label: label, + click: function() { + that.on_ok(); + } }); } if(that.visible_buttons.indexOf('cancel') > -1) { label = IPA.get_message('buttons.cancel', 'Cancel'); - that.add_button(label, function() { - that.on_cancel(); + that.create_button({ + name: 'cancel', + label: label, + click: function() { + that.on_cancel(); + } }); } }; diff --git a/install/ui/service.js b/install/ui/service.js index f8e95f897c65b22c9a77f48b2d232bacf60e5607..7db8a665760fe6a5f3812191d65375404fc887a8 100644 --- a/install/ui/service.js +++ b/install/ui/service.js @@ -261,20 +261,24 @@ IPA.service_provisioning_status_widget = function (spec) { dialog.container.append(IPA.messages.objects.service.unprovision_confirmation); }; - dialog.add_button(IPA.messages.objects.service.unprovision, function() { - var pkey = that.result['krbprincipalname'][0]; - IPA.command({ - entity: that.entity.name, - method: 'disable', - args: [pkey], - on_success: function(data, text_status, xhr) { - set_status('missing'); - dialog.close(); - }, - on_error: function(xhr, text_status, error_thrown) { - dialog.close(); - } - }).execute(); + dialog.create_button({ + name: 'unprovision', + label: IPA.messages.objects.service.unprovision, + click: function() { + var pkey = that.result['krbprincipalname'][0]; + IPA.command({ + entity: that.entity.name, + method: 'disable', + args: [pkey], + on_success: function(data, text_status, xhr) { + set_status('missing'); + dialog.close(); + }, + on_error: function(xhr, text_status, error_thrown) { + dialog.close(); + } + }).execute(); + } }); dialog.open(that.container); diff --git a/install/ui/sudo.js b/install/ui/sudo.js index a97731242fc00c0f688867a07284729ea7af507d..8586f5760c40ff0e5936505c504af87555505dd4 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -573,33 +573,41 @@ IPA.sudo.options_section = function(spec) { label: label })); - dialog.add_button(IPA.messages.buttons.add, function() { - var value = ipasudoopt.save()[0]; + dialog.create_button({ + name: 'add', + label: IPA.messages.buttons.add, + click: function() { + var value = ipasudoopt.save()[0]; - var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); - var command = IPA.command({ - entity: 'sudorule', - method: 'add_option', - args: [pkey], - options: { - ipasudoopt: value - }, - on_success: function(data) { - that.load(data.result.result); - dialog.close(); - }, - on_error: function(data) { - that.update(); - dialog.close(); - } - }); + var command = IPA.command({ + entity: 'sudorule', + method: 'add_option', + args: [pkey], + options: { + ipasudoopt: value + }, + on_success: function(data) { + that.load(data.result.result); + dialog.close(); + }, + on_error: function(data) { + that.update(); + dialog.close(); + } + }); - command.execute(); + command.execute(); + } }); - dialog.add_button(IPA.messages.buttons.cancel, function() { - dialog.close(); + dialog.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + dialog.close(); + } }); dialog.open(that.container); diff --git a/install/ui/user.js b/install/ui/user.js index 62794ad7524b3edcee5f735c87c248c5034a0623..60958cb43cf3f853c370554162600733f3d3d90d 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -261,19 +261,27 @@ IPA.user_status_widget = function(spec) { dialog.container.append(message); }; - dialog.add_button(action_label, function() { - that.set_status( - action == 'activate', - function(data, textStatus, xhr) { - var facet = that.entity.get_facet(); - facet.refresh(); - dialog.close(); - } - ); + dialog.create_button({ + name: 'set_status', + label: action_label, + click: function() { + that.set_status( + action == 'activate', + function(data, textStatus, xhr) { + var facet = that.entity.get_facet(); + facet.refresh(); + dialog.close(); + } + ); + } }); - dialog.add_button(IPA.messages.buttons.cancel, function() { - dialog.close(); + dialog.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + dialog.close(); + } }); dialog.open(that.container); @@ -334,33 +342,41 @@ IPA.user_password_widget = function(spec) { type: 'password' })); - dialog.add_button(IPA.messages.password.reset_password, function() { + dialog.create_button({ + name: 'reset_password', + label: IPA.messages.password.reset_password, + click: function() { - var record = {}; - dialog.save(record); + var record = {}; + dialog.save(record); - var new_password = record.password1[0]; - var repeat_password = record.password2[0]; + var new_password = record.password1[0]; + var repeat_password = record.password2[0]; - if (new_password != repeat_password) { - alert(IPA.messages.password.password_must_match); - return; - } - - that.set_password( - new_password, - function(data, text_status, xhr) { - alert(IPA.messages.password.password_change_complete); - dialog.close(); - }, - function(xhr, text_status, error_thrown) { - dialog.close(); + if (new_password != repeat_password) { + alert(IPA.messages.password.password_must_match); + return; } - ); + + that.set_password( + new_password, + function(data, text_status, xhr) { + alert(IPA.messages.password.password_change_complete); + dialog.close(); + }, + function(xhr, text_status, error_thrown) { + dialog.close(); + } + ); + } }); - dialog.add_button(IPA.messages.buttons.cancel, function() { - dialog.close(); + dialog.create_button({ + name: 'cancel', + label: IPA.messages.buttons.cancel, + click: function() { + dialog.close(); + } }); dialog.open(that.container); -- 1.7.5.1
_______________________________________________ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel