From f12cda7d6955dd65fc7948b716a3b0c698a45066 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Mon, 21 Dec 2020 17:16:33 +0100 Subject: [PATCH] FEAT #15677 TIME 6:20 Diffusion list + circuit history details --- migration/21.04/2104.sql | 3 + rest/index.php | 1 + sql/structure.sql | 1 + .../controllers/ListInstanceController.php | 14 + .../ListInstanceHistoryController.php | 97 +++- .../models/ListInstanceHistoryDetailModel.php | 3 +- .../history-diffusions-list.component.html | 8 +- .../history-diffusions-list.component.ts | 538 +----------------- .../history-visa-workflow.component.html | 8 +- .../history-visa-workflow.component.ts | 184 +++--- 10 files changed, 205 insertions(+), 652 deletions(-) diff --git a/migration/21.04/2104.sql b/migration/21.04/2104.sql index ddc747c6258..15def4e355c 100644 --- a/migration/21.04/2104.sql +++ b/migration/21.04/2104.sql @@ -26,3 +26,6 @@ CREATE TABLE attachment_types WITH (OIDS=FALSE); UPDATE history_batch SET total_errors = 0 WHERE total_errors IS NULL; + +ALTER TABLE listinstance_history_details DROP COLUMN IF EXISTS requested_signature; +ALTER TABLE listinstance_history_details ADD COLUMN requested_signature boolean default false; diff --git a/rest/index.php b/rest/index.php index ea4099aa019..f452a6a4733 100755 --- a/rest/index.php +++ b/rest/index.php @@ -416,6 +416,7 @@ $app->get('/resources/{resId}/visaCircuit', \Entity\controllers\ListInstanceCont $app->get('/resources/{resId}/opinionCircuit', \Entity\controllers\ListInstanceController::class . ':getOpinionCircuitByResId'); $app->get('/resources/{resId}/parallelOpinion', \Entity\controllers\ListInstanceController::class . ':getParallelOpinionByResId'); $app->get('/resources/{resId}/defaultCircuit', \Entity\controllers\ListTemplateController::class . ':getDefaultCircuitByResId'); +$app->get('/resources/{resId}/circuitsHistory', \Entity\controllers\ListInstanceHistoryController::class . ':getCircuitByResId'); $app->get('/resources/{resId}/linkedResources', \Resource\controllers\LinkController::class . ':getLinkedResources'); $app->post('/resources/{resId}/linkedResources', \Resource\controllers\LinkController::class . ':linkResources'); $app->put('/resources/{resId}/sign', \SignatureBook\controllers\SignatureBookController::class . ':signResource'); diff --git a/sql/structure.sql b/sql/structure.sql index 74ccdb47e9d..d69d4e56dfc 100755 --- a/sql/structure.sql +++ b/sql/structure.sql @@ -1030,6 +1030,7 @@ viewed bigint, difflist_type character varying(50), process_date timestamp without time zone, process_comment character varying(255), +requested_signature boolean default false, CONSTRAINT listinstance_history_details_pkey PRIMARY KEY (listinstance_history_details_id) ) WITH ( OIDS=FALSE ); diff --git a/src/app/entity/controllers/ListInstanceController.php b/src/app/entity/controllers/ListInstanceController.php index 5a702433166..1275889639a 100755 --- a/src/app/entity/controllers/ListInstanceController.php +++ b/src/app/entity/controllers/ListInstanceController.php @@ -477,6 +477,7 @@ class ListInstanceController } } + $listInstanceHistoryId = ListInstanceHistoryModel::create(['resId' => $resource['resId'], 'userId' => $GLOBALS['id']]); foreach ($listInstances as $key => $listInstance) { ListInstanceModel::create([ 'res_id' => $resource['resId'], @@ -491,6 +492,19 @@ class ListInstanceController 'requested_signature' => $listInstance['requested_signature'], 'delegate' => $listInstance['delegate'] ]); + ListInstanceHistoryDetailModel::create([ + 'listinstance_history_id' => $listInstanceHistoryId, + 'res_id' => $resource['resId'], + 'sequence' => $key, + 'item_id' => $listInstance['item_id'], + 'item_type' => $listInstance['item_type'], + 'item_mode' => $listInstance['item_mode'], + 'added_by_user' => $GLOBALS['id'], + 'difflist_type' => $args['type'] == 'visaCircuit' ? 'VISA_CIRCUIT' : 'AVIS_CIRCUIT', + 'process_date' => $listInstance['process_date'], + 'process_comment' => $listInstance['process_comment'], + 'requested_signature' => $listInstance['requested_signature'] + ]); } } diff --git a/src/app/entity/controllers/ListInstanceHistoryController.php b/src/app/entity/controllers/ListInstanceHistoryController.php index 92a5146765b..ca47c4f468f 100644 --- a/src/app/entity/controllers/ListInstanceHistoryController.php +++ b/src/app/entity/controllers/ListInstanceHistoryController.php @@ -18,6 +18,7 @@ use Entity\models\EntityModel; use Entity\models\ListInstanceHistoryDetailModel; use Entity\models\ListInstanceHistoryModel; use Resource\controllers\ResController; +use Resource\models\ResModel; use Respect\Validation\Validator; use Slim\Http\Request; use Slim\Http\Response; @@ -25,7 +26,69 @@ use User\models\UserModel; class ListInstanceHistoryController { - public function getByResId(Request $request, Response $response, array $args) + public function getdiffusionListByResId(Request $request, Response $response, array $args) + { + if (!Validator::intVal()->validate($args['resId']) || !ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { + return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); + } + + $resource = ResModel::getById(['select' => ['creation_date', 'typist'], 'resId' => $args['resId']]); + + $listInstancesModification = ListInstanceHistoryModel::get([ + 'select' => ['listinstance_history_id', 'updated_date', 'user_id'], + 'where' => ['res_id = ?'], + 'data' => [$args['resId']], + 'orderBy' => ['updated_date'] + ]); + + $formattedHistory = []; + foreach ($listInstancesModification as $limKey => $value) { + $listInstancesDetails = ListInstanceHistoryDetailModel::get([ + 'select' => ['*'], + 'where' => ['listinstance_history_id = ?', 'difflist_type = ?'], + 'data' => [$value['listinstance_history_id'], 'entity_id'] + ]); + $formattedDetails = []; + foreach ($listInstancesDetails as $key => $listInstancesDetail) { + if (empty($formattedDetails[$listInstancesDetail['item_mode']])) { + $formattedDetails[$listInstancesDetail['item_mode']] = ['items' => []]; + } + if ($listInstancesDetail['item_type'] == 'entity_id') { + $entity = EntityModel::getById(['id' => $listInstancesDetail['item_id'], 'select' => ['entity_label', 'entity_id']]); + $listInstancesDetail['item_id'] = $entity['entity_id']; + $listInstancesDetail['itemSerialId'] = $listInstancesDetail['item_id']; + $listInstancesDetail['itemLabel'] = $entity['entity_label']; + $listInstancesDetail['itemSubLabel'] = ''; + } else { + $listInstancesDetail['itemSerialId'] = $listInstancesDetail['item_id']; + $listInstancesDetail['itemLabel'] = UserModel::getLabelledUserById(['id' => $listInstancesDetail['item_id']]); + $listInstancesDetail['itemSubLabel'] = UserModel::getPrimaryEntityById(['id' => $listInstancesDetail['item_id'], 'select' => ['entities.entity_label']])['entity_label']; + } + $formattedDetails[$listInstancesDetail['item_mode']]['items'][] = $listInstancesDetail; + } + if (!empty($listInstancesDetails)) { + if ($limKey == 0) { + $formattedHistory[] = [ + 'userId' => $resource['typist'], + 'user' => UserModel::getLabelledUserById(['id' => $resource['typist']]), + 'creationDate' => $resource['creation_date'], + 'details' => $formattedDetails + ]; + } else { + $formattedHistory[] = [ + 'userId' => $listInstancesModification[$limKey - 1]['user_id'], + 'user' => UserModel::getLabelledUserById(['id' => $listInstancesModification[$limKey - 1]['user_id']]), + 'creationDate' => $listInstancesModification[$limKey - 1]['updated_date'], + 'details' => $formattedDetails + ]; + } + } + } + + return $response->withJson(['listInstanceHistory' => $formattedHistory]); + } + + public function getCircuitByResId(Request $request, Response $response, array $args) { if (!Validator::intVal()->validate($args['resId']) || !ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) { return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); @@ -33,15 +96,23 @@ class ListInstanceHistoryController $queryParams = $request->getQueryParams(); - $listInstancesModification = ListInstanceHistoryModel::get(['select' => ['listinstance_history_id', 'updated_date', 'user_id'], 'where' => ['res_id = ?'], 'data' => [$args['resId']]]); + $listInstancesModification = ListInstanceHistoryModel::get([ + 'select' => ['listinstance_history_id', 'updated_date', 'user_id'], + 'where' => ['res_id = ?'], + 'data' => [$args['resId']], + 'orderBy' => ['updated_date'] + ]); $formattedHistory = []; - foreach ($listInstancesModification as $value) { + foreach ($listInstancesModification as $limKey => $value) { $where = ['listinstance_history_id = ?']; $data = [$value['listinstance_history_id']]; - if (!empty($queryParams['type']) && in_array($queryParams['type'], ['diffusionList', 'visaCircuit', 'opinionCircuit'])) { + if (!empty($queryParams['type']) && in_array($queryParams['type'], ['visaCircuit', 'opinionCircuit'])) { + $where[] = 'difflist_type = ?'; + $data[] = str_replace(['visaCircuit', 'opinionCircuit'], ['VISA_CIRCUIT', 'AVIS_CIRCUIT'], $queryParams['type']); + } else { $where[] = 'difflist_type = ?'; - $data[] = str_replace(['diffusionList', 'visaCircuit', 'opinionCircuit'], ['entity_id', 'VISA_CIRCUIT', 'AVIS_CIRCUIT'], $queryParams['type']); + $data[] = 'VISA_CIRCUIT'; } $listInstancesDetails = ListInstanceHistoryDetailModel::get([ 'select' => ['*'], @@ -49,23 +120,15 @@ class ListInstanceHistoryController 'data' => $data ]); foreach ($listInstancesDetails as $key => $listInstancesDetail) { - if ($value['item_type'] == 'entity_id') { - $entity = EntityModel::getById(['id' => $listInstancesDetail['item_id'], 'select' => ['entity_label', 'entity_id']]); - $listInstances[$key]['item_id'] = $entity['entity_id']; - $listInstances[$key]['itemSerialId'] = $listInstancesDetail['item_id']; - $listInstances[$key]['labelToDisplay'] = $entity['entity_label']; - $listInstances[$key]['descriptionToDisplay'] = ''; - } else { - $listInstances[$key]['itemSerialId'] = $listInstancesDetail['item_id']; - $listInstances[$key]['labelToDisplay'] = UserModel::getLabelledUserById(['id' => $listInstancesDetail['item_id']]); - $listInstances[$key]['descriptionToDisplay'] = UserModel::getPrimaryEntityById(['id' => $listInstancesDetail['item_id'], 'select' => ['entities.entity_label']])['entity_label']; - } + $listInstancesDetails[$key]['itemSerialId'] = $listInstancesDetail['item_id']; + $listInstancesDetails[$key]['itemLabel'] = UserModel::getLabelledUserById(['id' => $listInstancesDetail['item_id']]); + $listInstancesDetails[$key]['itemSubLabel'] = UserModel::getPrimaryEntityById(['id' => $listInstancesDetail['item_id'], 'select' => ['entities.entity_label']])['entity_label']; } if (!empty($listInstancesDetails)) { $formattedHistory[] = [ 'userId' => $value['user_id'], 'user' => UserModel::getLabelledUserById(['id' => $value['user_id']]), - 'modificationDate' => $value['updated_date'], + 'creationDate' => $value['updated_date'], 'details' => $listInstancesDetails ]; } diff --git a/src/app/entity/models/ListInstanceHistoryDetailModel.php b/src/app/entity/models/ListInstanceHistoryDetailModel.php index bd112b59d8b..5452220e557 100644 --- a/src/app/entity/models/ListInstanceHistoryDetailModel.php +++ b/src/app/entity/models/ListInstanceHistoryDetailModel.php @@ -58,7 +58,8 @@ class ListInstanceHistoryDetailModel 'viewed' => 0, 'difflist_type' => $args['difflist_type'], 'process_date' => $args['process_date'], - 'process_comment' => $args['process_comment'] + 'process_comment' => $args['process_comment'], + 'requested_signature' => empty($args['requested_signature']) ? 'false' : 'true' ] ]); diff --git a/src/frontend/app/diffusions/history/history-diffusions-list.component.html b/src/frontend/app/diffusions/history/history-diffusions-list.component.html index a15125306de..56c1e098f90 100644 --- a/src/frontend/app/diffusions/history/history-diffusions-list.component.html +++ b/src/frontend/app/diffusions/history/history-diffusions-list.component.html @@ -5,18 +5,18 @@ <mat-divider></mat-divider> </div> <ng-container *ngFor="let role of availableRoles"> - <mat-expansion-panel *ngIf="diffList.listinstance[role.id].items.length > 0" class="diffusionList" + <mat-expansion-panel *ngIf="diffList.details[role.id]" class="diffusionList" [expanded]="role.id === 'dest' || expanded"> <mat-expansion-panel-header> <mat-panel-title> {{role.label}} <ng-container *ngIf="role.id !== 'dest'"> - ({{diffList.listinstance[role.id].items.length}}) + ({{diffList.details[role.id].items.length}}) </ng-container> </mat-panel-title> </mat-expansion-panel-header> <mat-list> <mat-list-item disableRipple class="item-diffusion-list" - *ngFor="let diffusion of diffList.listinstance[role.id].items;let i=index"> + *ngFor="let diffusion of diffList.details[role.id].items;let i=index"> <mat-icon mat-list-icon color="primary" class="fa" [class.fa-user]="diffusion.item_type === 'user_id' || diffusion.item_type === 'user'" [class.fa-sitemap]="diffusion.item_type === 'entity_id' || diffusion.item_type === 'entity'"> @@ -34,4 +34,4 @@ </ng-container> <div *ngIf="loading" style="display:flex;"> <mat-spinner style="margin:auto;"></mat-spinner> -</div> \ No newline at end of file +</div> diff --git a/src/frontend/app/diffusions/history/history-diffusions-list.component.ts b/src/frontend/app/diffusions/history/history-diffusions-list.component.ts index 6e13fc7700b..54fb71c59bb 100644 --- a/src/frontend/app/diffusions/history/history-diffusions-list.component.ts +++ b/src/frontend/app/diffusions/history/history-diffusions-list.component.ts @@ -55,547 +55,17 @@ export class HistoryDiffusionsListComponent implements OnInit { } getListinstanceHistory() { - this.diffListHistory = [ - { - user: 'Bernard BLIER', - creationDate: '2020-12-18 14:02:19.558904', - listinstance: { - 'dest': { - 'label': 'Attributaire', - 'items': [ - { - 'listinstance_id': 62, - 'item_mode': 'dest', - 'item_type': 'user', - 'itemSerialId': 19, - 'itemId': 'bbain', - 'itemLabel': 'Barbara BAIN', - 'itemSubLabel': 'Pôle Jeunesse et Sport', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'cc': { - 'label': 'En copie', - 'items': [ - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'avis': { - 'label': 'Pour avis', - 'items': [] - } - } - }, - { - user: 'Bernard BLIER', - creationDate: '2020-10-06 17:02:19.558904', - listinstance: { - 'dest': { - 'label': 'Attributaire', - 'items': [ - { - 'listinstance_id': 62, - 'item_mode': 'dest', - 'item_type': 'user', - 'itemSerialId': 19, - 'itemId': 'bbain', - 'itemLabel': 'Barbara BAIN', - 'itemSubLabel': 'Pôle Jeunesse et Sport', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'cc': { - 'label': 'En copie', - 'items': [ - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'avis': { - 'label': 'Pour avis', - 'items': [] - } - } - }, - { - user: 'Bernard BLIER', - creationDate: '2020-10-06 17:02:19.558904', - listinstance: { - 'dest': { - 'label': 'Attributaire', - 'items': [ - { - 'listinstance_id': 62, - 'item_mode': 'dest', - 'item_type': 'user', - 'itemSerialId': 19, - 'itemId': 'bbain', - 'itemLabel': 'Barbara BAIN', - 'itemSubLabel': 'Pôle Jeunesse et Sport', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'cc': { - 'label': 'En copie', - 'items': [ - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'avis': { - 'label': 'Pour avis', - 'items': [] - } - } - }, - { - user: 'Bernard BLIER', - creationDate: '2020-10-06 17:02:19.558904', - listinstance: { - 'dest': { - 'label': 'Attributaire', - 'items': [ - { - 'listinstance_id': 62, - 'item_mode': 'dest', - 'item_type': 'user', - 'itemSerialId': 19, - 'itemId': 'bbain', - 'itemLabel': 'Barbara BAIN', - 'itemSubLabel': 'Pôle Jeunesse et Sport', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'cc': { - 'label': 'En copie', - 'items': [ - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'avis': { - 'label': 'Pour avis', - 'items': [] - } - } - }, - { - user: 'Bernard BLIER', - creationDate: '2020-10-06 17:02:19.558904', - listinstance: { - 'dest': { - 'label': 'Attributaire', - 'items': [ - { - 'listinstance_id': 62, - 'item_mode': 'dest', - 'item_type': 'user', - 'itemSerialId': 19, - 'itemId': 'bbain', - 'itemLabel': 'Barbara BAIN', - 'itemSubLabel': 'Pôle Jeunesse et Sport', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'cc': { - 'label': 'En copie', - 'items': [ - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'avis': { - 'label': 'Pour avis', - 'items': [] - } - } - }, - { - user: 'Bernard BLIER', - creationDate: '2020-10-06 17:02:19.558904', - listinstance: { - 'dest': { - 'label': 'Attributaire', - 'items': [ - { - 'listinstance_id': 62, - 'item_mode': 'dest', - 'item_type': 'user', - 'itemSerialId': 19, - 'itemId': 'bbain', - 'itemLabel': 'Barbara BAIN', - 'itemSubLabel': 'Pôle Jeunesse et Sport', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'cc': { - 'label': 'En copie', - 'items': [ - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - }, - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'avis': { - 'label': 'Pour avis', - 'items': [] - } - } - }, - { - creationDate: '2020-11-06 17:02:19.558904', - listinstance: { - 'dest': { - 'label': 'Attributaire', - 'items': [ - { - 'listinstance_id': 62, - 'item_mode': 'dest', - 'item_type': 'user', - 'itemSerialId': 19, - 'itemId': 'bbain', - 'itemLabel': 'Barbara BAIN', - 'itemSubLabel': 'Pôle Jeunesse et Sport', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'cc': { - 'label': 'En copie', - 'items': [ - { - 'listinstance_id': 63, - 'item_mode': 'cc', - 'item_type': 'entity', - 'itemSerialId': 1, - 'itemId': 'VILLE', - 'itemLabel': 'Ville de Maarch-les-bains', - 'itemSubLabel': '', - 'difflist_type': 'entity_id', - 'process_date': null, - 'process_comment': null - } - ] - }, - 'avis': { - 'label': 'Pour avis', - 'items': [] - } - } - } - ]; - /*return new Promise((resolve, reject) => { - this.http.get(`../rest/resources/${this.resId}/fields/destination?alt=true`).pipe( + return new Promise((resolve, reject) => { + this.http.get(`../rest/resources/${this.resId}/listInstanceHistory`).pipe( tap((data: any) => { - this.currentEntityId = data.field; - diffusions.forEach((element: any) => { - if (!this.functions.empty(this.diffList[element.item_mode])) { - this.diffList.listinstance[element.item_mode].items.push(element); - } - }); + this.diffListHistory = data['listInstanceHistory']; }), catchError((err: any) => { this.notify.handleSoftErrors(err); return of(false); }) ).subscribe(); - });*/ + }); } initRoles() { diff --git a/src/frontend/app/visa/history/history-visa-workflow.component.html b/src/frontend/app/visa/history/history-visa-workflow.component.html index 2c001ffbf7a..787ea68be07 100644 --- a/src/frontend/app/visa/history/history-visa-workflow.component.html +++ b/src/frontend/app/visa/history/history-visa-workflow.component.html @@ -7,16 +7,16 @@ </div> <mat-divider></mat-divider> </div> - <mat-list-item disableRipple *ngFor="let diffusion of visaWorkflow.items;let i=index" class="workflow"> + <mat-list-item disableRipple *ngFor="let diffusion of visaWorkflow.details;let i=index" class="workflow"> <mat-icon class="fa fa-2x fa-user" mat-list-icon color="primary"> </mat-icon> <div mat-line class="workflowLine"> <div class="workflowLineContainer"> <div class="workflowLineLabel"> - {{diffusion.labelToDisplay}} + {{diffusion.itemLabel}} </div> <div class="workflowLineSubLabel"> - {{diffusion.item_entity}} + {{diffusion.itemSubLabel}} </div> </div> <div> @@ -30,4 +30,4 @@ </ng-container> <div *ngIf="loading" style="display:flex;padding: 10px;"> <mat-spinner style="margin:auto;"></mat-spinner> -</div> \ No newline at end of file +</div> diff --git a/src/frontend/app/visa/history/history-visa-workflow.component.ts b/src/frontend/app/visa/history/history-visa-workflow.component.ts index 0fbe516c807..3af626c6b62 100644 --- a/src/frontend/app/visa/history/history-visa-workflow.component.ts +++ b/src/frontend/app/visa/history/history-visa-workflow.component.ts @@ -40,99 +40,99 @@ export class HistoryVisaWorkflowComponent implements OnInit { loadWorkflowHistory() { this.loading = true; - this.visaWorkflowHistory = [ - { - user: 'Bernard BLIER', - creationDate: '2020-10-06 17:02:19.558904', - 'items': [ - { - 'listinstance_id': 101, - 'sequence': 0, - 'item_id': 7, - 'item_type': 'user', - 'item_firstname': 'Edith', - 'item_lastname': 'ERINA', - 'item_entity': 'Cabinet du Maire', - 'viewed': 0, - 'process_date': '2020-11-02 16:51:00.635663', - 'process_comment': null, - 'signatory': false, - 'requested_signature': true, - 'delegate': null, - 'isValid': false, - 'labelToDisplay': 'Edith ERINA', - 'delegatedBy': null, - 'hasPrivilege': true, - 'difflist_type': 'VISA_CIRCUIT' - }, - { - 'listinstance_id': 102, - 'sequence': 1, - 'item_id': 26, - 'item_type': 'user', - 'item_firstname': 'test', - 'item_lastname': 'test', - 'item_entity': 'Service Courrier', - 'viewed': 0, - 'process_date': '2020-11-30 09:35:11.06508', - 'process_comment': null, - 'signatory': false, - 'requested_signature': false, - 'delegate': 21, - 'isValid': true, - 'labelToDisplay': 'Bernard BLIER', - 'delegatedBy': 'test test', - 'hasPrivilege': true, - 'difflist_type': 'VISA_CIRCUIT' - }, - { - 'listinstance_id': 103, - 'sequence': 2, - 'item_id': 18, - 'item_type': 'user', - 'item_firstname': 'Denis', - 'item_lastname': 'DAULL', - 'item_entity': 'Secrétariat Général', - 'viewed': 0, - 'process_date': null, - 'process_comment': null, - 'signatory': false, - 'requested_signature': false, - 'delegate': null, - 'isValid': true, - 'labelToDisplay': 'Denis DAULL', - 'delegatedBy': null, - 'hasPrivilege': true, - 'difflist_type': 'VISA_CIRCUIT' - }, - { - 'listinstance_id': 104, - 'sequence': 3, - 'item_id': 6, - 'item_type': 'user', - 'item_firstname': 'Jenny', - 'item_lastname': 'JANE', - 'item_entity': 'Centre Communal d\'Action Sociale', - 'viewed': 0, - 'process_date': null, - 'process_comment': null, - 'signatory': false, - 'requested_signature': false, - 'delegate': null, - 'isValid': true, - 'labelToDisplay': 'Jenny JANE', - 'delegatedBy': null, - 'hasPrivilege': true, - 'difflist_type': 'VISA_CIRCUIT' - } - ] - } - ]; + // this.visaWorkflowHistory = [ + // { + // user: 'Bernard BLIER', + // creationDate: '2020-10-06 17:02:19.558904', + // 'items': [ + // { + // 'listinstance_id': 101, + // 'sequence': 0, + // 'item_id': 7, + // 'item_type': 'user', + // 'item_firstname': 'Edith', + // 'item_lastname': 'ERINA', + // 'item_entity': 'Cabinet du Maire', + // 'viewed': 0, + // 'process_date': '2020-11-02 16:51:00.635663', + // 'process_comment': null, + // 'signatory': false, + // 'requested_signature': true, + // 'delegate': null, + // 'isValid': false, + // 'labelToDisplay': 'Edith ERINA', + // 'delegatedBy': null, + // 'hasPrivilege': true, + // 'difflist_type': 'VISA_CIRCUIT' + // }, + // { + // 'listinstance_id': 102, + // 'sequence': 1, + // 'item_id': 26, + // 'item_type': 'user', + // 'item_firstname': 'test', + // 'item_lastname': 'test', + // 'item_entity': 'Service Courrier', + // 'viewed': 0, + // 'process_date': '2020-11-30 09:35:11.06508', + // 'process_comment': null, + // 'signatory': false, + // 'requested_signature': false, + // 'delegate': 21, + // 'isValid': true, + // 'labelToDisplay': 'Bernard BLIER', + // 'delegatedBy': 'test test', + // 'hasPrivilege': true, + // 'difflist_type': 'VISA_CIRCUIT' + // }, + // { + // 'listinstance_id': 103, + // 'sequence': 2, + // 'item_id': 18, + // 'item_type': 'user', + // 'item_firstname': 'Denis', + // 'item_lastname': 'DAULL', + // 'item_entity': 'Secrétariat Général', + // 'viewed': 0, + // 'process_date': null, + // 'process_comment': null, + // 'signatory': false, + // 'requested_signature': false, + // 'delegate': null, + // 'isValid': true, + // 'labelToDisplay': 'Denis DAULL', + // 'delegatedBy': null, + // 'hasPrivilege': true, + // 'difflist_type': 'VISA_CIRCUIT' + // }, + // { + // 'listinstance_id': 104, + // 'sequence': 3, + // 'item_id': 6, + // 'item_type': 'user', + // 'item_firstname': 'Jenny', + // 'item_lastname': 'JANE', + // 'item_entity': 'Centre Communal d\'Action Sociale', + // 'viewed': 0, + // 'process_date': null, + // 'process_comment': null, + // 'signatory': false, + // 'requested_signature': false, + // 'delegate': null, + // 'isValid': true, + // 'labelToDisplay': 'Jenny JANE', + // 'delegatedBy': null, + // 'hasPrivilege': true, + // 'difflist_type': 'VISA_CIRCUIT' + // } + // ] + // } + // ]; - /* return new Promise((resolve, reject) => { - this.http.get(`../rest/resources/${this.resId}/visaCircuitHistory`).pipe( + return new Promise((resolve, reject) => { + this.http.get(`../rest/resources/${this.resId}/circuitsHistory?type=visaCircuit`).pipe( tap((data: any) => { - + this.visaWorkflowHistory = data['listInstanceHistory']; }), finalize(() => { this.loading = false; @@ -143,6 +143,6 @@ export class HistoryVisaWorkflowComponent implements OnInit { return of(false); }) ).subscribe(); - });*/ + }); } } -- GitLab