/*jsl:import ipa.js */ /* Authors: * Endi Sukma 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, either version 3 of the License, or * (at your option) any later version. * * 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, see . */ /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ IPA.entity_factories.sudorule = function() { return IPA.entity_builder(). entity('sudorule'). search_facet({ columns:['cn','description','cmdcategory'] }). details_facet({ factory: IPA.sudorule_details_facet }). adder_dialog({ fields:['cn'] }). build(); }; IPA.entity_factories.sudocmd = function() { return IPA.entity_builder(). entity( 'sudocmd'). search_facet({ columns:['sudocmd','description']}). details_facet({sections:[ { name: 'general', label: IPA.messages.details.general, fields:['sudocmd','description'] }, { name: 'groups', label: IPA.messages.objects.sudocmd.groups, factory: IPA.details_section, fields:[{ factory: IPA.sudocmd_member_sudocmdgroup_table_widget, name: 'memberof_sudocmdgroup', label: '',//IPA.messages.objects.sudocmd.groups, other_entity: 'sudocmdgroup', save_values: false, columns:[ { name: 'cn', primary_key: true, width: '150px', link: true }, { name: 'description', width: '150px' } ], adder_columns:[ { name: 'cn', primary_key: true, width: '100px' }, { name: 'description', width: '100px' } ] }] }]}). adder_dialog({ fields:['sudocmd','description'] }). build(); }; IPA.entity_factories.sudocmdgroup = function() { return IPA.entity_builder(). entity('sudocmdgroup'). search_facet({ columns:['cn','description'] }). details_facet({sections:[ { name: 'general', label: IPA.messages.dialogs.general, fields:['cn','description'] }, { name: 'commands', factory: IPA.details_section, fields: [{ factory: IPA.association_table_widget, name: 'member_sudocmd', label: IPA.messages.objects.sudocmdgroup.commands, other_entity: 'sudocmd', save_values: false, columns:[ { name: 'sudocmd', primary_key: true, width: '150px', link: true }, { name: 'description', width: '150px' } ], adder_columns: [ { name: 'sudocmd', primary_key: true, width: '100px' }, { name: 'description', width: '100px' } ] }] }]}). adder_dialog({ fields:['cn','description'] }). build(); }; /* * TODO: user the serial associator to perform back end operations. */ IPA.sudocmd_member_sudocmdgroup_table_widget = function(spec) { spec = spec || {}; var that = IPA.association_table_widget(spec); that.get_records = function(on_success, on_error) { var length = that.values.length; if (!length) return; if (length > 100) { length = 100; } if (!that.values.length) return; var batch = IPA.batch_command({ 'name': that.entity_name+'_'+that.name+'_show', 'on_success': on_success, 'on_error': on_error }); for (var i=0; i= 0) { // prepare command to remove members if needed var attribute = field.name.substring(0, p); var other_entity = field.name.substring(p+1); if (member_operations[attribute] && values.length) { member_operations[attribute].command.set_option(other_entity, values.join(',')); member_operations[attribute].has_values = true; } continue; } // skip unchanged field if (!field.is_dirty()) continue; // check enable/disable if (field.name == 'ipaenabledflag') { if (values[0] == 'FALSE') enable_operation.command.method = 'disable'; enable_operation.execute = true; continue; } if (categories[field.name] && values[0] == 'all') { categories[field.name].remove_values = true; } if (param_info) { if (values.length == 1) { modify_operation.command.set_option(field.name, values[0]); } else if (field.join) { modify_operation.command.set_option(field.name, values.join(',')); } else { modify_operation.command.set_option(field.name, values); } } else { if (values.length) { modify_operation.command.set_option('setattr', field.name+'='+values[0]); } else { modify_operation.command.set_option('setattr', field.name+'='); } for (var k=1; k', { 'style': 'width: 100%;' }).appendTo(container); var param_info = IPA.get_entity_param(that.entity_name, 'cn'); var tr = $('').appendTo(table); var td = $('', { style: 'width: 100px; text-align: right;', html: param_info.label+':', title: param_info ? param_info.doc : 'cn' }).appendTo(tr); td = $('').appendTo(tr); var field = that.get_field('cn'); var span = $('', { name: 'cn', title: param_info ? param_info.doc : 'cn', 'class': 'details-field' }).appendTo(td); $('