diff --git a/src/frontend/app/administration/attachment/attachment-type-administration.component.html b/src/frontend/app/administration/attachment/attachment-type-administration.component.html index bf710cb64ea2596f6a575faebcc9759fbc6a49bc..b7096dedcf5dc7c5921fbdfe43995a39cfd52e85 100644 --- a/src/frontend/app/administration/attachment/attachment-type-administration.component.html +++ b/src/frontend/app/administration/attachment/attachment-type-administration.component.html @@ -38,7 +38,7 @@ <mat-list-item> <div mat-line style="display: flex;"> <mat-slide-toggle [formControlName]="idOpt" [name]="idOpt" - color="primary" [checked]="attachmentType[idOpt].value"> + color="primary" [checked]="attachmentType[idOpt].value" [disabled]="!isValidToggle(idOpt)"> {{'lang.' + idOpt + '_attachment' | translate}}</mat-slide-toggle> <i class="fa fa-question-circle" color="primary" style="cursor: help;" diff --git a/src/frontend/app/administration/attachment/attachment-type-administration.component.ts b/src/frontend/app/administration/attachment/attachment-type-administration.component.ts index 4cb49c7763db144147c9c0256b5673228d634d7b..5294123895c09048832192df866750976e3e665d 100644 --- a/src/frontend/app/administration/attachment/attachment-type-administration.component.ts +++ b/src/frontend/app/administration/attachment/attachment-type-administration.component.ts @@ -28,6 +28,7 @@ export class AttachmentTypeAdministrationComponent implements OnInit { emailLink: new FormControl({ value: false, disabled: false }), signable: new FormControl({ value: false, disabled: false }), icon: new FormControl({ value: '', disabled: false }), + versionEnabled: new FormControl({ value: false, disabled: false }), newVersionDefault: new FormControl({ value: false, disabled: false }), }; @@ -125,4 +126,13 @@ export class AttachmentTypeAdministrationComponent implements OnInit { }) ).subscribe(); } + + isValidToggle(id: string) { + if (id === 'newVersionDefault' && !this.attachmentType['versionEnabled'].value) { + this.attachmentType['newVersionDefault'].setValue(false); + return false; + } else { + return true; + } + } } diff --git a/src/frontend/app/attachments/attachments-page/attachment-page.component.html b/src/frontend/app/attachments/attachments-page/attachment-page.component.html index 1639fb0ca360177d5928641d5b75b389893d3b81..fa6559f70dba4b74839b725e30cb2c705f7bc5df 100755 --- a/src/frontend/app/attachments/attachments-page/attachment-page.component.html +++ b/src/frontend/app/attachments/attachments-page/attachment-page.component.html @@ -15,7 +15,7 @@ <mat-dialog-content class="attach-content"> <ng-container *ngIf="!loading"> <div class="attachment-form col-md-3 col-sm-12"> - <div *ngIf="editMode" class="attachment-form-item"> + <div *ngIf="editMode && isVersionEnabled()" class="attachment-form-item"> <mat-slide-toggle [checked]="newVersion" color="primary" (change)="newVersion = !newVersion;">{{'lang.newVersion' | translate}}</mat-slide-toggle> </div> 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 95c7d4c356e2839a617fa9da1663da968c64b3e0..33310ec108e47d00546f49358a9bb35a099317e8 100644 --- a/src/frontend/app/attachments/attachments-page/attachment-page.component.ts +++ b/src/frontend/app/attachments/attachments-page/attachment-page.component.ts @@ -141,6 +141,8 @@ export class AttachmentPageComponent implements OnInit { this.versions = data.versions; + this.newVersion = this.attachmentsTypes.filter((item: any) => item.typeId === data.type)[0].newVersionDefault; + this.attachFormGroup = new FormGroup(this.attachment); resolve(true); }), @@ -153,6 +155,10 @@ export class AttachmentPageComponent implements OnInit { }); } + isVersionEnabled() { + return this.attachmentsTypes.filter((item: any) => item.typeId === this.attachment.type.value)[0].versionEnabled; + } + createNewVersion(mode: string = 'default') { this.sendingData = true; this.appAttachmentViewer.getFile().pipe( diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json index b61b9c0ec9753d86b03d93a2b4267ef998db03ae..b2868d85cff3591a67726679eda464202831c3e5 100644 --- a/src/lang/lang-fr.json +++ b/src/lang/lang-fr.json @@ -2172,8 +2172,10 @@ "emailLink_attachmentDesc": "Les pièces jointes de ce type seront sélectionnées par défaut lors de l'envoi d'un courriel", "signable_attachment": "Autoriser la signature", "signable_attachmentDesc": "Possibilité d'apposer une griffe sur les pièces jointes de ce type dans le parapheur", - "newVersionDefault_attachment": "'Nouvelle version' activé par défaut", - "newVersionDefault_attachmentDesc": "Lors de la modification d'une pièce jointe, 'Nouvelle version' sera activé par défaut", + "newVersionDefault_attachment": "«Nouvelle version» activé par défaut", + "newVersionDefault_attachmentDesc": "Lors de la modification d'une pièce jointe, «Nouvelle version» sera activé par défaut", + "versionEnabled_attachment": "Création de nouvelles versions", + "versionEnabled_attachmentDesc": "Lors de la modification d'une pièce jointe, «Nouvelle version» pourra être choisi", "attachmentTypeCreation": "Création d'un type de pièce jointe", "attachmentTypeAdded": "Type de pièce jointe ajouté", "attachmentTypeUpdated": "Type de pièce jointe modifié",