declarative defintions

Delay the creation of entities until after ipa init is called
made the user and group entity definitions declarative
removed unused facet from groups
adjusted unit tests

made review changes:

factories are now in an associative array
entity init called right after factory
init dialogs in entity init
fixed type on search
This commit is contained in:
Adam Young committed 2011-01-27 16:46:44 -05:00
1 parent 442d6ad30c
commit f904df0f0d
24 files changed
+310 -368

No files matched your search

+31 -24
View File
@@ -110,8 +110,17 @@ IPA.entity = function (spec) {
dialog.entity_name = that.name;
that.dialogs.push(dialog);
that.dialogs_by_name[dialog.name] = dialog;
return that;
};
function init_dialogs (){
var i;
for (i = 0; i < that.dialogs.length; i += 1){
that.dialogs[i].init();
}
return that;
}
that.get_facet = function(name) {
return that.facets_by_name[name];
};
@@ -120,6 +129,14 @@ IPA.entity = function (spec) {
facet.entity_name = that.name;
that.facets.push(facet);
that.facets_by_name[facet.name] = facet;
return that;
};
that.facet = function(facet) {
facet.entity_name = that.name;
that.facets.push(facet);
that.facets_by_name[facet.name] = facet;
return that;
};
that.get_associations = function() {
@@ -141,6 +158,13 @@ IPA.entity = function (spec) {
return config;
};
that.association = function(spec) {
var config = IPA.association_config(spec);
that.add_association(config);
return that;
};
that.create_association_facet = function(attribute_member, other_entity, label, facet_group) {
if (!attribute_member) {
@@ -190,8 +214,12 @@ IPA.entity = function (spec) {
that.add_facet(facet);
}
}
return that;
};
that.standard_associations = that.create_association_facets;
that.init = function() {
if (!that.label) {
@@ -206,6 +234,7 @@ IPA.entity = function (spec) {
var facet = that.facets[i];
facet.init();
}
init_dialogs();
};
that.entity_init = that.init;
@@ -221,6 +250,7 @@ var window_hash_cache = {};
IPA.fetch_entity = function (entity_name) {
var entity = IPA.get_entity(entity_name);
/*
if (entity) return entity;
entity = IPA.entity({
@@ -228,6 +258,7 @@ IPA.fetch_entity = function (entity_name) {
});
IPA.add_entity(entity);
*/
return entity;
};
@@ -264,30 +295,6 @@ IPA.entity_set_search_definition = function (entity_name, data) {
};
IPA.entity_set_add_definition = function (entity_name, data) {
var entity = IPA.fetch_entity(entity_name);
var dialog = IPA.add_dialog({
'name': 'add',
'title': data[1]
});
entity.add_dialog(dialog);
for (var i=0; i<data[2].length; i++) {
var field = data[2][i];
dialog.add_field(IPA.text_widget({
name: field[0],
label: field[1],
setup: field[2],
undo: false
}));
}
dialog.init();
};
IPA.entity_get_add_dialog = function (entity_name) {
var entity = IPA.fetch_entity(entity_name);