summaryrefslogtreecommitdiffstats
path: root/install/static/entity.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/entity.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/entity.js')
-rw-r--r--install/static/entity.js65
1 files changed, 49 insertions, 16 deletions
diff --git a/install/static/entity.js b/install/static/entity.js
index f26f219b..24a49fc7 100644
--- a/install/static/entity.js
+++ b/install/static/entity.js
@@ -28,11 +28,19 @@ function ipa_facet(spec) {
var that = {};
that.name = spec.name;
that.label = spec.label;
- that.entity_name = spec.entity_name;
+ that._entity_name = spec.entity_name;
that.init = spec.init;
that.setup = spec.setup;
+ that.__defineGetter__("entity_name", function(){
+ return that._entity_name;
+ });
+
+ that.__defineSetter__("entity_name", function(entity_name){
+ that._entity_name = entity_name;
+ });
+
that.setup_views = ipa_facet_setup_views;
return that;
@@ -55,6 +63,9 @@ function ipa_entity(spec) {
this.facet_name = null;
+ that.associations = [];
+ that.associations_by_name = {};
+
that.get_add_dialog = function() {
return that.add_dialog;
};
@@ -74,31 +85,49 @@ function ipa_entity(spec) {
};
that.add_facet = function(facet) {
+ facet.entity_name = that.name;
that.facets.push(facet);
that.facets_by_name[facet.name] = facet;
};
that.create_search_facet = function(spec) {
- spec.entity_name = that.name;
var facet = ipa_search_facet(spec);
that.add_facet(facet);
return facet;
};
that.create_details_facet = function(spec) {
- spec.entity_name = that.name;
var facet = ipa_details_facet(spec);
that.add_facet(facet);
+ facet.init();
return facet;
};
that.create_association_facet = function(spec) {
- spec.entity_name = that.name;
var facet = ipa_association_facet(spec);
that.add_facet(facet);
return facet;
};
+ 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) {
+ var config = ipa_association_config(spec);
+ that.add_association(config);
+ return config;
+ };
+
return that;
}
@@ -213,14 +242,17 @@ function ipa_entity_get_association_facet(entity_name) {
function ipa_entity_set_association_definition(entity_name, data) {
- var facet = ipa_entity_get_association_facet(entity_name);
+ var entity = ipa_get_entity(entity_name);
+
+ ipa_entity_get_association_facet(entity_name);
for (var other_entity in data) {
var config = data[other_entity];
- facet.create_config({
+ entity.create_association({
'name': other_entity,
'associator': config.associator,
- 'method': config.method
+ 'add_method': config.add_method,
+ 'delete_method': config.delete_method
});
}
}
@@ -231,7 +263,6 @@ function ipa_entity_set_facet_definition(entity_name, list) {
for (var i=0; i<list.length; i++) {
var facet = list[i];
- facet.entity_name = entity_name;
entity.add_facet(facet);
}
}
@@ -244,8 +275,6 @@ function ipa_entity_setup(container, unspecified) {
var entity = this;
- container.empty();
-
var facet_name = $.bbq.getState(entity.name + '-facet', true) || unspecified || 'search';
var facet = entity.get_facet(facet_name);
@@ -262,6 +291,8 @@ function ipa_entity_setup(container, unspecified) {
IPA.entity_name = entity.name;
}
+ container.empty();
+
if (facet.setup) {
facet.setup(container, unspecified);
}
@@ -271,7 +302,7 @@ function ipa_facet_setup_views(container) {
var facet = this;
- var ul = $('<ul/>', {'class': 'entity-views'});
+ var ul = $('<ul/>', {'class': 'entity-views'}).appendTo(container);
var entity = IPA.get_entity(facet.entity_name);
var facets = entity.get_facets();
@@ -289,7 +320,9 @@ function ipa_facet_setup_views(container) {
title: other_facet.name,
text: label,
click: function(entity_name, facet_name) {
- return function() { IPA.show_page(entity_name, facet_name); }
+ return function() {
+ IPA.show_page(entity_name, facet_name);
+ };
}(facet.entity_name, facet_name)
}));
@@ -308,20 +341,20 @@ function ipa_facet_setup_views(container) {
title: other_entity,
text: label,
click: function(entity_name, facet_name, other_entity) {
- return function() { IPA.show_page(entity_name, facet_name, other_entity); }
+ return function() {
+ IPA.show_page(entity_name, facet_name, other_entity);
+ };
}(facet.entity_name, facet_name, other_entity)
}));
}
}
}
}
-
- container.append(ul);
}
function ipa_entity_quick_links(tr, attr, value, entry_attrs) {
- var obj_name = tr.closest('.search-container').attr('title');
+ var obj_name = tr.closest('.entity-container').attr('title');
var pkey = IPA.metadata[obj_name].primary_key;
var pkey_value = entry_attrs[pkey][0];