From 5317a20269bd39459ca22737a35e494ca972bf88 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Wed, 23 Dec 2015 23:23:12 +0100 Subject: haproxy-devel, small fixes for showing/hiding acl fields not applicable, fix custom action, pkg v0.36 --- config/haproxy-devel/pkg/haproxy.inc | 2 +- config/haproxy-devel/pkg/haproxy_htmllist.inc | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'config/haproxy-devel/pkg') diff --git a/config/haproxy-devel/pkg/haproxy.inc b/config/haproxy-devel/pkg/haproxy.inc index 8dce42ee..c8a225a3 100644 --- a/config/haproxy-devel/pkg/haproxy.inc +++ b/config/haproxy-devel/pkg/haproxy.inc @@ -253,7 +253,7 @@ $a_action["use_server"] = array('name' => "Use Server", 'mode' => '', 'syntax' = 'server' => array('name'=>"server",'columnheader'=>"Server",'type'=>"select",'size'=>"50",'mask'=>'server') )); // -$a_action["custom"] = array('name' => "Custom", 'mode' => '', +$a_action["custom"] = array('name' => "Custom", 'mode' => '', 'syntax' => '{customaction}', 'fields' => array( array('name'=>"customaction",'columnheader'=>"Custom action",'type'=>"textbox",'size'=>"50",'mask'=>'freetext') )); diff --git a/config/haproxy-devel/pkg/haproxy_htmllist.inc b/config/haproxy-devel/pkg/haproxy_htmllist.inc index 7eaad023..d5386fcd 100644 --- a/config/haproxy-devel/pkg/haproxy_htmllist.inc +++ b/config/haproxy-devel/pkg/haproxy_htmllist.inc @@ -42,8 +42,8 @@ class HaproxyHtmlList _field_changed(tableId, rowNr, fieldId, field) */ - private $tablename = ""; - private $fields = array(); + public $tablename = ""; + public $fields = array(); public $editmode = false; public $fields_details = null; public $keyfield = ""; @@ -269,7 +269,13 @@ class HaproxyHtmlList foreach($itemdetails as $item) { $itemname = $item['name']; $itemvalue = $value[$itemname]; - //TODO don't filter empty items, filter context un-related items through customizable function.. + if ($this->fields_details_showfieldfunction != null) { + // filter context un-related items through customizable function. + $fn = &$this->fields_details_showfieldfunction; + if ($fn($this, $itemname, $value) == false) { + continue; + } + } else if (empty($itemvalue)) { continue; } @@ -488,7 +494,10 @@ function haproxy_htmllist_js(){ subtr.appendChild(subtd); subtd = d.createElement("td"); subtd.setAttribute("class","vncell"); - subtd.innerHTML = field['description'] + "
" + fieldhtml; + if (field['description']) { + fieldhtml = field['description'] + "
" + fieldhtml; + } + subtd.innerHTML = fieldhtml; subtr.appendChild(subtd); table.appendChild(subtr); } @@ -539,6 +548,13 @@ function haproxy_htmllist_js(){ if (typeof fn === 'function'){ fn(tableId, totalrows); } + + // show/hide conditional fields if applicable using a custom function. + javascript_event = tableId + "_listitem_change"; + var fn = window[javascript_event]; + if (typeof fn === 'function'){ + fn(tableId, "toggle_details", totalrows, null); + } } function editRow(num) { var trview = document.getElementById('tr_view_' + num); -- cgit v1.2.3