From a746c613a4fb3d0eed5c73455ebb2e674ed7793d Mon Sep 17 00:00:00 2001 From: Adam Young Date: Fri, 8 Jul 2011 12:06:30 -0400 Subject: [PATCH] dnsrecord-mod ui Brings the DNS record infrastructure in line with the other entities. Uses widgets, nested search, and a littel bit of overloading for dns specific behavior The records now have their own page. simplified link widget and use for dns links work for nested entities. change the field in the link widget to other_entity to avoid name collision. unit test for entity link. fixed reference to entity for getting pkeys work around lack of setattr for dns record mod. update wasn't deducing locked_field type correctly. don't overwrite param_info in init data is required on adder dialog delete works for multiple records use show instead of find for entity_link_widget. https://fedorahosted.org/freeipa/ticket/1038 https://fedorahosted.org/freeipa/ticket/1448 https://fedorahosted.org/freeipa/ticket/577 https://fedorahosted.org/freeipa/ticket/1460 --- install/ui/add.js | 5 + install/ui/details.js | 7 +- install/ui/dns.js | 709 ++++++++--------------- install/ui/entity.js | 2 +- install/ui/host.js | 20 +- install/ui/navigation.js | 20 + install/ui/policy.js | 3 +- install/ui/search.js | 12 +- install/ui/test/data/dnsrecord_find.json | 37 +- install/ui/test/data/dnsrecord_show.json | 73 +++ install/ui/test/widget_tests.js | 35 ++ install/ui/user.js | 5 +- install/ui/webui.js | 8 +- install/ui/widget.js | 83 +-- 14 files changed, 510 insertions(+), 509 deletions(-) create mode 100644 install/ui/test/data/dnsrecord_show.json diff --git a/install/ui/add.js b/install/ui/add.js index 0a414b74b..b6b797c45 100644 --- a/install/ui/add.js +++ b/install/ui/add.js @@ -30,6 +30,7 @@ IPA.add_dialog = function (spec) { var that = IPA.dialog(spec); that.method = spec.method || 'add'; + that.pre_execute_hook = spec.pre_execute_hook; function show_edit_page(entity_name,result){ var pkey_name = IPA.metadata.objects[entity_name].primary_key; @@ -160,9 +161,13 @@ IPA.add_dialog = function (spec) { //alert(JSON.stringify(command.to_json())); + if (that.pre_execute_hook){ + that.pre_execute_hook(command); + } if (required_fields_filled){ command.execute(); } + }; that.add_dialog_init = that.init; diff --git a/install/ui/details.js b/install/ui/details.js index 746769702..b31305c69 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -591,9 +591,9 @@ IPA.details_facet = function(spec) { values = field.save(); if (!values) continue; - var param_info = IPA.get_entity_param(entity_name, field.name); + var param_info = field.param_info; if (param_info) { - if (param_info['primary_key']) continue; + if (param_info.primary_key) continue; if (values.length === 1) { command.set_option(field.name, values[0]); } else if (field.join) { @@ -601,8 +601,7 @@ IPA.details_facet = function(spec) { } else { command.set_option(field.name, values); } - - } else { + } else { if (values.length) { command.add_option('setattr', field.name+'='+values[0]); } else { diff --git a/install/ui/dns.js b/install/ui/dns.js index d689a8941..740192653 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -54,13 +54,15 @@ IPA.entity_factories.dnszone = function() { 'idnsallowdynupdate', 'idnsupdatepolicy']}] }). - facet({ - factory: IPA.dnsrecord_facet, - name: 'records', + nested_search_facet({ facet_group: 'member', + nested_entity : 'dnsrecord', + name: 'records', title: IPA.metadata.objects.dnszone.label_singular, label: IPA.metadata.objects.dnsrecord.label, - columns: [ + load: IPA.dns_record_search_load, + get_values: IPA.dnsrecord_get_delete_values, + columns:[ { name: 'idnsname', label: IPA.get_entity_param('dnsrecord', 'idnsname').label, @@ -87,6 +89,229 @@ IPA.entity_factories.dnszone = function() { build(); }; +IPA.dns_record_search_load = function (result) { + this.table.empty(); + var normalized_record; + var dns_record_types = IPA.dns_record_types(); + for (var i = 0; i -1){ + var rec_type = { + label: attr.substring(0,index).toUpperCase(), + value: attr + }; + record_types.push(rec_type); + } + } + return record_types; +}; + +IPA.dnsrecord_type_widget = function (spec){ + + spec.options = IPA.dns_record_types(); + var that = IPA.select_widget(spec); + return that; +}; + IPA.force_dnszone_add_checkbox_widget = function(spec) { var param_info = IPA.get_method_option('dnszone_add', 'force'); spec.name = 'force'; @@ -96,461 +321,39 @@ IPA.force_dnszone_add_checkbox_widget = function(spec) { return IPA.checkbox_widget(spec); }; -IPA.dnsrecord_facet = function(spec) { - spec = spec || {}; +IPA.dnsrecord_get_delete_values = function(){ - spec.disable_breadcrumb = false; - spec.disable_facet_tabs = false; + var records = {}; + var value; + var record_type; + $('input[name="select"]:checked', this.table.tbody).each(function() { - var that = IPA.search_facet(spec); + $('span',$(this).parent().parent()).each(function(){ + var name = this.attributes['name'].value; - function generate_recordtype_list(){ - var attrs = IPA.metadata.objects.dnsrecord.default_attributes; - var record_types = []; - for (var i =0; i < attrs.length; i+=1){ - var attr = attrs[i]; - var index = attr.search('record$'); - if (index > -1){ - var rec_type = attr.substring(0,index); - record_types.push(rec_type); + if (name === 'idnsname'){ + value = records[$(this).text()]; + if (!value){ + value = {pkey:$(this).text()}; + records[$(this).text()] = value; + } + }else if (name === 'type'){ + record_type = $(this).text(); + }else if (name === 'data'){ + if (!value[record_type]){ + value[record_type] = $(this).text(); + }else{ + value[record_type] += "," + $(this).text(); + } } - } - return record_types; + }); + }); + var value_array = []; + for (var key in records){ + value_array.push(records[key]); } - var record_types = generate_recordtype_list(); - - that.init = function() { - - that.facet_init(); - - that.table = IPA.table_widget({ - 'class': 'content-table', - name: 'search', - label: IPA.metadata.objects[that.entity_name].label, - entity_name: that.entity_name, - scrollable: true - }); - - var columns = that.columns.values; - for (var i=0; i',{ - id: id - }); - - if (add_none){ - type_select.append($('