webui: switch associators if default doesn't work

Make association auto-magic little bit less stupid. Now it supports
adding of new attribute member with add_member and remove_member
methods only on one side of the relationship.

https://fedorahosted.org/freeipa/ticket/4507

Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
This commit is contained in:
Petr Vobornik 2014-08-22 17:58:48 +02:00
parent 5e36cc5215
commit f70eafaedb

View File

@ -826,6 +826,16 @@ exp.association_facet_pre_op = function(spec, context) {
spec.other_entity = spec.other_entity ||
spec.name.substring(index+1);
if (!spec.associator) {
// batch associator (default) calls entity_command, serial associator
// calls other_entity_command --> if entity doesn't support the command,
// switch associators to try the other_entity
var add_command = spec.add_command || 'add_member';
if (!metadata_provider.get('@mc:'+entity.name+'_'+add_command)) {
spec.associator = IPA.serial_associator;
}
}
spec.add_title = '@i18n:association.add.'+spec.attribute_member;
spec.remove_title = '@i18n:association.remove.'+spec.attribute_member;