Advanced search improvements (restore 2018-04-10 revisions : r5635..r5641)

* Add 'search_manual_submit' config parameter to manage auto-submit
* bugfixes
** date i18n is now handled (using two new options `datepicker.dateFormat` and `datepicker.timeFormat` computed from `AttributeDateTime::GetFormat()->ToDatePicker()`
** handling of `empty` `not empty` operator titles
*** it led to tohers bugfixes and a redesign of the `_computeTitle` (from overwriting to extension using ie `_computeBetweenDaysOperatorTitle`
*** some bug still remain, because autocomplete needs to been finished before checking on them
* Promote 'friendlyname' in the 'most popular' list
* bugfixes
** filters (criterions, enum and FK without autocomplete) now ignore accent on matching with user input
** this is done by using a pre-existing tool used only by the portal, so it was moved to the core (latinize.min.js)
* Integration with manual submit parameter on client side.
* bugfixes : history/breadcrumb had several c[menu] appended (one for each refresh)
* Fix various sanity bugs

SVN:trunk[5632]
This commit is contained in:
Pierre Goiffon
2018-04-12 08:54:05 +00:00
parent 757130847f
commit efa7a4ee55
20 changed files with 259 additions and 253 deletions

View File

@@ -30,6 +30,8 @@ use AttributeEnum;
use Combodo\iTop\Application\Search\AjaxSearchException;
use Combodo\iTop\Application\Search\CriterionConversionAbstract;
use Combodo\iTop\Application\Search\SearchForm;
use Exception;
use MetaModel;
class CriterionToOQL extends CriterionConversionAbstract
{
@@ -59,6 +61,7 @@ class CriterionToOQL extends CriterionConversionAbstract
$aMappedOperators = array(
self::OP_CONTAINS => 'ContainsToOql',
self::OP_EQUALS => 'EqualsToOql',
self::OP_STARTS_WITH => 'StartsWithToOql',
self::OP_ENDS_WITH => 'EndsWithToOql',
self::OP_EMPTY => 'EmptyToOql',
@@ -110,6 +113,8 @@ class CriterionToOQL extends CriterionConversionAbstract
$aValues = self::GetValues($aCriteria);
$sValue = self::GetValue($aValues, 0);
if (empty($sValue)) return "1";
return "({$sRef} LIKE '%{$sValue}%')";
}
@@ -118,6 +123,8 @@ class CriterionToOQL extends CriterionConversionAbstract
$aValues = self::GetValues($aCriteria);
$sValue = self::GetValue($aValues, 0);
if (empty($sValue)) return "1";
return "({$sRef} LIKE '{$sValue}%')";
}
@@ -126,9 +133,21 @@ class CriterionToOQL extends CriterionConversionAbstract
$aValues = self::GetValues($aCriteria);
$sValue = self::GetValue($aValues, 0);
if (empty($sValue)) return "1";
return "({$sRef} LIKE '%{$sValue}')";
}
protected static function EqualsToOql($sRef, $aCriteria)
{
$aValues = self::GetValues($aCriteria);
$sValue = self::GetValue($aValues, 0);
if (empty($sValue)) return "1";
return "({$sRef} = '{$sValue}')";
}
protected static function EmptyToOql($sRef, $aCriteria)
{
if (isset($aCriteria['widget']))
@@ -164,7 +183,7 @@ class CriterionToOQL extends CriterionConversionAbstract
$bFilterOnUndefined = false;
try
{
$aAttributeDefs = \MetaModel::ListAttributeDefs($sClass);
$aAttributeDefs = MetaModel::ListAttributeDefs($sClass);
if (array_key_exists($sAttCode, $aAttributeDefs))
{
$oAttDef = $aAttributeDefs[$sAttCode];
@@ -272,17 +291,29 @@ class CriterionToOQL extends CriterionConversionAbstract
$sStartDate = $aValues[0]['value'];
if (!empty($sStartDate))
{
$oDate = $oFormat->parse($sStartDate);
$sStartDate = $oDate->format($sAttributeClass::GetSQLFormat());
$aOQL[] = "({$sRef} >= '$sStartDate')";
try
{
$oDate = $oFormat->parse($sStartDate);
$sStartDate = $oDate->format($sAttributeClass::GetSQLFormat());
$aOQL[] = "({$sRef} >= '$sStartDate')";
}
catch (Exception $e)
{
}
}
$sEndDate = $aValues[1]['value'];
if (!empty($sEndDate))
{
$oDate = $oFormat->parse($sEndDate);
$sEndDate = $oDate->format($sAttributeClass::GetSQLFormat());
$aOQL[] = "({$sRef} <= '$sEndDate')";
try
{
$oDate = $oFormat->parse($sEndDate);
$sEndDate = $oDate->format($sAttributeClass::GetSQLFormat());
$aOQL[] = "({$sRef} <= '$sEndDate')";
}
catch (Exception $e)
{
}
}
$sOQL = implode(' AND ', $aOQL);