Skip to content
Snippets Groups Projects
Commit d9c24ca4 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #13271 TIME 1:15 quick search + fix tu

parent 868d4a14
No related branches found
No related tags found
No related merge requests found
......@@ -317,33 +317,57 @@ class SearchController
$body = $args['body'];
//TODO finish
if (!empty($body['meta']) && !empty($body['meta']['values']) && is_string($body['meta']['values'])) {
if ($body['meta']['values'][0] == '"' && $body['meta']['values'][strlen($body['meta']['values']) - 1] == '"') {
$quick = trim($body['meta']['values'], '"');
$quickWhere = "(subject = ? OR res_id in (select res_id_master from res_attachments where title = ?)";
$quickWhere .= ' OR alt_identifier = ? OR res_id in (select res_id_master from res_attachments where identifier ilike ?)';
$quickWhere = "subject = ? OR res_id in (select res_id_master from res_attachments where title = ?)";
$quickWhere .= ' OR alt_identifier = ? OR res_id in (select res_id_master from res_attachments where identifier = ?)';
$quickWhere .= ' OR barcode = ?';
if (is_numeric($quick)) {
if (ctype_digit($quick)) {
$quickWhere .= ' OR res_id = ?';
$args['searchData'][] = $quick;
}
$quickWhere .= ')';
$args['searchWhere'][] = $quickWhere;
$args['searchWhere'][] = '(' . $quickWhere . ')';
$args['searchData'] = array_merge($args['searchData'], [$quick, $quick, $quick, $quick, $quick]);
} else {
$fields = ['subject', 'alt_identifier', 'barcode'];
$fields = AutoCompleteController::getUnsensitiveFieldsForRequest(['fields' => $fields]);
$requestData = AutoCompleteController::getDataForRequest([
$requestDataDocument = AutoCompleteController::getDataForRequest([
'search' => $body['meta']['values'],
'fields' => $fields,
'where' => [],
'data' => [],
'fieldsNumber' => 3
]);
$args['searchWhere'] = array_merge($args['searchWhere'], $requestData['where']);
$args['searchData'] = array_merge($args['searchData'], $requestData['data']);
$fields = ['title', 'identifier'];
$fields = AutoCompleteController::getUnsensitiveFieldsForRequest(['fields' => $fields]);
$requestDataAttachment = AutoCompleteController::getDataForRequest([
'search' => $body['meta']['values'],
'fields' => $fields,
'where' => [],
'data' => [],
'fieldsNumber' => 2
]);
if (!empty($requestDataDocument['where'])) {
$whereClause[] = implode(' OR ', $requestDataDocument['where']);
$args['searchData'] = array_merge($args['searchData'], $requestDataDocument['data']);
}
if (!empty($requestDataAttachment['where'])) {
$whereClause[] = 'res_id in (select res_id_master from res_attachments where ' . implode(' OR ', $requestDataAttachment['where']) . ')';
$args['searchData'] = array_merge($args['searchData'], $requestDataAttachment['data']);
}
if (ctype_digit(trim($body['meta']['values']))) {
$whereClause[] = 'res_id = ?';
$args['searchData'][] = trim($body['meta']['values']);
}
if (!empty($whereClause)) {
$args['searchWhere'][] = '(' . implode(' OR ', $whereClause) . ')';
}
}
}
......
......@@ -224,7 +224,7 @@
<mat-divider></mat-divider>
</mat-sidenav>
</mat-sidenav-container>
<app-folder-action-list #actionsListContext [contextMode]="true" [currentFolderInfo]="folderInfo"
<app-followed-action-list #actionsListContext [contextMode]="true" [currentFolderInfo]="folderInfo"
[totalRes]="allResInBasket.length" [selectedRes]="selectedRes" (refreshEvent)="refreshDaoAfterAction()"
(refreshPanelFolders)="foldersService.getFolders()">
</app-folder-action-list>
\ No newline at end of file
[menuShortcut]="menuShortcut" (refreshPanelFolders)="foldersService.getFolders()">
</app-followed-action-list>
......@@ -126,24 +126,6 @@ class SummarySheetControllerTest extends TestCase
$responseBody = json_decode((string)$response->getBody(), true);
$this->assertSame('Resources is not set or empty', $responseBody['errors']);
$body = [
"resources" => $GLOBALS['resources'],
"units" => [
['label' => 'Informations', 'unit' => 'primaryInformations']
],
];
$fullRequest = \httpRequestCustom::addContentInBody($body, $request);
$GLOBALS['login'] = 'ddur';
$userInfo = \User\models\UserModel::getByLogin(['login' => $GLOBALS['login'], 'select' => ['id']]);
$GLOBALS['id'] = $userInfo['id'];
$response = $summarySheetController->createList($fullRequest, new \Slim\Http\Response());
$this->assertSame(403, $response->getStatusCode());
$responseBody = json_decode((string)$response->getBody(), true);
$this->assertSame('Resources out of perimeter', $responseBody['errors']);
$GLOBALS['login'] = 'superadmin';
$userInfo = \User\models\UserModel::getByLogin(['login' => $GLOBALS['login'], 'select' => ['id']]);
$GLOBALS['id'] = $userInfo['id'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment