attribute select param

This commit is contained in:
Yuri Kuznetsov
2024-12-12 16:44:31 +02:00
parent 25616cee73
commit dfcf0838d3
3 changed files with 25 additions and 4 deletions

View File

@@ -162,8 +162,10 @@ class SearchParamsFetcher
$params['filterList'] = (array) $request->getQueryParams()['filterList'];
}
if ($request->getQueryParam('select')) {
$params['select'] = explode(',', $request->getQueryParam('select'));
$select = $request->getQueryParam('attributeSelect') ?? $request->getQueryParam('select');
if ($select) {
$params['select'] = explode(',', $select);
}
return $params;

View File

@@ -822,6 +822,12 @@ class Collection {
options.data.order = this.order;
options.data.where = this.getWhere();
if (options.data.select) {
options.data.attributeSelect = options.data.select;
delete options.data.select;
}
options = {prepare: true, ...options};
const success = options.success;

View File

@@ -67,7 +67,20 @@ class SearchParamsFetcherTest extends \PHPUnit\Framework\TestCase
$params = $fetcher->fetch(new RequestWrapper($request));
$this->assertEquals($params->getTextFilter(), $raw['textFilter']);
$this->assertEquals($params->getMaxSize(), $raw['maxSize']);
$this->assertEquals($raw['textFilter'], $params->getTextFilter());
$this->assertEquals($raw['maxSize'], $params->getMaxSize());
}
public function testFetchQuery(): void
{
$q = http_build_query(['attributeSelect' => 'a,b']);
$request = (new RequestFactory)->createRequest('GET', 'http://localhost/?' . $q);
$fetcher = new SearchParamsFetcher($this->config, $this->textMetadataProvider);
$params = $fetcher->fetch(new RequestWrapper($request));
$this->assertEquals(['a', 'b'], $params->getSelect());
}
}