diff --git a/management/univention-management-console-module-udm/umc/js/udm/DetailPage.js b/management/univention-management-console-module-udm/umc/js/udm/DetailPage.js index e6602d9..c843e70 100644 --- a/management/univention-management-console-module-udm/umc/js/udm/DetailPage.js +++ b/management/univention-management-console-module-udm/umc/js/udm/DetailPage.js @@ -49,6 +49,7 @@ define([ "umc/widgets/ComboBox", "umc/widgets/Form", "umc/widgets/Page", + "umc/widgets/LinkList", "umc/widgets/StandbyMixin", "umc/widgets/TabController", "dijit/layout/StackContainer", @@ -62,7 +63,7 @@ define([ "umc/i18n!umc/modules/udm", "dijit/registry", "umc/widgets" -], function(declare, lang, array, on, Deferred, all, when, construct, domClass, topic, json, TitlePane, render, tools, dialog, ContainerWidget, MultiInput, ComboBox, Form, Page, StandbyMixin, TabController, StackContainer, Text, Button, LabelPane, Template, OverwriteLabel, UMCPBundle, cache, _ ) { +], function(declare, lang, array, on, Deferred, all, when, construct, domClass, topic, json, TitlePane, render, tools, dialog, ContainerWidget, MultiInput, ComboBox, Form, Page, LinkList, StandbyMixin, TabController, StackContainer, Text, Button, LabelPane, Template, OverwriteLabel, UMCPBundle, cache, _ ) { var _StandbyPage = declare([Page, StandbyMixin], {}); @@ -443,6 +444,28 @@ define([ })); }, + _renderReferencingObjectsTab: function(loadedDeferred) { + when(this.ldapName, lang.hitch(this, function() { + this._referencingObjectsTab = new Page({ + title: _('Referencing objects'), + noFooter: true, + headerText: _('Objects referencing this %s', this.objectNameSingular) + }); + loadedDeferred.then(lang.hitch(this, '_createReferencingObjects')); + })); + }, + + _createReferencingObjects: function() { + if (!this.ldapName || !this._receivedObjOrigData.$references$ || !this._receivedObjOrigData.$references$.length) { + return; + } + this._addSubTab(this._referencingObjectsTab, 1); + var referencingObjects = new LinkList({ + staticValues: this._receivedObjOrigData.$references$ + }); + this._referencingObjectsTab.addChild(referencingObjects); + }, + _renderPolicyTab: function(policies) { this._policyWidgets = {}; if (policies && policies.length) { @@ -1022,7 +1045,8 @@ define([ })); }, - _addSubTab: function(page) { + _addSubTab: function(page, index) { + index = index || this._tabs.getChildren().length; var tabController = new TabController({ region: 'nav', containerId: this._tabs.id, @@ -1037,7 +1061,7 @@ define([ page.addChild(page.position_text); page.own(page.position_text); - this._tabs.addChild(page); + this._tabs.addChild(page, index); this.own(page); }, @@ -1118,6 +1142,7 @@ define([ this._autoUpdateTabTitle(widgets); this._renderSubTabs(widgets, layout, metaInfo).then(lang.hitch(this, function() { this._renderPolicyTab(policies); + this._renderReferencingObjectsTab(loadedDeferred); this._renderForm(widgets); this._renderMultiEditCheckBoxes(widgets); this._registerOptionWatchHandler(); diff --git a/management/univention-management-console-module-udm/umc/python/udm/__init__.py b/management/univention-management-console-module-udm/umc/python/udm/__init__.py index e605cc2..27cf8f3 100644 --- a/management/univention-management-console-module-udm/umc/python/udm/__init__.py +++ b/management/univention-management-console-module-udm/umc/python/udm/__init__.py @@ -481,6 +481,7 @@ def _thread(request): props['$labelObjectType$'] = module.title props['$flags$'] = obj.oldattr.get('univentionObjectFlag', []) props['$operations$'] = module.operations + props['$references$'] = module.get_references(ldap_dn) result.append(props) else: MODULE.process('The LDAP object for the LDAP DN %s could not be found' % ldap_dn) diff --git a/management/univention-management-console-module-udm/umc/python/udm/udm_ldap.py b/management/univention-management-console-module-udm/umc/python/udm/udm_ldap.py index 8514388..15bdd8d 100644 --- a/management/univention-management-console-module-udm/umc/python/udm/udm_ldap.py +++ b/management/univention-management-console-module-udm/umc/python/udm/udm_ldap.py @@ -32,7 +32,6 @@ # . import sys -import copy import re import threading import gc @@ -46,7 +45,6 @@ from univention.management.console.log import MODULE import univention.admin as udm -import univention.admin.layout as udm_layout import univention.admin.modules as udm_modules import univention.admin.objects as udm_objects import univention.admin.syntax as udm_syntax @@ -55,6 +53,7 @@ from .syntax import widget, default_value from ldap import LDAPError, NO_SUCH_OBJECT +from ldap.filter import filter_format try: import univention.admin.license @@ -633,15 +632,6 @@ def is_policy_module(self): def get_layout(self, ldap_dn=None): """Layout information""" layout = getattr(self.module, 'layout', []) - if ldap_dn is not None: - mod = get_module(None, ldap_dn) - if mod is not None and self.name == mod.name and self.is_policy_module(): - layout = copy.copy(layout) - tab = udm_layout.Tab(_('Referencing objects'), _('Objects referencing this policy object'), - layout=['_view_referencing_objects'] - ) - layout.append(tab) - if layout and isinstance(layout[0], udm.tab): return self._parse_old_layout(layout) @@ -695,34 +685,6 @@ def _scanLayout(_layout): if iprop['id'] in inLayout: properties.append(iprop) - if ldap_dn: - # hack reference list for policies into items - if self.is_policy_module(): - # create syntax object - syntax = udm_syntax.LDAP_Search( - filter='(&(objectClass=univentionPolicyReference)(univentionPolicyReference=%s))' % ldap_dn, - viewonly=True) - - # create item - item = { - 'id': '_view_referencing_objects', - 'label': '', - 'description': '', - 'syntax': syntax.name, - 'size': syntax.size, - 'required': False, - 'editable': False, - 'options': [], - 'readonly': False, - 'searchable': False, - 'multivalue': True, - 'identifies': False, - } - - # read UCR configuration - item.update(widget(syntax, item)) - properties.append(item) - return properties @property @@ -874,6 +836,12 @@ def policies(self): return policies + def get_references(self, dn): + if self.is_policy_module(): # TODO: move into the handlers/policies/*.py + search_filter = filter_format("(&(objectClass=univentionPolicyReference)(univentionPolicyReference=%s))", (dn,)) + return read_syntax_choices(udm_syntax.LDAP_Search(filter=search_filter, viewonly=True)) + return [] + def types4superordinate(self, flavor, superordinate): """List of object types for the given superordinate""" types = getattr(self.module, 'wizardtypesforsuper')