summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-11-11 15:40:11 +0100
committerPetr Vobornik <pvoborni@redhat.com>2014-04-15 12:41:53 +0200
commit2680d21402d8ac51146bf03be3c0fd63ab49cada (patch)
tree44edc1f54346026fad32a4b64137c3014b8228bd
parent75eaf0bddfe0ce3eaea86b42a767c16846379b4b (diff)
downloadfreeipa-2680d21402d8ac51146bf03be3c0fd63ab49cada.tar.gz
freeipa-2680d21402d8ac51146bf03be3c0fd63ab49cada.tar.xz
freeipa-2680d21402d8ac51146bf03be3c0fd63ab49cada.zip
webui: facet container
A widget which servers as container for facets. FacetContainer is a base class. App is specialization. Doing this abstraction will allow us to implement various facet containers. https://fedorahosted.org/freeipa/ticket/3903 Reviewed-By: Adam Misnyovszki <amisnyov@redhat.com>
-rw-r--r--install/ui/src/freeipa/Application_controller.js61
-rw-r--r--install/ui/src/freeipa/facet.js8
-rw-r--r--install/ui/src/freeipa/phases.js1
-rw-r--r--install/ui/src/freeipa/widgets/App.js15
-rw-r--r--install/ui/src/freeipa/widgets/FacetContainer.js88
5 files changed, 159 insertions, 14 deletions
diff --git a/install/ui/src/freeipa/Application_controller.js b/install/ui/src/freeipa/Application_controller.js
index b327f62a6..9fd1c7042 100644
--- a/install/ui/src/freeipa/Application_controller.js
+++ b/install/ui/src/freeipa/Application_controller.js
@@ -27,15 +27,16 @@ define([
'dojo/topic',
'dojo/query',
'dojo/dom-class',
- './json2',
+ './json2',
'./widgets/App',
+ './widgets/FacetContainer',
'./ipa',
- './navigation/Menu',
+ './navigation/Menu',
'./navigation/Router',
'./navigation/menu_spec'
],
function(declare, lang, array, Deferred, on, topic, query, dom_class,
- JSON, App_widget, IPA, Menu, Router, menu_spec) {
+ JSON, App_widget, FacetContainer, IPA, Menu, Router, menu_spec) {
/**
* Application controller
@@ -46,6 +47,11 @@ define([
*/
var App = declare(null, {
+ /**
+ * Facet container map
+ */
+ containers: null,
+
app_widget: null,
router: null,
@@ -56,12 +62,39 @@ define([
facet_changing: false,
+ /**
+ * Currently displayed facet
+ *
+ */
+ current_facet: null,
+
+ /**
+ * Currently displayed facet container
+ */
+ current_container: null,
+
init: function() {
this.menu = new Menu();
this.router = new Router();
+
+ var body_node = query('body')[0];
this.app_widget = new App_widget();
+ this.app_widget.container_node = body_node;
this.app_widget.menu_widget.set_menu(this.menu);
- this.app_widget.container_node = query('body')[0];
+
+ var simple_container = new FacetContainer();
+ simple_container.container_node = body_node;
+
+ this.containers = {
+ // Default view
+ main: {
+ widget: this.app_widget
+ },
+ // Mainly for standalone facets
+ simple: {
+ widget: simple_container
+ }
+ };
on(this.app_widget.menu_widget, 'item-select', lang.hitch(this, this.on_menu_click));
on(this.app_widget, 'profile-click', lang.hitch(this, this.on_profile));
@@ -77,6 +110,9 @@ define([
topic.subscribe('phase-error', lang.hitch(this, this.on_phase_error));
this.app_widget.render();
+ this.app_widget.hide();
+ simple_container.render();
+ simple_container.hide();
},
/**
@@ -248,12 +284,27 @@ define([
on_facet_show: function(event) {
var facet = event.facet;
+ // choose container
+ var container = this.containers[facet.preferred_container];
+ if (!container) container = this.containers.main;
+
+ if (this.current_container !== container) {
+
+ if (this.current_container) {
+ this.current_container.widget.hide();
+ }
+
+ this.current_container = container;
+ this.current_container.widget.show();
+ }
+
// update menu
var menu_item = this._find_menu_item(facet);
if (menu_item) this.menu.select(menu_item);
+ // show facet
if (!facet.container) {
- facet.container_node = this.app_widget.content_node;
+ facet.container_node = container.widget.content_node;
on(facet, 'facet-state-change', lang.hitch(this, this.on_facet_state_changed));
}
if (this.current_facet) {
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index 823ea2793..f235ddc8f 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -125,6 +125,14 @@ exp.facet = IPA.facet = function(spec, no_init) {
var that = new Evented();
/**
+ * Name of preferred facet container
+ *
+ * Leave unset to use default container.
+ * @property {string}
+ */
+ that.preferred_container = spec.preferred_container;
+
+ /**
* Entity this facet belongs to
* @property {entity.entity}
*/
diff --git a/install/ui/src/freeipa/phases.js b/install/ui/src/freeipa/phases.js
index 86605e3d6..15e64fe33 100644
--- a/install/ui/src/freeipa/phases.js
+++ b/install/ui/src/freeipa/phases.js
@@ -32,6 +32,7 @@ define([
//'resource-load', // implicit phase
'customization',
'registration',
+ 'login',
'init',
'metadata',
'post-metadata',
diff --git a/install/ui/src/freeipa/widgets/App.js b/install/ui/src/freeipa/widgets/App.js
index 4ce6efa75..82c0a24c4 100644
--- a/install/ui/src/freeipa/widgets/App.js
+++ b/install/ui/src/freeipa/widgets/App.js
@@ -28,14 +28,14 @@ define(['dojo/_base/declare',
'dojo/dom-style',
'dojo/query',
'dojo/on',
- 'dojo/Evented',
- 'dojo/Stateful',
'./Menu',
'./DropdownWidget',
+ './FacetContainer',
'dojo/NodeList-dom'
],
function(declare, lang, array, dom, construct, prop, dom_class,
- dom_style, query, on, Stateful, Evented, Menu, DropdownWidget) {
+ dom_style, query, on, Menu, DropdownWidget,
+ FacetContainer) {
/**
* Main application widget
@@ -45,13 +45,12 @@ define(['dojo/_base/declare',
*
* @class widgets.App
*/
- var app = declare([Stateful, Evented], {
+ var app = declare([FacetContainer], {
//widgets
menu_widget: null,
//nodes:
-
dom_node: null,
container_node: null,
@@ -64,9 +63,7 @@ define(['dojo/_base/declare',
menu_node: null,
- content_node: null,
-
- app_id: 'container',
+ id: 'container',
logged: false,
@@ -87,7 +84,7 @@ define(['dojo/_base/declare',
render: function() {
this.dom_node = construct.create('div', {
- id: this.app_id,
+ id: this.id,
'class': 'app-container'
});
diff --git a/install/ui/src/freeipa/widgets/FacetContainer.js b/install/ui/src/freeipa/widgets/FacetContainer.js
new file mode 100644
index 000000000..d5e6add74
--- /dev/null
+++ b/install/ui/src/freeipa/widgets/FacetContainer.js
@@ -0,0 +1,88 @@
+/* Authors:
+ * Petr Vobornik <pvoborni@redhat.com>
+ *
+ * Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
+*/
+
+define(['dojo/_base/declare',
+ 'dojo/_base/lang',
+ 'dojo/dom-construct',
+ 'dojo/dom-style',
+ 'dojo/Evented',
+ 'dojo/Stateful',
+ 'dojo/NodeList-dom'
+ ],
+ function(declare, lang, construct, dom_style,
+ Evented, Stateful) {
+
+ /**
+ * Container for standalone facets
+ *
+ * Main feature is that this container doesn't produce any
+ * surroundings. Therefore facets can occupy the entire page.
+ *
+ * @class widgets.FacetContainer
+ */
+ var FacetContainer = declare([Stateful, Evented], {
+
+ id: 'simple-container',
+
+ //nodes:
+ dom_node: null,
+
+ container_node: null,
+
+ content_node: null,
+
+ render: function() {
+
+ this.dom_node = construct.create('div', {
+ id: this.id,
+ 'class': 'app-container'
+ });
+
+ if (this.container_node) {
+ construct.place(this.dom_node, this.container_node);
+ }
+
+ this.content_node = construct.create('div', {
+ 'class': 'content'
+ }, this.dom_node);
+
+ return this.dom_node;
+ },
+
+ show: function() {
+ if (!this.dom_node) return;
+
+ dom_style.set(this.dom_node, 'display', '');
+ },
+
+ hide: function() {
+ if (!this.dom_node) return;
+
+ dom_style.set(this.dom_node, 'display', 'none');
+ },
+
+ constructor: function(spec) {
+ spec = spec || {};
+ declare.safeMixin(this, spec);
+ }
+ });
+
+ return FacetContainer;
+}); \ No newline at end of file