Additional option to add and del operations can be set

By setting the property 'additional_add_del_field' to the name of one of
the fields which are on current details page, we choose field which value
will be added to  *_add_* and *_del_* commands in this format:

{field_name: field_value}
--field_name: field_value

Part of: https://fedorahosted.org/freeipa/ticket/5426

Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
Pavel Vomacka authored and Martin Basti committed 2017-03-14 10:40:10 +01:00
1 parent da5487c407
commit c3115fa617
1 file changed
+22
+22
View File
@@ -421,6 +421,14 @@ IPA.association_table_widget = function (spec) {
var that = IPA.table_widget(spec);
/**
* The value should be name of the field, which will be added to *_add_*,
* *_del_* commands as option: {fieldname: fieldvalue}.
*
* @property {String} fieldname
*/
that.additional_add_del_field = spec.additional_add_del_field;
that.other_entity = IPA.get_entity(spec.other_entity);
that.attribute_member = spec.attribute_member;
@@ -677,9 +685,22 @@ IPA.association_table_widget = function (spec) {
});
command.set_option(that.other_entity.name, values);
that.join_additional_option(command);
command.execute();
};
that.join_additional_option = function(command) {
var add_opt = that.additional_add_del_field;
if (add_opt && typeof add_opt === 'string') {
var opt_field = that.entity.facet.get_field(add_opt);
var value;
if (opt_field) value = opt_field.get_value()[0];
command.set_option(add_opt, value);
}
};
that.show_remove_dialog = function() {
var selected_values = that.get_selected_values();
@@ -741,6 +762,7 @@ IPA.association_table_widget = function (spec) {
});
command.set_option(that.other_entity.name, values);
that.join_additional_option(command);
command.execute();
};