From c7af2458091ba95eccc26f4468234413e8b016b9 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Mon, 14 Apr 2014 14:10:20 +0200 Subject: webui: add action dropdown Reviewed-By: Endi Sukma Dewata --- .../ui/src/freeipa/widgets/ActionDropdownWidget.js | 191 +++++++++++++++++++++ install/ui/src/freeipa/widgets/DropdownWidget.js | 84 +++++++-- 2 files changed, 265 insertions(+), 10 deletions(-) create mode 100644 install/ui/src/freeipa/widgets/ActionDropdownWidget.js (limited to 'install/ui/src/freeipa/widgets') diff --git a/install/ui/src/freeipa/widgets/ActionDropdownWidget.js b/install/ui/src/freeipa/widgets/ActionDropdownWidget.js new file mode 100644 index 000000000..c43c79b54 --- /dev/null +++ b/install/ui/src/freeipa/widgets/ActionDropdownWidget.js @@ -0,0 +1,191 @@ +/* Authors: + * Petr Vobornik + * + * Copyright (C) 2014 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(['dojo/_base/declare', + 'dojo/_base/lang', + 'dojo/on', + '../jquery', + './DropdownWidget'], function(declare, lang, on, $, DropdownWidget) { + + return declare([DropdownWidget], { + /** + * Represents and creates a dropdown widget for executing facet actions + * + * @class widgets.ActionDropdownWidget + */ + + /** + * Facet which contains actions + * @type {facet.facet|facets.Facet} + */ + facet: null, + + /** + * Names of actions, which should be later obtained from facet + * @property {Array.} + */ + action_names: [], + + /** + * Actions + * @property {ordered_map} + */ + actions: [], + + on_item_click: function(event, item) { + + if (item.click) item.click(); + this.emit('item-click', item); + }, + + /** + * Initializes action list + * + * - set facet + * - get actions from facet + * - init child widgets + * + * @param {facet.facet} facet + */ + init: function(facet) { + + var options, actions, action, name, i; + + this.facet = facet; + + if (!this.action_names) return; + + for (i=0; i 0) { dom_class.add(li, 'dropdown-submenu'); this._render_items(item.items, li); -- cgit