From 283ad0802513844ffea64e93c89054d2230b35a3 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Wed, 11 Mar 2020 16:55:23 +0100
Subject: [PATCH] FIX #13468 TIME 0:40 set response project by default in
 attachment creation mode

---
 .../attachment-create/attachment-create.component.ts   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/frontend/app/attachments/attachment-create/attachment-create.component.ts b/src/frontend/app/attachments/attachment-create/attachment-create.component.ts
index 82ab5089ef9..c521ddec17c 100644
--- a/src/frontend/app/attachments/attachment-create/attachment-create.component.ts
+++ b/src/frontend/app/attachments/attachment-create/attachment-create.component.ts
@@ -122,11 +122,14 @@ export class AttachmentCreateComponent implements OnInit {
                     this.attachments.push({
                         title: new FormControl({ value: data.subject, disabled: false }, [Validators.required]),
                         recipient: new FormControl({ value: contact, disabled: false }),
-                        type: new FormControl({ value: '', disabled: false }, [Validators.required]),
+                        type: new FormControl({ value: 'response_project', disabled: false }, [Validators.required]),
                         validationDate: new FormControl({ value: '', disabled: false }),
                         format: new FormControl({ value: '', disabled: false }, [Validators.required]),
                         encodedFile: new FormControl({ value: '', disabled: false }, [Validators.required])
                     });
+                    setTimeout(() => {
+                        this.getAttachType('response_project', 0);
+                    }, 800);
 
                     this.attachFormGroup.push(new FormGroup(this.attachments[0]));
 
@@ -376,7 +379,7 @@ export class AttachmentCreateComponent implements OnInit {
                 this.attachments.push({
                     title: new FormControl({ value: '', disabled: false }, [Validators.required]),
                     recipient: new FormControl({ value: !this.functions.empty(this.resourceContacts[this.attachments.length]) ? [{ id: this.resourceContacts[this.attachments.length].id, type: this.resourceContacts[this.attachments.length].type }] : null, disabled: false }),
-                    type: new FormControl({ value: '', disabled: false }, [Validators.required]),
+                    type: new FormControl({ value: 'response_project', disabled: false }, [Validators.required]),
                     validationDate: new FormControl({ value: null, disabled: false }),
                     encodedFile: new FormControl({ value: '', disabled: false }, [Validators.required]),
                     format: new FormControl({ value: '', disabled: false }, [Validators.required])
@@ -384,6 +387,9 @@ export class AttachmentCreateComponent implements OnInit {
 
                 this.attachFormGroup.push(new FormGroup(this.attachments[this.attachments.length - 1]));
                 this.indexTab = this.attachments.length - 1;
+                setTimeout(() => {
+                    this.getAttachType('response_project', this.indexTab);
+                }, 800);
             }),
         ).subscribe();
 
-- 
GitLab