diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 0e668f45a..9b7ac1f6a 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -1114,13 +1114,13 @@ abstract class AttributeDefinition } /** - * @param array $aArgs - * @param string $sContains - * - * @return array|null - * @throws \CoreException - * @throws \OQLException - */ + * @param array $aArgs + * @param string $sContains + * + * @return array|null + * @throws \CoreException + * @throws \OQLException + */ public function GetAllowedValues($aArgs = array(), $sContains = '') { $oValSetDef = $this->GetValuesDef(); @@ -1132,6 +1132,20 @@ abstract class AttributeDefinition return $oValSetDef->GetValues($aArgs, $sContains); } + /** + * GetAllowedValuesForSelect is the same as GetAllowedValues except for field with obsolescence flag + * @param array $aArgs + * @param string $sContains + * + * @return array|null + * @throws \CoreException + * @throws \OQLException + */ + public function GetAllowedValuesForSelect($aArgs = array(), $sContains = '') + { + return $this->GetAllowedValues($aArgs, $sContains); + } + /** * Explain the change of the attribute (history) * @@ -6643,6 +6657,14 @@ class AttributeExternalKey extends AttributeDBFieldVoid } } + public function GetAllowedValuesForSelect($aArgs = array(), $sContains = '') + { + //$this->GetValuesDef(); + $oValSetDef = new ValueSetObjects('SELECT '.$this->GetTargetClass()); + return $oValSetDef->GetValuesForAutocomplete($aArgs, $sContains); + } + + public function GetAllowedValuesAsObjectSet($aArgs = array(), $sContains = '', $iAdditionalValue = null) { $oValSetDef = $this->GetValuesDef(); diff --git a/js/search/search_form_criteria_enum.js b/js/search/search_form_criteria_enum.js index 1b40d62d9..c7913ad05 100644 --- a/js/search/search_form_criteria_enum.js +++ b/js/search/search_form_criteria_enum.js @@ -226,7 +226,8 @@ $(function() { var sValCode = aSortedValues[i][0]; var sValLabel = aSortedValues[i][1]; - var oValueElem = this._makeListItemElement(sValLabel, sValCode); + //_makeListItemElement: function(sLabel, sValue, bInitChecked, bInitHidden,bObsolete, sAdditionalField) + var oValueElem = this._makeListItemElement(sValLabel, sValCode, false, false, aSortedValues[i][2], aSortedValues[i][3]); oValueElem.appendTo(oDynamicListElem); if (this._isSelectedValues(sValCode)) @@ -895,16 +896,20 @@ $(function() // eg. {2: "IT Department", 3: "Demo"} in regular mode else { - aSortable.push([sKey, oSource[sKey]]); + if(oSource[sKey]["label"]) { + aSortable.push([sKey, oSource[sKey]["label"], oSource[sKey]["obsolescence_flag"], oSource[sKey]["additional_field"]]); + } else { + aSortable.push([sKey, oSource[sKey]]); + } } } aSortable.sort(function(a, b) { - if(a[1] < b[1]) + if(a[1].toLowerCase() < b[1].toLowerCase()) { return -1; } - else if(a[1] > b[1]) + else if(a[1].toLowerCase() > b[1].toLowerCase()) { return 1; } diff --git a/sources/application/search/searchform.class.inc.php b/sources/application/search/searchform.class.inc.php index 2f39ebc7f..5e5cfe4c1 100644 --- a/sources/application/search/searchform.class.inc.php +++ b/sources/application/search/searchform.class.inc.php @@ -485,7 +485,7 @@ class SearchForm $aAllowedValues = array(); while ($oObject = $oSet->Fetch()) { - $aAllowedValues[$oObject->GetKey()] = $oObject->GetName(); + $aAllowedValues[] = ["value"=>$oObject->GetKey(), "label" => $oObject->GetName(), "obsolescence_flag"=>$oObject->IsObsolete()?"1":"0", "additional_field" => "je sais pas"]; } return array('values' => $aAllowedValues); } @@ -522,8 +522,7 @@ class SearchForm } } } - - $aAllowedValues = $oAttrDef->GetAllowedValues(); + $aAllowedValues = $oAttrDef->GetAllowedValuesForSelect(); return array('values' => $aAllowedValues); }