mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-28 01:41:14 -06:00
create entities on demand.
fixed changes from code review Fixed unit tests for entity on demand changes.
This commit is contained in:
parent
0238cb845a
commit
0330339003
@ -131,7 +131,20 @@ var IPA = ( function () {
|
||||
};
|
||||
|
||||
that.get_entity = function(name) {
|
||||
return that.entities.get(name);
|
||||
var entity = that.entities.get(name);
|
||||
if (!entity){
|
||||
var factory = that.entity_factories[name];
|
||||
try {
|
||||
entity = factory();
|
||||
that.add_entity(entity);
|
||||
entity.init();
|
||||
} catch (e) {
|
||||
/*exceptions thrown by builder just mean that entities
|
||||
are not to be registered. */
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
};
|
||||
|
||||
that.add_entity = function(entity) {
|
||||
@ -142,22 +155,6 @@ var IPA = ( function () {
|
||||
that.entities.remove(name);
|
||||
};
|
||||
|
||||
that.start_entities = function() {
|
||||
var factory;
|
||||
var name;
|
||||
for (name in that.entity_factories) {
|
||||
factory = that.entity_factories[name];
|
||||
try {
|
||||
var entity = factory();
|
||||
that.add_entity(entity);
|
||||
entity.init();
|
||||
} catch (e) {
|
||||
/*exceptions thrown by builder just mean that entities
|
||||
are not to be registered. */
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
that.test_dirty = function(){
|
||||
if (IPA.current_entity){
|
||||
var facet_name = IPA.current_facet(IPA.current_entity);
|
||||
|
@ -43,7 +43,6 @@ module('details', {
|
||||
return IPA.entity({name:obj_name,
|
||||
metadata:IPA.metadata.objects.user});
|
||||
};
|
||||
IPA.start_entities();
|
||||
},
|
||||
teardown: function() {
|
||||
details_container.remove();
|
||||
|
@ -39,7 +39,6 @@ module('entity',{
|
||||
columns:['uid']}).
|
||||
build();
|
||||
};
|
||||
IPA.start_entities();
|
||||
},
|
||||
function(xhr, text_status, error_thrown) {
|
||||
ok(false, "ipa_init() failed: "+error_thrown);
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
|
||||
module('navigation', {
|
||||
|
||||
setup: function() {
|
||||
IPA.ajax_options.async = false;
|
||||
IPA.init(
|
||||
@ -32,11 +33,14 @@ module('navigation', {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
test("Testing IPA.navigation.create().", function() {
|
||||
|
||||
var entity;
|
||||
var user_mock_called = false;
|
||||
var group_mock_called = false;
|
||||
|
||||
IPA.entity_factories.user = function() {
|
||||
var that = IPA.entity({name: 'user',
|
||||
@ -59,13 +63,8 @@ test("Testing IPA.navigation.create().", function() {
|
||||
return that;
|
||||
};
|
||||
|
||||
IPA.start_entities();
|
||||
|
||||
IPA.metadata = {};
|
||||
var navigation_container = $('<div id="navigation"/>').appendTo(document.body);
|
||||
var entity_container = $('<div id="content"/>').appendTo(document.body);
|
||||
var user_mock_called = false;
|
||||
var group_mock_called = false;
|
||||
|
||||
var navigation = IPA.navigation({
|
||||
container: navigation_container,
|
||||
|
@ -143,8 +143,6 @@ $(function() {
|
||||
$('#loggedinas a').fragment(
|
||||
{'user-facet': 'details', 'user-pkey': IPA.whoami_pkey}, 2);
|
||||
|
||||
IPA.start_entities();
|
||||
|
||||
IPA.nav = create_navigation();
|
||||
IPA.nav.create();
|
||||
IPA.nav.update();
|
||||
|
Loading…
Reference in New Issue
Block a user