From 65c9442e2697f9e5d8b6cc2b7c22a6b8da426247 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata"
Date: Tue, 9 Nov 2010 14:22:31 -0600
Subject: HBAC Services
The HBAC Service search and details pages have been added under the HBAC
tab. This requires some changes to the framework.
Currently the navigation framework doesn't support multiple entities under
one tab. As a temporary solution, an 'entity' URL parameter is used to
determine the entity to be displayed. This parameter is now only used by
HBAC tab, but its use might be expanded later. The navigation framework
needs be redesigned to provide more flexibility.
The search page in all entities except DNS records have been changed to
use the ipa_search_widget. The Select/Unselect All checbox and Delete
button now work correctly and consistently.
The Add dialog has been enhanced to render and work in a more consistent
way while still supporting custom widgets & layouts. For the search page,
the Add button will refresh the search results and clear the fields in
the dialog box.
The framework now provides some extension points which can be overriden
by the subclasses:
- init(): for initialization and configuration
- create(): for creating the layout dynamically or from template
- setup(): for setting the look and feel
- load(): for loading the data
Entity and facet initialization is now done after IPA.init(). This is to
ensure the metadata is loaded first so the entities and facets can use
localized messages/labels/titles.
The group entity has been partially converted to use the new framework.
The unit tests have been updated accordingly.
---
install/static/search.js | 433 +++++++++++++++++++++--------------------------
1 file changed, 195 insertions(+), 238 deletions(-)
(limited to 'install/static/search.js')
diff --git a/install/static/search.js b/install/static/search.js
index 1dfeda41..ecdf56d2 100644
--- a/install/static/search.js
+++ b/install/static/search.js
@@ -1,6 +1,7 @@
/* Authors:
* Pavel Zuna
* Adam Young
+ * Endi S. Dewata
*
* Copyright (C) 2010 Red Hat
* see file 'COPYING' for use and warranty information
@@ -21,299 +22,279 @@
/* REQUIRES: ipa.js */
-function ipa_search_column(spec) {
+function ipa_search_widget(spec) {
spec = spec || {};
- spec.init = spec.init || init;
- spec.setup = spec.setup || setup;
+ var that = ipa_table_widget(spec);
- var that = ipa_column_widget(spec);
+ that.super_create = that.super('create');
+ that.super_setup = that.super('setup');
- function init() {
- }
+ that.create = function(container) {
- function setup(tr, attr, value, entry_attrs) {
- search_generate_td(tr, attr, value, entry_attrs);
- }
+ var div = $('#'+that.id);
- return that;
-}
+ var search_controls = $('', {
+ 'class': 'search-controls'
+ }).appendTo(div);
-function ipa_search_facet(spec) {
+ var search_filter = $('', {
+ 'class': 'search-filter'
+ }).appendTo(search_controls);
- spec = spec || {};
-
- var that = ipa_facet(spec);
+ this.filter = $('', {
+ 'type': 'text',
+ 'name': 'search-' + that.entity_name + '-filter'
+ }).appendTo(search_filter);
- that.init = spec.init || init;
- that.setup = spec.setup || setup;
+ ipa_button({
+ 'label': IPA.messages.button.find,
+ 'icon': 'ui-icon-search',
+ 'click': function() { that.find(container); }
+ }).appendTo(search_filter);
- that.columns = [];
- that.columns_by_name = {};
+ ipa_button({
+ 'label': IPA.messages.button.remove,
+ 'icon': 'ui-icon-trash',
+ 'click': function() { that.remove(container); }
+ }).appendTo(search_filter);
- that.__defineGetter__("entity_name", function(){
- return that._entity_name;
- });
+ ipa_button({
+ 'label': IPA.messages.button.add,
+ 'icon': 'ui-icon-plus',
+ 'click': function() { that.add(container); }
+ }).appendTo(search_filter);
- that.__defineSetter__("entity_name", function(entity_name){
- that._entity_name = entity_name;
+ search_controls.append('');
- for (var i=0; i', {
+ 'class': 'search-results'
+ }).appendTo(div);
- that.get_columns = function() {
- return that.columns;
+ that.super_create(container);
};
- that.get_column = function(name) {
- return that.columns_by_name[name];
- };
+ that.setup = function(container) {
- that.add_column = function(column) {
- column.entity_name = that.entity_name;
- that.columns.push(column);
- that.columns_by_name[column.name] = column;
+ that.super_setup(container);
+
+ var filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
+ this.filter.val(filter);
};
- that.create_column = function(spec) {
- var column = ipa_search_column(spec);
- that.add_column(column);
- return column;
+ that.find = function(container) {
+ var filter = this.filter.val();
+ var state = {};
+ state[that.entity_name + '-filter'] = filter;
+ $.bbq.pushState(state);
};
- function init() {
- }
+ that.add = function(container) {
- that.is_dirty = function() {
- var filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
- return filter != that.filter;
+ var entity = IPA.get_entity(that.entity_name);
+
+ var dialog = entity.get_dialog('add');
+ dialog.open(container);
+
+ return false;
};
- function setup(container, unspecified) {
+ that.remove = function(container) {
- that.filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
+ var values = that.get_selected_values();
- search_create(that.entity_name, that.columns, container);
+ if (!values.length) {
+ alert('Select '+that.label+' to be removed.');
+ return;
+ }
- ipa_button({
- 'label': IPA.messages.button.add,
- 'icon': 'ui-icon-plus',
- 'click': function() {
- var entity = IPA.get_entity(that.entity_name);
- if (entity) {
- entity.add_dialog.open();
- return false;
- }
+ var title = 'Remove '+that.label;
- var dialog = ipa_entity_get_add_dialog(that.entity_name);
- dialog.open();
+ var dialog = ipa_deleter_dialog({
+ 'title': title,
+ 'parent': container,
+ 'values': values
+ });
- return false;
- }
- }).appendTo($('.search-controls', container));
+ dialog.remove = function() {
+ var batch = ipa_batch_command();
- search_load(container, that.filter);
- }
+ for (var i=0; i', {
- title: IPA.messages.button.remove
- });
+ var result = data.result.result;
+ for (var i = 0; iError: '+error_thrown.name+'