[PATCH] 186 Add external group

Added new option to group adder dialog for defining external group. Posix group and external group are mutually exclusive.


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

[PATCH] 187 Make group external

New action for creating plain group external. Posix group can't be made external.

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

[PATCH] 188 Make group posix

New option for creating plain user group posix group. External group can't be made posix.

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

[PATCH] 189 Display group type

Added two fields to group details facet to display whether a group is external or posix. The decision is based on group's objectclass.

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

[PATCH] 190 Attribute facet

Created new type of facet: attribute facet. This facet is similar to association facet but it serves for displaying object's multivalued attributes which behaves like association attributes. It will serve as a basis for displaying group's externalmember attribute.

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

[PATCH] 191 Group external member facet

Added 'external' attribute facet to group entity. It serves for displaying group's externalmember attribute.

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

[PATCH] 192 Read-only external facet for non-external groups

Added evaluators to decide if attribute facet should be read-only based on attribute level rights.
Default values serves well for group's external member.

https://fedorahosted.org/freeipa/ticket/2895
--
Petr Vobornik

From c12ffdbbd3121e2577d82398723e5f7848b2eee7 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 30 Jul 2012 13:31:11 +0200
Subject: [PATCH] Add external group

Added new option to group adder dialog for defining external group. Posix group and external group are mutually exclusive.

https://fedorahosted.org/freeipa/ticket/2895
---
 install/ui/group.js                |   21 +++++++++++++++++++++
 install/ui/test/data/ipa_init.json |    1 +
 ipalib/plugins/internal.py         |    1 +
 3 files changed, 23 insertions(+)

diff --git a/install/ui/group.js b/install/ui/group.js
index 5ad9ba1f1d887c1297573a90c209ace00e3f3a86..9bad142809ea8744ddf0561b53e27953859aad53 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -111,6 +111,11 @@ IPA.group.entity = function(spec) {
                     name: 'description'
                 },
                 {
+                    type: 'checkbox',
+                    name: 'external',
+                    label: IPA.messages.objects.group.external
+                },
+                {
                     type: 'nonposix_checkbox',
                     name: 'nonposix',
                     label: IPA.messages.objects.group.posix,
@@ -151,18 +156,34 @@ IPA.group_adder_dialog = function(spec) {
     var init = function() {
 
         var posix_field = that.fields.get_field('nonposix');
+        var external_field = that.fields.get_field('external');
         posix_field.widget.value_changed.attach(that.on_posix_change);
+        external_field.widget.value_changed.attach(that.on_external_change);
     };
 
     that.on_posix_change = function (value) {
 
         var gid_field = that.fields.get_field('gidnumber');
+        var external_field = that.fields.get_field('external');
         if (value[0]) {
             gid_field.reset();
         }
+        external_field.reset();
         gid_field.set_enabled(!value[0]);
     };
 
+    that.on_external_change = function (value) {
+
+        var gid_field = that.fields.get_field('gidnumber');
+        var posix_field = that.fields.get_field('nonposix');
+
+        if (value[0]) {
+            posix_field.widget.update([false]);
+            gid_field.reset();
+            gid_field.set_enabled(false);
+        }
+    };
+
     init();
 
     return that;
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 4325a5552e1205a3839e5830c59af73448785789..111fb88e495b90b477613cc6a4593596b505002e 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -268,6 +268,7 @@
                         },
                         "group": {
                             "details": "Group Settings",
+                            "external": "External",
                             "posix": "POSIX group"
                         },
                         "hbacrule": {
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 08d7a255f322e8391ee81aeaced660363d8078c4..7e046781279ebf140e8447ec8848f9d4c4d50849 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -405,6 +405,7 @@ class i18n_messages(Command):
             },
             "group": {
                 "details": _("Group Settings"),
+                "external": _("External"),
                 "posix": _("POSIX group"),
             },
             "hbacrule": {
-- 
1.7.10.4

From e4bbd554110dc24bcc3dea1c51debc3e184219c0 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 30 Jul 2012 14:30:31 +0200
Subject: [PATCH] Make group external

New action for creating plain group external. Posix group can't be made external.

https://fedorahosted.org/freeipa/ticket/2895
---
 install/ui/details.js                |   29 +++++++++++++++++++++++++++++
 install/ui/group.js                  |   29 ++++++++++++++++++++++++++++-
 install/ui/test/data/group_show.json |    8 ++++++++
 install/ui/test/data/ipa_init.json   |    1 +
 ipalib/plugins/internal.py           |    1 +
 5 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/install/ui/details.js b/install/ui/details.js
index e652fa3e5f31f921aab8b324c67c77169ec597b6..0530592d71592e0caeae33cdd279873d82fb647c 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -1068,6 +1068,33 @@ IPA.value_state_evaluator = function(spec) {
     return that;
 };
 
+IPA.object_class_evaluator = function(spec) {
+
+    spec.name = spec.name || 'object_class_evaluator';
+    spec.event = spec.event || 'post_load';
+
+    var that = IPA.state_evaluator(spec);
+
+
+    that.on_event = function(data) {
+
+        var old_state, classes, i;
+
+        old_state = that.state;
+        classes = data.result.result.objectclass;
+
+        that.state = [];
+
+        for (i=0; i<classes.length; i++) {
+            that.state.push('oc_'+classes[i]);
+        }
+
+        that.notify_on_change(old_state);
+    };
+
+    return that;
+};
+
 IPA.object_action = function(spec) {
 
     spec = spec || {};
@@ -1076,6 +1103,7 @@ IPA.object_action = function(spec) {
 
     that.method = spec.method;
     that.confirm_msg = spec.confirm_msg || IPA.messages.actions.confirm;
+    that.options = spec.options || {};
 
     that.execute_action = function(facet, on_success, on_error) {
 
@@ -1088,6 +1116,7 @@ IPA.object_action = function(spec) {
             entity: entity_name,
             method: that.method,
             args: [pkey],
+            options: that.options,
             on_success: that.get_on_success(facet, on_success),
             on_error: that.get_on_error(facet, on_error)
         }).execute();
diff --git a/install/ui/group.js b/install/ui/group.js
index 9bad142809ea8744ddf0561b53e27953859aad53..134f4f21ab588ab3c31566c6db9002c4f9e7d1e0 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -53,7 +53,18 @@ IPA.group.entity = function(spec) {
                         'gidnumber'
                     ]
                 }
-            ]
+            ],
+            actions: [
+                IPA.select_action,
+                IPA.group.make_external_action,
+                IPA.delete_action
+            ],
+            header_actions: ['select_action', 'make_external', 'delete'],
+            state: {
+                evaluators: [
+                    IPA.object_class_evaluator
+                ]
+            }
         }).
         association_facet({
             name: 'member_user',
@@ -189,4 +200,20 @@ IPA.group_adder_dialog = function(spec) {
     return that;
 };
 
+IPA.group.make_external_action = function(spec) {
+
+    spec = spec || {};
+    spec.name = spec.name || 'make_external';
+    spec.method = spec.method || 'mod';
+    spec.label = spec.label || IPA.messages.objects.group.make_external;
+    spec.disable_cond = spec.disable_cond || ['oc_posixgroup','oc_ipaexternalgroup'];
+    spec.options = spec.options || {
+        external: true
+    };
+
+    var that = IPA.object_action(spec);
+
+    return that;
+};
+
 IPA.register('group', IPA.group.entity);
diff --git a/install/ui/test/data/group_show.json b/install/ui/test/data/group_show.json
index 4ac6e0c06dc6259ea6c0f10f56886013998884c0..136f8f0e721dcdadd9dd700ee3fa553a9056b012 100644
--- a/install/ui/test/data/group_show.json
+++ b/install/ui/test/data/group_show.json
@@ -264,6 +264,14 @@
             ],
             "memberof_group": [
                 "editors"
+            ],
+            "objectclass": [
+                "top",
+                "groupofnames",
+                "nestedgroup",
+                "ipausergroup",
+                "ipaobject",
+                "posixgroup"
             ]
         },
         "summary": null,
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 111fb88e495b90b477613cc6a4593596b505002e..1a8b45eca8625ea860513cbed5bd70a1de05ba99 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -269,6 +269,7 @@
                         "group": {
                             "details": "Group Settings",
                             "external": "External",
+                            "make_external": "Change to external group",
                             "posix": "POSIX group"
                         },
                         "hbacrule": {
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 7e046781279ebf140e8447ec8848f9d4c4d50849..1f022fe238a2ab5dd59bf1c29cef28a850153c60 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -406,6 +406,7 @@ class i18n_messages(Command):
             "group": {
                 "details": _("Group Settings"),
                 "external": _("External"),
+                "make_external": _("Change to external group"),
                 "posix": _("POSIX group"),
             },
             "hbacrule": {
-- 
1.7.10.4

From 9c9650826b3bc83e9d415d9fb507da8d3ec6d747 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 30 Jul 2012 14:32:54 +0200
Subject: [PATCH] Make group posix

New option for creating plain user group posix group. External group can't be made posix.

https://fedorahosted.org/freeipa/ticket/2338
---
 install/ui/group.js                |   19 ++++++++++++++++++-
 install/ui/test/data/ipa_init.json |    1 +
 ipalib/plugins/internal.py         |    1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/install/ui/group.js b/install/ui/group.js
index 134f4f21ab588ab3c31566c6db9002c4f9e7d1e0..c626bbb49e45c01da9439331e904eab82566a886 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -56,10 +56,11 @@ IPA.group.entity = function(spec) {
             ],
             actions: [
                 IPA.select_action,
+                IPA.group.make_posix_action,
                 IPA.group.make_external_action,
                 IPA.delete_action
             ],
-            header_actions: ['select_action', 'make_external', 'delete'],
+            header_actions: ['select_action', 'make_posix', 'make_external', 'delete'],
             state: {
                 evaluators: [
                     IPA.object_class_evaluator
@@ -200,6 +201,22 @@ IPA.group_adder_dialog = function(spec) {
     return that;
 };
 
+IPA.group.make_posix_action = function(spec) {
+
+    spec = spec || {};
+    spec.name = spec.name || 'make_posix';
+    spec.method = spec.method || 'mod';
+    spec.label = spec.label || IPA.messages.objects.group.make_posix;
+    spec.disable_cond = spec.disable_cond || ['oc_posixgroup', 'oc_ipaexternalgroup'];
+    spec.options = spec.options || {
+        posix: true
+    };
+
+    var that = IPA.object_action(spec);
+
+    return that;
+};
+
 IPA.group.make_external_action = function(spec) {
 
     spec = spec || {};
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 1a8b45eca8625ea860513cbed5bd70a1de05ba99..08f06dc7e0d70e21a9a3f3ee7f68c530d8c5c62a 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -270,6 +270,7 @@
                             "details": "Group Settings",
                             "external": "External",
                             "make_external": "Change to external group",
+                            "make_posix": "Change to posix group",
                             "posix": "POSIX group"
                         },
                         "hbacrule": {
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 1f022fe238a2ab5dd59bf1c29cef28a850153c60..7cf335a568ba66c4c5dad1d97990d87765c8847a 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -407,6 +407,7 @@ class i18n_messages(Command):
                 "details": _("Group Settings"),
                 "external": _("External"),
                 "make_external": _("Change to external group"),
+                "make_posix": _("Change to posix group"),
                 "posix": _("POSIX group"),
             },
             "hbacrule": {
-- 
1.7.10.4

From 44c9c46345caca4fdbe9759e2dc0c10c69ba623c Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 30 Jul 2012 15:12:07 +0200
Subject: [PATCH] Display group type

Added two fields to group details facet to display whether a group is external or posix. The decision is based on group's objectclass.

https://fedorahosted.org/freeipa/ticket/2895
---
 install/ui/field.js  |   19 ++++++++++---------
 install/ui/group.js  |   14 ++++++++++++++
 install/ui/widget.js |   39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+), 9 deletions(-)

diff --git a/install/ui/field.js b/install/ui/field.js
index fb292ff2a6c5fb29b84262236fd5be2c7c7f7e42..d24e2b58a57d5766862c837307c0683479dc02ab 100644
--- a/install/ui/field.js
+++ b/install/ui/field.js
@@ -911,17 +911,18 @@ IPA.field_builder = function(spec) {
     return that;
 };
 
-IPA.field_factories['field'] = IPA.field;
-IPA.field_factories['text'] = IPA.field;
-IPA.field_factories['password'] = IPA.field;
 IPA.field_factories['checkbox'] = IPA.checkbox_field;
 IPA.field_factories['checkboxes'] = IPA.checkboxes_field;
-IPA.field_factories['radio'] = IPA.radio_field;
+IPA.field_factories['combobox'] = IPA.combobox_field;
+IPA.field_factories['enable'] = IPA.enable_field;
+IPA.field_factories['entity_select'] = IPA.combobox_field;
+IPA.field_factories['field'] = IPA.field;
+IPA.field_factories['link'] = IPA.link_field;
 IPA.field_factories['multivalued'] = IPA.multivalued_field;
+IPA.field_factories['password'] = IPA.field;
+IPA.field_factories['radio'] = IPA.radio_field;
 IPA.field_factories['select'] = IPA.select_field;
+IPA.field_factories['sshkeys'] = IPA.sshkeys_field;
 IPA.field_factories['textarea'] = IPA.field;
-IPA.field_factories['entity_select'] = IPA.combobox_field;
-IPA.field_factories['combobox'] = IPA.combobox_field;
-IPA.field_factories['link'] = IPA.link_field;
-IPA.field_factories['enable'] = IPA.enable_field;
-IPA.field_factories['sshkeys'] = IPA.sshkeys_field;
\ No newline at end of file
+IPA.field_factories['text'] = IPA.field;
+IPA.field_factories['value_status'] = IPA.field;
\ No newline at end of file
diff --git a/install/ui/group.js b/install/ui/group.js
index c626bbb49e45c01da9439331e904eab82566a886..696ee9efb15f310d54a1023362c615ce50171637 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -50,6 +50,20 @@ IPA.group.entity = function(spec) {
                             type: 'textarea',
                             name: 'description'
                         },
+                        {
+                            type: 'value_status',
+                            name: 'external',
+                            param: 'objectclass',
+                            label: IPA.messages.objects.group.external,
+                            value: 'ipaexternalgroup'
+                        },
+                        {
+                            type: 'value_status',
+                            name: 'posix',
+                            param: 'objectclass',
+                            label: IPA.messages.objects.group.posix,
+                            value: 'posixgroup'
+                        },
                         'gidnumber'
                     ]
                 }
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 9b15f2f1b236c1dd4dae027272664c7178218d97..97158ca1710895fd5248410520062a2dbde9fa0b 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -3487,6 +3487,44 @@ IPA.action_panel = function(spec) {
     return that;
 };
 
+IPA.value_status_widget = function(spec) {
+
+    spec = spec  || {};
+    spec.read_only = true;
+
+    var that = IPA.input_widget(spec);
+    that.true_msg = spec.true_msg || IPA.messages['true'];
+    that.false_msg = spec.false_msg || IPA.messages['false'];
+    that.value = spec.value;
+
+    that.create = function(container) {
+        that.widget_create(container);
+        container.addClass('status-widget');
+
+        that.display_control = $('<span/>', {
+            name: that.name
+        }).appendTo(container);
+    };
+
+    that.update = function(values) {
+
+        var value;
+
+        if ($.isArray(values) && values.indexOf(that.value) > -1) {
+            value = that.true_msg;
+        } else {
+            value = that.false_msg;
+        }
+
+        that.display_control.text(value);
+    };
+
+    that.clear = function() {
+        that.display_control.text('');
+    };
+
+    return that;
+};
 
 IPA.widget_factories['attribute_table'] = IPA.attribute_table_widget;
 IPA.widget_factories['button'] = IPA.button_widget;
@@ -3509,3 +3547,4 @@ IPA.widget_factories['select'] = IPA.select_widget;
 IPA.widget_factories['sshkeys'] = IPA.sshkeys_widget;
 IPA.widget_factories['textarea'] = IPA.textarea_widget;
 IPA.widget_factories['text'] = IPA.text_widget;
+IPA.widget_factories['value_status'] = IPA.value_status_widget;
\ No newline at end of file
-- 
1.7.10.4

From ab457a17f333c7352c1cd7a41bb912416896ffa3 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Thu, 2 Aug 2012 17:37:12 +0200
Subject: [PATCH] Attribute facet

Created new type of facet: attribute facet. This facet is similar to association facet but it serves for displaying object's multivalued attributes which behaves like association attributes. It will serve as a basis for displaying group's externalmember attribute.

https://fedorahosted.org/freeipa/ticket/2895
---
 install/ui/add.js         |    5 +-
 install/ui/association.js |  255 ++++++++++++++++++++++++++++++++++++++++++++-
 install/ui/entity.js      |    9 ++
 install/ui/facet.js       |   16 ++-
 4 files changed, 276 insertions(+), 9 deletions(-)

diff --git a/install/ui/add.js b/install/ui/add.js
index 4ca0f04182f37e56b5e47e7fb84de1d4bc485ea0..caa1ab5a0b13e43c8c8988cec027707d45d72333 100644
--- a/install/ui/add.js
+++ b/install/ui/add.js
@@ -36,6 +36,7 @@ IPA.entity_adder_dialog = function(spec) {
     that.retry = typeof spec.retry !== 'undefined' ? spec.retry : true;
     that.command = null;
     that.added = IPA.observer();
+    that.subject = spec.subject || that.entity.metadata.label_singular;
 
     that.show_edit_page = spec.show_edit_page || show_edit_page;
 
@@ -64,9 +65,8 @@ IPA.entity_adder_dialog = function(spec) {
                 that.add(
                     function(data, text_status, xhr) {
                         that.added.notify();
-                        var label = that.entity.metadata.label_singular;
                         var message = IPA.messages.dialogs.add_confirmation;
-                        message = message.replace('${entity}', label);
+                        message = message.replace('${entity}', that.subject);
                         that.show_message(message);
 
                         var facet = IPA.current_entity.get_facet();
@@ -184,4 +184,3 @@ IPA.entity_adder_dialog = function(spec) {
 
     return that;
 };
-
diff --git a/install/ui/association.js b/install/ui/association.js
index be8b8459dded9b024e5d998311eab62c70e57756..a30ca53281e5d0a8ef120adff91ea5399f34a056 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -50,8 +50,8 @@ IPA.associator = function (spec) {
 
 
 /**
-*This associator is built for the case where each association requires a separate rpc
-*/
+ * This associator is built for the case where each association requires a separate rpc
+ */
 IPA.serial_associator = function(spec) {
 
     spec = spec || {};
@@ -95,9 +95,9 @@ IPA.serial_associator = function(spec) {
 };
 
 /**
-*This associator is for the common case where all the asociations can be sent
-in a single rpc
-*/
+ * This associator is for the common case where all the asociations can be sent
+ * in a single rpc
+ */
 IPA.bulk_associator = function(spec) {
 
     spec = spec || {};
@@ -131,6 +131,50 @@ IPA.bulk_associator = function(spec) {
 };
 
 /**
+ * This dialog is for adding value of multivalued attribute which behaves like
+ * association attribute.
+ */
+IPA.attribute_adder_dialog = function(spec) {
+
+    spec = spec || {};
+
+    spec.name = spec.name || 'attr_adder_dialog';
+    spec.method = spec.method || 'add_member';
+
+    var metadata = IPA.get_command_option(spec.entity.name+'_'+spec.method, spec.attribute);
+
+    spec.fields = spec.fields || [
+        {
+            name: spec.attribute,
+            metadata: metadata,
+            required: true
+        }
+    ];
+    spec.title = spec.title || IPA.messages.dialogs.add_title.replace('${entity}', metadata.label);
+    spec.subject = metadata.label;
+
+    var that = IPA.entity_adder_dialog(spec);
+
+    that.create_add_command = function(record) {
+
+        var command = that.entity_adder_dialog_create_add_command(record);
+
+        command.add_args(that.entity.get_primary_key());
+
+        return command;
+    };
+
+    that.create_buttons = function() {
+
+        that.buttons.remove('add_and_edit');
+    };
+
+    that.create_buttons();
+
+    return that;
+};
+
+/**
  * This dialog is used for adding associations between two entities.
  */
 IPA.association_adder_dialog = function(spec) {
@@ -1093,3 +1137,204 @@ IPA.association_facet = function (spec, no_init) {
 
     return that;
 };
+
+IPA.attribute_facet = function(spec, no_init) {
+
+    spec = spec || {};
+
+    //default buttons and their actions
+    spec.actions = spec.actions || [];
+    spec.actions.unshift(
+        IPA.refresh_action,
+        {
+            name: 'remove',
+            hide_cond: ['read-only'],
+            enable_cond: ['item-selected'],
+            handler: function(facet) {
+                facet.show_remove_dialog();
+            }
+        },
+        {
+            name: 'add',
+            hide_cond: ['read-only'],
+            handler: function(facet) {
+                facet.show_add_dialog();
+            }
+        }
+    );
+
+    spec.control_buttons = spec.control_buttons || [];
+    spec.control_buttons.unshift(
+        {
+            name: 'refresh',
+            label: IPA.messages.buttons.refresh,
+            icon: 'reset-icon'
+        },
+        {
+            name: 'remove',
+            label: IPA.messages.buttons.remove,
+            icon: 'remove-icon'
+        },
+        {
+            name: 'add',
+            label: IPA.messages.buttons.add,
+            icon: 'add-icon'
+        });
+
+    spec.state = spec.state || {};
+    spec.state.evaluators = spec.state.evaluators || [];
+    spec.state.evaluators.push(
+        IPA.selected_state_evaluator,
+        IPA.read_only_state_evaluator);
+
+    spec.columns = spec.columns || [ spec.attribute ];
+    spec.table_name = spec.table_name || spec.attribute;
+
+    var that = IPA.table_facet(spec, true);
+
+    that.attribute = spec.attribute;
+
+    that.add_method = spec.add_method || 'add_member';
+    that.remove_method = spec.remove_method || 'remove_member';
+
+    that.create_header = function(container) {
+
+        that.facet_create_header(container);
+        that.create_control_buttons(that.controls);
+    };
+
+    that.show = function() {
+        that.facet_show();
+
+        that.pkey = IPA.nav.get_state(that.entity.name+'-pkey');
+        that.header.set_pkey(that.pkey);
+    };
+
+    that.get_records_map = function(data) {
+
+        var records_map = $.ordered_map();
+        var pkeys = data.result.result[that.attribute];
+
+        for (var i=0; pkeys && i<pkeys.length; i++) {
+            var pkey = pkeys[i];
+            var record = {};
+            record[that.attribute] = pkey;
+            records_map.put(pkey, record);
+        }
+
+        return records_map;
+    };
+
+    that.refresh = function() {
+
+        var pkey = that.entity.get_primary_key();
+
+        var command = IPA.command({
+            entity: that.entity.name,
+            method: 'show',
+            args: pkey
+        });
+
+        command.on_success = function(data, text_status, xhr) {
+            that.load(data);
+            that.show_content();
+        };
+
+        command.on_error = function(xhr, text_status, error_thrown) {
+            that.redirect_error(error_thrown);
+            that.report_error(error_thrown);
+        };
+
+        command.execute();
+    };
+
+    that.clear = function() {
+        that.header.clear();
+        that.table.clear();
+    };
+
+    that.needs_update = function() {
+        if (that._needs_update !== undefined) return that._needs_update;
+
+        var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
+        if (that.pkey !== pkey) return true;
+
+        var page = parseInt(IPA.nav.get_state(that.entity.name+'-page'), 10) || 1;
+        if (that.table.current_page !== page) return true;
+
+        return that.facet_needs_update();
+    };
+
+    that.show_add_dialog = function() {
+
+        var dialog = IPA.attribute_adder_dialog({
+            attribute: spec.attribute,
+            entity: that.entity
+        });
+
+        dialog.open(that.container);
+    };
+
+    that.show_remove_dialog = function() {
+
+        var selected_values = that.get_selected_values();
+
+        if (!selected_values.length) {
+            var message = IPA.messages.dialogs.remove_empty;
+            alert(message);
+            return;
+        }
+
+        var dialog = IPA.deleter_dialog({
+            entity: that.entity,
+            values: selected_values
+        });
+
+        dialog.execute = function() {
+            that.remove(
+                selected_values,
+                function(data) {
+                    that.load(data);
+                    that.show_content();
+                    dialog.close();
+                },
+                function() {
+                    that.refresh();
+                    dialog.close();
+                }
+            );
+        };
+
+
+        dialog.open(that.container);
+    };
+
+    that.remove = function(values, on_success, on_error) {
+
+        var pkey = that.entity.get_primary_key();
+
+        var command = IPA.command({
+            entity: that.entity.name,
+            method: that.remove_method,
+            args: pkey,
+            on_success: on_success,
+            on_error: on_error
+        });
+
+        command.set_option(that.attribute, values);
+
+        command.execute();
+    };
+
+
+    that.init_attribute_facet = function() {
+
+        that.init_facet();
+        that.init_table_columns();
+        that.init_table(that.entity);
+    };
+
+    if (!no_init) that.init_attribute_facet();
+
+    return that;
+};
\ No newline at end of file
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 49f30b0b2fb6e7c094409580011a11fb902ef369..d474ad95b4ce49bfa98d0b01336781797f2fe2e7 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -420,6 +420,15 @@ IPA.entity_builder = function() {
         return that;
     };
 
+    that.attribute_facet = function(spec) {
+
+        spec.type = spec.type || 'attribute';
+
+        that.facet(spec);
+
+        return that;
+    };
+
     that.standard_association_facets = function(spec) {
 
         spec = spec || {};
diff --git a/install/ui/facet.js b/install/ui/facet.js
index 3f6d559eaf01082427baebace384fa2e6f4dc345..267fc3332e696b676896b2f16eb50f3eb61d0e41 100644
--- a/install/ui/facet.js
+++ b/install/ui/facet.js
@@ -747,6 +747,8 @@ IPA.table_facet = function(spec, no_init) {
     that.row_disabled_attribute = spec.row_disabled_attribute;
     that.details_facet_name = spec.details_facet || 'default';
 
+    that.table_name = spec.table_name;
+
     that.columns = $.ordered_map();
 
     that.get_columns = function() {
@@ -1003,7 +1005,7 @@ IPA.table_facet = function(spec, no_init) {
 
         that.table = IPA.table_widget({
             'class': 'content-table',
-            name: entity.metadata.primary_key,
+            name: that.table_name || entity.metadata.primary_key,
             label: entity.metadata.label,
             entity: entity,
             pagination: true,
@@ -1125,6 +1127,7 @@ IPA.facet_builder = function(entity) {
         that.prepare_methods.nested_search = that.prepare_nested_search_spec;
         that.prepare_methods.details = that.prepare_details_spec;
         that.prepare_methods.association = that.prepare_association_spec;
+        that.prepare_methods.attribute = that.prepare_attribute_spec;
     }
 
     that.build_facets = function() {
@@ -1195,6 +1198,17 @@ IPA.facet_builder = function(entity) {
         return spec;
     };
 
+    that.prepare_attribute_spec = function(spec) {
+        spec.title = spec.title || entity.metadata.label_singular;
+        spec.label = spec.label || entity.metadata.label_singular;
+
+        var attr_metadata = IPA.get_entity_param(entity.name, spec.attribute);
+        spec.tab_label = spec.tab_label || attr_metadata.label;
+        spec.factory = spec.factory || IPA.attribute_facet;
+
+        return spec;
+    };
+
     that.prepare_association_spec = function(spec) {
 
         spec.entity = entity;
-- 
1.7.10.4

From 3cab0bbf822a41c95725ee8b9d508c21179c8949 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Thu, 2 Aug 2012 17:37:44 +0200
Subject: [PATCH] Group external member facet

Added 'external' attribute facet to group entity. It serves for displaying group's externalmember attribute.

https://fedorahosted.org/freeipa/ticket/2895
---
 install/ui/group.js |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/install/ui/group.js b/install/ui/group.js
index 696ee9efb15f310d54a1023362c615ce50171637..414b2f07677994925f31db45d54fefbe3e0ade08 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -101,6 +101,21 @@ IPA.group.entity = function(spec) {
                     width: '100px'
                 }
             ]
+        }).
+        association_facet({
+            name: 'member_group'
+        }).
+        attribute_facet({
+            name: 'member_external',
+            attribute: 'ipaexternalmember',
+            tab_label: 'External',
+            facet_group: 'member',
+            columns: [
+                {
+                    name: 'ipaexternalmember',
+                    label: IPA.get_command_option('group_add_member', 'ipaexternalmember').label
+                }
+            ]
 
         }).
         association_facet({
-- 
1.7.10.4

From b6e5b8f3824677a4eef0235fa104be2fd8ae452a Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 3 Aug 2012 13:39:25 +0200
Subject: [PATCH] Read-only external facet for non-external groups

Added evaluators to decide if attribute facet should be read-only based on attribute level rights.
Default values serves well for group's external member.

https://fedorahosted.org/freeipa/ticket/2895
---
 install/ui/association.js |   52 ++++++++++++++++++++++++++++++++++++++++++++-
 install/ui/ipa.js         |    6 ++++++
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/install/ui/association.js b/install/ui/association.js
index a30ca53281e5d0a8ef120adff91ea5399f34a056..bb10387a51cd8081147eb6acd02b3b0587f30e56 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -1185,7 +1185,11 @@ IPA.attribute_facet = function(spec, no_init) {
     spec.state.evaluators = spec.state.evaluators || [];
     spec.state.evaluators.push(
         IPA.selected_state_evaluator,
-        IPA.read_only_state_evaluator);
+        IPA.read_only_state_evaluator,
+        {
+            factory: IPA.attr_read_only_evaluator,
+            attribute: spec.attribute
+        });
 
     spec.columns = spec.columns || [ spec.attribute ];
     spec.table_name = spec.table_name || spec.attribute;
@@ -1235,6 +1239,13 @@ IPA.attribute_facet = function(spec, no_init) {
             args: pkey
         });
 
+        if (command.check_option('all')) {
+            command.set_option('all', true);
+        }
+        if (command.check_option('rights')) {
+            command.set_option('rights', true);
+        }
+
         command.on_success = function(data, text_status, xhr) {
             that.load(data);
             that.show_content();
@@ -1323,6 +1334,13 @@ IPA.attribute_facet = function(spec, no_init) {
 
         command.set_option(that.attribute, values);
 
+        if (command.check_option('all')) {
+            command.set_option('all', true);
+        }
+        if (command.check_option('rights')) {
+            command.set_option('rights', true);
+        }
+
         command.execute();
     };
 
@@ -1337,4 +1355,36 @@ IPA.attribute_facet = function(spec, no_init) {
     if (!no_init) that.init_attribute_facet();
 
     return that;
+};
+
+IPA.attr_read_only_evaluator = function(spec) {
+
+    spec.name = spec.name || 'attr_read_only_evaluator';
+    spec.event = spec.event || 'post_load';
+
+    var that = IPA.state_evaluator(spec);
+    that.attribute = spec.attribute;
+
+    that.on_event = function(data) {
+
+        var old_state, record, rights, i, state;
+
+        old_state = that.state;
+        record = data.result.result;
+
+        // ignore loads without --rights
+        if (!record.attributelevelrights) return;
+
+        that.state = [];
+
+        rights = record.attributelevelrights[that.attribute];
+
+        if (!rights || rights.indexOf('w') === -1) {
+            that.state.push('read-only');
+        }
+
+        that.notify_on_change(old_state);
+    };
+
+    return that;
 };
\ No newline at end of file
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 8a690c98447ab1dd3d4e704f068ab7e1b62b1227..92cd1dfd3ac344169de55756788f6028a1876bf2 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -833,6 +833,12 @@ IPA.command = function(spec) {
         return errors;
     };
 
+    that.check_option = function(option_name) {
+
+        var metadata = IPA.get_command_option(that.get_command(), option_name);
+        return metadata !== null;
+    };
+
     that.to_json = function() {
         var json = {};
 
-- 
1.7.10.4

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

Reply via email to