From aabdf12160576a45118ef5f8541dc03444c17235 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Wed, 13 Jun 2018 14:45:27 +0000 Subject: [PATCH] FEAT #7737 front admin templates --- .../template-administration.component.html | 24 +++++++++++-------- .../template-administration.component.ts | 13 ++++++++++ .../js/angular/lang/lang-en.ts | 4 +++- .../js/angular/lang/lang-fr.ts | 4 +++- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/apps/maarch_entreprise/Views/template-administration.component.html b/apps/maarch_entreprise/Views/template-administration.component.html index 09142b3a6ec..d85bf3e3c2f 100755 --- a/apps/maarch_entreprise/Views/template-administration.component.html +++ b/apps/maarch_entreprise/Views/template-administration.component.html @@ -61,7 +61,7 @@ <div class="col-sm-12"> <mat-form-field> <mat-select id="template_attachment_type" name="template_attachment_type" title="{{lang.attachmentType}}" placeholder="{{lang.attachmentType}}" [(ngModel)]="template.template_attachment_type"> - <mat-option value="all">Tous les attachements</mat-option> + <mat-option value="all">{{lang.allAttachments}}</mat-option> <mat-option *ngFor="let value of attachmentTypesList" [value]="value.id"> {{value.label}} </mat-option> @@ -79,10 +79,10 @@ </div> </div> <div class="form-group" *ngIf="template.template_type=='OFFICE'"> - <div class="col-sm-12" style="overflow:hidden;"> + <div class="col-sm-5" style="overflow:hidden"> <div class="form-group"> <div class="col-sm-12" style="text-align:center;"> - <button mat-raised-button color="primary" type="button" (click)="clickOnUploader('uploadSignFile')"><i class="fa fa-paperclip fa-2x"></i></button> + <button mat-raised-button color="primary" type="button" (click)="clickOnUploader('uploadSignFile')"><i class="fa fa-paperclip fa-2x"></i> {{lang.chooseFile}}</button> </div> </div> <div class="col-md-12"> @@ -93,7 +93,10 @@ </div> </div> </div> - <div class="col-sm-12"> + <div class="col-sm-2" style="margin-top: 10px"> + - ou - + </div> + <div class="col-sm-5"> <mat-form-field> <mat-select id="template_style" [disabled]="!creationMode" name="template_style" title="{{lang.defaultTemplate}}" placeholder="{{lang.defaultTemplate}}" [(ngModel)]="template.template_style"> <mat-option *ngFor="let default of defaultTemplatesList" value="{{default.fileExt}}: {{default.fileName}}"> @@ -101,10 +104,11 @@ </mat-option> </mat-select> </mat-form-field> + <div class="col-sm-12" (click)="startJnlp()" *ngIf="template.template_style" style="text-align: center"> + <button mat-raised-button color="primary" type="button"><i class="fas fa-pencil-alt fa-2x"></i> {{lang.templateEdition}}</button> + </div> </div> - <div class="col-sm-12" (click)="startJnlp()"> - <i class="fa fa-pencil fa-2x"></i>{{lang.templateEdition}} - </div> + </div> <div class="form-group" *ngIf="template.template_type=='TXT'"> <div class="col-sm-12"> @@ -128,9 +132,9 @@ <mat-form-field> <mat-select id="template_datasource" name="template_datasource" title="{{lang.templateDatasource}}" placeholder="{{lang.templateDatasource}}" [(ngModel)]="template.template_datasource"> <mat-option value="">{{lang.noDatasource}}</mat-option> - <mat-option *ngFor="let datasource of datasourcesList" [value]="datasource.id"> - {{datasource.label}} - </mat-option> + <ng-container *ngFor="let datasource of datasourcesList"> + <mat-option *ngIf="displayDatasources(datasource)" [value]="datasource.id">{{datasource.label}}</mat-option> + </ng-container> </mat-select> </mat-form-field> </div> diff --git a/apps/maarch_entreprise/js/angular/app/administration/template-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/template-administration.component.ts index 112c438bb29..be919b7990f 100755 --- a/apps/maarch_entreprise/js/angular/app/administration/template-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/administration/template-administration.component.ts @@ -171,6 +171,7 @@ export class TemplateAdministrationComponent implements OnInit { resfreshUpload(b64Content: any) { this.template.uploadedFile.base64 = b64Content.replace(/^data:.*?;base64,/, ""); this.template.uploadedFile.base64ForJs = b64Content; + this.template.template_style = null; } startJnlp() { @@ -187,10 +188,12 @@ export class TemplateAdministrationComponent implements OnInit { } this.jnlpValue.table = 'templates'; this.jnlpValue.uniqueId = 0; + this.jnlpValue.cookies = document.cookie; this.http.post(this.coreUrl + 'rest/jnlp', this.jnlpValue) .subscribe((data: any) => { this.template.userUniqueId = data.userUniqueId; + this.template.uploadedFile = null; window.location.href = this.coreUrl + 'rest/jnlp?fileName=' + data.generatedJnlp; }, (err) => { this.notify.error(err.error.errors); @@ -232,4 +235,14 @@ export class TemplateAdministrationComponent implements OnInit { }); } } + + displayDatasources(datasource:any) + { + if(datasource.target=='notification' && this.template.template_target == 'notifications'){ + return true; + } else if(datasource.target=='document' && this.template.template_target != 'notifications'){ + return true; + } + return false; + } } \ No newline at end of file diff --git a/apps/maarch_entreprise/js/angular/lang/lang-en.ts b/apps/maarch_entreprise/js/angular/lang/lang-en.ts index 0cf1777ed01..e265da30770 100755 --- a/apps/maarch_entreprise/js/angular/lang/lang-en.ts +++ b/apps/maarch_entreprise/js/angular/lang/lang-en.ts @@ -543,6 +543,8 @@ export const LANG_EN = { "duplicate" : "Duplicate", "confirmDuplicate" : "Do you really want to duplicate this template ?", "noDatasource" : "No datasources", - "templateDuplicated" : "Template duplicated" + "templateDuplicated" : "Template duplicated", + "chooseFile" : "Choose a file", + "allAttachments" : "All attachments" }; diff --git a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts index 3c1f40385f5..b54beede8d9 100755 --- a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts +++ b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts @@ -565,6 +565,8 @@ export const LANG_FR = { "duplicate" : "Dupliquer", "confirmDuplicate" : "Voulez-vous vraiment dupliquer ce template ?", "noDatasource" : "Aucune source de données", - "templateDuplicated" : "Modèle dupliqué" + "templateDuplicated" : "Modèle dupliqué", + "chooseFile" : "Choisissez un fichier", + "allAttachments" : "Tous les attachements" }; -- GitLab