From 98e25cf7960f5bd2da8532ac9aa95c02b7941d03 Mon Sep 17 00:00:00 2001 From: Guillaume Heurtier <guillaume.heurtier@maarch.org> Date: Thu, 9 Apr 2020 15:18:25 +0200 Subject: [PATCH] FEAT #11961 TIME 4:00 added document status to block actions if document is being converted --- lang/en.json | 3 ++- lang/fr.json | 3 ++- sql/2010.sql | 12 ++++++++++++ src/app/convert/scripts/ThumbnailScript.php | 19 +++++++++++++++++++ .../controllers/DocumentController.php | 6 ++++-- .../app/document/document.component.html | 7 +++++-- .../app/document/document.component.ts | 3 ++- 7 files changed, 46 insertions(+), 7 deletions(-) create mode 100755 sql/2010.sql diff --git a/lang/en.json b/lang/en.json index c76518c429..c487a244db 100755 --- a/lang/en.json +++ b/lang/en.json @@ -268,6 +268,7 @@ "attachedElements" : "Attached elements", "note" : "Note", "collapseNote" : "Collapse the note", - "expandNote" : "Expand the note" + "expandNote" : "Expand the note", + "convertingDocument" : "Converting document..." } } diff --git a/lang/fr.json b/lang/fr.json index bc6a662fc2..be42d50935 100755 --- a/lang/fr.json +++ b/lang/fr.json @@ -269,6 +269,7 @@ "attachedElements" : "Document(s) attaché(s)", "note" : "Note", "collapseNote" : "Réduire la note", - "expandNote" : "Ouvrir la note" + "expandNote" : "Ouvrir la note", + "convertingDocument" : "Document en cours de conversion" } } diff --git a/sql/2010.sql b/sql/2010.sql new file mode 100755 index 0000000000..967875e848 --- /dev/null +++ b/sql/2010.sql @@ -0,0 +1,12 @@ +-- *************************************************************************-- +-- -- +-- -- +-- Model migration script - 20.03 to 20.10 -- +-- -- +-- -- +-- *************************************************************************-- + +ALTER TABLE main_documents DROP COLUMN IF EXISTS status; +ALTER TABLE main_documents ADD COLUMN status varchar(10); + +UPDATE main_documents SET status = 'READY'; diff --git a/src/app/convert/scripts/ThumbnailScript.php b/src/app/convert/scripts/ThumbnailScript.php index c804e7221c..fc760662e2 100644 --- a/src/app/convert/scripts/ThumbnailScript.php +++ b/src/app/convert/scripts/ThumbnailScript.php @@ -17,6 +17,7 @@ namespace Convert\scripts; require 'vendor/autoload.php'; use Convert\controllers\ConvertThumbnailController; +use Document\models\DocumentModel; use History\controllers\HistoryController; use SrcCore\models\DatabasePDO; @@ -37,12 +38,24 @@ class ThumbnailScript $GLOBALS['id'] = $args['userId']; + DocumentModel::update([ + 'set' => ['status' => 'CONVERTING'], + 'where' => ['id = ?'], + 'data' => [$args['id']] + ]); + if (isset($args['page'])) { $isConverted = ConvertThumbnailController::convertOnePage(['id' => $args['id'], 'type' => $args['type'], 'page' => $args['page']]); } else { $isConverted = ConvertThumbnailController::convert(['id' => $args['id'], 'type' => $args['type']]); } if (!empty($isConverted['errors'])) { + DocumentModel::update([ + 'set' => ['status' => 'ERROR'], + 'where' => ['id = ?'], + 'data' => [$args['id']] + ]); + HistoryController::add([ 'code' => 'KO', 'objectType' => $args['type'], @@ -51,6 +64,12 @@ class ThumbnailScript 'message' => '{thumbnailFailed}', 'data' => ['errors' => $isConverted['errors']] ]); + } else { + DocumentModel::update([ + 'set' => ['status' => 'READY'], + 'where' => ['id = ?'], + 'data' => [$args['id']] + ]); } return $isConverted; diff --git a/src/app/document/controllers/DocumentController.php b/src/app/document/controllers/DocumentController.php index f2f97aba05..12b910bf5f 100755 --- a/src/app/document/controllers/DocumentController.php +++ b/src/app/document/controllers/DocumentController.php @@ -154,7 +154,8 @@ class DocumentController 'notes' => !empty($document['notes']) ? json_decode($document['notes'], true) : null, 'creationDate' => $document['creation_date'], 'modificationDate' => $document['modification_date'], - 'pages' => $adr[0]['count'] + 'pages' => $adr[0]['count'], + 'status' => $document['status'] ]; if (!empty($document['deadline'])) { $date = new \DateTime($document['deadline']); @@ -342,7 +343,8 @@ class DocumentController 'deadline' => empty($body['deadline']) ? null : $body['deadline'], 'notes' => $notes ?? null, 'link_id' => (string)$body['linkId'] ?? null, - 'metadata' => empty($body['metadata']) ? '{}' : json_encode($body['metadata']) + 'metadata' => empty($body['metadata']) ? '{}' : json_encode($body['metadata']), + 'status' => 'CREATED' ]); AdrModel::createDocumentAdr([ diff --git a/src/frontend/app/document/document.component.html b/src/frontend/app/document/document.component.html index 96be0dc366..4ef815e9bc 100755 --- a/src/frontend/app/document/document.component.html +++ b/src/frontend/app/document/document.component.html @@ -85,6 +85,9 @@ *ngIf="authService.user.substitute !== null && !this.signaturesService.annotationMode && docList[currentDoc]"> <div>{{'lang.substitutionInfo' | translate}}</div> </mat-card> + <mat-card class="substitutedInformations" *ngIf="mainDocument.id !== 0 && mainDocument.status !== 'READY'" style="background: rgb(231,76,60)"> + <div>{{'lang.convertingDocument' | translate}}</div> + </mat-card> <app-overlay *ngIf="this.signaturesService.annotationMode" [appDocumentNotePad]="appDocumentNotePad"> </app-overlay> <ng-container *ngIf="!freezeSidenavClose && !loadingUI"> @@ -120,7 +123,7 @@ [@slideUp]> <ng-container *ngFor="let action of actionsList;"> <button [style.color]="action.color" [style.borderColor]="action.color" class="btn" - (click)="launchEvent(action)"><i class="{{action.logo}} fa-2x"></i>{{action.label | translate}} + (click)="launchEvent(action)" [disabled]="mainDocument.status !== 'READY'"><i class="{{action.logo}} fa-2x"></i>{{action.label | translate}} </button> </ng-container> </footer> @@ -141,4 +144,4 @@ [mainDocument]="mainDocument" *ngIf="signaturesService.sideNavRigtDatas.mode == 'mainDocumentDetail'"> </app-main-document-detail> </mat-sidenav> -</mat-sidenav-container> \ No newline at end of file +</mat-sidenav-container> diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts index 7c68d9fb98..5ddf14f2d1 100755 --- a/src/frontend/app/document/document.component.ts +++ b/src/frontend/app/document/document.component.ts @@ -112,6 +112,7 @@ export class DocumentComponent implements OnInit { mainDocument: any = { id: 0, + status, attachments: [], workflow: [], }; @@ -344,7 +345,7 @@ export class DocumentComponent implements OnInit { e = e.srcEvent; - if (!this.signaturesService.annotationMode && this.currentDoc === 0) { + if (!this.signaturesService.annotationMode && this.currentDoc === 0 && this.mainDocument.status === 'READY') { this.backToDetails(); -- GitLab