From 458e41128ff0d7b095eb238f1ffd33d2e7cc59ae Mon Sep 17 00:00:00 2001 From: Guillaume Heurtier <guillaume.heurtier@maarch.org> Date: Thu, 17 Sep 2020 12:33:46 +0200 Subject: [PATCH] FEAT #13274 TIME 1:30 do not add multiple summary sheet in email + save sheet in draft + show hidden types in attachment page --- apps/maarch_entreprise/xml/entreprise.xml | 2 +- .../attachment-page.component.ts | 40 +++++++++---------- .../sent-resource-page.component.html | 2 +- .../sent-resource-page.component.ts | 24 ++++++----- .../app/search/SearchControllerTest.php | 2 +- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/apps/maarch_entreprise/xml/entreprise.xml b/apps/maarch_entreprise/xml/entreprise.xml index e636b27a329..453d952a0fb 100755 --- a/apps/maarch_entreprise/xml/entreprise.xml +++ b/apps/maarch_entreprise/xml/entreprise.xml @@ -33,7 +33,7 @@ <id>outgoing_mail</id> <label>_OUTGOING_MAIL</label> </type> - <type show="true" with_chrono="true" icon="" sign="false"> + <type show="false" with_chrono="true" icon="" sign="false"> <id>summary_sheet</id> <label>_SUMMARY_SHEET</label> </type> diff --git a/src/frontend/app/attachments/attachments-page/attachment-page.component.ts b/src/frontend/app/attachments/attachments-page/attachment-page.component.ts index 0a27f3d4e41..1fee4aa37c9 100644 --- a/src/frontend/app/attachments/attachments-page/attachment-page.component.ts +++ b/src/frontend/app/attachments/attachments-page/attachment-page.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, Inject, ViewChild } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { TranslateService } from '@ngx-translate/core'; import { catchError, tap, finalize, exhaustMap, filter } from 'rxjs/operators'; -import { of } from 'rxjs'; +import { of } from 'rxjs/internal/observable/of'; import { NotificationService } from '../../../service/notification/notification.service'; import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { AppService } from '../../../service/app.service'; @@ -16,7 +16,7 @@ import { FunctionsService } from '../../../service/functions.service'; @Component({ selector: 'app-attachment-page', - templateUrl: "attachment-page.component.html", + templateUrl: 'attachment-page.component.html', styleUrls: [ 'attachment-page.component.scss', '../../indexation/indexing-form/indexing-form.component.scss' @@ -26,8 +26,6 @@ import { FunctionsService } from '../../../service/functions.service'; export class AttachmentPageComponent implements OnInit { - - loading: boolean = true; sendMassMode: boolean = false; sendingData: boolean = false; @@ -71,19 +69,17 @@ export class AttachmentPageComponent implements OnInit { } loadAttachmentTypes() { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { this.http.get('../rest/attachmentsTypes').pipe( tap((data: any) => { Object.keys(data.attachmentsTypes).forEach(templateType => { - if (data.attachmentsTypes[templateType].show) { - this.attachmentsTypes.push({ - id: templateType, - ...data.attachmentsTypes[templateType] - }); - } + this.attachmentsTypes.push({ + id: templateType, + ...data.attachmentsTypes[templateType] + }); }); this.attachmentsTypes = this.sortPipe.transform(this.attachmentsTypes, 'label'); - resolve(true) + resolve(true); }), catchError((err: any) => { this.notify.handleSoftErrors(err); @@ -95,7 +91,7 @@ export class AttachmentPageComponent implements OnInit { } loadAttachment() { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { this.http.get(`../rest/attachments/${this.data.resId}`).pipe( tap((data: any) => { let contact: any = null; @@ -211,7 +207,7 @@ export class AttachmentPageComponent implements OnInit { } generateMailling(resId: number) { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { this.http.post(`../rest/attachments/${resId}/mailing`, {}).pipe( tap(() => { resolve(true); @@ -240,13 +236,13 @@ export class AttachmentPageComponent implements OnInit { } getAttachmentValues(newAttachment: boolean = false, mode: string) { - let attachmentValues = {}; + const attachmentValues = {}; Object.keys(this.attachment).forEach(element => { if (this.attachment[element] !== undefined && (this.attachment[element].value !== null && this.attachment[element].value !== undefined)) { if (element === 'validationDate') { - let day = this.attachment[element].value.getDate(); - let month = this.attachment[element].value.getMonth() + 1; - let year = this.attachment[element].value.getFullYear(); + const day = this.attachment[element].value.getDate(); + const month = this.attachment[element].value.getMonth() + 1; + const year = this.attachment[element].value.getFullYear(); attachmentValues[element] = ('00' + day).slice(-2) + '-' + ('00' + month).slice(-2) + '-' + year + ' 23:59:59'; } else if (element === 'recipient') { attachmentValues['recipientId'] = this.attachment[element].value.length > 0 ? this.attachment[element].value[0].id : null; @@ -258,7 +254,7 @@ export class AttachmentPageComponent implements OnInit { if (this.attachment[element].value === '_CURRENT_FILE') { attachmentValues['encodedFile'] = null; } - //attachmentValues['format'] = this.appAttachmentViewer.getFile().format; + // attachmentValues['format'] = this.appAttachmentViewer.getFile().format; } if (mode === 'mailing') { attachmentValues['inMailing'] = true; @@ -277,7 +273,7 @@ export class AttachmentPageComponent implements OnInit { } setDatasViewer(ev: any) { - let datas: any = {}; + const datas: any = {}; Object.keys(this.attachment).forEach(element => { if (['title', 'validationDate', 'effectiveDate'].indexOf(element) > -1) { datas['attachment_' + element] = this.attachment[element].value; @@ -289,9 +285,9 @@ export class AttachmentPageComponent implements OnInit { this.attachment['encodedFile'].setValue(null); } else { datas['resId'] = this.attachment['resIdMaster'].value; - //this.attachment.encodedFile.setValue(this.appAttachmentViewer.getFile().content); + // this.attachment.encodedFile.setValue(this.appAttachmentViewer.getFile().content); this.appAttachmentViewer.setDatas(datas); - //this.setNewVersion(); + // this.setNewVersion(); } } diff --git a/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.html b/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.html index 72b1362a4b8..8d7f053cf0d 100644 --- a/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.html +++ b/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.html @@ -102,7 +102,7 @@ <input matInput [placeholder]="this.translate.instant('lang.object')" [readonly]="!canManageMail()" [(ngModel)]="emailsubject" maxlength="255"> <button mat-icon-button matSuffix *ngFor="let keyVal of emailAttachTool | keyvalue" - [disabled]="!canManageMail() || (emailAttachTool[keyVal.key].list.length === 0 && keyVal.key !== 'summarySheet')" + [disabled]="!canManageMail() ||(keyVal.key !== 'summarySheet' && (emailAttachTool[keyVal.key].list.length === 0) || (keyVal.key === 'summarySheet' && summarySheetUnits.length !== 0))" [title]="emailAttachTool[keyVal.key].title" (click)="$event.stopPropagation();currentEmailAttachTool=keyVal.key;openSummarySheetModal(keyVal.key)" [matMenuTriggerFor]="emailAttachListMenu"> diff --git a/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.ts b/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.ts index 45bb1f4a2f8..4c373ef327b 100644 --- a/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.ts +++ b/src/frontend/app/sentResource/sent-resource-page/sent-resource-page.component.ts @@ -382,8 +382,6 @@ export class SentResourcePageComponent implements OnInit { } }); - console.log(this.emailAttach); - resolve(true); }), catchError((err) => { @@ -604,13 +602,9 @@ export class SentResourcePageComponent implements OnInit { this.filteredEmails = of([]); } - async onSubmit() { + onSubmit() { this.emailStatus = 'WAITING'; - if (this.summarySheetUnits !== null) { - await this.createSummarySheet(); - } - if (this.data.emailId === null) { if (!this.isAllEmailRightFormat()) { this.notify.error(this.translate.instant('lang.badEmailsFormat')); @@ -633,7 +627,11 @@ export class SentResourcePageComponent implements OnInit { } } - createEmail(closeModal: boolean = true) { + async createEmail(closeModal: boolean = true) { + if (this.summarySheetUnits.length !== 0) { + await this.createSummarySheet(); + } + this.http.post(`../rest/emails`, this.formatEmail()).pipe( tap(() => { if (this.emailStatus === 'DRAFT') { @@ -675,7 +673,11 @@ export class SentResourcePageComponent implements OnInit { ).subscribe(); } - updateEmail(closeModal: boolean = true) { + async updateEmail(closeModal: boolean = true) { + if (this.summarySheetUnits.length !== 0) { + await this.createSummarySheet(); + } + this.http.put(`../rest/emails/${this.data.emailId}`, this.formatEmail()).pipe( tap(() => { if (this.emailStatus === 'DRAFT') { @@ -919,12 +921,14 @@ export class SentResourcePageComponent implements OnInit { } }); dialogRef.afterClosed().pipe( + filter((data: string) => data !== undefined), tap((data: any) => { this.summarySheetUnits = data; this.emailAttach['summarySheet'].push({ label: title, format: 'pdf', - title: title + title: title, + list: [] }); }), catchError((err: any) => { diff --git a/test/unitTests/app/search/SearchControllerTest.php b/test/unitTests/app/search/SearchControllerTest.php index b1fea929d0c..47ac2f6ee1b 100755 --- a/test/unitTests/app/search/SearchControllerTest.php +++ b/test/unitTests/app/search/SearchControllerTest.php @@ -41,7 +41,7 @@ class SearchControllerTest extends TestCase $this->assertIsArray($responseBody->resources); $this->assertNotEmpty($responseBody->resources); - $this->assertSame(2, count($responseBody->resources)); + $this->assertSame(3, count($responseBody->resources)); foreach ($responseBody->resources as $resource) { $this->assertIsInt($resource->resId); $this->assertSame('incoming', $resource->category); -- GitLab