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

FEAT #11271 TIME 0:25 route entitites list

parent 1dfc78f3
No related branches found
No related tags found
No related merge requests found
...@@ -136,6 +136,7 @@ $app->delete('/customFields/{id}', \CustomField\controllers\CustomFieldControlle ...@@ -136,6 +136,7 @@ $app->delete('/customFields/{id}', \CustomField\controllers\CustomFieldControlle
//IndexingModels //IndexingModels
$app->get('/indexingModels', \IndexingModel\controllers\IndexingModelController::class . ':get'); $app->get('/indexingModels', \IndexingModel\controllers\IndexingModelController::class . ':get');
$app->get('/indexingModels/entities', \IndexingModel\controllers\IndexingModelController::class . ':getEntities');
$app->get('/indexingModels/{id}', \IndexingModel\controllers\IndexingModelController::class . ':getById'); $app->get('/indexingModels/{id}', \IndexingModel\controllers\IndexingModelController::class . ':getById');
$app->post('/indexingModels', \IndexingModel\controllers\IndexingModelController::class . ':create'); $app->post('/indexingModels', \IndexingModel\controllers\IndexingModelController::class . ':create');
$app->put('/indexingModels/{id}', \IndexingModel\controllers\IndexingModelController::class . ':update'); $app->put('/indexingModels/{id}', \IndexingModel\controllers\IndexingModelController::class . ':update');
......
...@@ -17,10 +17,12 @@ ...@@ -17,10 +17,12 @@
namespace IndexingModel\controllers; namespace IndexingModel\controllers;
use Entity\models\EntityModel;
use Group\models\ServiceModel; use Group\models\ServiceModel;
use History\controllers\HistoryController; use History\controllers\HistoryController;
use IndexingModel\models\IndexingModelFieldModel; use IndexingModel\models\IndexingModelFieldModel;
use IndexingModel\models\IndexingModelModel; use IndexingModel\models\IndexingModelModel;
use Resource\controllers\IndexingController;
use Respect\Validation\Validator; use Respect\Validation\Validator;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
...@@ -207,4 +209,41 @@ class IndexingModelController ...@@ -207,4 +209,41 @@ class IndexingModelController
return $response->withStatus(204); return $response->withStatus(204);
} }
public function getEntities(Request $request, Response $response, array $aArgs)
{
$entitiesTmp = EntityModel::get([
'select' => ['id', 'entity_label', 'entity_id'],
'where' => ['enabled = ?', '(parent_entity_id is null OR parent_entity_id = \'\')'],
'data' => ['Y'],
'orderBy' => ['entity_label']
]);
if (!empty($entitiesTmp)) {
foreach ($entitiesTmp as $key => $value) {
$entitiesTmp[$key]['level'] = 0;
}
$entitiesId = array_column($entitiesTmp, 'entity_id');
$entitiesChild = IndexingController::getEntitiesChildrenLevel(['entitiesId' => $entitiesId, 'level' => 1]);
$entitiesTmp = array_merge([$entitiesTmp], $entitiesChild);
}
$entities = [];
foreach ($entitiesTmp as $keyLevel => $levels) {
foreach ($levels as $entity) {
if ($keyLevel == 0) {
$entities[] = $entity;
continue;
} else {
foreach ($entities as $key => $oEntity) {
if ($oEntity['entity_id'] == $entity['parent_entity_id']) {
array_splice($entities, $key+1, 0, [$entity]);
continue;
}
}
}
}
}
return $response->withJson(['entities' => $entities]);
}
} }
...@@ -293,7 +293,7 @@ export class IndexingFormComponent implements OnInit { ...@@ -293,7 +293,7 @@ export class IndexingFormComponent implements OnInit {
} else } else
if (elem.identifier === 'destination') { if (elem.identifier === 'destination') {
if (this.adminMode) { if (this.adminMode) {
this.http.get("../../rest/indexing/entities").pipe( this.http.get("../../rest/indexingModels/entities").pipe(
tap((data: any) => { tap((data: any) => {
let title = ''; let title = '';
elem.values = data.entities.map((entity: any) => { elem.values = data.entities.map((entity: any) => {
......
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