From 4a91a6237c8dac57e49fcfe0dd254c240e5ba71a Mon Sep 17 00:00:00 2001
From: RIHTARSIC Joze <joze.rihtarsic@ext.ec.europa.eu>
Date: Fri, 20 Sep 2024 06:11:12 +0200
Subject: [PATCH] [EDELIVERY-13743] UI fix for update of the domain properties
 in resource creation.

---
 .../document-edit-panel.component.html                   | 4 ++--
 .../document-edit-panel/document-edit-panel.component.ts | 9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/smp-angular/src/app/common/panels/document-edit-panel/document-edit-panel.component.html b/smp-angular/src/app/common/panels/document-edit-panel/document-edit-panel.component.html
index 5de4f74e9..13231a440 100644
--- a/smp-angular/src/app/common/panels/document-edit-panel/document-edit-panel.component.html
+++ b/smp-angular/src/app/common/panels/document-edit-panel/document-edit-panel.component.html
@@ -16,7 +16,7 @@
       <button id="validateResource_id" mat-raised-button
               color="primary"
               matTooltip="{{ 'document.edit.panel.tooltip.validate' | translate }}"
-              [disabled]="!documentEditable"
+              [disabled]="!documentEditable  || isResourceDocument"
               (click)="onDocumentValidateButtonClicked()">
         <mat-icon>check_circle</mat-icon>
         <span>{{ "document.edit.panel.button.validate" | translate }}</span>
@@ -48,7 +48,7 @@
        style="display: flex;flex-direction: row;flex-grow: 1; ">
     <div
       style="display:flex; overflow: auto;flex: 2;align-self: stretch; flex-direction: column;">
-      <ng-container *ngIf="hasDocumentReference; else selectedDocumentVersionDataTemplate" >
+      <ng-container *ngIf="hasDocumentReference && isNotReviewMode; else selectedDocumentVersionDataTemplate" >
         <div style="display:flex;  flex-direction: row;align-items: center;">
           <mat-form-field style="min-width: 250px"
                           subscriptSizing="dynamic"
diff --git a/smp-angular/src/app/common/panels/document-edit-panel/document-edit-panel.component.ts b/smp-angular/src/app/common/panels/document-edit-panel/document-edit-panel.component.ts
index d1488c271..5dafee9d8 100644
--- a/smp-angular/src/app/common/panels/document-edit-panel/document-edit-panel.component.ts
+++ b/smp-angular/src/app/common/panels/document-edit-panel/document-edit-panel.component.ts
@@ -291,7 +291,7 @@ export class DocumentEditPanelComponent implements BeforeLeaveGuard, OnInit {
     }
     this.documentForm.controls['editorText'].valueChanges.subscribe(() => {
       // disable change back option
-      if (this.documentEditable && this.documentForm.controls['editorText'].dirty) {
+      if (this.documentEditable) {
         this.documentForm.controls['selectDocumentSource'].disable();
       } else {
         this.documentForm.controls['selectDocumentSource'].enable();
@@ -321,10 +321,12 @@ export class DocumentEditPanelComponent implements BeforeLeaveGuard, OnInit {
       this.documentForm.controls['documentConfiguration'].setValue(value.documentConfiguration);
       this.documentForm.controls['documentReferenceName'].setValue(value.documentConfiguration?.referenceDocumentName);
       // the method documentVersionsExists already uses the current value to check if versions exists
-      if (this.documentVersionsExists && this.isNotReviewMode) {
+      if (this.documentVersionsExists && this.isNotReviewMode && !this.isNewDocumentVersion) {
         this.documentForm.controls['payloadVersion'].enable();
       }
-      this.documentForm.controls['selectDocumentSource'].enable();
+      if (!this.documentEditable && !this.isNewDocumentVersion ) {
+        this.documentForm.controls['selectDocumentSource'].enable();
+      }
       this.updateTextToEditor()
       this.documentForm.markAsPristine();
     } else {
@@ -344,7 +346,6 @@ export class DocumentEditPanelComponent implements BeforeLeaveGuard, OnInit {
       this.documentForm.controls['documentConfiguration'].setValue(null);
       this.documentForm.markAsPristine();
     }
-
   }
 
   get document(): DocumentRo {
-- 
GitLab