From e3e83272c9ffaf2a09f910e754c4a0421c816fd0 Mon Sep 17 00:00:00 2001 From: Pavel Vomacka Date: Fri, 22 Apr 2016 10:22:30 +0200 Subject: [PATCH] Add support for custom menu in multivalued widget Every single widget which is in multivalued widget can now have custom action menu and the delete button is included in this custom action menu. Part of this ticket: https://fedorahosted.org/freeipa/ticket/5381 Reviewed-By: Petr Vobornik --- install/ui/src/freeipa/widget.js | 84 +++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 17 deletions(-) diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 0f3e7f27b..9084ac584 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -988,6 +988,27 @@ IPA.multivalued_widget = function(spec) { that.initialized = true; that.updating = false; + /** + * + * CUSTOM ACTION MENU HELP: + * + * Custom actions variable sets whether each row will use custom menu + * for showing remove button or not. Default is false - button will be + * displayed classicaly as any other button. True means custom menu is + * present.. + * + * In case that the variable is set to true, the widget of each row + * has to offer following method: + * action_object get_custom_actions(); + * + * Then the action_object has to have following interface: + * Array[item] get_items(); + * set_items(Array[item]); + * enable_item(name); + * disable_item(name); + */ + that.custom_actions = !!spec.custom_actions; + that.rows = []; that.base_css_class = that.base_css_class + ' multivalued-widget'; @@ -1165,23 +1186,41 @@ IPA.multivalued_widget = function(spec) { that.emit('error-show', { source: that }); }); - var remove_link_visible = !(row.is_new || !that.is_writable()); - row.remove_link = $('