2010-09-16 09:28:07 -05:00
|
|
|
/* Authors:
|
|
|
|
* Pavel Zuna <pzuna@redhat.com>
|
|
|
|
* Adam Young <ayoung@redhat.com>
|
2010-11-09 14:22:31 -06:00
|
|
|
* Endi S. Dewata <edewata@redhat.com>
|
2010-09-16 09:28:07 -05:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 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; version 2 only
|
|
|
|
*
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* REQUIRES: ipa.js */
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
function ipa_search_widget(spec) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var that = ipa_table_widget(spec);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-12 19:51:15 -06:00
|
|
|
that.superior_create = that.superior('create');
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.create = function(container) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var search_controls = $('<div/>', {
|
|
|
|
'class': 'search-controls'
|
2010-11-15 11:10:55 -06:00
|
|
|
}).appendTo(container);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var search_filter = $('<span/>', {
|
|
|
|
'class': 'search-filter'
|
|
|
|
}).appendTo(search_controls);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
this.filter = $('<input/>', {
|
|
|
|
'type': 'text',
|
|
|
|
'name': 'search-' + that.entity_name + '-filter'
|
|
|
|
}).appendTo(search_filter);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
ipa_button({
|
|
|
|
'label': IPA.messages.button.find,
|
|
|
|
'icon': 'ui-icon-search',
|
|
|
|
'click': function() { that.find(container); }
|
|
|
|
}).appendTo(search_filter);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-13 20:34:31 -06:00
|
|
|
var li = $('<li />', {
|
|
|
|
html: ipa_button({
|
|
|
|
'label': IPA.messages.button.remove,
|
|
|
|
'icon': 'ui-icon-trash',
|
|
|
|
'click': function() { that.remove(container); }
|
|
|
|
})});
|
|
|
|
li.append(
|
|
|
|
ipa_button({
|
|
|
|
'label': IPA.messages.button.add,
|
|
|
|
'icon': 'ui-icon-plus',
|
|
|
|
'click': function() { that.add(container); }
|
|
|
|
})
|
|
|
|
);
|
2010-11-15 10:32:28 -06:00
|
|
|
li.prependTo($('.action-panel ul'));
|
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.
2010-11-02 20:16:55 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
search_controls.append('<span class="search-buttons"></span>');
|
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.
2010-11-02 20:16:55 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
$('<div/>', {
|
2010-11-09 14:22:31 -06:00
|
|
|
'class': 'search-results'
|
2010-11-15 11:10:55 -06:00
|
|
|
}).appendTo(container);
|
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.
2010-11-02 20:16:55 -05:00
|
|
|
|
2010-11-12 19:51:15 -06:00
|
|
|
that.superior_create(container);
|
2010-10-27 22:32:30 -05:00
|
|
|
};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.setup = function(container) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
that.table_setup(container);
|
2010-11-09 14:22:31 -06:00
|
|
|
|
|
|
|
var filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
|
|
|
|
this.filter.val(filter);
|
2010-10-27 22:32:30 -05:00
|
|
|
};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.find = function(container) {
|
|
|
|
var filter = this.filter.val();
|
|
|
|
var state = {};
|
|
|
|
state[that.entity_name + '-filter'] = filter;
|
|
|
|
$.bbq.pushState(state);
|
2010-10-27 22:32:30 -05:00
|
|
|
};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.add = function(container) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var entity = IPA.get_entity(that.entity_name);
|
|
|
|
|
|
|
|
var dialog = entity.get_dialog('add');
|
2010-11-15 11:10:55 -06:00
|
|
|
dialog.open(that.container);
|
2010-11-09 14:22:31 -06:00
|
|
|
|
|
|
|
return false;
|
2010-10-27 22:32:30 -05:00
|
|
|
};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.remove = function(container) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var values = that.get_selected_values();
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
if (!values.length) {
|
|
|
|
alert('Select '+that.label+' to be removed.');
|
|
|
|
return;
|
|
|
|
}
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var title = 'Remove '+that.label;
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var dialog = ipa_deleter_dialog({
|
|
|
|
'title': title,
|
2010-11-15 11:10:55 -06:00
|
|
|
'parent': that.container,
|
2010-11-09 14:22:31 -06:00
|
|
|
'values': values
|
|
|
|
});
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
dialog.remove = function() {
|
2010-11-15 11:10:55 -06:00
|
|
|
|
|
|
|
var batch = ipa_batch_command({
|
|
|
|
'on_success': function() {
|
|
|
|
that.refresh(that.container);
|
|
|
|
dialog.close();
|
|
|
|
},
|
|
|
|
'on_error': function() {
|
|
|
|
that.refresh(that.container);
|
|
|
|
dialog.close();
|
|
|
|
}
|
|
|
|
});
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
for (var i=0; i<values.length; i++) {
|
|
|
|
var command = ipa_command({
|
|
|
|
'method': that.entity_name+'_del'
|
|
|
|
});
|
|
|
|
command.add_arg(values[i]);
|
|
|
|
batch.add_command(command);
|
|
|
|
}
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
batch.execute();
|
2010-11-09 14:22:31 -06:00
|
|
|
};
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
dialog.init();
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
dialog.open(that.container);
|
2010-11-09 14:22:31 -06:00
|
|
|
};
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.refresh = function(container) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
function on_success(data, text_status, xhr) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.tbody.empty();
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var result = data.result.result;
|
|
|
|
for (var i = 0; i<result.length; i++) {
|
|
|
|
var record = that.get_record(result[i], 0);
|
2010-11-15 11:10:55 -06:00
|
|
|
that.add_row(that.container, record);
|
2010-11-09 14:22:31 -06:00
|
|
|
}
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var summary = $('span[name=summary]', that.tfoot);
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
if (data.result.truncated) {
|
|
|
|
summary.text(
|
|
|
|
'Query returned results than configured size limit will show.' +
|
|
|
|
'First ' + data.result.count + ' results shown.'
|
2010-10-01 11:40:30 -05:00
|
|
|
);
|
2010-11-09 14:22:31 -06:00
|
|
|
} else {
|
|
|
|
summary.text(data.result.summary);
|
2010-10-01 11:40:30 -05:00
|
|
|
}
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
function on_error(xhr, text_status, error_thrown) {
|
2010-11-15 11:10:55 -06:00
|
|
|
var summary = $('span[name=summary]', that.tfoot).empty();
|
|
|
|
summary.append('<p>Error: '+error_thrown.name+'</p>');
|
|
|
|
summary.append('<p>'+error_thrown.title+'</p>');
|
|
|
|
summary.append('<p>'+error_thrown.message+'</p>');
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
|
|
|
|
ipa_cmd(
|
|
|
|
'find', [filter], {all: true}, on_success, on_error, that.entity_name
|
|
|
|
);
|
|
|
|
};
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
return that;
|
|
|
|
}
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
function ipa_search_column(spec) {
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
spec = spec || {};
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var that = ipa_column_widget(spec);
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
return that;
|
|
|
|
}
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
function ipa_search_facet(spec) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
spec = spec || {};
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var that = ipa_facet(spec);
|
2010-10-13 12:07:43 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.init = spec.init || init;
|
|
|
|
that.create = spec.create || ipa_search_facet_create;
|
|
|
|
that.setup = spec.setup || setup;
|
|
|
|
that.load = spec.load || load;
|
2010-10-13 12:07:43 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.columns = [];
|
|
|
|
that.columns_by_name = {};
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.__defineGetter__("entity_name", function(){
|
|
|
|
return that._entity_name;
|
|
|
|
});
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.__defineSetter__("entity_name", function(entity_name){
|
|
|
|
that._entity_name = entity_name;
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
for (var i=0; i<that.columns.length; i++) {
|
|
|
|
that.columns[i].entity_name = entity_name;
|
|
|
|
}
|
|
|
|
});
|
2010-09-29 00:52:56 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.get_columns = function() {
|
|
|
|
return that.columns;
|
|
|
|
};
|
2010-09-29 00:52:56 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.get_column = function(name) {
|
|
|
|
return that.columns_by_name[name];
|
|
|
|
};
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.add_column = function(column) {
|
|
|
|
column.entity_name = that.entity_name;
|
|
|
|
that.columns.push(column);
|
|
|
|
that.columns_by_name[column.name] = column;
|
|
|
|
};
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.create_column = function(spec) {
|
|
|
|
var column = ipa_search_column(spec);
|
|
|
|
that.add_column(column);
|
|
|
|
return column;
|
|
|
|
};
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
function init() {
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.table = ipa_search_widget({
|
|
|
|
'id': that.entity_name+'-search',
|
2010-11-15 11:10:55 -06:00
|
|
|
'name': 'search', 'label': IPA.metadata[that.entity_name].label,
|
2010-11-09 14:22:31 -06:00
|
|
|
'entity_name': that.entity_name
|
|
|
|
});
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
for (var i=0; i<that.columns.length; i++) {
|
|
|
|
var column = that.columns[i];
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
var param_info = ipa_get_param_info(that.entity_name, column.name);
|
|
|
|
var primary_key = param_info && param_info['primary_key'];
|
2010-10-01 11:40:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
column.primary_key = primary_key;
|
|
|
|
column.link = primary_key;
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.table.add_column(column);
|
|
|
|
}
|
|
|
|
}
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.is_dirty = function() {
|
|
|
|
var filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
|
|
|
|
return filter != that.filter;
|
|
|
|
};
|
2010-08-23 21:32:23 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
function ipa_search_facet_create(container) {
|
2010-08-23 21:32:23 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
container.attr('title', that.entity_name);
|
2010-09-07 09:08:19 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
var span = $('<span/>', { 'name': 'search' }).appendTo(container);
|
2010-09-29 00:52:56 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
that.table.create(span);
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
function setup(container) {
|
|
|
|
var span = $('span[name=search]', container);
|
|
|
|
that.table.setup(span);
|
2010-11-09 14:22:31 -06:00
|
|
|
}
|
|
|
|
|
2010-11-15 11:10:55 -06:00
|
|
|
function load(container) {
|
2010-11-09 14:22:31 -06:00
|
|
|
that.filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
|
2010-11-15 11:10:55 -06:00
|
|
|
var span = $('span[name=search]', container);
|
|
|
|
that.table.refresh(span);
|
2010-11-09 14:22:31 -06:00
|
|
|
}
|
2010-09-29 00:52:56 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
if (spec.columns) {
|
|
|
|
for (var i=0; i<spec.columns.length; i++) {
|
|
|
|
var column = spec.columns[i];
|
|
|
|
column.facet = that;
|
|
|
|
that.add_column(column);
|
|
|
|
}
|
2010-09-29 00:52:56 -05:00
|
|
|
}
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
return that;
|
2010-08-06 09:01:44 -05:00
|
|
|
}
|
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
function search_generate_tr(thead, tbody, entry_attrs)
|
|
|
|
{
|
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.
2010-11-02 20:16:55 -05:00
|
|
|
var obj_name = tbody.closest('.entity-container').attr('title');
|
2010-10-27 22:32:30 -05:00
|
|
|
var pkey = IPA.metadata[obj_name].primary_key;
|
2010-10-01 11:40:30 -05:00
|
|
|
var pkey_value = entry_attrs[pkey];
|
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
var entity = IPA.get_entity(obj_name);
|
|
|
|
var facet = entity ? entity.get_facet('search') : null;
|
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
tbody.append('<tr></tr>');
|
|
|
|
var tr = tbody.children().last();
|
2010-10-01 11:40:30 -05:00
|
|
|
search_generate_checkbox_td(tr, pkey_value);
|
2010-09-16 09:28:07 -05:00
|
|
|
|
|
|
|
var ths = thead.find('th');
|
2010-10-01 11:40:30 -05:00
|
|
|
for (var i = 1; i < ths.length; ++i) {
|
2010-09-16 09:28:07 -05:00
|
|
|
var jobj = $(ths[i]);
|
|
|
|
var attr = jobj.attr('abbr');
|
|
|
|
var value = entry_attrs[attr];
|
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
var column = facet ? facet.get_column(attr) : null;
|
2010-09-16 09:28:07 -05:00
|
|
|
var render_call = window[jobj.attr('title')];
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
if (column && column.setup) {
|
|
|
|
column.setup(tr, attr, value, entry_attrs);
|
|
|
|
|
|
|
|
} else if (typeof render_call == 'function') {
|
2010-09-14 21:26:15 -05:00
|
|
|
render_call(tr, attr, value, entry_attrs);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-09-14 21:26:15 -05:00
|
|
|
} else
|
2010-10-27 22:32:30 -05:00
|
|
|
search_generate_td(tr, attr, value, entry_attrs);
|
2010-08-06 09:01:44 -05:00
|
|
|
}
|
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
tbody.find('.search-a-pkey').click(function () {
|
|
|
|
var jobj = $(this);
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
var state = {};
|
|
|
|
state[obj_name + '-facet'] = 'details';
|
|
|
|
state[obj_name + '-pkey'] = $(this).text();
|
|
|
|
$.bbq.pushState(state);
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
return (false);
|
|
|
|
});
|
|
|
|
}
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-10-01 11:40:30 -05:00
|
|
|
function search_generate_checkbox_td(tr, pkey)
|
|
|
|
{
|
|
|
|
var checkbox = $('<input />', {
|
|
|
|
name: pkey,
|
|
|
|
title: pkey,
|
|
|
|
type: 'checkbox',
|
2010-10-27 22:32:30 -05:00
|
|
|
'class': 'search-selector'
|
2010-10-01 11:40:30 -05:00
|
|
|
});
|
|
|
|
var td = $('<td></td>');
|
|
|
|
|
|
|
|
td.append(checkbox);
|
|
|
|
tr.append(td);
|
|
|
|
}
|
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
var _search_td_template = '<td title="A">V</td>';
|
|
|
|
var _search_a_pkey_template = '<a href="jslink" class="search-a-pkey">V</a>';
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
function search_generate_td(tr, attr, value, entry_attrs)
|
2010-09-16 09:28:07 -05:00
|
|
|
{
|
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.
2010-11-02 20:16:55 -05:00
|
|
|
var obj_name = tr.closest('.entity-container').attr('title');
|
2010-09-16 09:28:07 -05:00
|
|
|
|
|
|
|
var param_info = ipa_get_param_info(obj_name, attr);
|
|
|
|
if (param_info && param_info['primary_key'])
|
|
|
|
value = _search_a_pkey_template.replace('V', value);
|
2010-08-06 09:01:44 -05:00
|
|
|
|
2010-09-16 09:28:07 -05:00
|
|
|
tr.append(_search_td_template.replace('A', attr).replace('V', value));
|
2010-08-23 21:32:23 -05:00
|
|
|
}
|