diff options
author | Endi S. Dewata <edewata@redhat.com> | 2011-09-28 15:56:25 -0500 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-09-29 16:57:19 +0000 |
commit | f99ab781ea33f0d7ca6df26090cd99f9315454ac (patch) | |
tree | 548558b589a656503eeb50aa090eed3a45b6f8e4 /install/ui | |
parent | ecb58275e30f215143c57bdf96094103c8fda7ba (diff) | |
download | freeipa-f99ab781ea33f0d7ca6df26090cd99f9315454ac.tar.gz freeipa-f99ab781ea33f0d7ca6df26090cd99f9315454ac.tar.xz freeipa-f99ab781ea33f0d7ca6df26090cd99f9315454ac.zip |
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
Diffstat (limited to 'install/ui')
-rw-r--r-- | install/ui/add.js | 72 | ||||
-rwxr-xr-x | install/ui/certificate.js | 96 | ||||
-rw-r--r-- | install/ui/dialog.js | 137 | ||||
-rw-r--r-- | install/ui/dns.js | 10 | ||||
-rw-r--r-- | install/ui/entitle.js | 140 | ||||
-rw-r--r-- | install/ui/hbac.js | 18 | ||||
-rw-r--r-- | install/ui/host.js | 84 | ||||
-rw-r--r-- | install/ui/ipa.js | 58 | ||||
-rw-r--r-- | install/ui/service.js | 32 | ||||
-rw-r--r-- | install/ui/sudo.js | 52 | ||||
-rw-r--r-- | 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 21707df13..5a4537ba3 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 15789fc1a..9334ad037 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 50bb194b3..d291120ea 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,12 +512,16 @@ IPA.adder_dialog = function(spec) { that.available_table.add_rows(rows); }; - that.get_filter = function() { - return that.filter_field.val(); + that.update_buttons = function() { + + var values = that.selected_table.save(); + + var button = that.get_button('add'); + button.set_enabled(values && values.length); }; - that.get_hide_checkbox = function() { - return that.hide_checkbox.checked; + that.get_filter = function() { + return that.filter_field.val(); }; that.clear_available_values = function() { @@ -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 0115a311e..ea09e227c 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -638,9 +638,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 b8cff6ee2..eaa960693 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.entity.register_online( - record.username[0], - record.password[0], - record.ipaentitlementid[0], - function() { - var facet = that.entity.get_facet(); - facet.refresh(); - that.close(); - } - ); + 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.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; - } + if (!that.is_valid()) { + return; + } - var record = {}; - that.save(record); + var record = {}; + that.save(record); - that.entity.consume( - record.quantity[0], - function() { - var facet = that.entity.get_facet(); - facet.refresh(); - that.close(); - } - ); + 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 f4f262c81..c4b4877e2 100644 --- a/install/ui/hbac.js +++ b/install/ui/hbac.js @@ -580,13 +580,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 01b366e5e..007d20387 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -508,20 +508,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); @@ -637,34 +645,42 @@ IPA.host_password_widget = function(spec) { type: 'password' })); - dialog.add_button(label, function() { - - var record = {}; - dialog.save(record); + dialog.create_button({ + name: 'set_password', + label: label, + click: function() { - var new_password = record.password1[0]; - var repeat_password = record.password2[0]; + var record = {}; + dialog.save(record); - if (new_password != repeat_password) { - alert(IPA.messages.password.password_must_match); - return; - } + var new_password = record.password1[0]; + var repeat_password = record.password2[0]; - 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 ca081dc0d..a4fef6018 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.close(); - that.callback(); - }); + that.create_button({ + name: 'update', + label: IPA.messages.buttons.update, + click: function() { + that.facet.update(function() { + that.close(); + that.callback(); + }); + } }); - that.add_button(IPA.messages.buttons.reset, function() { - that.facet.reset(); - 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.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 f8e95f897..7db8a6657 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 acc1c9f4f..6855283ec 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -609,33 +609,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 62794ad75..60958cb43 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() { - - var record = {}; - dialog.save(record); + dialog.create_button({ + name: 'reset_password', + label: IPA.messages.password.reset_password, + click: function() { - var new_password = record.password1[0]; - var repeat_password = record.password2[0]; + var record = {}; + dialog.save(record); - if (new_password != repeat_password) { - alert(IPA.messages.password.password_must_match); - return; - } + var new_password = record.password1[0]; + var repeat_password = record.password2[0]; - 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); |