https://fedorahosted.org/freeipa/ticket/1883

based on patch edewata-284

Not sure if this patch is the right approach. This logic shouldn't probably be in association dialog as it isn't application independent. Cleaner but more complex would be to make this decision sooner (probably on some metadata/spec information). This all depends on how we want to make the framework flexible.

--
Petr Vobornik
From ac0fd222072d9360ac50dfd2ea7db9c8cdee6c6c Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Tue, 27 Sep 2011 10:00:27 +0200
Subject: [PATCH] Fixed: Enrolment dialog offers to add entity to reflexive
 association.

https://fedorahosted.org/freeipa/ticket/1883

It's a regression introduced by patch for #1797

Reproduce:

 * show user group foo
 * click on user groups tab
 * click on enroll button

Result:
User group 'foo' is listed in available list.

Expected result:
User group 'foo' is not listed in available list.
---
 install/ui/association.js |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/install/ui/association.js b/install/ui/association.js
index 47d8db1739a78fcc385efbb753cec72ad501a672..f2ef11dac63d3f5482c702f68b488e65c9502094 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -180,10 +180,12 @@ IPA.association_adder_dialog = function(spec) {
             var selected = that.get_selected_values();
 
             var results = data.result;
+            var same_entity = that.entity.name === other_entity.name;
             for (var i=0; i<results.count; i++) {
                 var result = results.result[i];
                 var pkey = result[pkey_attr][0];
 
+                if (same_entity && pkey === that.pkey) continue;
                 if (that.exclude.indexOf(pkey) >= 0) continue;
                 if (selected.indexOf(pkey) >= 0) continue;
 
-- 
1.7.6

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

Reply via email to