On 03/04/2016 07:03 PM, Petr Vobornik wrote:
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.
Hi,

thank you for your patch. It's definitely better to see names of groups instead of numbers. Your solution works well.

I merged your patch with mine and the result is attached. I also removed definitions of new string (was used as label) from my first patch .

Pavel^3 Vomacka
>From 553b7388e480123443e1c788daf95228422ed530 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Tue, 1 Mar 2016 12:17:04 +0100
Subject: [PATCH] Add field for group id in user add dialog

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

https://fedorahosted.org/freeipa/ticket/5505
---
 install/ui/src/freeipa/user.js   | 10 ++++++++++
 install/ui/src/freeipa/widget.js |  6 ++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js
index a920e088aacd02585cd131dce725272f47e4cf1c..a9727f57d69e7126d87707f541786ffab4d0c999 100644
--- a/install/ui/src/freeipa/user.js
+++ b/install/ui/src/freeipa/user.js
@@ -447,6 +447,16 @@ return {
                         name: 'noprivate',
                         label: '@i18n:objects.user.noprivate',
                         metadata: '@mc-opt:user_add:noprivate'
+                    },
+                    {
+                        $type: 'entity_select',
+                        name: '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