From 6a007865359c0bf67ac2511c4dbbaf8ecbe7ee05 Mon Sep 17 00:00:00 2001 From: XavierGR Date: Thu, 21 Nov 2024 15:11:55 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B0=205874=20-=20Quick=20create:=20improvem?= =?UTF-8?q?ent=20for=20newcomer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config.class.inc.php | 8 + .../datamodel.itop-config-mgmt.xml | 2 +- .../datamodel.itop-request-mgmt-itil.xml | 2 +- .../datamodel.itop-request-mgmt.xml | 2 +- .../cs.dictionary.itop.quick-create.php | 1 + .../da.dictionary.itop.quick-create.php | 1 + .../de.dictionary.itop.quick-create.php | 1 + .../en.dictionary.itop.quick-create.php | 1 + .../en_gb.dictionary.itop.quick-create.php | 1 + .../es_cr.dictionary.itop.quick-create.php | 1 + .../fr.dictionary.itop.quick-create.php | 1 + .../hu.dictionary.itop.quick-create.php | 1 + .../it.dictionary.itop.quick-create.php | 1 + .../ja.dictionary.itop.quick-create.php | 1 + .../nl.dictionary.itop.quick-create.php | 1 + .../pl.dictionary.itop.quick-create.php | 1 + .../pt_br.dictionary.itop.quick-create.php | 1 + .../ru.dictionary.itop.quick-create.php | 1 + .../sk.dictionary.itop.quick-create.php | 1 + .../tr.dictionary.itop.quick-create.php | 1 + .../zh_cn.dictionary.itop.quick-create.php | 1 + .../Component/QuickCreate/QuickCreate.php | 28 +- .../QuickCreate/QuickCreateHelper.php | 72 +++- .../components/quick-create/layout.html.twig | 22 +- tests/php-unit-tests/composer.lock | 321 +++++++++--------- .../QuickCreate/QuickCreateHelperTest.php | 60 ++++ 26 files changed, 364 insertions(+), 170 deletions(-) create mode 100644 tests/php-unit-tests/unitary-tests/sources/Application/UI/Base/Components/QuickCreate/QuickCreateHelperTest.php diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 3534f7588..8380a3fdc 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -1436,6 +1436,14 @@ class Config 'quick_create.max_history_results' => [ 'type' => 'integer', 'description' => 'Max. number of elements in the history', + 'default' => 5, + 'value' => 5, + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ], + 'quick_create.max_popular_results' => [ + 'type' => 'integer', + 'description' => 'Max. number of elements in the popular classes section', 'default' => 10, 'value' => 10, 'source_of_value' => '', diff --git a/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml b/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml index 392ec9beb..161eedcab 100755 --- a/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml +++ b/datamodels/2.x/itop-config-mgmt/datamodel.itop-config-mgmt.xml @@ -4,7 +4,7 @@ cmdbAbstractObject - bizmodel,searchable + bizmodel,searchable,popular true autoincrement functionalci diff --git a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml index fe6627ed9..1f908f7a7 100755 --- a/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml +++ b/datamodels/2.x/itop-request-mgmt-itil/datamodel.itop-request-mgmt-itil.xml @@ -10,7 +10,7 @@ * @copyright Copyright (C) 2010-2024 Combodo SAS * @license http://opensource.org/licenses/AGPL-3.0 */]]> - bizmodel,searchable,requestmgmt + bizmodel,searchable,requestmgmt,popular false autoincrement ticket_request diff --git a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml index 92a8cfdec..6bebfd7fa 100755 --- a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml +++ b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml @@ -10,7 +10,7 @@ * @copyright Copyright (C) 2010-2024 Combodo SAS * @license http://opensource.org/licenses/AGPL-3.0 */]]> - bizmodel,searchable,requestmgmt + bizmodel,searchable,requestmgmt,popular false autoincrement ticket_request diff --git a/dictionaries/ui/components/quick-create/cs.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/cs.dictionary.itop.quick-create.php index d11e78fea..2b04cd3d3 100644 --- a/dictionaries/ui/components/quick-create/cs.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/cs.dictionary.itop.quick-create.php @@ -15,5 +15,6 @@ Dict::Add('CS CZ', 'Czech', 'Čeština', [ 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Populární', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', ]); diff --git a/dictionaries/ui/components/quick-create/da.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/da.dictionary.itop.quick-create.php index 56cea8bae..b699a62f1 100644 --- a/dictionaries/ui/components/quick-create/da.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/da.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('DA DA', 'Danish', 'Dansk', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', ]); diff --git a/dictionaries/ui/components/quick-create/de.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/de.dictionary.itop.quick-create.php index bd645fdbd..a63759816 100644 --- a/dictionaries/ui/components/quick-create/de.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/de.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('DE DE', 'German', 'Deutsch', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Wählen Sie einen Objekttyp aus...', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Quick-Create-Menu öffnen', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Sie haben noch keine Objekte erstellt', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Am beliebtesten', 'UI:Component:QuickCreate:Recents:Title' => 'Letzte', 'UI:Component:QuickCreate:Tooltip' => 'Erstellen Sie schnell jeden Typ von Objekt', ]); diff --git a/dictionaries/ui/components/quick-create/en.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/en.dictionary.itop.quick-create.php index 58f9d2a9a..523395277 100644 --- a/dictionaries/ui/components/quick-create/en.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/en.dictionary.itop.quick-create.php @@ -23,6 +23,7 @@ Dict::Add('EN US', 'English', 'English', array( 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...', 'UI:Component:QuickCreate:Recents:Title' => 'Recents', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular', 'UI:Component:QuickCreate:HistoryDisabled' => 'History is disabled', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create', )); \ No newline at end of file diff --git a/dictionaries/ui/components/quick-create/en_gb.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/en_gb.dictionary.itop.quick-create.php index 331e8337e..f4fd1adad 100644 --- a/dictionaries/ui/components/quick-create/en_gb.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/en_gb.dictionary.itop.quick-create.php @@ -10,6 +10,7 @@ Dict::Add('EN GB', 'British English', 'British English', array( 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...', 'UI:Component:QuickCreate:Recents:Title' => 'Recents', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular', 'UI:Component:QuickCreate:HistoryDisabled' => 'History is disabled', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create', )); \ No newline at end of file diff --git a/dictionaries/ui/components/quick-create/es_cr.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/es_cr.dictionary.itop.quick-create.php index 799bebbed..8059c0508 100644 --- a/dictionaries/ui/components/quick-create/es_cr.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/es_cr.dictionary.itop.quick-create.php @@ -12,6 +12,7 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Seleccionar tipo de objeto...', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Abrir creación rápida', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Aún no has creado ningún objeto.', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Más popular', 'UI:Component:QuickCreate:Recents:Title' => 'Recientes', 'UI:Component:QuickCreate:Tooltip' => 'Crear rápidamente cualquier tipo de objeto', ]); diff --git a/dictionaries/ui/components/quick-create/fr.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/fr.dictionary.itop.quick-create.php index c401948a1..01662ea7b 100644 --- a/dictionaries/ui/components/quick-create/fr.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/fr.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('FR FR', 'French', 'Français', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Type d\'objet...', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Ouvrir la création rapide', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Vous n\'avez pas encore créé d\'objet', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Populaires', 'UI:Component:QuickCreate:Recents:Title' => 'Types récents', 'UI:Component:QuickCreate:Tooltip' => 'Création rapide de n\'importe quel objet', ]); diff --git a/dictionaries/ui/components/quick-create/hu.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/hu.dictionary.itop.quick-create.php index d34aa000d..4cfe344c4 100644 --- a/dictionaries/ui/components/quick-create/hu.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/hu.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('HU HU', 'Hungarian', 'Magyar', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Objektumtípus kiválasztása...', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Gyors létrehozás megnyitása', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Még nem hozott létre objektumot', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Legnépszerűbb', 'UI:Component:QuickCreate:Recents:Title' => 'Legutóbbiak', 'UI:Component:QuickCreate:Tooltip' => 'Bármilyen típusú objektum gyors létrehozása', ]); diff --git a/dictionaries/ui/components/quick-create/it.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/it.dictionary.itop.quick-create.php index 7b5a79253..60798b551 100644 --- a/dictionaries/ui/components/quick-create/it.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/it.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('IT IT', 'Italian', 'Italiano', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Seleziona il tipo di oggetto...', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Apri la creazione rapida', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Non hai ancora creato alcun oggetto', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Più popolari', 'UI:Component:QuickCreate:Recents:Title' => 'Recenti', 'UI:Component:QuickCreate:Tooltip' => 'Crea rapidamente qualsiasi tipo di oggetto', ]); diff --git a/dictionaries/ui/components/quick-create/ja.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/ja.dictionary.itop.quick-create.php index 97f47d3ab..4581d44cb 100644 --- a/dictionaries/ui/components/quick-create/ja.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/ja.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('JA JP', 'Japanese', '日本語', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', ]); diff --git a/dictionaries/ui/components/quick-create/nl.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/nl.dictionary.itop.quick-create.php index 32725079b..05186947a 100644 --- a/dictionaries/ui/components/quick-create/nl.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/nl.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Selecteer een objectsoort…', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open snel object aanmaken', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Je hebt nog geen objecten gemaakt', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Meest populair', 'UI:Component:QuickCreate:Recents:Title' => 'Recente', 'UI:Component:QuickCreate:Tooltip' => 'Snel een object aanmaken', ]); diff --git a/dictionaries/ui/components/quick-create/pl.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/pl.dictionary.itop.quick-create.php index eab616904..bf34c7511 100644 --- a/dictionaries/ui/components/quick-create/pl.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/pl.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('PL PL', 'Polish', 'Polski', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Wybierz typ obiektu...', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Otwórz szybkie tworzenie', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Nie utworzyłeś jeszcze żadnego obiektu', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Najbardziej popularne', 'UI:Component:QuickCreate:Recents:Title' => 'Ostatnie', 'UI:Component:QuickCreate:Tooltip' => 'Szybko utwórz dowolny rodzaj obiektu', ]); diff --git a/dictionaries/ui/components/quick-create/pt_br.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/pt_br.dictionary.itop.quick-create.php index 4df567fec..7709924ec 100644 --- a/dictionaries/ui/components/quick-create/pt_br.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/pt_br.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Selecione o tipo de objeto...', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Abrir criação rápida', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Você ainda não criou nenhum objeto', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Mais popular', 'UI:Component:QuickCreate:Recents:Title' => 'Recentes', 'UI:Component:QuickCreate:Tooltip' => 'Crie rapidamente qualquer tipo de objeto', ]); diff --git a/dictionaries/ui/components/quick-create/ru.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/ru.dictionary.itop.quick-create.php index 7f6d9179e..b6d3dad55 100755 --- a/dictionaries/ui/components/quick-create/ru.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/ru.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('RU RU', 'Russian', 'Русский', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Выбрать тип объекта...', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Открыть быстрое создание объекта', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'Вы ещё не создавали объекты', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Популярные', 'UI:Component:QuickCreate:Recents:Title' => 'Недавние', 'UI:Component:QuickCreate:Tooltip' => 'Быстрое создание объекта любого типа', ]); diff --git a/dictionaries/ui/components/quick-create/sk.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/sk.dictionary.itop.quick-create.php index 448b02f35..32415e0bd 100644 --- a/dictionaries/ui/components/quick-create/sk.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/sk.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('SK SK', 'Slovak', 'Slovenčina', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', ]); diff --git a/dictionaries/ui/components/quick-create/tr.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/tr.dictionary.itop.quick-create.php index 2636da717..9f20f9b01 100644 --- a/dictionaries/ui/components/quick-create/tr.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/tr.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', [ 'UI:Component:QuickCreate:Input:Placeholder' => 'Select object type...~~', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => 'Open quick create~~', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => 'You haven\'t create any object yet~~', + 'UI:Component:QuickCreate:MostPopular:Title' => 'Most popular~~', 'UI:Component:QuickCreate:Recents:Title' => 'Recents~~', 'UI:Component:QuickCreate:Tooltip' => 'Quickly create any type of object~~', ]); diff --git a/dictionaries/ui/components/quick-create/zh_cn.dictionary.itop.quick-create.php b/dictionaries/ui/components/quick-create/zh_cn.dictionary.itop.quick-create.php index 194a63a8b..e501648f9 100644 --- a/dictionaries/ui/components/quick-create/zh_cn.dictionary.itop.quick-create.php +++ b/dictionaries/ui/components/quick-create/zh_cn.dictionary.itop.quick-create.php @@ -14,6 +14,7 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', [ 'UI:Component:QuickCreate:Input:Placeholder' => '请选择对象类型...', 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer' => '打开快速创建', 'UI:Component:QuickCreate:LastClasses:NoClass:Placeholder' => '您尚未创建任何对象', + 'UI:Component:QuickCreate:MostPopular:Title' => '最常用', 'UI:Component:QuickCreate:Recents:Title' => '最近', 'UI:Component:QuickCreate:Tooltip' => '快速创建任意类型的对象', ]); diff --git a/sources/Application/UI/Base/Component/QuickCreate/QuickCreate.php b/sources/Application/UI/Base/Component/QuickCreate/QuickCreate.php index b7ae9ee76..e59dc7460 100644 --- a/sources/Application/UI/Base/Component/QuickCreate/QuickCreate.php +++ b/sources/Application/UI/Base/Component/QuickCreate/QuickCreate.php @@ -59,10 +59,14 @@ class QuickCreate extends UIBlock implements iKeyboardShortcut protected $aLastClasses; /** @var int $iMaxAutocompleteResults Max. number of elements returned by the autocomplete */ protected $iMaxAutocompleteResults; - /** @var bool $bShowHistory Whether or not to display the elements in the history */ + /** @var bool $bShowHistory Whether to display the elements in the history */ protected $bShowHistory; /** @var int $iMaxHistoryResults Max. number of elements in the history */ protected $iMaxHistoryResults; + /** @var int $iMaxPopularResults Max. number of elements in the popular section */ + protected $iMaxPopularResults; + /** @var array $aPopularClasses */ + protected $aPopularClasses; /** * QuickCreate constructor. @@ -82,6 +86,8 @@ class QuickCreate extends UIBlock implements iKeyboardShortcut $this->iMaxAutocompleteResults = (int) MetaModel::GetConfig()->Get('quick_create.max_autocomplete_results'); $this->bShowHistory = (bool) MetaModel::GetConfig()->Get('quick_create.show_history'); $this->iMaxHistoryResults = (int) MetaModel::GetConfig()->Get('quick_create.max_history_results'); + $this->iMaxPopularResults = (int) MetaModel::GetConfig()->Get('quick_create.max_popular_results'); + $this->aPopularClasses = QuickCreateHelper::GetPopularClasses(); } /** @@ -89,7 +95,7 @@ class QuickCreate extends UIBlock implements iKeyboardShortcut * If $bRelativeUrl is true, then $sEndpoint will be complete with the app_root_url * * @param string $sEndpoint URL to the endpoint - * @param bool $bRelativeUrl Whether or not the $sEndpoint parameter is a relative URL + * @param bool $bRelativeUrl Whether the $sEndpoint parameter is a relative URL * * @return $this * @throws \Exception @@ -203,6 +209,24 @@ class QuickCreate extends UIBlock implements iKeyboardShortcut return $this->iMaxHistoryResults; } + /** + * @see $aMaxPopularClasses + * @return array + */ + public function GetPopularClasses(): array + { + return $this->aPopularClasses; + } + + /** + * @see $iMaxPopularResults + * @return int + */ + public function GetMaxPopularResults(): int + { + return $this->iMaxPopularResults; + } + public static function GetShortcutKeys(): array { return [['id' => 'ibo-open-quick-create', 'label' => 'UI:Component:QuickCreate:KeyboardShortcut:OpenDrawer', 'key' => 'c', 'event' => 'open_drawer']]; diff --git a/sources/Application/UI/Base/Component/QuickCreate/QuickCreateHelper.php b/sources/Application/UI/Base/Component/QuickCreate/QuickCreateHelper.php index 63c066fca..ee30d35a4 100644 --- a/sources/Application/UI/Base/Component/QuickCreate/QuickCreateHelper.php +++ b/sources/Application/UI/Base/Component/QuickCreate/QuickCreateHelper.php @@ -24,6 +24,7 @@ use appUserPreferences; use DBObject; use MetaModel; use utils; +use UserRights; /** * Class QuickCreateHelper @@ -71,7 +72,7 @@ class QuickCreateHelper array_unshift($aHistoryEntries, $aNewEntry); // Truncate history - static::TruncateHistory($aHistoryEntries); + static::Truncate($aHistoryEntries, 'quick_create.max_history_results'); appUserPreferences::SetPref(static::USER_PREF_CODE, $aHistoryEntries); } @@ -88,7 +89,8 @@ class QuickCreateHelper { /** @var array $aHistoryEntries */ $aHistoryEntries = appUserPreferences::GetPref(static::USER_PREF_CODE, []); - static::TruncateHistory($aHistoryEntries); + + static::Truncate($aHistoryEntries, 'quick_create.max_history_results'); for($iIdx = 0; $iIdx < count($aHistoryEntries); $iIdx++) { @@ -125,16 +127,70 @@ class QuickCreateHelper } /** - * Truncate $aHistoryEntries to 'global_search.max_history_results' entries + * Return an array of popular object classes * - * @param array $aHistoryEntries + * @return array + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \MySQLException */ - protected static function TruncateHistory(array &$aHistoryEntries): void + public static function GetPopularClasses(): array { - $iMaxHistoryResults = (int) MetaModel::GetConfig()->Get('quick_create.max_history_results'); - if(count($aHistoryEntries) > $iMaxHistoryResults) + $aHistoryEntries = appUserPreferences::GetPref(static::USER_PREF_CODE, []); + static::Truncate($aHistoryEntries, 'quick_create.max_history_results'); + $aPopularClassesNames = UserRights::GetAllowedClasses(UR_ACTION_CREATE, array('popular'), false); + + // Prevent classes in both Popular and Recent to appear twice + for($iIdx = 0; $iIdx < count($aHistoryEntries); $iIdx++) { - $aHistoryEntries = array_slice($aHistoryEntries, 0, $iMaxHistoryResults); + if (($key = array_search($aHistoryEntries[$iIdx]['class'], $aPopularClassesNames)) !== false) { + unset($aPopularClassesNames[$key]); + } + } + //die(var_dump($aPopularClassesNames)); + static::Truncate($aPopularClassesNames, 'quick_create.max_popular_results'); + $aPopularClasses = array(); + foreach($aPopularClassesNames as $sClass) + { + if (!MetaModel::IsValidClass($sClass)) { + continue; + } + + // Add class icon + $sClassIconUrl = MetaModel::GetClassIcon($sClass, false); + // Mind that some classes don't have an icon + $sClassIconUrl = !empty($sClassIconUrl) ? $sClassIconUrl : null; + + // Add class label + $sLabelHtml = utils::EscapeHtml(MetaModel::GetName($sClass)); + + // Add URL + $sTargetUrl = DBObject::ComputeStandardUIPage($sClass).'?operation=new&class='.$sClass; + + $aPopularClasses[] = array( + 'class' => $sClass, + 'icon_url' => $sClassIconUrl, + 'label_html' => $sLabelHtml, + 'target_url' => $sTargetUrl + ); + } + return $aPopularClasses; + } + + /** + * Truncate an array to $sMaxEntriesParam + * + * @param array $aEntries + * @param string $sMaxEntriesParam + */ + protected static function Truncate(array &$aEntries, string $sMaxEntriesParam = 'global_search.max_history_results'): void + { + $iMaxResults = (int) MetaModel::GetConfig()->Get($sMaxEntriesParam); + if(count($aEntries) > $iMaxResults) + { + $aEntries = array_slice($aEntries, 0, $iMaxResults); } } + + } \ No newline at end of file diff --git a/templates/base/components/quick-create/layout.html.twig b/templates/base/components/quick-create/layout.html.twig index ad17277b5..e3e43b2b8 100644 --- a/templates/base/components/quick-create/layout.html.twig +++ b/templates/base/components/quick-create/layout.html.twig @@ -20,10 +20,11 @@
-
+ {# History section #} +
{{ 'UI:Component:QuickCreate:Recents:Title'|dict_s }}
-
+
{% if oUIBlock.GetShowHistory == false %}
{{ 'UI:Component:QuickCreate:HistoryDisabled'|dict_s }}
@@ -48,6 +49,23 @@
{% endif %}
+ {# Popular classes section #} + {% if oUIBlock.GetPopularClasses()|length > 0 %} + + + {% endif %}
\ No newline at end of file diff --git a/tests/php-unit-tests/composer.lock b/tests/php-unit-tests/composer.lock index b59369d20..d1ac7cfdc 100644 --- a/tests/php-unit-tests/composer.lock +++ b/tests/php-unit-tests/composer.lock @@ -9,30 +9,30 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.5.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^11", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.30 || ^5.4" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -59,7 +59,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -75,20 +75,20 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:15:36+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.11.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", "shasum": "" }, "require": { @@ -96,11 +96,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -126,7 +127,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" }, "funding": [ { @@ -134,29 +135,31 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2024-11-08T17:47:46+00:00" }, { "name": "nikic/php-parser", - "version": "v4.15.2", + "version": "v5.3.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc" + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", - "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -164,7 +167,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -188,26 +191,27 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" }, - "time": "2022-11-12T15:38:23+00:00" + "time": "2024-10-08T18:51:32+00:00" }, { "name": "phar-io/manifest", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + "reference": "54750ef60c58e43759730615a392c31c80e23176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", @@ -248,9 +252,15 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, - "time": "2021-07-20T11:28:43+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" }, { "name": "phar-io/version", @@ -305,44 +315,44 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.23", + "version": "9.2.32", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c" + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", - "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.14", + "nikic/php-parser": "^4.19.1 || ^5.1.0", "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.6" }, "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "9.2.x-dev" } }, "autoload": { @@ -370,7 +380,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.23" + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" }, "funding": [ { @@ -378,7 +389,7 @@ "type": "github" } ], - "time": "2022-12-28T12:41:10+00:00" + "time": "2024-08-22T04:23:01+00:00" }, { "name": "phpunit/php-file-iterator", @@ -623,50 +634,50 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.27", + "version": "9.6.21", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38" + "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38", - "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", + "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -674,7 +685,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.5-dev" + "dev-master": "9.6-dev" } }, "autoload": { @@ -705,7 +716,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21" }, "funding": [ { @@ -721,20 +733,20 @@ "type": "tidelift" } ], - "time": "2022-12-09T07:31:23+00:00" + "time": "2024-09-19T10:50:18+00:00" }, { "name": "sebastian/cli-parser", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", "shasum": "" }, "require": { @@ -769,7 +781,7 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" }, "funding": [ { @@ -777,7 +789,7 @@ "type": "github" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2024-03-02T06:27:43+00:00" }, { "name": "sebastian/code-unit", @@ -966,20 +978,20 @@ }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1011,7 +1023,7 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" }, "funding": [ { @@ -1019,20 +1031,20 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2023-12-22T06:19:30+00:00" }, { "name": "sebastian/diff", - "version": "4.0.4", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", "shasum": "" }, "require": { @@ -1077,7 +1089,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" }, "funding": [ { @@ -1085,20 +1097,20 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2024-03-02T06:30:58+00:00" }, { "name": "sebastian/environment", - "version": "5.1.4", + "version": "5.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", "shasum": "" }, "require": { @@ -1140,7 +1152,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" }, "funding": [ { @@ -1148,20 +1160,20 @@ "type": "github" } ], - "time": "2022-04-03T09:37:03+00:00" + "time": "2023-02-03T06:03:51+00:00" }, { "name": "sebastian/exporter", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", "shasum": "" }, "require": { @@ -1217,7 +1229,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" }, "funding": [ { @@ -1225,20 +1237,20 @@ "type": "github" } ], - "time": "2022-09-14T06:03:37+00:00" + "time": "2024-03-02T06:33:00+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.5", + "version": "5.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", "shasum": "" }, "require": { @@ -1281,7 +1293,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" }, "funding": [ { @@ -1289,24 +1301,24 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2024-03-02T06:35:11+00:00" }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1338,7 +1350,7 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" }, "funding": [ { @@ -1346,7 +1358,7 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2023-12-22T06:20:34+00:00" }, { "name": "sebastian/object-enumerator", @@ -1462,16 +1474,16 @@ }, { "name": "sebastian/recursion-context", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { @@ -1510,10 +1522,10 @@ } ], "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, "funding": [ { @@ -1521,20 +1533,20 @@ "type": "github" } ], - "time": "2020-10-26T13:17:30+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { "name": "sebastian/resource-operations", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { @@ -1546,7 +1558,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1567,8 +1579,7 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { @@ -1576,20 +1587,20 @@ "type": "github" } ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { "name": "sebastian/type", - "version": "3.2.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { @@ -1624,7 +1635,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { @@ -1632,7 +1643,7 @@ "type": "github" } ], - "time": "2022-09-12T14:47:03+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { "name": "sebastian/version", @@ -1727,16 +1738,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", "shasum": "" }, "require": { @@ -1765,7 +1776,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" }, "funding": [ { @@ -1773,15 +1784,15 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2024-03-03T12:36:25+00:00" } ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/tests/php-unit-tests/unitary-tests/sources/Application/UI/Base/Components/QuickCreate/QuickCreateHelperTest.php b/tests/php-unit-tests/unitary-tests/sources/Application/UI/Base/Components/QuickCreate/QuickCreateHelperTest.php new file mode 100644 index 000000000..ac8a71378 --- /dev/null +++ b/tests/php-unit-tests/unitary-tests/sources/Application/UI/Base/Components/QuickCreate/QuickCreateHelperTest.php @@ -0,0 +1,60 @@ +GivenRecentClasses(['Person']); + + $aPopularClasses = QuickCreateHelper::GetPopularClasses(); + $this->AssertPopularClassesMatches(['FunctionalCI', 'UserRequest'], $aPopularClasses, ""); + } + + public function testPopularClassesShouldBeLeftUnchangedWhenNoRecent() + { + // Given popular classes = ['FunctionalCI', 'UserRequest'], as defined in datamodel + $this->GivenRecentClasses([]); + + $aPopularClasses = QuickCreateHelper::GetPopularClasses(); + $this->AssertPopularClassesMatches(['FunctionalCI', 'UserRequest'], $aPopularClasses, ""); + } + + public function testClassInRecentShouldNotBeInPopular() + { + // Given popular classes = ['FunctionalCI', 'UserRequest'], as defined in datamodel + $this->GivenRecentClasses(['UserRequest']); + + $aPopularClasses = QuickCreateHelper::GetPopularClasses(); + $this->AssertPopularClassesMatches(['FunctionalCI'], $aPopularClasses, ""); + } + private function GivenRecentClasses(array $aGivenClasses) + { + $aRecentClasses = []; + // User preferences will be reset during the rollback + foreach($aGivenClasses as $sClass) { + $aRecentClasses[] = array( + 'class' => $sClass, + ); + } + + appUserPreferences::SetPref(QuickCreateHelper::USER_PREF_CODE, $aRecentClasses); + } + + private function AssertPopularClassesMatches(array $aExpectedClasses, array $aPopularClasses, string $sMessage = '') + { + $aFoundClasses = []; + foreach($aPopularClasses as $aClassData) { + $aFoundClasses[] = $aClassData['class']; + } + sort($aFoundClasses); + sort($aExpectedClasses); + $this->assertEquals($aExpectedClasses, $aFoundClasses, $sMessage); + } +} \ No newline at end of file