/* Authors: * Pavel Zuna * 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 */ function ipa_facet(spec) { spec = spec || {}; var that = {}; that.display_class = spec.display_class || 'entity-facet'; that.name = spec.name; that.label = spec.label; that._entity_name = spec.entity_name; that.init = spec.init || init; that.create = spec.create || create; that.setup = spec.setup || setup; that.load = spec.load || load; that.__defineGetter__("entity_name", function(){ return that._entity_name; }); that.__defineSetter__("entity_name", function(entity_name){ that._entity_name = entity_name; }); that.setup_views = ipa_facet_setup_views; that.superior = function(name) { var method = that[name]; return function () { return method.apply(that, arguments); }; }; function init() { } function create() { } function setup() { } function load() { } return that; } function ipa_entity(spec) { spec = spec || {}; var that = {}; that.name = spec.name; that.label = spec.label; that.setup = spec.setup || ipa_entity_setup; that.dialogs = []; that.dialogs_by_name = {}; that.facets = []; that.facets_by_name = {}; that.facet_name = null; that.associations = []; that.associations_by_name = {}; that.superior = function(name) { var method = that[name]; return function () { return method.apply(that, arguments); }; }; that.get_dialog = function(name) { return that.dialogs_by_name[name]; }; that.add_dialog = function(dialog) { dialog.entity_name = that.name; that.dialogs.push(dialog); that.dialogs_by_name[dialog.name] = dialog; }; that.get_facet = function(name) { return that.facets_by_name[name]; }; that.add_facet = function(facet) { facet.entity_name = that.name; that.facets.push(facet); that.facets_by_name[facet.name] = facet; }; that.get_associations = function() { return that.associations; }; that.get_association = function(name) { return that.associations_by_name[name]; }; that.add_association = function(config) { that.associations.push(config); that.associations_by_name[config.name] = config; }; that.create_association = function(spec) { var config = ipa_association_config(spec); that.add_association(config); return config; }; that.init = function() { for (var i=0; i', { "class" : other_facet.display_class, title: other_entity, text: label, click: function(entity_name, other_facet_name) { return function() { if($(this).hasClass('entity-facet-disabled')){ return false; } var this_pkey = $('.action-panel input[id=pkey]').val(); IPA.switch_and_show_page( entity_name, other_facet_name, this_pkey, other_entity); return false; }; }(entity_name, other_facet_name) }); return li; } var div = $('
', { "class":"action-panel", html: $('

Actions

') }); /*Note, for debugging purposes, it is useful to set var pkey_type = 'text';*/ var pkey_type = 'hidden'; $('', {'type': pkey_type, id:'pkey', name:'pkey'}).appendTo(div); var ul = $('
    ', {'class': 'action'}).appendTo(div); var entity = IPA.get_entity(entity_name); var facet_name = ipa_current_facet(entity); for (var i=0; i