mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°5024 - Missing result in search widget for external key (#327)
* N°5024 - Missing result in search widget for external key
This commit is contained in:
@@ -778,16 +778,14 @@ JS
|
||||
* @param DBObject $oObj The current object for the OQL context
|
||||
* @param string $sContains The text of the autocomplete to filter the results
|
||||
* @param string $sOutputFormat
|
||||
* @param null $sOperation for the values @see ValueSetObjects->LoadValues()
|
||||
* @param null $sOperation for the values @see ValueSetObjects->LoadValues() not used since 3.0.0
|
||||
*
|
||||
* @throws CoreException
|
||||
* @throws OQLException
|
||||
*
|
||||
* @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $oObj for PHP 8.0 compatibility
|
||||
*/
|
||||
public function AutoComplete(
|
||||
WebPage $oP, $sFilter, $oObj, $sContains, $sOutputFormat = self::ENUM_OUTPUT_FORMAT_CSV, $sOperation = null
|
||||
)
|
||||
public function AutoComplete(WebPage $oP, $sFilter, $oObj, $sContains, $sOutputFormat = self::ENUM_OUTPUT_FORMAT_CSV, $sOperation = null )
|
||||
{
|
||||
if (is_null($sFilter)) {
|
||||
throw new Exception('Implementation: null value for allowed values definition');
|
||||
@@ -801,13 +799,13 @@ JS
|
||||
$oValuesSet->SetSort(false);
|
||||
$oValuesSet->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
|
||||
$oValuesSet->SetLimit($iMax);
|
||||
$aValuesContains = $oValuesSet->GetValuesForAutocomplete(array('this' => $oObj, 'current_extkey_id' => $iCurrentExtKeyId), $sContains, 'start_with');
|
||||
asort($aValuesContains);
|
||||
$aValues = $aValuesContains;
|
||||
$aValuesStartWith = $oValuesSet->GetValuesForAutocomplete(array('this' => $oObj, 'current_extkey_id' => $iCurrentExtKeyId), $sContains, 'start_with');
|
||||
asort($aValuesStartWith);
|
||||
$aValues = $aValuesStartWith;
|
||||
if (sizeof($aValues) < $iMax) {
|
||||
$aValuesContains = $oValuesSet->GetValuesForAutocomplete(array('this' => $oObj, 'current_extkey_id' => $iCurrentExtKeyId), $sContains, 'contains');
|
||||
asort($aValuesContains);
|
||||
$iSize = sizeof($aValuesContains);
|
||||
$iSize = sizeof($aValues);
|
||||
foreach ($aValuesContains as $sKey => $sFriendlyName)
|
||||
{
|
||||
if (!isset($aValues[$sKey]))
|
||||
|
||||
@@ -428,7 +428,6 @@ $(function()
|
||||
bSearchMode: 'true',
|
||||
sOutputFormat: 'json',
|
||||
operation: 'ac_extkey',
|
||||
sAutocompleteOperation: 'equals_start_with'
|
||||
}
|
||||
)
|
||||
.done(function(oResponse, sStatus, oXHR){
|
||||
@@ -441,28 +440,7 @@ $(function()
|
||||
return;
|
||||
}
|
||||
|
||||
oACXHR = $.post(
|
||||
AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'),
|
||||
{
|
||||
sTargetClass: me.options.field.target_class,
|
||||
sFilter: 'SELECT ' + me.options.field.target_class,
|
||||
q: sQuery,
|
||||
bSearchMode: 'true',
|
||||
sOutputFormat: 'json',
|
||||
operation: 'ac_extkey',
|
||||
sAutocompleteOperation: 'contains'
|
||||
}
|
||||
)
|
||||
.done(function(oResponseContains, sStatus, oXHR){
|
||||
//filter duplicates
|
||||
$.each(oResponse, function(index, value) {
|
||||
delete oResponseContains[index];
|
||||
});
|
||||
|
||||
me._onACSearchContainsSuccess(oResponseContains);
|
||||
|
||||
|
||||
});
|
||||
me._onACSearchContainsSuccess(oResponse);
|
||||
})
|
||||
.fail(function(oResponse, sStatus, oXHR){ me._onACSearchFail(oResponse, sStatus); })
|
||||
.always(function(oResponse, sStatus, oXHR){
|
||||
@@ -701,44 +679,16 @@ $(function()
|
||||
}
|
||||
}
|
||||
this._setACWaitTempHint();
|
||||
},
|
||||
|
||||
// Autocomplete CONTAINS callbacks
|
||||
_onACSearchContainsSuccess: function(oResponse)
|
||||
{
|
||||
if(typeof oResponse !== 'object')
|
||||
{
|
||||
this._emptyACTempHint();
|
||||
return false;
|
||||
}
|
||||
|
||||
var oDynamicListElem = this.element.find('.sfc_opc_mc_items_dynamic');
|
||||
if(Object.keys(oResponse).length > 0)
|
||||
{
|
||||
// Note: Response is indexed by labels from server so the JSON is always ordered on decoding.
|
||||
for(var skey in oResponse)
|
||||
{
|
||||
var sValue = oResponse[skey].value;
|
||||
var sLabel = oResponse[skey].label;
|
||||
|
||||
// Note: We don't use the _isSelectedValue() method here as it only returns "applied" values; at this moment will could have a checked value that is not among selected (me.options.values) yet. The result would be an hidden item from the AC results.
|
||||
var bSelected = (this.element.find(this._getSelectedValuesWrapperSelector() + ' .sfc_opc_mc_item[data-value-code="' + sValue + '"]').length > 0);
|
||||
var bInitChecked = bSelected;
|
||||
var bInitHidden = bSelected;
|
||||
var oValueElem = this._makeListItemElement(sLabel, sValue, bInitChecked, bInitHidden,oResponse[skey].obsolescence_flag,oResponse[skey].additional_field);
|
||||
oValueElem.appendTo(oDynamicListElem);
|
||||
}
|
||||
}
|
||||
|
||||
if (oDynamicListElem.find('.sfc_opc_mc_item').length == 0)
|
||||
{
|
||||
this._setACNoResultHint();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._emptyACTempHint();
|
||||
if (oDynamicListElem.find('.sfc_opc_mc_item').length == 0)
|
||||
{
|
||||
this._setACNoResultHint();
|
||||
}
|
||||
},
|
||||
else
|
||||
{
|
||||
this._emptyACTempHint();
|
||||
}
|
||||
},
|
||||
_onACSearchFail: function(oResponse, sStatus)
|
||||
{
|
||||
if(sStatus !== 'abort')
|
||||
|
||||
@@ -364,7 +364,6 @@ try
|
||||
$sContains = utils::ReadParam('q', '', false, 'raw_data');
|
||||
$bSearchMode = (utils::ReadParam('bSearchMode', 'false') == 'true');
|
||||
$sOutputFormat = utils::ReadParam('sOutputFormat', UIExtKeyWidget::ENUM_OUTPUT_FORMAT_CSV, false, 'raw_data');
|
||||
$sAutocompleteOperation = utils::ReadParam('sAutocompleteOperation', null, false, 'raw_data');
|
||||
if ($sContains != '')
|
||||
{
|
||||
if (!empty($sJson))
|
||||
@@ -378,7 +377,7 @@ try
|
||||
$oObj = null;
|
||||
}
|
||||
$oWidget = new UIExtKeyWidget($sTargetClass, $iInputId, '', $bSearchMode);
|
||||
$oWidget->AutoComplete($oPage, $sFilter, $oObj, $sContains, $sOutputFormat, $sAutocompleteOperation);
|
||||
$oWidget->AutoComplete($oPage, $sFilter, $oObj, $sContains, $sOutputFormat);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user