2010-09-16 09:28:07 -05:00
|
|
|
/* Authors:
|
|
|
|
* Pavel Zuna <pzuna@redhat.com>
|
2010-10-01 16:33:57 -05:00
|
|
|
* Endi S. Dewata <edewata@redhat.com>
|
2010-11-23 21:24:50 -06:00
|
|
|
* Adam Young <ayoung@redhat.com>
|
2010-09-16 09:28:07 -05:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Red Hat
|
|
|
|
* see file 'COPYING' for use and warranty information
|
|
|
|
*
|
2010-12-09 06:59:11 -06:00
|
|
|
* 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.
|
2010-09-16 09:28:07 -05:00
|
|
|
*
|
|
|
|
* 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
|
2010-12-09 06:59:11 -06:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-09-16 09:28:07 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* REQUIRES: ipa.js, details.js, search.js, add.js */
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.facet = function (spec) {
|
2010-10-13 12:07:43 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
spec = spec || {};
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
var that = {};
|
2010-11-15 15:41:21 -06:00
|
|
|
that.display_class = spec.display_class || 'entity-facet';
|
2010-10-27 22:32:30 -05:00
|
|
|
that.name = spec.name;
|
|
|
|
that.label = spec.label;
|
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
|
|
|
that._entity_name = spec.entity_name;
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.init = spec.init || init;
|
|
|
|
that.create = spec.create || create;
|
|
|
|
that.setup = spec.setup || setup;
|
|
|
|
that.load = spec.load || load;
|
2010-10-22 08:41:34 -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
|
|
|
that.__defineGetter__("entity_name", function(){
|
|
|
|
return that._entity_name;
|
|
|
|
});
|
|
|
|
|
|
|
|
that.__defineSetter__("entity_name", function(entity_name){
|
|
|
|
that._entity_name = entity_name;
|
|
|
|
});
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
that.create_action_panel = IPA.facet_create_action_panel;
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
function init() {
|
|
|
|
}
|
|
|
|
|
2010-11-18 20:17:14 -06:00
|
|
|
function create(container) {
|
2010-11-09 14:22:31 -06:00
|
|
|
}
|
|
|
|
|
2010-11-18 20:17:14 -06:00
|
|
|
function setup(container) {
|
|
|
|
that.container = container;
|
2010-11-09 14:22:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
function load() {
|
|
|
|
}
|
|
|
|
|
2010-11-19 11:38:35 -06:00
|
|
|
that.get_client_area = function() {
|
2010-11-19 23:52:33 -06:00
|
|
|
return $('.client', that.container);
|
2010-11-19 11:38:35 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
that.get_action_panel = function() {
|
2010-11-19 23:52:33 -06:00
|
|
|
return $('.action-panel', that.container);
|
2010-11-19 11:38:35 -06:00
|
|
|
};
|
|
|
|
|
2010-11-18 20:17:14 -06:00
|
|
|
that.facet_init = that.init;
|
|
|
|
that.facet_create = that.create;
|
|
|
|
that.facet_setup = that.setup;
|
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
return that;
|
|
|
|
}
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity = function (spec) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
var that = {};
|
|
|
|
that.name = spec.name;
|
|
|
|
that.label = spec.label;
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
that.setup = spec.setup || IPA.entity_setup;
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.dialogs = [];
|
|
|
|
that.dialogs_by_name = {};
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
that.facets = [];
|
|
|
|
that.facets_by_name = {};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.facet_name = null;
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-19 23:52:33 -06:00
|
|
|
that.autogenerate_associations = false;
|
|
|
|
|
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
|
|
|
that.associations = [];
|
|
|
|
that.associations_by_name = {};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.get_dialog = function(name) {
|
|
|
|
return that.dialogs_by_name[name];
|
2010-10-27 22:32:30 -05:00
|
|
|
};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.add_dialog = function(dialog) {
|
|
|
|
dialog.entity_name = that.name;
|
|
|
|
that.dialogs.push(dialog);
|
|
|
|
that.dialogs_by_name[dialog.name] = dialog;
|
2010-10-27 22:32:30 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
that.get_facet = function(name) {
|
|
|
|
return that.facets_by_name[name];
|
|
|
|
};
|
|
|
|
|
|
|
|
that.add_facet = function(facet) {
|
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
|
|
|
facet.entity_name = that.name;
|
2010-10-27 22:32:30 -05:00
|
|
|
that.facets.push(facet);
|
|
|
|
that.facets_by_name[facet.name] = facet;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
that.get_associations = function() {
|
|
|
|
return that.associations;
|
|
|
|
};
|
|
|
|
|
|
|
|
that.get_association = function(name) {
|
|
|
|
return that.associations_by_name[name];
|
|
|
|
};
|
|
|
|
|
|
|
|
that.add_association = function(config) {
|
|
|
|
that.associations.push(config);
|
|
|
|
that.associations_by_name[config.name] = config;
|
|
|
|
};
|
|
|
|
|
|
|
|
that.create_association = function(spec) {
|
2011-01-12 18:51:22 -06:00
|
|
|
var config = IPA.association_config(spec);
|
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
|
|
|
that.add_association(config);
|
|
|
|
return config;
|
|
|
|
};
|
|
|
|
|
2011-01-04 14:21:18 -06:00
|
|
|
that.create_association_facet = function(attribute_member, other_entity, label, facet_group) {
|
2010-11-19 23:52:33 -06:00
|
|
|
|
|
|
|
if (!attribute_member) {
|
2011-01-12 18:51:22 -06:00
|
|
|
attribute_member = IPA.get_member_attribute(
|
2011-01-12 13:47:29 -06:00
|
|
|
that.entity_name, other_entity);
|
2010-11-19 23:52:33 -06:00
|
|
|
}
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
return IPA.association_facet({
|
2010-11-19 23:52:33 -06:00
|
|
|
'name': attribute_member+'_'+other_entity,
|
|
|
|
'label': label,
|
2011-01-04 14:21:18 -06:00
|
|
|
'other_entity': other_entity,
|
|
|
|
'facet_group': facet_group,
|
2011-01-12 13:47:29 -06:00
|
|
|
'attribute_member': attribute_member
|
2010-11-19 23:52:33 -06:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
that.create_association_facets = function() {
|
|
|
|
|
|
|
|
var attribute_members = IPA.metadata[that.name].attribute_members;
|
|
|
|
|
|
|
|
for (var attribute_member in attribute_members) {
|
2010-12-02 17:16:34 -06:00
|
|
|
|
|
|
|
// skip non-assignable associations
|
|
|
|
if (attribute_member === 'memberindirect') continue;
|
|
|
|
if (attribute_member === 'enrolledby') continue;
|
|
|
|
|
2010-11-19 23:52:33 -06:00
|
|
|
var other_entities = attribute_members[attribute_member];
|
|
|
|
|
|
|
|
for (var j = 0; j < other_entities.length; j++) {
|
|
|
|
var other_entity = other_entities[j];
|
2010-12-02 17:16:34 -06:00
|
|
|
var other_entity_name = IPA.metadata[other_entity].label;
|
|
|
|
|
|
|
|
var label = other_entity_name;
|
|
|
|
|
2011-01-04 14:21:18 -06:00
|
|
|
var relationships = IPA.metadata[that.name].relationships;
|
2010-12-02 17:16:34 -06:00
|
|
|
|
2011-01-04 14:21:18 -06:00
|
|
|
var relationship = relationships[attribute_member];
|
|
|
|
if (!relationship)
|
|
|
|
relationship = ['Member', '', 'no_'];
|
|
|
|
var facet_group = relationship[0];
|
2010-12-02 17:16:34 -06:00
|
|
|
|
2011-01-04 14:21:18 -06:00
|
|
|
var facet = that.create_association_facet(
|
2011-01-12 13:47:29 -06:00
|
|
|
attribute_member, other_entity, label, facet_group);
|
2010-11-19 23:52:33 -06:00
|
|
|
|
|
|
|
if (that.get_facet(facet.name)) continue;
|
2011-01-04 14:21:18 -06:00
|
|
|
|
2010-11-19 23:52:33 -06:00
|
|
|
that.add_facet(facet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
that.init = function() {
|
2010-11-19 23:52:33 -06:00
|
|
|
|
2010-12-07 12:17:12 -06:00
|
|
|
if (!that.label) {
|
|
|
|
that.label = IPA.metadata[that.name].label;
|
|
|
|
}
|
|
|
|
|
2010-11-19 23:52:33 -06:00
|
|
|
if (that.autogenerate_associations) {
|
|
|
|
that.create_association_facets();
|
|
|
|
}
|
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
for (var i=0; i<that.facets.length; i++) {
|
|
|
|
var facet = that.facets[i];
|
|
|
|
facet.init();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-11-16 18:10:40 -06:00
|
|
|
that.entity_init = that.init;
|
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
return that;
|
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2010-09-30 15:37:33 -05:00
|
|
|
/* use this to track individual changes between two hashchange events */
|
|
|
|
var window_hash_cache = {};
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
/*renamed to avoid clash with IPA.get_entity*/
|
|
|
|
IPA.fetch_entity = function (entity_name) {
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
var entity = IPA.get_entity(entity_name);
|
|
|
|
if (entity) return entity;
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
entity = IPA.entity({
|
2010-10-27 22:32:30 -05:00
|
|
|
'name': entity_name
|
|
|
|
});
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
IPA.add_entity(entity);
|
|
|
|
return entity;
|
2010-09-16 09:28:07 -05:00
|
|
|
}
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity_get_search_facet = function (entity_name) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var entity = IPA.fetch_entity(entity_name);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
var facet = entity.get_facet('search');
|
|
|
|
if (facet) return facet;
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
facet = IPA.search_facet({
|
2010-10-27 22:32:30 -05:00
|
|
|
'name': 'search',
|
|
|
|
'label': 'Search'
|
|
|
|
});
|
2010-11-09 14:22:31 -06:00
|
|
|
entity.add_facet(facet);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
return facet;
|
Certificate management for services.
This is an initial implementation of certificate management for
services. It addresses the mechanism required to view and update
certificates. The complete UI implementation will be addressed in
subsequent patches.
On the server side, the service.py has been modified to define
usercertificate in the service object's takes_params. This is
needed to generate the proper JSON metadata which is needed by
the UI. It also has been modified to accept null certificate for
deletion.
On the client side, the service details page has been modified to
display the base64-encoded certificate in a text area. When the
page is saved, the action handler will store the base64-encoded
certificate in the proper JSON structure. Also the service name
and service hostname are now displayed in separate fields.
The details configuration has been modified to support displaying
and updating certificates. The structure is changed to use maps
to define sections and fields. A section contains name, label,
and an array of fields. A field contains name, label, setup
function, load function, and save function. This is used to
implement custom interface and behavior for certificates.
All other entities, test cases, and test data have been updated
accordingly. Some functions and variables have been renamed to
improve clarity and consistency.
2010-10-07 14:02:44 -05:00
|
|
|
}
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity_set_search_definition = function (entity_name, data) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var facet = IPA.entity_get_search_facet(entity_name);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
for (var i=0; i<data.length; i++) {
|
|
|
|
var defn = data[i];
|
|
|
|
facet.create_column({
|
|
|
|
'name': defn[0],
|
|
|
|
'label': defn[1],
|
|
|
|
'setup': defn[2]
|
|
|
|
});
|
|
|
|
}
|
2010-10-01 16:33:57 -05:00
|
|
|
}
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity_set_add_definition = function (entity_name, data) {
|
2010-10-06 16:24:58 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var entity = IPA.fetch_entity(entity_name);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var dialog = IPA.add_dialog({
|
2010-11-09 14:22:31 -06:00
|
|
|
'name': 'add',
|
2010-10-27 22:32:30 -05:00
|
|
|
'title': data[1]
|
|
|
|
});
|
2010-11-09 14:22:31 -06:00
|
|
|
entity.add_dialog(dialog);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
for (var i=0; i<data[2].length; i++) {
|
|
|
|
var field = data[2][i];
|
2011-01-12 18:51:22 -06:00
|
|
|
dialog.add_field(IPA.text_widget({
|
2010-10-27 22:32:30 -05:00
|
|
|
name: field[0],
|
|
|
|
label: field[1],
|
2010-11-15 11:10:55 -06:00
|
|
|
setup: field[2],
|
|
|
|
undo: false
|
2010-11-09 14:22:31 -06:00
|
|
|
}));
|
2010-10-22 08:41:34 -05:00
|
|
|
}
|
2010-12-06 16:30:10 -06:00
|
|
|
|
|
|
|
dialog.init();
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity_get_add_dialog = function (entity_name) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var entity = IPA.fetch_entity(entity_name);
|
2010-10-27 22:32:30 -05:00
|
|
|
return entity.get_add_dialog();
|
2010-10-22 08:41:34 -05:00
|
|
|
}
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity_get_details_facet = function (entity_name) {
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var entity = IPA.fetch_entity(entity_name);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
var facet = entity.get_facet('details');
|
|
|
|
if (facet) return facet;
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
facet = IPA.details_facet({
|
2010-10-27 22:32:30 -05:00
|
|
|
'name': 'details',
|
|
|
|
'label': 'Details'
|
|
|
|
});
|
2010-11-09 14:22:31 -06:00
|
|
|
entity.add_facet(facet);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
return facet;
|
2010-10-06 16:24:58 -05:00
|
|
|
}
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity_set_details_definition = function (entity_name, sections) {
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var facet = IPA.entity_get_details_facet(entity_name);
|
2010-10-27 22:32:30 -05:00
|
|
|
|
|
|
|
for (var i=0; i<sections.length; i++) {
|
|
|
|
var section = sections[i];
|
|
|
|
facet.add_section(section);
|
2010-09-30 15:37:33 -05:00
|
|
|
}
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity_set_association_definition = function (entity_name, data) {
|
2010-09-30 15:37:33 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var entity = IPA.fetch_entity(entity_name);
|
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-19 23:52:33 -06:00
|
|
|
entity.autogenerate_associations = true;
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
for (var other_entity in data) {
|
|
|
|
var config = data[other_entity];
|
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
|
|
|
entity.create_association({
|
2010-10-27 22:32:30 -05:00
|
|
|
'name': other_entity,
|
|
|
|
'associator': config.associator,
|
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
|
|
|
'add_method': config.add_method,
|
2010-12-02 22:12:59 -06:00
|
|
|
'remove_method': config.remove_method
|
2010-10-27 22:32:30 -05:00
|
|
|
});
|
Certificate management for services.
This is an initial implementation of certificate management for
services. It addresses the mechanism required to view and update
certificates. The complete UI implementation will be addressed in
subsequent patches.
On the server side, the service.py has been modified to define
usercertificate in the service object's takes_params. This is
needed to generate the proper JSON metadata which is needed by
the UI. It also has been modified to accept null certificate for
deletion.
On the client side, the service details page has been modified to
display the base64-encoded certificate in a text area. When the
page is saved, the action handler will store the base64-encoded
certificate in the proper JSON structure. Also the service name
and service hostname are now displayed in separate fields.
The details configuration has been modified to support displaying
and updating certificates. The structure is changed to use maps
to define sections and fields. A section contains name, label,
and an array of fields. A field contains name, label, setup
function, load function, and save function. This is used to
implement custom interface and behavior for certificates.
All other entities, test cases, and test data have been updated
accordingly. Some functions and variables have been renamed to
improve clarity and consistency.
2010-10-07 14:02:44 -05:00
|
|
|
}
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity_set_facet_definition = function (entity_name, list) {
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var entity = IPA.fetch_entity(entity_name);
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
for (var i=0; i<list.length; i++) {
|
|
|
|
var facet = list[i];
|
|
|
|
entity.add_facet(facet);
|
Certificate management for services.
This is an initial implementation of certificate management for
services. It addresses the mechanism required to view and update
certificates. The complete UI implementation will be addressed in
subsequent patches.
On the server side, the service.py has been modified to define
usercertificate in the service object's takes_params. This is
needed to generate the proper JSON metadata which is needed by
the UI. It also has been modified to accept null certificate for
deletion.
On the client side, the service details page has been modified to
display the base64-encoded certificate in a text area. When the
page is saved, the action handler will store the base64-encoded
certificate in the proper JSON structure. Also the service name
and service hostname are now displayed in separate fields.
The details configuration has been modified to support displaying
and updating certificates. The structure is changed to use maps
to define sections and fields. A section contains name, label,
and an array of fields. A field contains name, label, setup
function, load function, and save function. This is used to
implement custom interface and behavior for certificates.
All other entities, test cases, and test data have been updated
accordingly. Some functions and variables have been renamed to
improve clarity and consistency.
2010-10-07 14:02:44 -05:00
|
|
|
}
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
2010-09-28 09:19:05 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.current_facet = function (entity){
|
2010-12-07 12:17:12 -06:00
|
|
|
var facet_name = $.bbq.getState(entity.name + '-facet', true);
|
|
|
|
if (!facet_name && entity.facets.length) {
|
|
|
|
facet_name = entity.facets[0].name;
|
|
|
|
}
|
|
|
|
return facet_name;
|
2010-11-15 15:41:21 -06:00
|
|
|
}
|
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA.entity_setup = function (container) {
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
var entity = this;
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
var facet_name = IPA.current_facet(entity);
|
2010-11-15 15:41:21 -06:00
|
|
|
|
2010-10-22 08:41:34 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
var facet = entity.get_facet(facet_name);
|
|
|
|
if (!facet) return;
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
if (IPA.entity_name == entity.name) {
|
|
|
|
if (entity.facet_name == facet_name) {
|
|
|
|
if (!facet.is_dirty()) return;
|
2010-09-16 09:28:07 -05:00
|
|
|
|
2010-10-27 22:32:30 -05:00
|
|
|
} else {
|
|
|
|
entity.facet_name = facet_name;
|
2010-09-16 09:28:07 -05:00
|
|
|
}
|
2010-10-27 22:32:30 -05:00
|
|
|
} else {
|
|
|
|
IPA.entity_name = entity.name;
|
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
|
|
|
container.empty();
|
|
|
|
|
2010-11-19 11:38:35 -06:00
|
|
|
facet.create_action_panel(container);
|
2010-11-09 14:22:31 -06:00
|
|
|
facet.create(container);
|
2010-11-09 19:04:49 -06:00
|
|
|
container.children().last().addClass('client');
|
2010-11-15 11:10:55 -06:00
|
|
|
facet.setup(container);
|
2010-11-18 20:17:14 -06:00
|
|
|
facet.refresh();
|
2010-10-27 22:32:30 -05:00
|
|
|
}
|
|
|
|
|
2010-11-29 13:26:55 -06:00
|
|
|
|
|
|
|
|
|
|
|
/*Returns the entity requested, as well as:
|
|
|
|
any nested tabs underneath it or
|
|
|
|
its parent tab and the others nested at the same level*/
|
|
|
|
|
|
|
|
IPA.nested_tabs = function(entity_name){
|
|
|
|
|
|
|
|
var siblings = [];
|
2011-01-12 13:47:29 -06:00
|
|
|
var nested_index;
|
|
|
|
var nested_entities;
|
2010-11-29 13:26:55 -06:00
|
|
|
|
2010-12-01 14:51:39 -06:00
|
|
|
if (!IPA.tab_set) {
|
|
|
|
siblings.push(entity_name);
|
|
|
|
return siblings;
|
|
|
|
}
|
|
|
|
|
2010-11-29 13:26:55 -06:00
|
|
|
for (var top_tab_index = 0;
|
|
|
|
top_tab_index < IPA.tab_set.length;
|
|
|
|
top_tab_index += 1){
|
|
|
|
var top_tab = IPA.tab_set[top_tab_index];
|
|
|
|
for (var subtab_index = 0;
|
|
|
|
subtab_index < top_tab.children.length;
|
|
|
|
subtab_index += 1){
|
|
|
|
if(top_tab.children[subtab_index].name){
|
|
|
|
if (top_tab.children[subtab_index].name === entity_name){
|
|
|
|
siblings.push(entity_name);
|
|
|
|
if (top_tab.children[subtab_index].children){
|
2011-01-12 13:47:29 -06:00
|
|
|
nested_entities = top_tab.children[subtab_index].children;
|
|
|
|
for ( nested_index = 0;
|
|
|
|
nested_index < nested_entities.length;
|
|
|
|
nested_index += 1){
|
2010-11-29 13:26:55 -06:00
|
|
|
siblings.push (nested_entities[nested_index].name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if (top_tab.children[subtab_index].children){
|
2011-01-12 13:47:29 -06:00
|
|
|
nested_entities = top_tab.children[subtab_index].children;
|
|
|
|
for (nested_index = 0;
|
2010-11-29 13:26:55 -06:00
|
|
|
nested_index < nested_entities.length;
|
|
|
|
nested_index += 1){
|
|
|
|
if (nested_entities[nested_index].name === entity_name){
|
|
|
|
siblings.push(top_tab.children[subtab_index].name);
|
|
|
|
for (var nested_index2 = 0;
|
|
|
|
nested_index2 < nested_entities.length;
|
|
|
|
nested_index2 += 1){
|
|
|
|
siblings.push(nested_entities[nested_index2].name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return siblings;
|
2011-01-12 13:47:29 -06:00
|
|
|
};
|
2010-11-29 13:26:55 -06:00
|
|
|
|
2011-01-12 18:51:22 -06:00
|
|
|
IPA. facet_create_action_panel = function(container) {
|
2010-11-19 11:38:35 -06:00
|
|
|
|
|
|
|
var that = this;
|
|
|
|
var entity_name = that.entity_name;
|
|
|
|
var action_panel = $('<div/>', {
|
|
|
|
"class": "action-panel",
|
2010-11-23 21:24:50 -06:00
|
|
|
html: $('<h3>',{
|
|
|
|
text: IPA.metadata[entity_name].label
|
|
|
|
})
|
2010-11-19 11:38:35 -06:00
|
|
|
}).appendTo(container);
|
2010-11-19 23:52:33 -06:00
|
|
|
function build_link(other_facet,label){
|
2010-11-15 15:41:21 -06:00
|
|
|
var li = $('<li/>', {
|
|
|
|
"class" : other_facet.display_class,
|
2010-11-19 23:52:33 -06:00
|
|
|
title: other_facet.name,
|
2010-11-15 15:41:21 -06:00
|
|
|
text: label,
|
|
|
|
click: function(entity_name, other_facet_name) {
|
2010-11-29 13:26:55 -06:00
|
|
|
return function() {
|
|
|
|
if($(this).hasClass('entity-facet-disabled')){
|
2010-11-15 15:41:21 -06:00
|
|
|
return false;
|
2010-11-29 13:26:55 -06:00
|
|
|
}
|
|
|
|
var this_pkey = $('input[id=pkey]', action_panel).val();
|
|
|
|
IPA.switch_and_show_page(
|
|
|
|
entity_name, other_facet_name,
|
|
|
|
this_pkey);
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}(entity_name, other_facet_name)
|
|
|
|
});
|
2010-11-15 15:41:21 -06:00
|
|
|
return li;
|
|
|
|
}
|
|
|
|
/*Note, for debugging purposes, it is useful to set var pkey_type = 'text';*/
|
|
|
|
var pkey_type = 'hidden';
|
2010-11-19 11:38:35 -06:00
|
|
|
$('<input/>', {
|
|
|
|
'type': pkey_type,
|
|
|
|
id:'pkey',
|
|
|
|
name:'pkey'
|
|
|
|
}).appendTo(action_panel);
|
|
|
|
var ul = $('<ul/>', {'class': 'action'}).appendTo(action_panel);
|
2010-11-12 14:23:58 -06:00
|
|
|
var entity = IPA.get_entity(entity_name);
|
2011-01-12 18:51:22 -06:00
|
|
|
var facet_name = IPA.current_facet(entity);
|
2010-11-23 21:24:50 -06:00
|
|
|
var other_facet = entity.facets[0];
|
|
|
|
var other_facet_name = other_facet.name;
|
2010-11-29 13:26:55 -06:00
|
|
|
var nested_tabs = IPA.nested_tabs(entity_name);
|
2011-01-12 13:47:29 -06:00
|
|
|
var main_facet = build_link(other_facet,other_facet.label);
|
2010-11-29 13:26:55 -06:00
|
|
|
for (var nested_index = 0 ;
|
|
|
|
nested_index < nested_tabs.length;
|
|
|
|
nested_index += 1){
|
|
|
|
if (nested_tabs[nested_index] === entity_name){
|
|
|
|
/*assume for now that entities with only a single facet
|
|
|
|
do not have search*/
|
|
|
|
if (entity.facets.length > 0 ){
|
2011-01-12 18:51:22 -06:00
|
|
|
if ( entity.facets[0].name === IPA.current_facet( entity)){
|
2011-01-06 10:22:57 -06:00
|
|
|
main_facet.text( IPA.metadata[entity_name].label);
|
|
|
|
main_facet.appendTo(ul);
|
|
|
|
ul.append($('<li><span class="action-controls"/></li>'));
|
|
|
|
}else{
|
|
|
|
main_facet.html(
|
|
|
|
$('<span />',{
|
2011-01-12 13:47:29 -06:00
|
|
|
"class":"input_link"
|
|
|
|
}).
|
|
|
|
append(
|
|
|
|
$('<span/>',{
|
|
|
|
"class":"ui-icon ui-icon-triangle-1-w "
|
|
|
|
})).
|
|
|
|
append('Back to List '));
|
2011-01-06 10:22:57 -06:00
|
|
|
main_facet.appendTo(ul);
|
|
|
|
}
|
2010-11-29 13:26:55 -06:00
|
|
|
}
|
2011-01-04 14:21:18 -06:00
|
|
|
var facet_groups = {};
|
2011-01-12 13:47:29 -06:00
|
|
|
var li;
|
2010-11-29 13:26:55 -06:00
|
|
|
for (var i=1; i<entity.facets.length; i++) {
|
|
|
|
other_facet = entity.facets[i];
|
|
|
|
other_facet_name = other_facet.name;
|
2011-01-04 14:21:18 -06:00
|
|
|
|
|
|
|
if (other_facet.facet_group) {
|
|
|
|
var facet_group = other_facet.facet_group;
|
|
|
|
if (!facet_groups[facet_group]) {
|
2011-01-12 13:47:29 -06:00
|
|
|
li = $('<li/>', {
|
2011-01-04 14:21:18 -06:00
|
|
|
'class': 'entity-facet-relation-label',
|
|
|
|
'text': other_facet.facet_group,
|
2011-01-12 13:47:29 -06:00
|
|
|
'title': other_facet.facet_group
|
|
|
|
});
|
2011-01-04 14:21:18 -06:00
|
|
|
ul.append(li);
|
|
|
|
facet_groups[facet_group] = li;
|
|
|
|
}
|
2011-01-12 13:47:29 -06:00
|
|
|
li = facet_groups[facet_group];
|
|
|
|
var link = build_link(other_facet, other_facet.label);
|
2011-01-06 16:14:13 -06:00
|
|
|
link.addClass('facet-group-member');
|
2011-01-06 10:22:57 -06:00
|
|
|
li.after(link );
|
2011-01-06 16:14:13 -06:00
|
|
|
/*
|
|
|
|
If we are on the current facet, we make the text black, non-clickable,
|
|
|
|
add an icon and make suer the action controls are positioned underneath it.
|
|
|
|
*/
|
2011-01-12 18:51:22 -06:00
|
|
|
if ( other_facet.name === IPA.current_facet( entity)){
|
2011-01-06 10:22:57 -06:00
|
|
|
var text = link.text();
|
|
|
|
link.text('');
|
|
|
|
link.append($('<ul>').
|
2011-01-06 16:14:13 -06:00
|
|
|
append($('<li />',{
|
|
|
|
'class': 'entity-facet-selected',
|
|
|
|
html: $('<span />',{
|
|
|
|
'class':'input_link',
|
|
|
|
html:'<span class="ui-icon ui-icon-triangle-1-e" />'+ text
|
|
|
|
})})).
|
2011-01-06 10:22:57 -06:00
|
|
|
append($('<li/>',{
|
|
|
|
html:$('<span />',{
|
2011-01-12 13:47:29 -06:00
|
|
|
'class':"action-controls"
|
2011-01-06 16:14:13 -06:00
|
|
|
})
|
2011-01-12 13:47:29 -06:00
|
|
|
})));
|
2011-01-06 10:22:57 -06:00
|
|
|
}
|
2011-01-04 14:21:18 -06:00
|
|
|
facet_groups[facet_group] = li.next();
|
|
|
|
} else {
|
2011-01-06 16:14:13 -06:00
|
|
|
var innerlist = $('<ul/>').appendTo(ul);
|
|
|
|
innerlist.append(build_link(other_facet, other_facet.label));
|
2011-01-12 18:51:22 -06:00
|
|
|
if ( other_facet.name === IPA.current_facet( entity)){
|
2011-01-06 16:14:13 -06:00
|
|
|
innerlist.append($('<li class="entity-facet"><span class="action-controls" /></li>'));
|
2011-01-06 10:22:57 -06:00
|
|
|
}
|
2011-01-04 14:21:18 -06:00
|
|
|
}
|
2010-11-29 13:26:55 -06:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$('<li/>', {
|
|
|
|
title: nested_tabs[nested_index],
|
|
|
|
text: IPA.metadata[nested_tabs[nested_index]].label,
|
|
|
|
"class": "search-facet",
|
|
|
|
click: function() {
|
|
|
|
var state = {};
|
|
|
|
state[nested_tabs[0]+'-entity'] =
|
|
|
|
this.title;
|
|
|
|
nav_push_state(state);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}).appendTo(ul);
|
2010-12-01 14:51:39 -06:00
|
|
|
}
|
2010-10-22 08:41:34 -05:00
|
|
|
}
|
2010-11-15 15:41:21 -06:00
|
|
|
/*When we land on the search page, disable all facets
|
2010-11-29 13:26:55 -06:00
|
|
|
that require a pkey until one is selected*/
|
2010-11-15 15:41:21 -06:00
|
|
|
if (facet_name === 'search'){
|
2010-11-19 11:38:35 -06:00
|
|
|
$('.entity-facet', action_panel).addClass('entity-facet-disabled');
|
2010-11-15 15:41:21 -06:00
|
|
|
}
|
2010-11-19 11:38:35 -06:00
|
|
|
return action_panel;
|
2010-10-01 12:53:13 -05:00
|
|
|
}
|