mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-22 03:44:12 +01:00
Compare commits
5 Commits
3.0.0-beta
...
3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b60fb4fb99 | ||
|
|
8fb5a9acd0 | ||
|
|
4c289edac7 | ||
|
|
f6be3736fd | ||
|
|
f8f9c2d7bb |
@@ -748,7 +748,7 @@ JS
|
||||
// Current extkey value, so we can display event if it is not available anymore (eg. archived).
|
||||
$iCurrentExtKeyId = (is_null($oObj) || $this->sAttCode === '') ? 0 : $oObj->Get($this->sAttCode);
|
||||
$oValuesSet = new ValueSetObjects($sFilter, 'friendlyname'); // Bypass GetName() to avoid the encoding by htmlentities
|
||||
$iMax = 150;
|
||||
$iMax = MetaModel::GetConfig()->Get('max_autocomplete_results');
|
||||
$oValuesSet->SetLimit($iMax);
|
||||
$oValuesSet->SetSort(false);
|
||||
$oValuesSet->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode);
|
||||
@@ -756,9 +756,8 @@ JS
|
||||
$aValuesContains = $oValuesSet->GetValuesForAutocomplete(array('this' => $oObj, 'current_extkey_id' => $iCurrentExtKeyId), $sContains, 'start_with');
|
||||
asort($aValuesContains);
|
||||
$aValues = $aValuesContains;
|
||||
if (sizeof($aValues) < $iMax)
|
||||
{
|
||||
$aValuesContains = $oValuesSet->GetValuesForAutocomplete(array('this' => $oObj, 'current_extkey_id' => $iCurrentExtKeyId), $sContains, 'contains');
|
||||
if (sizeof($aValues) < $iMax) {
|
||||
$aValuesContains = $oValuesSet->GetValuesForAutocomplete(array('this' => $oObj, 'current_extkey_id' => $iCurrentExtKeyId), $sContains, 'contains');
|
||||
asort($aValuesContains);
|
||||
$iSize = sizeof($aValuesContains);
|
||||
foreach ($aValuesContains as $sKey => $sFriendlyName)
|
||||
|
||||
@@ -6845,6 +6845,15 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
return $this->GetOptional('min_autocomplete_chars', MetaModel::GetConfig()->Get('min_autocomplete_chars'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function GetMaxAutoCompleteResults(): int
|
||||
{
|
||||
return MetaModel::GetConfig()->Get('max_autocomplete_results');
|
||||
}
|
||||
|
||||
public function AllowTargetCreation()
|
||||
{
|
||||
return $this->GetOptional('allow_target_creation', MetaModel::GetConfig()->Get('allow_target_creation'));
|
||||
@@ -6889,8 +6898,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
|
||||
public function MakeFormField(DBObject $oObject, $oFormField = null)
|
||||
{
|
||||
if ($oFormField === null)
|
||||
{
|
||||
if ($oFormField === null) {
|
||||
// Later : We should check $this->Get('display_style') and create a Radio / Select / ... regarding its value
|
||||
$sFormFieldClass = static::GetFormFieldClass();
|
||||
$oFormField = new $sFormFieldClass($this->GetCode());
|
||||
@@ -6899,11 +6907,11 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
// Setting params
|
||||
$oFormField->SetMaximumComboLength($this->GetMaximumComboLength());
|
||||
$oFormField->SetMinAutoCompleteChars($this->GetMinAutoCompleteChars());
|
||||
$oFormField->SetMaxAutoCompleteResults($this->GetMaxAutoCompleteResults());
|
||||
$oFormField->SetHierarchical(MetaModel::IsHierarchicalClass($this->GetTargetClass()));
|
||||
// Setting choices regarding the field dependencies
|
||||
$aFieldDependencies = $this->GetPrerequisiteAttributes();
|
||||
if (!empty($aFieldDependencies))
|
||||
{
|
||||
if (!empty($aFieldDependencies)) {
|
||||
$oTmpAttDef = $this;
|
||||
$oTmpField = $oFormField;
|
||||
$oFormField->SetOnFinalizeCallback(function () use ($oTmpField, $oTmpAttDef, $oObject) {
|
||||
|
||||
@@ -301,6 +301,14 @@ class Config
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
],
|
||||
'max_autocomplete_results' => [
|
||||
'type' => 'integer',
|
||||
'description' => 'The maximum number of result elements to display, no matter the total number of results',
|
||||
'default' => 150,
|
||||
'value' => 150,
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
],
|
||||
'allow_menu_on_linkset' => [
|
||||
'type' => 'bool',
|
||||
'description' => 'Display Action menus in view mode on any LinkedSet with edit_mode != none',
|
||||
|
||||
@@ -9,6 +9,7 @@ $ibo-input-select-autocomplete--value--min-midth: 150px;
|
||||
$ibo-input-select-selectize--value--min-midth: 150px;
|
||||
$ibo-input-select-selectize--value--height: 100% !default;
|
||||
$ibo-input-select-selectize--value--line-height: $ibo-input--height !default;
|
||||
$ibo-input-select-selectize--dropdown--max-height: 50vh !default;
|
||||
|
||||
$ibo-input-select-wrapper--width: 100% !default;
|
||||
|
||||
@@ -160,8 +161,10 @@ $ibo-input-select--action-button--padding-right: 2px !default;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.selectize-dropdown{
|
||||
z-index:2000; /* Note: This is not great as it does not take into account other elements z-index, but as selectize puts its dropdown under the <body> tag, we cannot have a z-index relative to input container */
|
||||
.selectize-dropdown {
|
||||
z-index: 2000; /* Note: This is not great as it does not take into account other elements z-index, but as selectize puts its dropdown under the <body> tag, we cannot have a z-index relative to input container */
|
||||
max-height: $ibo-input-select-selectize--dropdown--max-height;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.selectize-dropdown.ui-menu .ui-state-active {
|
||||
margin: unset;
|
||||
|
||||
@@ -640,7 +640,7 @@ class ObjectController extends BrickController
|
||||
$oSet = new DBObjectSet($oSearch, array(), array('this' => $oHostObject, 'ac_query' => '%'.$sQuery.'%'));
|
||||
$oSet->OptimizeColumnLoad(array($oSearch->GetClassAlias() => array('friendlyname')));
|
||||
// Note : This limit is also used in the field renderer by typeahead to determine how many suggestions to display
|
||||
$oSet->SetLimit(MetaModel::GetConfig()->Get('max_display_limit'));
|
||||
$oSet->SetLimit(MetaModel::GetConfig()->Get('max_autocomplete_results'));
|
||||
|
||||
// - Retrieving objects
|
||||
while ($oItem = $oSet->Fetch())
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -2711,11 +2711,11 @@ EOF
|
||||
$oSearch = DBObjectSearch::FromOQL("SELECT $sTargetClass WHERE friendlyname LIKE :needle");
|
||||
$oSet = new DBObjectSet($oSearch, array(), array('needle' => "%$sNeedle%"));
|
||||
$oSet->OptimizeColumnLoad(array($oSearch->GetClassAlias() => array()));
|
||||
$oSet->SetLimit(5);
|
||||
$oSet->SetLimit(MetaModel::GetConfig()->Get('max_autocomplete_results'));
|
||||
// Note: We have to this manually because of a bug in DBSearch not checking the user prefs. by default.
|
||||
$oSet->SetShowObsoleteData(utils::ShowObsoleteData());
|
||||
|
||||
while($oObject = $oSet->Fetch()) {
|
||||
while ($oObject = $oSet->Fetch()) {
|
||||
// Note $oObject finalclass might be different than $sTargetClass
|
||||
$sObjectClass = get_class($oObject);
|
||||
$iObjectId = $oObject->GetKey();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -724,10 +724,10 @@ EOF
|
||||
foreach ($aLicenses as $oLicense)
|
||||
{
|
||||
$oPage->add('<li><b>'.$oLicense->product.'</b>, © '.$oLicense->author.' is licensed under the <b>'.$oLicense->license_type.' license</b>. (<span class="toggle" id="toggle_'.$index.'">Details</span>)');
|
||||
$oPage->add('<div id="license_'.$index.'" class="license_text" style="display:none;overflow:auto;max-height:10em;font-size:small;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;">'.$oLicense->text.'</div>');
|
||||
$oPage->add('<div id="license_'.$index.'" class="license_text" style="display:none;overflow:auto;max-height:10em;font-size:small;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;"><pre>'.$oLicense->text.'</pre></div>');
|
||||
$oPage->add_ready_script('$(".license_text a").attr("target", "_blank").addClass("no-arrow");');
|
||||
$oPage->add_ready_script('$("#toggle_'.$index.'").on("click", function() { $("#license_'.$index.'").toggle(); } );');
|
||||
$index++;
|
||||
$index++;
|
||||
}
|
||||
$oPage->add('</ul>');
|
||||
$oPage->add('</fieldset>');
|
||||
|
||||
@@ -26,6 +26,7 @@ use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
|
||||
use DBObjectSet;
|
||||
use DBSearch;
|
||||
use FieldExpression;
|
||||
use MetaModel;
|
||||
use ScalarExpression;
|
||||
|
||||
/**
|
||||
@@ -43,10 +44,22 @@ class SelectObjectField extends Field
|
||||
|
||||
/** @var \DBSearch $oSearch */
|
||||
protected $oSearch;
|
||||
/** @var int $iMaximumComboLength */
|
||||
/**
|
||||
* @see \Config 'max_combo_length'
|
||||
* @var int $iMaximumComboLength
|
||||
*/
|
||||
protected $iMaximumComboLength;
|
||||
/** @var int $iMinAutoCompleteChars */
|
||||
/**
|
||||
* @see \Config 'min_autocomplete_chars'
|
||||
* @var int $iMinAutoCompleteChars
|
||||
*/
|
||||
protected $iMinAutoCompleteChars;
|
||||
/**
|
||||
* @see \Config 'max_autocomplete_results'
|
||||
* @var int
|
||||
* @since 3.0.0
|
||||
*/
|
||||
protected $iMaxAutoCompleteResults;
|
||||
/** @var bool $bHierarchical */
|
||||
protected $bHierarchical;
|
||||
/** @var int $iControlType */
|
||||
@@ -61,8 +74,9 @@ class SelectObjectField extends Field
|
||||
{
|
||||
parent::__construct($sId, $onFinalizeCallback);
|
||||
$this->oSearch = null;
|
||||
$this->iMaximumComboLength = null;
|
||||
$this->iMinAutoCompleteChars = 3;
|
||||
$this->iMaximumComboLength = MetaModel::GetConfig()->Get('max_combo_length');
|
||||
$this->iMinAutoCompleteChars = MetaModel::GetConfig()->Get('min_autocomplete_chars');
|
||||
$this->iMaxAutoCompleteResults = MetaModel::GetConfig()->Get('max_autocomplete_results');
|
||||
$this->bHierarchical = false;
|
||||
$this->iControlType = self::CONTROL_SELECT;
|
||||
$this->sSearchEndpoint = null;
|
||||
@@ -104,6 +118,21 @@ class SelectObjectField extends Field
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see static::$iMaxAutoCompleteResults
|
||||
*
|
||||
* @param int $iMaxAutoCompleteResults
|
||||
*
|
||||
* @return $this;
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function SetMaxAutoCompleteResults(int $iMaxAutoCompleteResults)
|
||||
{
|
||||
$this->iMaxAutoCompleteResults = $iMaxAutoCompleteResults;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bHierarchical
|
||||
*
|
||||
@@ -187,6 +216,16 @@ class SelectObjectField extends Field
|
||||
return $this->iMinAutoCompleteChars;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see static::$iMaxAutoCompleteResults
|
||||
* @return int
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function GetMaxAutoCompleteResults(): int
|
||||
{
|
||||
return $this->iMaxAutoCompleteResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -266,7 +266,7 @@ EOF
|
||||
},{
|
||||
name: '{$this->oField->GetId()}',
|
||||
source: oAutocompleteSource_{$this->oField->GetId()},
|
||||
limit: 20,
|
||||
limit: {$this->oField->GetMaxAutoCompleteResults()},
|
||||
display: 'name',
|
||||
templates: {
|
||||
suggestion: Handlebars.compile('<div>{{name}}</div>'),
|
||||
|
||||
Reference in New Issue
Block a user