From 5db9fed8a5c62a65adf43f1d8c24a0e061f6b301 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 2 Nov 2011 12:21:39 -0500 Subject: Moved facet code into facet.js. Facet-related code has been moved from entity.js into a new facet.js because the file is getting too big. --- install/ui/Makefile.am | 1 + install/ui/aci.js | 2 +- install/ui/automount.js | 2 +- install/ui/dns.js | 2 +- install/ui/entitle.js | 2 +- install/ui/entity.js | 568 +------------------------------- install/ui/facet.js | 588 ++++++++++++++++++++++++++++++++++ install/ui/group.js | 2 +- install/ui/hbac.js | 2 +- install/ui/host.js | 2 +- install/ui/hostgroup.js | 2 +- install/ui/index.html | 1 + install/ui/jsl.conf | 1 + install/ui/netgroup.js | 2 +- install/ui/policy.js | 2 +- install/ui/rule.js | 2 +- install/ui/serverconfig.js | 2 +- install/ui/service.js | 2 +- install/ui/sudo.js | 2 +- install/ui/test/aci_tests.html | 1 + install/ui/test/all_tests.html | 1 + install/ui/test/details_tests.html | 1 + install/ui/test/entity_tests.html | 1 + install/ui/test/navigation_tests.html | 1 + install/ui/user.js | 2 +- 25 files changed, 615 insertions(+), 579 deletions(-) create mode 100644 install/ui/facet.js (limited to 'install') diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am index a15b070b9..8e1ec46fb 100644 --- a/install/ui/Makefile.am +++ b/install/ui/Makefile.am @@ -18,6 +18,7 @@ app_DATA = \ dns.js \ entitle.js \ entity.js \ + facet.js \ favicon.ico \ group.js \ hbac.js \ diff --git a/install/ui/aci.js b/install/ui/aci.js index 7a331118a..5ffb2108b 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ +/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */ IPA.entity_factories.permission = function() { diff --git a/install/ui/automount.js b/install/ui/automount.js index 2dfb9ddcb..b692e5831 100644 --- a/install/ui/automount.js +++ b/install/ui/automount.js @@ -21,7 +21,7 @@ * along with this program. If not, see . */ -/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ +/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */ /**Automount*/ diff --git a/install/ui/dns.js b/install/ui/dns.js index 769eee602..b7de11bd6 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -21,7 +21,7 @@ * along with this program. If not, see . */ -/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js, widget.js */ +/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js, widget.js */ /* DNS */ IPA.entity_factories.dnszone = function() { diff --git a/install/ui/entitle.js b/install/ui/entitle.js index dcaf5638f..8bd6c456c 100644 --- a/install/ui/entitle.js +++ b/install/ui/entitle.js @@ -20,7 +20,7 @@ * along with this program. If not, see . */ -/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */ +/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */ IPA.entitle = {}; diff --git a/install/ui/entity.js b/install/ui/entity.js index 526e2795d..ce086bd1c 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -1,10 +1,12 @@ /*jsl:import ipa.js */ +/*jsl:import facet.js */ /*jsl:import navigation.js */ /* Authors: * Pavel Zuna * Endi Sukma Dewata * Adam Young + * Petr Vobornik * * Copyright (C) 2010-2011 Red Hat * see file 'COPYING' for use and warranty information @@ -23,442 +25,9 @@ * along with this program. If not, see . */ -/* REQUIRES: ipa.js, details.js, search.js, add.js */ +/* REQUIRES: ipa.js, facet.js, details.js, search.js, add.js */ -IPA.facet = function (spec) { - - spec = spec || {}; - - var that = {}; - - that.entity = spec.entity; - - that.name = spec.name; - that.label = spec.label; - that.title = spec.title || that.label; - that.display_class = spec.display_class; - - that.disable_breadcrumb = spec.disable_breadcrumb; - that.disable_facet_tabs = spec.disable_facet_tabs; - - that.header = spec.header || IPA.facet_header({ facet: that }); - - that.entity_name = spec.entity_name; - that._needs_update = spec.needs_update; - - that.dialogs = $.ordered_map(); - - // facet group name - that.facet_group = spec.facet_group; - - that.state = {}; - - that.get_dialog = function(name) { - return that.dialogs.get(name); - }; - - that.dialog = function(dialog) { - that.dialogs.put(dialog.name, dialog); - return that; - }; - - that.create = function(container) { - - that.container = container; - - if (that.disable_facet_tabs) that.container.addClass('no-facet-tabs'); - that.container.addClass(that.display_class); - - that.header_container = $('
', { - 'class': 'facet-header' - }).appendTo(container); - that.create_header(that.header_container); - - that.content = $('
', { - 'class': 'facet-content' - }).appendTo(container); - that.create_content(that.content); - }; - - that.create_header = function(container) { - - that.header.create(container); - - that.controls = $('
', { - 'class': 'facet-controls' - }).appendTo(container); - }; - - that.create_content = function(container) { - }; - - that.set_title = function(container, title) { - var element = $('h1', that.title_container); - element.html(title); - }; - - that.show = function() { - that.container.css('display', 'block'); - }; - - that.hide = function() { - that.container.css('display', 'none'); - }; - - that.load = function(data) { - that.data = data; - that.header.load(data); - }; - - that.clear = function() { - }; - - that.needs_update = function() { - if (that._needs_update !== undefined) return that._needs_update; - return true; - }; - - that.is_dirty = function() { - return false; - }; - - that.report_error = function(error_thrown) { - // TODO: The error message should be displayed in the facet footer. - // There should be a standard footer section for all facets. - that.content.empty(); - that.content.append('

'+IPA.get_message('errors.error', 'Error')+': '+error_thrown.name+'

'); - that.content.append('

'+error_thrown.message+'

'); - }; - - that.redirect = function() { - var entity = that.entity; - while (entity.containing_entity) { - entity = entity.get_containing_entity(); - } - - IPA.nav.show_page( - entity.name, - that.entity.redirect_facet); - }; - - var redirect_errors = [4001]; - - that.on_error = function(xhr, text_status, error_thrown) { - - /*If the error is in talking to the server, don't attempt to redirect, - as there is nothing any other facet can do either. */ - if (that.entity.redirect_facet) { - for (var i=0; i', { - 'class': 'breadcrumb-element', - text: IPA.nav.get_state(entity.name+'-pkey'), - title: entity.metadata.label_singular, - click: function(entity) { - return function() { - IPA.nav.show_page(entity.name, 'default'); - return false; - }; - }(entity) - })); - - entity = entity.get_containing_entity(); - } - - that.path.empty(); - - for (var i=0; i', { - 'class': 'breadcrumb-element', - text: value - }).appendTo(that.path); - } - - that.title_container.empty(); - var h3 = $('

').appendTo(that.title_container); - h3.append(that.facet.title); - h3.append(': '); - - $('', { - 'class': 'facet-pkey', - text: value - }).appendTo(h3); - }; - - that.create_facet_link = function(container, other_facet) { - - var li = $('
  • ', { - name: other_facet.name, - title: other_facet.name, - click: function() { - if (li.hasClass('entity-facet-disabled')) { - return false; - } - - var pkey = IPA.nav.get_state(that.facet.entity.name+'-pkey'); - IPA.nav.show_page(that.facet.entity.name, other_facet.name, pkey); - - return false; - } - }).appendTo(container); - - $('', { - text: other_facet.label, - id: other_facet.name - }).appendTo(li); - }; - - that.create_facet_group = function(container, facet_group) { - - var section = $('', { - name: facet_group.name, - 'class': 'facet-group' - }).appendTo(container); - - $('
    ', { - 'class': 'facet-group-label' - }).appendTo(section); - - var ul = $('