Re: [Freeipa-devel] [PATCH] 279 Fixed problem enrolling member with the same name.

2011-09-22 Thread Petr Vobornik

On 09/20/2011 02:19 AM, Endi Sukma Dewata wrote:

The IPA.association_adder_dialog has been modified to use an exclusion
list to hide entries that are already enrolled.

The IPA.adder_dialog has been modified to store the columns directly
in the available  selected tables.

Ticket #1797



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

ACK

--
Petr Vobornik

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


Re: [Freeipa-devel] [PATCH] 279 Fixed problem enrolling member with the same name.

2011-09-22 Thread Endi Sukma Dewata

On 9/22/2011 11:14 AM, Petr Vobornik wrote:

On 09/20/2011 02:19 AM, Endi Sukma Dewata wrote:

The IPA.association_adder_dialog has been modified to use an exclusion
list to hide entries that are already enrolled.

The IPA.adder_dialog has been modified to store the columns directly
in the available  selected tables.

Ticket #1797



ACK


Pushed to master and ipa-2-1.

--
Endi S. Dewata

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


[Freeipa-devel] [PATCH] 279 Fixed problem enrolling member with the same name.

2011-09-19 Thread Endi Sukma Dewata

The IPA.association_adder_dialog has been modified to use an exclusion
list to hide entries that are already enrolled.

The IPA.adder_dialog has been modified to store the columns directly
in the available  selected tables.

Ticket #1797

--
Endi S. Dewata
From f8339f3fb32840fc6f2aa5b4b98f587cabd80075 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata edew...@redhat.com
Date: Mon, 19 Sep 2011 18:51:43 -0500
Subject: [PATCH] Fixed problem enrolling member with the same name.

The IPA.association_adder_dialog has been modified to use an exclusion
list to hide entries that are already enrolled.

The IPA.adder_dialog has been modified to store the columns directly
in the available  selected tables.

Ticket #1797
---
 install/ui/association.js |   67 +++-
 install/ui/dialog.js  |   68 -
 install/ui/sudo.js|   23 +--
 3 files changed, 67 insertions(+), 91 deletions(-)

diff --git a/install/ui/association.js b/install/ui/association.js
index 2f08c73b92385497496d0afd2c54f91d4483ac23..3d75072ae3d14b0c3cfe46d020df6c9659c2a55d 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -144,17 +144,9 @@ IPA.bulk_associator = function(spec) {
 /**
  * This dialog is used for adding associations between two entities.
  */
-IPA.association_adder_dialog = function (spec) {
+IPA.association_adder_dialog = function(spec) {
 
 spec = spec || {};
-/*
-  TODO: columns map in IPA.adder_dialog should be removed and add_column()
-  should be modified to add the column directly into the available_table
-  and selected_table. This way IPA.association_adder_dialog can call
-  create_column() from the initialization area, no need to modify the
-  parameters.
-*/
-default_columns(spec);
 
 var that = IPA.adder_dialog(spec);
 
@@ -162,17 +154,35 @@ IPA.association_adder_dialog = function (spec) {
 that.pkey = spec.pkey;
 that.other_entity = spec.other_entity;
 that.attribute_member = spec.attribute_member;
+that.exclude = spec.exclude || [];
+
+var init = function() {
+if (!that.get_columns().length) {
+var pkey_name = IPA.metadata.objects[spec.other_entity].primary_key;
+that.create_column({
+entity: that.entity,
+name: pkey_name,
+label: IPA.metadata.objects[spec.other_entity].label,
+primary_key: true,
+width: '600px'
+});
+}
+};
 
 that.search = function() {
 function on_success(data, text_status, xhr) {
-var results = data.result;
+
 that.clear_available_values();
 
-var pkey_attr = that.entity.metadata.primary_key;
+var other_entity = IPA.get_entity(that.other_entity);
+var pkey_attr = other_entity.metadata.primary_key;
 
-for (var i=0; iresults.count; i++){
+var results = data.result;
+for (var i=0; iresults.count; i++) {
 var result = results.result[i];
-if (result[pkey_attr] != spec.pkey){
+var pkey = result[pkey_attr][0];
+
+if (that.exclude.indexOf(pkey)  0) {
 that.add_available_value(result);
 }
 }
@@ -207,18 +217,7 @@ IPA.association_adder_dialog = function (spec) {
 }).execute();
 };
 
-/*initialization*/
-function default_columns(spec){
-if (!spec.columns) {
-var pkey_name = IPA.metadata.objects[spec.other_entity].primary_key;
-spec.columns = [{
-name: pkey_name,
-label: IPA.metadata.objects[spec.other_entity].label,
-primary_key: true,
-width: '600px'
-}];
-}
-}
+init();
 
 return that;
 };
@@ -526,7 +525,8 @@ IPA.association_table_widget = function (spec) {
 pkey: pkey,
 other_entity: that.other_entity,
 attribute_member: that.attribute_member,
-method: that.add_method
+method: that.add_method,
+exclude: that.values
 });
 };
 
@@ -963,12 +963,15 @@ IPA.association_facet = function (spec) {
 title = title.replace('${primary_key}', pkey);
 title = title.replace('${other_entity}', label);
 
+var pkeys = that.data[that.get_attribute_name()];
+
 var dialog = IPA.association_adder_dialog({
-'title': title,
-'entity': that.entity,
-'pkey': pkey,
-'other_entity': that.other_entity,
-'attribute_member': that.attribute_member
+title: title,
+entity: that.entity,
+pkey: pkey,
+other_entity: that.other_entity,
+attribute_member: that.attribute_member,
+exclude: pkeys
 });
 
 var adder_columns =