summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPavel Vomacka <pvomacka@redhat.com>2017-03-12 22:46:06 +0100
committerMartin Basti <mbasti@redhat.com>2017-03-14 10:40:10 +0100
commitde4d4a51b542b8e473919dbc14f7a0810944b544 (patch)
treec2dfd61d5fba6ca3e3387780f422f5e402d39b13 /install
parent8dfe692251d38934a21ad3bc648d839d83e27caa (diff)
downloadfreeipa-de4d4a51b542b8e473919dbc14f7a0810944b544.tar.gz
freeipa-de4d4a51b542b8e473919dbc14f7a0810944b544.tar.xz
freeipa-de4d4a51b542b8e473919dbc14f7a0810944b544.zip
WebUI: search facet's default actions might be overriden
While defining search facet and adding custom actions with the same name as default actions in search facet. Custom actions will be used and their definition will override default actions. Part of:https://fedorahosted.org/freeipa/ticket/5426 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
Diffstat (limited to 'install')
-rw-r--r--install/ui/src/freeipa/search.js31
1 files changed, 26 insertions, 5 deletions
diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js
index ee0052288..e2fbf44ae 100644
--- a/install/ui/src/freeipa/search.js
+++ b/install/ui/src/freeipa/search.js
@@ -37,12 +37,33 @@ var exp = {};
exp.search_facet_control_buttons_pre_op = function(spec, context) {
- spec.actions = spec.actions || [];
- spec.actions.unshift(
- 'refresh',
- 'batch_remove',
- 'add');
+ var override_actions = function(cust_acts, def_acts) {
+ if (!cust_acts) return def_acts;
+ var new_default_actions = [];
+ for (var i=0, l=def_acts.length; i<l; i++) {
+ var d_action = def_acts[i];
+
+ var chosen_action = d_action;
+
+ for (var k=0, j=cust_acts.length; k<j; k++) {
+ var custom_act = cust_acts[k];
+ if (custom_act === d_action || (custom_act.$type && custom_act.$type === d_action)) {
+ chosen_action = custom_act;
+ break;
+ }
+ }
+
+ new_default_actions.push(chosen_action);
+ }
+
+ return new_default_actions;
+ };
+
+ var default_actions = ['refresh', 'batch_remove', 'add'];
+ var merged_actions = override_actions(spec.custom_actions, default_actions);
+
+ spec.actions = merged_actions.concat(spec.actions);
spec.control_buttons = spec.control_buttons || [];
if (!spec.no_update) {