From af9ac52e317ff751163e91aad8df1ee6d04e2949 Mon Sep 17 00:00:00 2001 From: Vinciane <vinciane.bizet@maarch.org> Date: Thu, 28 Feb 2019 11:51:13 +0100 Subject: [PATCH] FIX #9511 Refactoring initMce and check doc --- .../template-administration.component.html | 4 +- .../template-administration.component.ts | 52 +++---------------- 2 files changed, 9 insertions(+), 47 deletions(-) diff --git a/src/frontend/app/administration/template/template-administration.component.html b/src/frontend/app/administration/template/template-administration.component.html index 382981b3d30..7305b755be6 100755 --- a/src/frontend/app/administration/template/template-administration.component.html +++ b/src/frontend/app/administration/template/template-administration.component.html @@ -89,7 +89,7 @@ *ngIf="template.template_target=='attachments' || template.template_target==''">{{lang.office}}</mat-radio-button> <mat-radio-button style="margin-left:10px" color="primary" name="template_type" value="HTML" [checked]="template.template_type=='HTML'" *ngIf="template.template_target=='sendmail' || template.template_target=='doctypes' || template.template_target == 'notifications' || template.template_target == ''" - (click)="initMce()">{{lang.html}}</mat-radio-button> + (click)="initMce('textarea#templateHtml')">{{lang.html}}</mat-radio-button> <mat-radio-button style="margin-left:10px" color="primary" name="template_type" value="TXT" [checked]="template.template_type=='TXT'" *ngIf="template.template_target=='sendmail' || template.template_target=='notes' || template.template_target == ''">{{lang.txt}}</mat-radio-button> </mat-radio-group> @@ -158,7 +158,7 @@ </div> <div class="form-group" *ngIf="template.template_type=='OFFICE_HTML'"> - <mat-tab-group (selectedTabChange)="initMatTabMce()"> + <mat-tab-group (selectedTabChange)="initMce('textarea#templateOfficeHtml')"> <mat-tab label="{{lang.electronicTemplate}}"> <div class="form-group" *ngIf="template.template_type=='OFFICE_HTML'"> <div class="col-sm-12"> diff --git a/src/frontend/app/administration/template/template-administration.component.ts b/src/frontend/app/administration/template/template-administration.component.ts index 3992cc4f7e6..4297d8c35fa 100755 --- a/src/frontend/app/administration/template/template-administration.component.ts +++ b/src/frontend/app/administration/template/template-administration.component.ts @@ -90,10 +90,10 @@ export class TemplateAdministrationComponent implements OnInit { this.headerService.setHeader(this.lang.templateModification, this.template.template_label); this.loading = false; if(this.template.template_type=='HTML'){ - this.initMce(); + this.initMce('textarea#templateHtml'); } if(this.template.template_type=='OFFICE_HTML'){ - this.initMatTabMce(); + this.initMce('textarea#templateOfficeHtml'); } if (this.template.template_style == '') { this.buttonFileName = this.template.template_file_name; @@ -112,48 +112,14 @@ export class TemplateAdministrationComponent implements OnInit { }); } - initMce() { + initMce(selectorId:string) { setTimeout(() => { tinymce.remove('textarea'); //LOAD EDITOR TINYMCE for MAIL SIGN tinymce.baseURL = "../../node_modules/tinymce"; tinymce.suffix = '.min'; tinymce.init({ - selector: "textarea#templateHtml", - statusbar: false, - language: "fr_FR", - language_url: "tools/tinymce/langs/fr_FR.js", - height: "200", - plugins: [ - "textcolor", - "autoresize", - "code" - ], - external_plugins: { - 'bdesk_photo': "../../apps/maarch_entreprise/tools/tinymce/bdesk_photo/plugin.min.js" - }, - menubar: false, - toolbar: "undo | bold italic underline | alignleft aligncenter alignright | bdesk_photo | forecolor | code", - theme_buttons1_add: "fontselect,fontsizeselect", - theme_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator", - theme_buttons2_add: "separator,insertdate,inserttime,preview,separator,forecolor,backcolor", - theme_buttons3_add_before: "tablecontrols,separator", - 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" - }); - }, 20); - } - - initMatTabMce() { - setTimeout(() => { - tinymce.remove('textarea'); - //LOAD EDITOR TINYMCE - tinymce.baseURL = "../../node_modules/tinymce"; - tinymce.suffix = '.min'; - tinymce.init({ - selector: "textarea#templateOfficeHtml", + selector: selectorId, statusbar: false, language: "fr_FR", language_url: "tools/tinymce/langs/fr_FR.js", @@ -312,11 +278,7 @@ export class TemplateAdministrationComponent implements OnInit { if (this.template.template_target != 'notifications') { this.template.template_datasource = 'letterbox_attachment'; } - if (this.creationMode && this.template.template_style != 'uploadFile' && !this.template.jnlpUniqueId && this.template.template_type == 'OFFICE') { - alert(this.lang.editModelFirst); - return; - } - if (this.creationMode && this.template.template_style != 'uploadFile' && !this.template.jnlpUniqueId && this.template.template_type == 'OFFICE_HTML' && this.template.template_style) { + if (this.creationMode && this.template.template_style != 'uploadFile' && !this.template.jnlpUniqueId && (this.template.template_type == 'OFFICE' || (this.template.template_type == 'OFFICE_HTML' && this.template.template_style))) { alert(this.lang.editModelFirst); return; } @@ -365,13 +327,13 @@ export class TemplateAdministrationComponent implements OnInit { this.template.template_type = 'OFFICE'; } else if (this.template.template_target == 'notifications' || this.template.template_target == 'doctypes' || this.template.template_target == 'sendmail') { this.template.template_type = 'HTML'; - this.initMce(); + this.initMce('textarea#templateHtml'); } else if (this.template.template_target == 'notes') { this.template.template_type = 'TXT'; } else if(this.template.template_target == 'acknowledgementReceipt'){ this.template.template_type = 'OFFICE_HTML'; this.template.template_attachment_type = ''; - this.initMatTabMce(); + this.initMce('textarea#templateOfficeHtml'); } } -- GitLab