On 03/01/2016 01:37 PM, Pavel Vomacka wrote:
Hi,

The patch adds new field in user add dialog. This combo box lists GIDs
of posix groups
so user can choose one. It is also possible to fill a GID number
which is not in the list.

Link to the ticket: https://fedorahosted.org/freeipa/ticket/5505

--
Pavel^3 Vomacka


1. We can keep default label 'GID' by removing 'label' from spec, which is also used on details page. No need to add a new string.

2. It is hard to pick a group from a list because the only thing administrator see are GID numbers, e.g.,:
  * 330800000
  * 330800002

It would be good to show a group name there or group name + GID
  * admins
  * editors

Reasoning:
a) If admin wants to set arbitrary GID number not manage in IPA, he already knows it and can enter it directly.
b) If he want's to set a specific group then he will search for it by name.

Such change will require a change in combobox widget so that we can specify a label field and a value field. E.g. list will operate with e.g.:
[
   { label: 'admins', value: 330800000 },
   { label: 'editors', value: 330800000 }
]

and not [ 330800000, 330800000 ]

I tried if it is possible to do easily and yes. See attached wippatch. Would be good to check if it breaks anything. If not then we can merge it into your patch.
--
Petr Vobornik
From 4d45c2ea139d7996439c2166265b316589f945b1 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 4 Mar 2016 19:02:47 +0100
Subject: [PATCH] try different value and label field in entity widget

---
 install/ui/src/freeipa/user.js   | 2 +-
 install/ui/src/freeipa/widget.js | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js
index 7583215dbeb9ae7085a4cd6c48648b6705fd141d..a9727f57d69e7126d87707f541786ffab4d0c999 100644
--- a/install/ui/src/freeipa/user.js
+++ b/install/ui/src/freeipa/user.js
@@ -451,11 +451,11 @@ return {
                     {
                         $type: 'entity_select',
                         name: 'gidnumber',
-                        label: '@i18n:objects.user.gidnumber',
                         editable: true,
                         searchable: true,
                         other_entity: 'group',
                         other_field: 'gidnumber',
+                        label_field: 'cn',
                         filter_options: {'posix': true}
                     }
                 ]
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 41d75fe0cd80024f6bb44405456bedc5f3fbca47..fc2d6ef0bf9fd9361a88c9bf7523077739dc615f 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -4299,6 +4299,7 @@ IPA.entity_select_widget = function(spec) {
 
     that.other_entity = IPA.get_entity(spec.other_entity);
     that.other_field = spec.other_field;
+    that.label_field = spec.label_field || spec.other_field;
 
     that.options = spec.options || [];
     that.filter_options = spec.filter_options || {};
@@ -4339,9 +4340,10 @@ IPA.entity_select_widget = function(spec) {
         for (var i=0; i<data.result.count; i++) {
             var entry = entries[i];
             var values = adapter.load(entry, that.other_field);
-            var value = values[0];
+            var label = adapter.load(entry, that.label_field);
+            var option = { label: label[0], value: values[0] };
 
-            options.push(value);
+            options.push(option);
         }
 
         that.set_options(options);
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to