Skip to content
Snippets Groups Projects
Verified Commit 5b3a1644 authored by Damien's avatar Damien
Browse files

FEAT #11690 TIME 0:20 Refactor notes

parent acd354f1
No related branches found
No related tags found
No related merge requests found
...@@ -45,12 +45,15 @@ class NoteController ...@@ -45,12 +45,15 @@ class NoteController
$user = UserModel::getByLogin(['select' => ['id'], 'login' => $GLOBALS['userId']]); $user = UserModel::getByLogin(['select' => ['id'], 'login' => $GLOBALS['userId']]);
$aNotes = NoteModel::getByUserIdForResource(['select' => ['*'], 'resId' => $aArgs['resId'], 'userId' => $user['id']]); $aNotes = NoteModel::getByUserIdForResource(['select' => ['*'], 'resId' => $aArgs['resId'], 'userId' => $user['id']]);
foreach ($aNotes as $key => $aNote) { foreach ($aNotes as $key => $note) {
$user = UserModel::getById(['select' => ['firstname', 'lastname', 'user_id'], 'id' => $aNote['user_id']]); $user = UserModel::getById(['select' => ['firstname', 'lastname', 'user_id'], 'id' => $note['user_id']]);
$primaryEntity = UserModel::getPrimaryEntityByUserId(['userId' => $user['user_id']]); $primaryEntity = UserModel::getPrimaryEntityByUserId(['userId' => $user['user_id']]);
$aNotes[$key]['firstname'] = $user['firstname']; $aNotes[$key]['firstname'] = $user['firstname'];
$aNotes[$key]['lastname'] = $user['lastname']; $aNotes[$key]['lastname'] = $user['lastname'];
$aNotes[$key]['entity_label'] = $primaryEntity['entity_label']; $aNotes[$key]['entity_label'] = $primaryEntity['entity_label'];
$aNotes[$key]['value'] = $note['note_text'];
unset($aNotes[$key]['note_text']);
} }
return $response->withJson($aNotes); return $response->withJson($aNotes);
...@@ -70,8 +73,11 @@ class NoteController ...@@ -70,8 +73,11 @@ class NoteController
$entities = NoteEntityModel::get(['select' => ['item_id'], 'where' => ['note_id = ?'], 'data' => [$args['id']]]); $entities = NoteEntityModel::get(['select' => ['item_id'], 'where' => ['note_id = ?'], 'data' => [$args['id']]]);
$entities = array_column($entities, 'item_id'); $entities = array_column($entities, 'item_id');
$note['value'] = $note['note_text'];
$note['entities'] = $entities; $note['entities'] = $entities;
unset($note['note_text']);
return $response->withJson($note); return $response->withJson($note);
} }
......
...@@ -78,7 +78,7 @@ class ResController ...@@ -78,7 +78,7 @@ class ResController
$finfo = new \finfo(FILEINFO_MIME_TYPE); $finfo = new \finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->buffer($file); $mimeType = $finfo->buffer($file);
if (!StoreController::isFileAllowed(['extension' => $body['format'], 'type' => $mimeType])) { if (!StoreController::isFileAllowed(['extension' => $body['format'], 'type' => $mimeType])) {
return $response->withStatus(400)->withJson(['errors' => _FILE_NOT_ALLOWED_INFO_1.' "'.$body['format'].'" '._FILE_NOT_ALLOWED_INFO_2.' "'. $mimeType. '" '._FILE_NOT_ALLOWED_INFO_3]); return $response->withStatus(400)->withJson(['errors' => "Format with this mimeType is not allowed : {$body['format']} {$mimeType}"]);
} }
$resId = StoreController::storeResource($body); $resId = StoreController::storeResource($body);
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<p class="noteTextContent"> <p class="noteTextContent">
{{note.note_text}} {{note.value}}
</p> </p>
<span *ngFor="let entity of note.entities_restriction" class="label label-default noteRestriction" <span *ngFor="let entity of note.entities_restriction" class="label label-default noteRestriction"
title="{{lang.restrictedEntity}}"><i class="fa fa-sitemap"></i> {{entity.short_label}}</span> title="{{lang.restrictedEntity}}"><i class="fa fa-sitemap"></i> {{entity.short_label}}</span>
</mat-card-content> </mat-card-content>
</mat-card> </mat-card>
</ng-container> </ng-container>
\ No newline at end of file
This diff is collapsed.
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