summaryrefslogtreecommitdiffstats
path: root/install/static/search.js
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-11-02 20:16:55 -0500
committerAdam Young <ayoung@redhat.com>2010-11-04 14:22:32 -0400
commitd99ebc0f3798c84e612c79c43eb85c31b20ab1ce (patch)
treef2a758dfc9028d32f00236340b409469c73848a4 /install/static/search.js
parent05a16f50d7fe8c01408ec445e6b5ad26ff65d9d5 (diff)
downloadfreeipa-d99ebc0f3798c84e612c79c43eb85c31b20ab1ce.tar.gz
freeipa-d99ebc0f3798c84e612c79c43eb85c31b20ab1ce.tar.xz
freeipa-d99ebc0f3798c84e612c79c43eb85c31b20ab1ce.zip
HBAC Details Page
The UI framework has been extended to include a collection of widgets: - ipa_widget: base class - ipa_text_widget: text field - ipa_radio_widget: radio button - ipa_textarea_widget: textarea - ipa_button_widget: button - ipa_column_widget: column for table - ipa_table_widget: table These widgets can be used to create input controls. They can also be extended to create custom controls. The framework has also been enhanced to support custom layouts. This can be used to change the look of the application without changing the code. Initially this is only available in details section. Layout consists of a collection of HTML templates. Each template is a complete and valid HTML file representing a portion of a page. The template will be loaded and initialized by the code, then filled with the data from the server. The layouts are located in install/static/layouts/<name> folder. By default, if no templates are used, the fields in the details page are rendered vertically using dd/dt/dd tags. For pages that require different layout, a custom UI needs to be developed. There are two ways to do that: - write a custom widget to generate the UI dynamically - create an HTML template and write the initialization code For components that are quite complex or used frequently, it's might be better to use the first method. For simple pages that are used only in one location or need to support customization, the second method might be preferable. Other benefits of templates: - cleaner code and UI separation - more flexibility in customization - new pages can be developed quickly and require less coding - multiple templates can be used with the same initialization code - easier to maintain The HBAC details page has been implemented using both methods. By default it will use custom widgets to generate the page. To use a custom layout, add the following parameter to the URL, then reload the page: &layout=<name> Currently the only available layout is 'default' which produces the same look as the custom widgets. The HBAC details page is usable, but it still needs additional work. The access time is not working yet. There is no undo button, hint, or validation yet. The table in the association facet has also been changed to use ipa_association_widget which is derived from ipa_table_widget. The Makefile has been updated to include the layouts. The unit tests have been updated as well.
Diffstat (limited to 'install/static/search.js')
-rw-r--r--install/static/search.js66
1 files changed, 39 insertions, 27 deletions
diff --git a/install/static/search.js b/install/static/search.js
index 62fffbe9..508f6ed4 100644
--- a/install/static/search.js
+++ b/install/static/search.js
@@ -25,14 +25,10 @@ function ipa_search_column(spec) {
spec = spec || {};
- var that = {};
+ spec.init = spec.init || init;
+ spec.setup = spec.setup || setup;
- that.name = spec.name;
- that.label = spec.label || that.name;
- that.facet = spec.facet;
-
- that.init = spec.init || init;
- that.setup = spec.setup || setup;
+ var that = ipa_column_widget(spec);
function init() {
}
@@ -56,6 +52,18 @@ function ipa_search_facet(spec) {
that.columns = [];
that.columns_by_name = {};
+ that.__defineGetter__("entity_name", function(){
+ return that._entity_name;
+ });
+
+ that.__defineSetter__("entity_name", function(entity_name){
+ that._entity_name = entity_name;
+
+ for (var i=0; i<that.columns.length; i++) {
+ that.columns[i].entity_name = entity_name;
+ }
+ });
+
that.get_columns = function() {
return that.columns;
};
@@ -65,12 +73,12 @@ function ipa_search_facet(spec) {
};
that.add_column = function(column) {
+ column.entity_name = that.entity_name;
that.columns.push(column);
that.columns_by_name[column.name] = column;
};
that.create_column = function(spec) {
- spec.facet = that;
var column = ipa_search_column(spec);
that.add_column(column);
return column;
@@ -90,8 +98,10 @@ function ipa_search_facet(spec) {
search_create(that.entity_name, that.columns, container);
- ipa_make_button('ui-icon-plus', IPA.messages.button.add).
- click(function() {
+ 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();
@@ -102,8 +112,8 @@ function ipa_search_facet(spec) {
dialog.open();
return false;
- }).
- appendTo($('.search-controls', container));
+ }
+ }).appendTo($('.search-controls', container));
search_load(container, that.filter);
}
@@ -183,7 +193,6 @@ function search_create(entity_name, columns, container) {
}
container.attr('title', entity_name);
- container.addClass('search-container');
var search_controls = $('<div/>', {
'class': 'search-controls'
@@ -198,11 +207,17 @@ function search_create(entity_name, columns, container) {
'name': 'search-' + entity_name + '-filter'
}).appendTo(search_filter);
- ipa_make_button('ui-icon-search', IPA.messages.button.find).
- click(find_on_click).appendTo(search_filter);
+ ipa_button({
+ 'label': IPA.messages.button.find,
+ 'icon': 'ui-icon-search',
+ 'click': find_on_click
+ }).appendTo(search_filter);
- ipa_make_button('ui-icon-trash',IPA.messages.button.delete).
- click(delete_on_click_outer).appendTo(search_filter);
+ ipa_button({
+ 'label': IPA.messages.button.delete,
+ 'icon': 'ui-icon-trash',
+ 'click': delete_on_click_outer
+ }).appendTo(search_filter);
search_controls.append('<span class="search-buttons"></span>');
@@ -231,20 +246,17 @@ function search_insert_checkbox_th(jobj)
function select_all_on_click() {
var jobj = $(this);
- var checked = null;
- if (jobj.attr('checked')) {
- checked = true;
+ var checked = jobj.is(':checked');
+ if (checked) {
jobj.attr('title', 'Unselect All');
} else {
- checked = false;
jobj.attr('title', 'Select All');
}
- jobj.attr('checked', checked);
- var chks = jobj.closest('.search-container').find('.search-selector');
+ var chks = jobj.closest('.entity-container').find('.search-selector').get();
for (var i = 0; i < chks.length; ++i)
chks[i].checked = checked;
- };
+ }
var checkbox = $('<input />', {
type: 'checkbox',
@@ -307,7 +319,7 @@ function search_load(container, criteria, on_win, on_fail)
function search_generate_tr(thead, tbody, entry_attrs)
{
- var obj_name = tbody.closest('.search-container').attr('title');
+ var obj_name = tbody.closest('.entity-container').attr('title');
var pkey = IPA.metadata[obj_name].primary_key;
var pkey_value = entry_attrs[pkey];
@@ -368,7 +380,7 @@ var _search_a_pkey_template = '<a href="jslink" class="search-a-pkey">V</a>';
function search_generate_td(tr, attr, value, entry_attrs)
{
- var obj_name = tr.closest('.search-container').attr('title');
+ var obj_name = tr.closest('.entity-container').attr('title');
var param_info = ipa_get_param_info(obj_name, attr);
if (param_info && param_info['primary_key'])
@@ -379,7 +391,7 @@ function search_generate_td(tr, attr, value, entry_attrs)
function search_display(obj_name, data)
{
- var selector = '.search-container[title=' + obj_name + ']';
+ var selector = '.entity-container[title=' + obj_name + ']';
var thead = $(selector + ' thead');
var tbody = $(selector + ' tbody');
var tfoot = $(selector + ' tfoot');