Rename factory to $factory in spec objects modifications

https://fedorahosted.org/freeipa/ticket/3235
This commit is contained in:
Petr Vobornik 2013-04-11 15:44:40 +02:00
parent 4ae3372682
commit 9dc8e26b73
9 changed files with 34 additions and 34 deletions

View File

@ -842,7 +842,7 @@ IPA.association_facet = function (spec, no_init) {
var column; var column;
var factory; var factory;
if (spec instanceof Object) { if (spec instanceof Object) {
factory = spec.factory || IPA.column; factory = spec.$factory || IPA.column;
} else { } else {
factory = IPA.column; factory = IPA.column;
spec = { name: spec }; spec = { name: spec };

View File

@ -133,8 +133,8 @@ exp.section_builder = IPA.section_builder = function(spec) {
if(!section_spec.name) section_spec.name = 'section'+index; if(!section_spec.name) section_spec.name = 'section'+index;
section_spec.factory = section_spec.factory || that.section_factory; section_spec.$factory = section_spec.$factory || that.section_factory;
var section = section_spec.factory(section_spec); var section = section_spec.$factory(section_spec);
that.container.widgets.add_widget(section); that.container.widgets.add_widget(section);
@ -152,8 +152,8 @@ exp.section_builder = IPA.section_builder = function(spec) {
var widget = that.widget_builder.build_widget(field_spec, section.widgets); var widget = that.widget_builder.build_widget(field_spec, section.widgets);
//spec.factory refers to widget factory //spec.$factory refers to widget factory
if(field_spec.factory) delete field_spec.factory; if(field_spec.$factory) delete field_spec.$factory;
var field = that.field_builder.build_field(field_spec, that.container.fields); var field = that.field_builder.build_field(field_spec, that.container.fields);

View File

@ -111,7 +111,7 @@ IPA.dialog = function(spec) {
}); });
that.create_button = function(spec) { that.create_button = function(spec) {
var factory = spec.factory || IPA.dialog_button; var factory = spec.$factory || IPA.dialog_button;
var button = factory(spec); var button = factory(spec);
that.add_button(button); that.add_button(button);
return button; return button;

View File

@ -1684,7 +1684,7 @@ IPA.dns.record_type_table_widget = function(spec) {
spec.entity = that.entity; spec.entity = that.entity;
spec.label = spec.label || IPA.dns.record_get_attr_label(spec.name); spec.label = spec.label || IPA.dns.record_get_attr_label(spec.name);
var factory = spec.factory || IPA.column; var factory = spec.$factory || IPA.column;
var column = factory(spec); var column = factory(spec);
that.add_column(column); that.add_column(column);

View File

@ -182,7 +182,7 @@ IPA.entity_builder = function() {
that.entity = function(spec) { that.entity = function(spec) {
var factory = IPA.entity; var factory = IPA.entity;
if (spec instanceof Object) { if (spec instanceof Object) {
factory = spec.factory || IPA.entity; factory = spec.$factory || IPA.entity;
} else { } else {
spec = { name: spec }; spec = { name: spec };
} }
@ -203,7 +203,7 @@ IPA.entity_builder = function() {
that.facet_group = function(spec) { that.facet_group = function(spec) {
spec.entity = entity; spec.entity = entity;
if (spec instanceof Object) { if (spec instanceof Object) {
var factory = spec.factory || IPA.facet_group; var factory = spec.$factory || IPA.facet_group;
facet_group = factory(spec); facet_group = factory(spec);
} else { } else {
facet_group = IPA.facet_group({ name: spec }); facet_group = IPA.facet_group({ name: spec });
@ -378,7 +378,7 @@ IPA.entity_builder = function() {
that.dialog = function(spec) { that.dialog = function(spec) {
if (spec instanceof Object) { if (spec instanceof Object) {
spec.factory = spec.factory || IPA.dialog; spec.$factory = spec.$factory || IPA.dialog;
spec.entity = entity; spec.entity = entity;
} else { } else {
@ -394,7 +394,7 @@ IPA.entity_builder = function() {
}; };
that.adder_dialog = function(spec) { that.adder_dialog = function(spec) {
spec.factory = spec.factory || IPA.entity_adder_dialog; spec.$factory = spec.$factory || IPA.entity_adder_dialog;
spec.name = spec.name || 'add'; spec.name = spec.name || 'add';
if (!spec.title) { if (!spec.title) {
@ -407,7 +407,7 @@ IPA.entity_builder = function() {
}; };
that.deleter_dialog = function(spec) { that.deleter_dialog = function(spec) {
spec.factory = spec.factory || IPA.search_deleter_dialog; spec.$factory = spec.$factory || IPA.search_deleter_dialog;
spec.name = spec.name || 'remove'; spec.name = spec.name || 'remove';
return that.dialog(spec); return that.dialog(spec);
@ -439,7 +439,7 @@ IPA.dialog_builder = function(entity) {
spec.entity = entity; spec.entity = entity;
//add dialog //add dialog
var dialog = spec.factory(spec); var dialog = spec.$factory(spec);
entity.dialog(dialog); entity.dialog(dialog);
}; };

View File

@ -1109,7 +1109,7 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
that.create_column = function(spec) { that.create_column = function(spec) {
var column; var column;
if (spec instanceof Object) { if (spec instanceof Object) {
var factory = spec.factory || IPA.column; var factory = spec.$factory || IPA.column;
} else { } else {
factory = IPA.column; factory = IPA.column;
spec = { name: spec }; spec = { name: spec };
@ -1502,7 +1502,7 @@ exp.facet_builder = IPA.facet_builder = function(entity) {
} }
//add facet //add facet
var facet = spec.factory(spec); var facet = spec.$factory(spec);
entity.add_facet(facet); entity.add_facet(facet);
}; };
@ -1519,7 +1519,7 @@ exp.facet_builder = IPA.facet_builder = function(entity) {
spec.title = spec.title || entity.metadata.label; spec.title = spec.title || entity.metadata.label;
spec.label = spec.label || entity.metadata.label; spec.label = spec.label || entity.metadata.label;
spec.tab_label = spec.tab_label || '@i18n:facets.search'; spec.tab_label = spec.tab_label || '@i18n:facets.search';
spec.factory = spec.factory || IPA.search_facet; spec.$factory = spec.$factory || IPA.search_facet;
add_redirect_info(); add_redirect_info();
return spec; return spec;
@ -1530,7 +1530,7 @@ exp.facet_builder = IPA.facet_builder = function(entity) {
spec.title = spec.title || entity.metadata.label_singular; spec.title = spec.title || entity.metadata.label_singular;
spec.label = spec.label || entity.metadata.label; spec.label = spec.label || entity.metadata.label;
spec.tab_label = spec.tab_label || '@i18n:facets.search'; spec.tab_label = spec.tab_label || '@i18n:facets.search';
spec.factory = spec.factory || IPA.nested_search_facet; spec.$factory = spec.$factory || IPA.nested_search_facet;
return spec; return spec;
}; };
@ -1539,7 +1539,7 @@ exp.facet_builder = IPA.facet_builder = function(entity) {
spec.title = spec.title || entity.metadata.label_singular; spec.title = spec.title || entity.metadata.label_singular;
spec.label = spec.label || entity.metadata.label_singular; spec.label = spec.label || entity.metadata.label_singular;
spec.tab_label = spec.tab_label || '@i18n:facets.details'; spec.tab_label = spec.tab_label || '@i18n:facets.details';
spec.factory = spec.factory || IPA.details_facet; spec.$factory = spec.$factory || IPA.details_facet;
return spec; return spec;
}; };
@ -1550,7 +1550,7 @@ exp.facet_builder = IPA.facet_builder = function(entity) {
var attr_metadata = IPA.get_entity_param(entity.name, spec.attribute); var attr_metadata = IPA.get_entity_param(entity.name, spec.attribute);
spec.tab_label = spec.tab_label || attr_metadata.label; spec.tab_label = spec.tab_label || attr_metadata.label;
spec.factory = spec.factory || IPA.attribute_facet; spec.$factory = spec.$factory || IPA.attribute_facet;
entity.policies.add_policy(IPA.build({ entity.policies.add_policy(IPA.build({
$factory: IPA.facet_update_policy, $factory: IPA.facet_update_policy,
@ -1576,7 +1576,7 @@ exp.facet_builder = IPA.facet_builder = function(entity) {
spec.facet_group = spec.facet_group || spec.attribute_member; spec.facet_group = spec.facet_group || spec.attribute_member;
spec.factory = spec.factory || IPA.association_facet; spec.$factory = spec.$factory || IPA.association_facet;
spec.label = spec.label || entity.metadata.label_singular; spec.label = spec.label || entity.metadata.label_singular;
spec.tab_label = spec.tab_label || spec.tab_label = spec.tab_label ||
@ -2423,23 +2423,23 @@ var FacetState = exp.FacetState = declare([Stateful, Evented], {
}); });
exp.action_builder = IPA.action_builder = new Builder({ exp.action_builder = IPA.action_builder = new Builder({
$factory: exp.action factory: exp.action
}); });
exp.action_holder_builder = new Builder({ exp.action_holder_builder = new Builder({
$factory: exp.action_holder factory: exp.action_holder
}); });
exp.state_builder = IPA.state_builder = new Builder({ exp.state_builder = IPA.state_builder = new Builder({
$factory: exp.state factory: exp.state
}); });
exp.state_evaluator_builder = IPA.state_evaluator_builder = new Builder({ exp.state_evaluator_builder = IPA.state_evaluator_builder = new Builder({
$factory: exp.state factory: exp.state
}); });
exp.action_button_widget_builder = IPA.action_button_widget_builder = new Builder({ exp.action_button_widget_builder = IPA.action_button_widget_builder = new Builder({
$factory: exp.action_button_widget factory: exp.action_button_widget
}); });
return exp; return exp;

View File

@ -875,8 +875,8 @@ IPA.field_builder = function(spec) {
that.get_field_factory = function(spec) { that.get_field_factory = function(spec) {
var factory; var factory;
if (spec.factory) { if (spec.$factory) {
factory = spec.factory; factory = spec.$factory;
} else if(spec.type) { } else if(spec.type) {
factory = IPA.field_factories[spec.type]; factory = IPA.field_factories[spec.type];
} }

View File

@ -730,8 +730,8 @@ IPA.option_widget_base = function(spec, that) {
value: option value: option
}; };
} else { } else {
if (option.type || option.factory) { if (option.type || option.$factory) {
var factory = option.factory || IPA.widget_factories[option.type]; var factory = option.$factory || IPA.widget_factories[option.type];
if (typeof factory !== 'function') throw { if (typeof factory !== 'function') throw {
error: 'Invalid factory', error: 'Invalid factory',
$factory: factory $factory: factory
@ -1995,7 +1995,7 @@ IPA.attribute_table_widget = function(spec) {
spec.entity = that.entity; spec.entity = that.entity;
var factory = spec.factory || IPA.column; var factory = spec.$factory || IPA.column;
var column = factory(spec); var column = factory(spec);
that.add_column(column); that.add_column(column);
@ -2215,7 +2215,7 @@ IPA.attribute_table_widget = function(spec) {
dialog_spec.title = dialog_spec.title.replace('${pkey}', pkey); dialog_spec.title = dialog_spec.title.replace('${pkey}', pkey);
var factory = dialog_spec.factory || IPA.entity_adder_dialog; var factory = dialog_spec.$factory || IPA.entity_adder_dialog;
var dialog = factory(dialog_spec); var dialog = factory(dialog_spec);
var cancel_button = dialog.buttons.get('cancel'); var cancel_button = dialog.buttons.get('cancel');
@ -3532,8 +3532,8 @@ IPA.widget_builder = function(spec) {
that.get_widget_factory = function(spec) { that.get_widget_factory = function(spec) {
var factory; var factory;
if (spec.factory) { if (spec.$factory) {
factory = spec.factory; factory = spec.$factory;
} else if(spec.type) { } else if(spec.type) {
factory = IPA.widget_factories[spec.type]; factory = IPA.widget_factories[spec.type];
} }

View File

@ -49,7 +49,7 @@ test('Testing metadata validator', function() {
// using strings as values because it is an output of inputs // using strings as values because it is an output of inputs
var validator = IPA.build({ var validator = IPA.build({
factory: IPA.metadata_validator $factory: IPA.metadata_validator
}); });
var metadata = { var metadata = {