filter_ui: Improve display of filters with only one operator
This commit is contained in:
committed by
Chris Morgan
parent
0a305197fd
commit
7a138bd2c2
@@ -165,8 +165,21 @@ class FilterInterface
|
|||||||
$oColumn = $this->aFilterInfo[$oFilter->getColumn()];
|
$oColumn = $this->aFilterInfo[$oFilter->getColumn()];
|
||||||
|
|
||||||
$sId = ($iId == -1) ? '' : $iId;
|
$sId = ($iId == -1) ? '' : $iId;
|
||||||
$shEditor = $oColumn->getDisplayName();
|
$shEditor = $oColumn->getDisplayName().' ';
|
||||||
|
|
||||||
|
$aTypes = $oColumn->getTypes();
|
||||||
|
|
||||||
|
/* It doesn't make sense to show a dropdown menu of choices if there is only one
|
||||||
|
If the filter is already active then there are more than one; one to remove */
|
||||||
|
if($iId == -1 && sizeof($aTypes) == 1)
|
||||||
|
{
|
||||||
|
echo "<input type=\"hidden\" name=\"i{$sColumn}Op$sId\" value=\"{$aTypes[0]}\" />";
|
||||||
|
|
||||||
|
/* Printing 'equal to' sounds weird if it is the only choice */
|
||||||
|
if($aTypes[0] != FILTER_EQUALS)
|
||||||
|
$shEditor .= $oColumn->getOpName($aTypes[0]);
|
||||||
|
} else
|
||||||
|
{
|
||||||
$shEditor .= "<select name='i{$sColumn}Op$sId'>";
|
$shEditor .= "<select name='i{$sColumn}Op$sId'>";
|
||||||
|
|
||||||
if($iId == -1)
|
if($iId == -1)
|
||||||
@@ -181,7 +194,7 @@ class FilterInterface
|
|||||||
|
|
||||||
$shEditor .= "<option value='0'$sSel>-- $sText --</option>";
|
$shEditor .= "<option value='0'$sSel>-- $sText --</option>";
|
||||||
|
|
||||||
foreach($oColumn->getTypes() as $iType)
|
foreach($aTypes as $iType)
|
||||||
{
|
{
|
||||||
if($oFilter->getOperatorId() == $iType)
|
if($oFilter->getOperatorId() == $iType)
|
||||||
$sSel = " selected='selected'";
|
$sSel = " selected='selected'";
|
||||||
@@ -189,8 +202,8 @@ class FilterInterface
|
|||||||
$sSel = '';
|
$sSel = '';
|
||||||
$shEditor .= "<option value='$iType'$sSel>".$oColumn->getOpName($iType).'</option><br />';
|
$shEditor .= "<option value='$iType'$sSel>".$oColumn->getOpName($iType).'</option><br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
$shEditor .= '</select> ';
|
$shEditor .= '</select> ';
|
||||||
|
}
|
||||||
|
|
||||||
switch($oColumn->getValueType())
|
switch($oColumn->getValueType())
|
||||||
{
|
{
|
||||||
@@ -344,7 +357,7 @@ class FilterInterface
|
|||||||
$sData = $aClean["s{$sColumn}Data"];
|
$sData = $aClean["s{$sColumn}Data"];
|
||||||
$iOp = $aClean["i{$sColumn}Op"];
|
$iOp = $aClean["i{$sColumn}Op"];
|
||||||
|
|
||||||
if($iOp)
|
if($iOp && $sData)
|
||||||
{
|
{
|
||||||
$oFilter = new Filter($oOption->getColumn(), $iOp, $sData);
|
$oFilter = new Filter($oOption->getColumn(), $iOp, $sData);
|
||||||
$aReturn[] = $oFilter;
|
$aReturn[] = $oFilter;
|
||||||
|
|||||||
Reference in New Issue
Block a user