diff --git a/src/frontend/app/administration/template/template-administration.component.html b/src/frontend/app/administration/template/template-administration.component.html index ad9b05c9375e2c3bbd31e0c86f847d2ad1404e0f..4cab181ab718c2f389883bd9a20134bd9749231e 100755 --- a/src/frontend/app/administration/template/template-administration.component.html +++ b/src/frontend/app/administration/template/template-administration.component.html @@ -106,7 +106,7 @@ <div class="col-sm-12"> <mat-form-field *ngIf="creationMode || template.template_style"> <mat-select id="template_style" [disabled]="!creationMode" name="template_style" title="{{lang.defaultTemplate}}" placeholder="{{lang.chosenModel}}" - [(ngModel)]="template.template_style" (ngModelChange)="resetFileUploaded()"> + [(ngModel)]="template.template_style" (ngModelChange)="resetFileUploaded()" [required]="template.template_target!='acknowledgementReceipt'"> <mat-optgroup label="{{lang.loadedFile}} :"> <mat-option class="selectFile" (click)="clickOnUploader('uploadSignFileOffice')" value="uploadFile"> <mat-icon class="fa fa-paperclip" color="primary" style="height:auto;"></mat-icon> {{buttonFileName}} @@ -131,7 +131,7 @@ <div class="col-sm-12"> <mat-form-field> <textarea matInput [(ngModel)]="template.template_content" name="templateTxt" id="templateTxt" placeholder="{{lang.contentTxtTemplate}}" - title="{{lang.contentTxtTemplate}}" matTextareaAutosize matAutosizeMinRows="5" matAutosizeMaxRows="5"> + title="{{lang.contentTxtTemplate}}" matTextareaAutosize matAutosizeMinRows="5" matAutosizeMaxRows="5" [required]="template.template_target!='acknowledgementReceipt'"> </textarea> </mat-form-field> </div> @@ -139,7 +139,7 @@ <div class="form-group" *ngIf="template.template_type=='HTML'"> <div class="col-sm-12"> <div id="html_mode" style="display: block; width:100%;"> - <textarea [(ngModel)]="template.template_content" name="templateHtml" id="templateHtml" style="width:100%" rows="15" cols="60"></textarea> + <textarea [(ngModel)]="template.template_content" name="templateHtml" id="templateHtml" style="width:100%" rows="15" cols="60" [required]="template.template_target!='acknowledgementReceipt'"></textarea> </div> </div> </div> @@ -162,7 +162,7 @@ <mat-tab label="{{lang.electronicTemplate}}"> <div class="col-sm-12"> <div id="html_mode" style="display: block; width:100%;"> - <textarea [(ngModel)]="template.template_content" name="templateOfficeHtml" id="templateOfficeHtml" style="width:100%" rows="15" cols="60"></textarea> + <textarea [(ngModel)]="template.template_content" name="templateOfficeHtml" id="templateOfficeHtml" style="width:100%" rows="15" cols="60" [required]="template.template_target!='acknowledgementReceipt'"></textarea> </div> </div> </mat-tab> @@ -177,7 +177,7 @@ <div class="col-sm-12"> <mat-form-field> <mat-select id="template_style" [disabled]="!creationMode && template.template_file_name != null" name="template_style" title="{{lang.defaultTemplate}}" placeholder="{{lang.chosenModel}}" - [(ngModel)]="template.template_style" (ngModelChange)="resetFileUploaded()"> + [(ngModel)]="template.template_style" (ngModelChange)="resetFileUploaded()" [required]="template.template_target!='acknowledgementReceipt'"> <mat-optgroup label="{{lang.loadedFile}} :"> <mat-option (click)="clickOnUploader('uploadSignFileOfficeHtml')" style="text-align: center;" value="uploadFile"> <mat-icon class="fa fa-paperclip" color="primary" style="height:auto;"></mat-icon> {{buttonFileName}} diff --git a/src/frontend/app/administration/template/template-administration.component.ts b/src/frontend/app/administration/template/template-administration.component.ts index 9a647bf74443280f587c5c6f853742ba13dcbd6a..692d0557ec810cbd353a7a7e71332cd04a23109e 100755 --- a/src/frontend/app/administration/template/template-administration.component.ts +++ b/src/frontend/app/administration/template/template-administration.component.ts @@ -146,7 +146,18 @@ export class TemplateAdministrationComponent implements OnInit { theme_buttons3_add: "separator,print,separator,ltr,rtl,separator,fullscreen,separator,insertlayer,moveforward,movebackward,absolut", theme_toolbar_align: "left", theme_advanced_toolbar_location: "top", - theme_styles: "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1" + theme_styles: "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1", + setup: (ed :any) => { + ed.on('keyup', (e: any) => { + if (this.template.template_type == 'HTML' && tinymce.get('templateHtml') != null) { + this.template.template_content = tinymce.get('templateHtml').getContent(); + } + if (this.template.template_type == 'OFFICE_HTML' && tinymce.get('templateOfficeHtml') != null) { + this.template.template_content = tinymce.get('templateOfficeHtml').getContent(); + } + }); + } + }); }, 20); } @@ -286,22 +297,25 @@ export class TemplateAdministrationComponent implements OnInit { this.template.template_datasource = 'letterbox_attachment'; } - if (this.template.template_style != 'uploadFile' && !this.template.jnlpUniqueId && !this.template.template_file_name && this.template.template_style && (this.template.template_type == 'OFFICE' || this.template.template_type == 'OFFICE_HTML')) { - alert(this.lang.editModelFirst); - return; - } - if (this.template.template_type == 'HTML') { this.template.template_content = tinymce.get('templateHtml').getContent(); - } - if (this.template.template_type == 'OFFICE_HTML') { + + } else if (this.template.template_type == 'OFFICE_HTML') { this.template.template_content = tinymce.get('templateOfficeHtml').getContent(); + } - if (this.template.template_content == '' && !this.template.template_style) { + if (this.template.template_target == 'acknowledgementReceipt') { + if (this.template.template_content == '' && (!this.template.template_style || (this.template.template_style && !this.template.jnlpUniqueId && !this.template.uploadedFile && !this.template.template_file_name))) { alert(this.lang.mustCompleteAR); return; } + } else if (this.template.template_target != 'acknowledgementReceipt' && this.template.template_type == 'OFFICE') { + if (!this.template.template_style || (this.template.template_style && !this.template.jnlpUniqueId && !this.template.template_file_name)) { + alert(this.lang.editModelFirst); + return; + } } + if (this.creationMode) { if (this.template.template_style == 'uploadFile') { this.template.template_style = ''; @@ -347,6 +361,15 @@ export class TemplateAdministrationComponent implements OnInit { } } + checkArMode() { + if (this.template.template_content == '' && !this.template.template_style && this.template.target === 'acknowledgementReceipt') { + alert(this.lang.mustCompleteAR); + return true; + } else { + return false; + } + } + displayDatasources(datasource: any) { if (datasource.target == 'notification' && this.template.template_target == 'notifications') { return true;