Hi,

Please review the attached patch. This patch requires 
pzuna-freeipa-0022-2-BIG.patch.

Should we create a branch in the main repository for this redesign? I
think we will need to make a number of changes before we could merge
this to master. Once the redesigned code is the same level as the old
one we could merge it back to master.

Thanks!

Patch description:

The render_call() signature has been modified to pass the entry_attrs
so each callback function can construct the appropriate quick links
using any attributes from the search results.

The callback function has been implemented for user and group entities.

--
Endi S. Dewata
>From bef6aa95bdfd13d360e4a0420d467915330db833 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edew...@redhat.com>
Date: Tue, 14 Sep 2010 22:26:15 -0400
Subject: [PATCH] Adding quick links in user and group search results.

The render_call() signature has been modified to pass the entry_attrs
so each callback function can construct the appropriate quick links
using any attributes from the search results.

The callback function has been implemented for user and group entities.
---
 install/static/group.js  |   44 ++++++++++++++++++++++++++++++++++
 install/static/search.js |    6 ++--
 install/static/user.js   |   58 +++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 104 insertions(+), 4 deletions(-)

diff --git a/install/static/group.js b/install/static/group.js
index 113c1f1..685c5be 100644
--- a/install/static/group.js
+++ b/install/static/group.js
@@ -24,6 +24,7 @@ ipa_entity_set_search_definition('group', [
     ['cn', 'Name', null],
     ['gidnumber', 'GID', null],
     ['description', 'Description', null],
+    ['actions', 'Actions', group_render_actions]
 ]);
 
 ipa_entity_set_add_definition('group', [
@@ -64,3 +65,46 @@ function f_posix(dlg, mode)
     }
 }
 
+function group_render_actions(tr, attr, value, entry_attrs) {
+
+    var td = $("<td/>");
+    tr.append(td);
+
+    $("<a/>", {
+        href: "jslink",
+        html: "[D]",
+        click: function() {
+            var state = {};
+            state['group-facet'] = 'details';
+            state['group-pkey'] = entry_attrs['cn'][0];
+            $.bbq.pushState(state);
+            return false;
+        }
+    }).appendTo(td);
+
+    $("<a/>", {
+        href: "jslink",
+        html: "[U]",
+        click: function() {
+            var state = {};
+            state['group-facet'] = 'associate';
+            state['group-enroll'] = 'user';
+            state['group-pkey'] = entry_attrs['cn'][0];
+            $.bbq.pushState(state);
+            return false;
+        }
+    }).appendTo(td);
+
+    $("<a/>", {
+        href: "jslink",
+        html: "[N]",
+        click: function() {
+            var state = {};
+            state['group-facet'] = 'associate';
+            state['group-enroll'] = 'netgroup';
+            state['group-pkey'] = entry_attrs['cn'][0];
+            $.bbq.pushState(state);
+            return false;
+        }
+    }).appendTo(td);
+}
diff --git a/install/static/search.js b/install/static/search.js
index 6a7c40b..7347dfc 100644
--- a/install/static/search.js
+++ b/install/static/search.js
@@ -113,9 +113,9 @@ function search_generate_tr(thead, tbody, entry_attrs)
         var value = entry_attrs[attr];
 
         var render_call = window[jobj.attr('title')];
-        if (typeof render_call == 'function')
-            render_call(tr, attr, value);
-        else
+        if (typeof render_call == 'function') {
+            render_call(tr, attr, value, entry_attrs);
+        } else
             search_generate_td(tr, attr, value);
     }
 
diff --git a/install/static/user.js b/install/static/user.js
index a8954be..2d77fac 100644
--- a/install/static/user.js
+++ b/install/static/user.js
@@ -27,7 +27,7 @@ ipa_entity_set_search_definition('user', [
     ['mail', 'EMAIL', null],
     ['telephonenumber', 'Phone', null],
     ['title', 'Job Title', null],
-    ['actions', 'Actions', null]
+    ['actions', 'Actions', user_render_actions]
 ]);
 
 ipa_entity_set_add_definition('user', [
@@ -209,3 +209,59 @@ function a_manager(jobj, result, mode)
 {
 }
 
+function user_render_actions(tr, attr, value, entry_attrs) {
+
+    var td = $("<td/>");
+    tr.append(td);
+
+    $("<a/>", {
+        href: "jslink",
+        html: "[D]",
+        click: function() {
+            var state = {};
+            state['user-facet'] = 'details';
+            state['user-pkey'] = entry_attrs['uid'][0];
+            $.bbq.pushState(state);
+            return false;
+        }
+    }).appendTo(td);
+
+    $("<a/>", {
+        href: "jslink",
+        html: "[G]",
+        click: function() {
+            var state = {};
+            state['user-facet'] = 'associate';
+            state['user-enroll'] = 'group';
+            state['user-pkey'] = entry_attrs['uid'][0];
+            $.bbq.pushState(state);
+            return false;
+        }
+    }).appendTo(td);
+
+    $("<a/>", {
+        href: "jslink",
+        html: "[N]",
+        click: function() {
+            var state = {};
+            state['user-facet'] = 'associate';
+            state['user-enroll'] = 'netgroup';
+            state['user-pkey'] = entry_attrs['uid'][0];
+            $.bbq.pushState(state);
+            return false;
+        }
+    }).appendTo(td);
+
+    $("<a/>", {
+        href: "jslink",
+        html: "[R]",
+        click: function() {
+            var state = {};
+            state['user-facet'] = 'associate';
+            state['user-enroll'] = 'role';
+            state['user-pkey'] = entry_attrs['uid'][0];
+            $.bbq.pushState(state);
+            return false;
+        }
+    }).appendTo(td);
+}
-- 
1.7.2.2

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

Reply via email to