Commit 458e4112 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #13274 TIME 1:30 do not add multiple summary sheet in email + save sheet...

FEAT #13274 TIME 1:30 do not add multiple summary sheet in email + save sheet in draft + show hidden types in attachment page
parent 5008ad8b
......@@ -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>
......
......@@ -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();
}
}
......
......@@ -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">
......
......@@ -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) => {
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment