/*jsl:import ipa.js */ /* Authors: * Adam Young * Endi S. Dewata * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; version 2 only * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ IPA.entity_factories.permission = function() { return IPA.entity_builder(). entity('permission'). facet_groups([ 'privilege' , 'settings' ]). search_facet({ columns:['cn'] }). details_facet({sections:[ { name: 'identity', fields: [ { factory: IPA.text_widget, name: 'cn', read_only: true } ] }, { name: 'rights', label: IPA.messages.objects.permission.rights, fields: [ { factory: IPA.rights_widget, name: 'permissions', join: true } ] }, { factory: IPA.target_section, name: 'target', label: IPA.messages.objects.permission.target }]}). association_facet({ name: 'member_privilege', facet_group: 'privilege' }). adder_dialog({ width: 500, height: 400, fields: [ 'cn', { factory: IPA.rights_widget, name: 'permissions', join: true, undo: false }, { factory: IPA.target_section, name: 'target', label: IPA.messages.objects.permission.target, undo: false } ] }). build(); }; IPA.entity_factories.privilege = function() { return IPA.entity_builder(). entity('privilege'). facet_groups([ 'role', 'settings', 'permission' ]). search_facet({ columns:['cn','description']}). details_facet({ sections: [{ name:'identity', label: IPA.messages.details.identity, fields:['cn','description'] }]}). association_facet({ name: 'member_role', facet_group: 'role', add_method: 'add_privilege', remove_method: 'remove_privilege', associator: IPA.serial_associator }). association_facet({ name: 'memberof_permission', facet_group: 'permission', add_method: 'add_permission', remove_method: 'remove_permission' }). standard_association_facets(). adder_dialog({ fields:['cn', 'description'] }). build(); }; IPA.entity_factories.role = function() { return IPA.entity_builder(). entity('role'). facet_groups([ 'member', 'settings', 'privilege' ]). search_facet({ columns:['cn','description']}). details_facet({sections:[ { name:'identity', label:IPA.messages.objects.role.identity, fields:['cn','description']}]}). association_facet({ name: 'memberof_privilege', facet_group: 'privilege', add_method: 'add_privilege', remove_method: 'remove_privilege' }). standard_association_facets(). adder_dialog({ fields:['cn', 'description'] }). build(); }; IPA.entity_factories.selfservice = function() { return IPA.entity_builder(). entity('selfservice'). search_facet({ columns:['aciname']}). details_facet({ sections:[{ name:'general', label: IPA.messages.details.general, fields: [ 'aciname', { factory:IPA.attributes_widget, object_type:'user', name:'attrs' }]}]}). adder_dialog({ fields:[ 'aciname', {factory:IPA.attributes_widget, object_type:'user', name:'attrs', undo: false }] }). build(); }; IPA.entity_factories.delegation = function() { return IPA.entity_builder(). entity('delegation'). search_facet({ columns:['aciname']}). details_facet({sections:[ { name:'general', label: IPA.messages.details.general, fields:[ 'aciname', { factory: IPA.entity_select_widget, name: 'group', other_entity: 'group', other_field: 'cn' }, { factory: IPA.entity_select_widget, name: 'memberof', other_entity: 'group', other_field: 'cn', join: true }, { factory:IPA.attributes_widget, name: 'attrs', object_type: 'user', join: true }]}]}). standard_association_facets(). adder_dialog({ fields:[ 'aciname', { factory: IPA.entity_select_widget, name: 'group', other_entity: 'group', other_field: 'cn', undo: false }, { factory: IPA.entity_select_widget, name: 'memberof', other_entity: 'group', other_field: 'cn', join: true, undo: false }, { factory:IPA.attributes_widget, name: 'attrs', object_type: 'user', join: true, undo: false }] }). build(); }; IPA.attributes_widget = function(spec) { spec = spec || {}; var that = IPA.checkboxes_widget(spec); that.object_type = spec.object_type; var id = spec.name; that.create = function(container) { that.container = container; that.table = $('', { id:id, 'class':'search-table aci-attribute-table' }). append(''). append(''). appendTo(container); var tr = $('').appendTo($('thead', that.table)); tr.append($('').appendTo(table); var td = $('', { style: 'display: none' }).appendTo(table); td = $('
', { style:"height:2em; vertical-align:bottom;", html:$('',{ type: "checkbox", click: function(){ $('.aci-attribute', that.table). attr('checked', $(this).attr('checked')); that.set_dirty(that.test_dirty()); } }) })).append($('', { 'class': 'aci-attribute-column', html: IPA.messages.objects.aci.attribute })); if (that.undo) { that.create_undo(container); that.get_undo().click(function(){ that.reset(); }); } if (that.object_type){ that.populate (that.object_type); } }; that.load = function(record) { that.record = record; that.values = []; var values = record[that.name] || []; for (var i=0; i').appendTo(tbody); var td = $('').appendTo(aci_tr); td.append($('',{ type: 'checkbox', name: that.name, value: value, 'class': 'aci-attribute', click: function() { that.set_dirty(that.test_dirty()); } })); td = $('').appendTo(aci_tr); td.append($('').appendTo(tr); td.append($('', { type: 'checkbox', name: that.name, value: value, 'class': 'aci-attribute', change: function() { that.set_dirty(that.test_dirty()); } })); td = $('').appendTo(tr); td.append($('
', { 'class': 'section-cell-label' }).appendTo(tr); $('', { 'class': 'section-cell-field' }).appendTo(tr); var field_container = $('
', { name: 'target', 'class': 'field' }).appendTo(td); that.target_type_select = $('
', { 'class': 'section-cell-label' }).appendTo(tr); $('', { 'class': 'section-cell-field' }).appendTo(tr); field_container = $('
', { name: target_type.name, title: target_type.label, 'class': 'field' }).appendTo(td); target_type.create(field_container); target_type.container = tr; } }; function reset_target_widgets() { that.filter_text.record = null; that.subtree_textarea.record = null; that.group_select.record = null; that.type_select.record = null; that.attribute_table.record = null; that.filter_text.reset(); that.subtree_textarea.reset(); that.group_select.reset(); that.type_select.reset(); that.attribute_table.reset(); } function set_target_type(record) { reset_target_widgets(); var target_type_name ; for (var i=0; i