diff options
author | Endi S. Dewata <edewata@redhat.com> | 2011-03-04 14:58:48 -0600 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-03-04 16:39:07 -0500 |
commit | b4952e27ecb299cc38bda401e3e8ed290c59d42c (patch) | |
tree | d2aab34223a336a00e8b77ef8fee577401034aa5 | |
parent | 6fc488e12fdf45ae67439dc9883e78eb07cc4113 (diff) | |
download | freeipa-b4952e27ecb299cc38bda401e3e8ed290c59d42c.tar.gz freeipa-b4952e27ecb299cc38bda401e3e8ed290c59d42c.tar.xz freeipa-b4952e27ecb299cc38bda401e3e8ed290c59d42c.zip |
Fixed memory leak caused by DNS record adder dialog.
Ticket 1054
-rw-r--r-- | install/ui/policy.js | 110 |
1 files changed, 62 insertions, 48 deletions
diff --git a/install/ui/policy.js b/install/ui/policy.js index 54a0f36ea..784f97cf1 100644 --- a/install/ui/policy.js +++ b/install/ui/policy.js @@ -124,68 +124,82 @@ IPA.records_facet = function (spec){ function add_click(){ - var add_dialog = $('<div/>',{ - id: 'add_dns_resource_record', + var dialog = IPA.dialog({ title: IPA.messages.objects.dnsrecord.add }); - var dl = $('<dl></dl>').appendTo(add_dialog); - dl.append('<dt>'+IPA.messages.objects.dnsrecord.resource+'</dt>'); - dl.append( $('<dd/>'). - append($('<input type="text" id="dns-record-resource" />'))); - dl.append('<dt>'+IPA.messages.objects.dnsrecord.type+'</dt>'); - dl.append( $('<dd/>').append(create_type_select('dns-record-type'))); - dl.append('<dt>'+IPA.messages.objects.dnsrecord.data+'</dt>'); - dl.append($('<dd/>').append($('<textarea/>',{ - id: 'dns-record-data', - rows:"8", - cols:"20" - }))); - - - function add(evt, called_from_add_and_edit) { - var params = []; - var options = {}; - function add_win(data, text_status, xhr) { - reload(); - } - function add_fail(data, text_status, xhr) { - } + dialog.create = function() { - params.push( $.bbq.getState(that.entity_name+'-pkey', true)); - params.push(add_dialog.find('#dns-record-resource').val()); + var dl = $('<dl/>').appendTo(dialog.container); - var key = add_dialog.find('#dns-record-type').val().toLowerCase()+ - "record"; - var value = add_dialog.find('#dns-record-data').val(); - options[key] = value; + $('<dt/>', { + html: IPA.messages.objects.dnsrecord.resource + }).appendTo(dl); + var dd = $('<dd/>').appendTo(dl); - IPA.cmd('dnsrecord_add', params, options, add_win, add_fail); - //add_dialog.dialog('close'); - } + dialog.resource = $('<input/>', { + type: 'text' + }).appendTo(dd); - function add_and_close(evt) { - add(evt, true); - add_dialog.dialog('close'); - } + $('<dt/>', { + html: IPA.messages.objects.dnsrecord.type + }).appendTo(dl); - function cancel() { - add_dialog.dialog('close'); - } + dd = $('<dd/>').appendTo(dl); - var buttons = {}; + dialog.type = create_type_select('dns-record-type').appendTo(dd); - buttons[IPA.messages.buttons.add_many] = add; - buttons[IPA.messages.buttons.add_and_close] = add_and_close; - buttons[IPA.messages.buttons.cancel] = cancel; + $('<dt/>', { + html: IPA.messages.objects.dnsrecord.data + }).appendTo(dl); - add_dialog.dialog({ - modal: true, - buttons: buttons + dd = $('<dd/>').appendTo(dl); + + dialog.data = $('<textarea/>', { + rows: 8, + cols: 20 + }).appendTo(dd); + }; + + dialog.add_button(IPA.messages.buttons.add_many, function() { + dialog.add(); }); - } + dialog.add_button(IPA.messages.buttons.add_and_close, function() { + dialog.add(); + dialog.close(); + }); + + dialog.add_button(IPA.messages.buttons.cancel, function() { + dialog.close(); + }); + + dialog.add = function() { + + var pkey = $.bbq.getState(that.entity_name+'-pkey', true); + var resource = dialog.resource.val(); + + var options = {}; + var key = dialog.type.val().toLowerCase()+'record'; + options[key] = dialog.data.val(); + + var command = IPA.command({ + method: 'dnsrecord_add', + args: [pkey, resource], + options: options, + on_success: function(data, text_status, xhr) { + reload(); + } + }); + + command.execute(); + }; + + dialog.init(); + + dialog.open(that.container); + } function delete_records(records_table){ |