Re: [Freeipa-devel] [PATCH] 276 Fixed problem enabling/disabling DNS zone.

2011-09-22 Thread Endi Sukma Dewata

On 9/22/2011 6:59 AM, Petr Vobornik wrote:

On 09/17/2011 12:18 AM, Endi Sukma Dewata wrote:

The details facet for DNS zone has been modified to use dnszone-
enable/disable for idnszoneactive and dnszone-mod for other fields.

Ticket #1813


ACK


Pushed to master and ipa-2-1.


Btw it doesn't matter (besides performance) if you move 'if
(!field.is_dirty()) continue;' in sudo and hbac facet couple lines lower
because to execute member_operation you have to fulfil two conditions,
which won't be never reached - name of the association fields changed so
'if (categories[field.name])' will be never true. Even if it would be
the next condition ('values[0] == 'all) won't be either because of weird
implementation of table_widget.save method.
Anyway if it would be functional it would be IMO bad - checking line
doesn't imply that user wants it to be deleted right now. Even if
marking the line could be used only for deletion.

This code should be cleaned in the future (erased or fixed).


As mentioned on IRC, this fixes a regression in the UI when changing the 
category. The two conditions (remove_values and has_values) are set by 
different fields (category and table), that's why the logic is kind of 
complicated. The server side will be fixed in ticket #1440. Once that's 
fixed we no longer need this code so it can be cleaned up.


--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 276 Fixed problem enabling/disabling DNS zone.

2011-09-16 Thread Endi Sukma Dewata

The details facet for DNS zone has been modified to use dnszone-
enable/disable for idnszoneactive and dnszone-mod for other fields.

Ticket #1813

--
Endi S. Dewata
From edffb9b9c7cd2c0ae4f7ca07fa5e46bca5d33386 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata edew...@redhat.com
Date: Fri, 16 Sep 2011 16:06:07 -0500
Subject: [PATCH] Fixed problem enabling/disabling DNS zone.

The details facet for DNS zone has been modified to use dnszone-
enable/disable for idnszoneactive and dnszone-mod for other fields.

Ticket #1813
---
 install/ui/dns.js  |  119 +---
 install/ui/hbac.js |   26 ++-
 install/ui/sudo.js |   28 +++--
 3 files changed, 142 insertions(+), 31 deletions(-)

diff --git a/install/ui/dns.js b/install/ui/dns.js
index 4cd222758f4e38492a65021af15178aa4efe82f2..da00a0495172f5195f30217552939b64ca7ab490 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -38,12 +38,13 @@ IPA.entity_factories.dnszone = function() {
 facet_groups([ 'dnsrecord', 'settings' ]).
 search_facet({
 title: IPA.metadata.objects.dnszone.label,
-columns:['idnsname']
+columns: [ 'idnsname' ]
 }).
 details_facet({
-sections:[{
-name:'identity',
-fields:[
+factory: IPA.dnszone_details_facet,
+sections: [{
+name: 'identity',
+fields: [
 'idnsname',
 'idnszoneactive',
 'idnssoamname',
@@ -56,7 +57,9 @@ IPA.entity_factories.dnszone = function() {
 'dnsttl',
 'dnsclass',
 'idnsallowdynupdate',
-'idnsupdatepolicy']}]
+'idnsupdatepolicy'
+]
+}]
 }).
 nested_search_facet({
 facet_group: 'dnsrecord',
@@ -66,7 +69,7 @@ IPA.entity_factories.dnszone = function() {
 label: IPA.metadata.objects.dnsrecord.label,
 load: IPA.dns_record_search_load,
 get_values: IPA.dnsrecord_get_delete_values,
-columns:[
+columns: [
 {
 name: 'idnsname',
 label: IPA.get_entity_param('dnsrecord', 'idnsname').label,
@@ -110,6 +113,110 @@ IPA.entity_factories.dnszone = function() {
 build();
 };
 
+IPA.dnszone_details_facet = function(spec) {
+
+spec = spec || {};
+
+var that = IPA.details_facet(spec);
+
+that.update = function(on_success, on_error) {
+
+var args = that.get_primary_key();
+
+var modify_operation = {
+execute: false,
+command: IPA.command({
+entity: that.entity.name,
+method: 'mod',
+args: args,
+options: { all: true, rights: true }
+})
+};
+
+var enable_operation = {
+execute: false,
+command: IPA.command({
+entity: that.entity.name,
+method: 'enable',
+args: args,
+options: { all: true, rights: true }
+})
+};
+
+var sections = that.sections.values;
+for (var i=0; isections.length; i++) {
+var section = sections[i];
+
+var section_fields = section.fields.values;
+for (var j=0; jsection_fields.length; j++) {
+var field = section_fields[j];
+if (!field.is_dirty()) continue;
+
+var values = field.save();
+if (!values) continue;
+
+var param_info = field.param_info;
+
+// skip primary key
+if (param_info  param_info.primary_key) continue;
+
+// check enable/disable
+if (field.name == 'idnszoneactive') {
+if (values[0] == 'FALSE') enable_operation.command.method = 'disable';
+enable_operation.execute = true;
+continue;
+}
+
+if (param_info) {
+if (values.length == 1) {
+modify_operation.command.set_option(field.name, values[0]);
+} else if (field.join) {
+modify_operation.command.set_option(field.name, values.join(','));
+} else {
+modify_operation.command.set_option(field.name, values);
+}
+
+} else {
+if (values.length) {
+modify_operation.command.set_option('setattr', field.name+'='+values[0]);
+} else {
+modify_operation.command.set_option('setattr', field.name+'=');
+}
+for (var l=1; lvalues.length; l++) {
+