/*jsl:import ipa.js */ /* Authors: * Petr Vobornik * * Copyright (C) 2012 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, facet.js, entity.js */ IPA.automember = {}; IPA.automember.entity = function(spec) { //HACK: Automember takes_params is missing a cn attribute. This hack //copies cn from mod command. Also it is set as pkey. var pkey_attr = IPA.metadata.commands.automember_mod.takes_args[0]; pkey_attr.primary_key = true; IPA.metadata.objects.automember.takes_params.push(pkey_attr); IPA.metadata.objects.automember.primary_key = pkey_attr.name; var that = IPA.entity(spec); that.init = function() { that.entity_init(); that.builder.search_facet({ factory: IPA.automember.rule_search_facet, name: 'searchgroup', group_type: 'group', label: 'User group rules', //TODO: translate details_facet: 'usergrouprule', columns: [ 'cn', 'description' ] }). search_facet({ factory: IPA.automember.rule_search_facet, name: 'searchhostgroup', group_type: 'hostgroup', label: 'Host group rules', //TODO: translate details_facet: 'hostgrouprule', columns: [ 'cn', 'description' ] }). details_facet({ factory: IPA.automember.rule_details_facet, name: 'usergrouprule', group_type: 'group', label: 'User group rule', //TODO: translate disable_facet_tabs: true, redirect_info: { tab: 'amgroup' } }). details_facet({ factory: IPA.automember.rule_details_facet, name: 'hostgrouprule', group_type: 'hostgroup', label: 'Host group rule',//TODO: translate disable_facet_tabs: true, redirect_info: { tab: 'amhostgroup' } }). adder_dialog({ factory: IPA.automember.rule_adder_dialog, fields: [ { type: 'entity_select', name: 'cn', other_entity: 'group', other_field: 'cn' } ], height: '300' }). deleter_dialog({ factory: IPA.automember.rule_deleter_dialog }); }; return that; }; IPA.automember.rule_search_facet = function(spec) { spec = spec || {}; var that = IPA.search_facet(spec); that.group_type = spec.group_type; that.get_records_command_name = function() { return that.managed_entity.name + that.group_type+'_get_records'; }; that.get_search_command_name = function() { var name = that.managed_entity.name + that.group_type + '_find'; if (that.pagination && !that.search_all_entries) { name += '_pkeys'; } return name; }; that.create_get_records_command = function(pkeys, on_success, on_error) { var batch = that.table_facet_create_get_records_command(pkeys, on_success, on_error); for (var i=0; i= 0) { if (results[i].completed === 1){ that.reload_facet({ result: results[i] }); return; } i--; } that.refresh_facet(); }; that.create_remove_command = function(values, on_success, on_error) { var batch = IPA.batch_command({ name: 'automember_remove_condition', on_success: on_success, on_error: on_error }); var pkeys = that.get_pkeys(); for (var i=0; i