/* 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 . */ define([ './ipa', './jquery', './phases', './reg', './rpc', './details', './search', './association', './entity'], function(IPA, $, phases, reg, rpc) { IPA.rule_details_widget = function(spec) { spec = spec || {}; var that = IPA.composite_widget(spec); that.radio_name = spec.radio_name; that.options = spec.options || []; that.tables = spec.tables || []; that.columns = spec.columns; that.init = function() { that.enable_radio = IPA.rule_radio_widget({ name: that.radio_name, options: that.options, entity: that.entity, css_class: 'rule-enable-radio' }); that.widgets.add_widget(that.enable_radio); that.enable_radio.value_changed.attach(that.on_enable_radio_changed); }; that.on_enable_radio_changed = function() { var value = that.enable_radio.save(); if(value.length > 0) { var enabled = ('' === value[0]); for (var i=0; i 0) { //no need to delete if has no values var command = rpc.command({ entity: that.entity.name, method: that.widget.remove_method, args: that.facet.get_pkeys() }); command.set_option(that.widget.other_entity.name, values); update_info.append_command(command, that.priority); } } return update_info; }; return that; }; IPA.rule_association_adder_dialog = function(spec) { spec = spec || {}; var that = IPA.association_adder_dialog(spec); that.external = spec.external; that.add = function() { var rows = that.available_table.remove_selected_rows(); that.selected_table.add_rows(rows); if (that.external) { var pkey_name = that.other_entity.metadata.primary_key; var value = that.external_field.val(); if (!value) return; var record = {}; record[pkey_name] = value; that.selected_table.add_record(record); that.external_field.val(''); } }; return that; }; phases.on('registration', function() { var w = reg.widget; var f = reg.field; w.register('rule_association_table', IPA.rule_association_table_widget); f.register('rule_association_table', IPA.rule_association_table_field); }); return {}; });