Unverified Commit c6944271 authored by Xacobo Freire's avatar Xacobo Freire Committed by GitHub
Browse files

Show product_number in dropdown (#8253)



* Show product_number in dropdown

* check alphanumeric
Co-authored-by: default avatarCédric Anne <cedric.anne@gmail.com>

* Adding new test
Co-authored-by: default avatarCédric Anne <cedric.anne@gmail.com>
parent 90d34a14
......@@ -2671,6 +2671,10 @@ class Dropdown {
$orwhere[$table . '.' . $item->getIndexName()] = ['LIKE', "%{$post['searchText']}%"];
}
if ($item instanceof CommonDCModelDropdown) {
$orwhere[$table . '.product_number'] = ['LIKE', $search];
}
if (Session::haveTranslations($post['itemtype'], $field)) {
$orwhere['namet.value'] = ['LIKE', $search];
}
......@@ -2879,6 +2883,8 @@ class Dropdown {
} else {
$outputval = $tmpitem->getTypeName();
}
} else if ($item instanceof CommonDCModelDropdown) {
$outputval =sprintf(__('%1$s - %2$s'), $data[$field], $data['product_number']);
} else {
$outputval = $data[$field];
}
......
......@@ -97,7 +97,7 @@ function loadDataset() {
// Unit test data definition
$data = [
// bump this version to force reload of the full dataset, when content change
'_version' => '4.4',
'_version' => '4.5',
// Type => array of entries
'Entity' => [
......@@ -143,6 +143,14 @@ function loadDataset() {
'name' => '_test_pc22',
'entities_id' => '_test_child_2',
]
], 'ComputerModel' => [
[
'name' => '_test_computermodel_1',
'product_number' => 'CMP_ADEAF5E1',
], [
'name' => '_test_computermodel_2',
'product_number' => 'CMP_567AEC68',
],
], 'Software' => [
[
'name' => '_test_soft',
......
......@@ -708,7 +708,43 @@ class Dropdown extends DbTestCase {
'session_params' => [
'glpiis_ids_visible' => true
]
]
], [
'params' => [
'display_emptychoice' => 0,
'itemtype' => 'ComputerModel',
],
'expected' => [
'results' => [
[
'id' => getItemByTypeName('ComputerModel', '_test_computermodel_1', true),
'text' => '_test_computermodel_1 - CMP_ADEAF5E1',
'title' => '_test_computermodel_1 - CMP_ADEAF5E1',
],
[
'id' => getItemByTypeName('ComputerModel', '_test_computermodel_2', true),
'text' => '_test_computermodel_2 - CMP_567AEC68',
'title' => '_test_computermodel_2 - CMP_567AEC68',
]
],
'count' => 2
]
], [
'params' => [
'display_emptychoice' => 0,
'itemtype' => 'ComputerModel',
'searchText' => 'CMP_56',
],
'expected' => [
'results' => [
[
'id' => getItemByTypeName('ComputerModel', '_test_computermodel_2', true),
'text' => '_test_computermodel_2 - CMP_567AEC68',
'title' => '_test_computermodel_2 - CMP_567AEC68',
]
],
'count' => 1
]
],
];
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment