Skip to content
Snippets Groups Projects
Commit 615da743 authored by Pegane Nestor's avatar Pegane Nestor
Browse files

FEAT #7358 update multiple mail status front

parent da2604fd
No related branches found
No related tags found
No related merge requests found
...@@ -19,39 +19,66 @@ ...@@ -19,39 +19,66 @@
<mat-spinner style="margin:auto;"></mat-spinner> <mat-spinner style="margin:auto;"></mat-spinner>
</div> </div>
<mat-card *ngIf="!loading" class="card-app-content"> <mat-card *ngIf="!loading" class="card-app-content">
<form class="form-horizontal" (ngSubmit)="onSubmit()" #updateStatusForm="ngForm"> <form class="form-horizontal" (ngSubmit)="onSubmit()" #updateStatusForm="ngForm">
<mat-tab-group (selectedTabChange)="resetInput($event)"> <mat-tab-group (selectedTabChange)="resetInput($event)">
<mat-tab label="{{lang.chronoNumber}}"> <mat-tab label="{{lang.chronoNumber}}">
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
{{lang.updateStatusInformationsChrono}} {{lang.updateStatusInformationsChrono}}
</div> </div>
<mat-form-field> <mat-form-field>
<input matInput name="chrono" title="{{lang.chronoNumber}}" placeholder="{{lang.chronoNumber}}" [(ngModel)]="chrono"> <input matInput name="chrono" title="{{lang.chronoNumber}}" placeholder="{{lang.chronoNumber}}" [(ngModel)]="chrono">
</mat-form-field> </mat-form-field>
<div class="row">
<div class="form-group">
<div class="col-md-12 text-left" style="padding:10px;">
<button mat-raised-button [disabled]="!chrono" type="button" color="primary" (click)="addChrono()" style="position:relative;left:15px;">{{lang.add}}</button>
</div>
</div>
<mat-chip-list [(ngModel)]="chronoList" name="chronoChips" #chipList>
<mat-chip *ngFor="let chrono of chronoList" color="primary" [removable]="true" (removed)="removeChrono(chrono)">
<span class="badge badge-pill badge-dark">{{chronoList.indexOf(chrono)+1}}</span> &nbsp;{{chrono}}
<mat-icon matChipRemove class="fa fa-times-circle"></mat-icon>
</mat-chip>
</mat-chip-list>
</div>
<mat-divider></mat-divider>
</mat-tab> </mat-tab>
<mat-tab label="{{lang.resId}}"> <mat-tab label="{{lang.resId}}">
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
{{lang.updateStatusInformationsGed}} {{lang.updateStatusInformationsGed}}
</div> </div>
<mat-form-field> <mat-form-field>
<input type="number" matInput name="resId" title="{{lang.resId}}" placeholder="{{lang.resId}}" [(ngModel)]="resId"> <input type="number" id="" matInput name="resId" title="{{lang.resId}}" placeholder="{{lang.resId}}" [(ngModel)]="resId">
</mat-form-field> </mat-form-field>
<div class="row">
<div class="form-group">
<div class="col-md-12 text-left" style="padding:10px;">
<button mat-raised-button [disabled]="!resId" color="primary" type="button" (click)="addResId();" style="position:relative;left:15px;">{{lang.add}}</button>
</div>
</div>
<mat-chip-list [(ngModel)]="resIdList" name="resIdChips" #chipList>
<mat-chip *ngFor="let resId of resIdList" color="primary" [removable]="true" (removed)="removeResId(resId)">
<span class="badge badge-pill badge-dark">{{resIdList.indexOf(resId)+1}}</span> &nbsp;{{resId}}
<mat-icon matChipRemove class="fa fa-times-circle"></mat-icon>
</mat-chip>
</mat-chip-list>
</div>
<mat-divider></mat-divider>
</mat-tab> </mat-tab>
</mat-tab-group> </mat-tab-group>
<mat-form-field> <mat-form-field>
<input matInput [formControl]="statusCtrl" name="statusesList" placeholder="{{lang.availableStatuses}}" [(ngModel)]="this.statusId" <input matInput [formControl]="statusCtrl" name="statusesList" placeholder="{{lang.availableStatuses}}" [(ngModel)]="this.statusId"
[matAutocomplete]="auto" required> [matAutocomplete]="auto" required>
<mat-autocomplete #auto="matAutocomplete"> <mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let status of filteredStatuses | async" [value]="status.id"> <mat-option *ngFor="let status of filteredStatuses | async" [value]="status.id">
{{status.idToDisplay}} {{status.idToDisplay}}
<small style="opacity:0.3;">{{status.id}}</small> <small style="opacity:0.3;">{{status.id}}</small>
</mat-option> </mat-option>
</mat-autocomplete> </mat-autocomplete>
</mat-form-field> </mat-form-field>
<div class="form-group"> <div class="form-group">
<div class="col-md-12 text-center" style="padding:10px;"> <div class="col-md-12 text-center" style="padding:10px;">
<button mat-raised-button [disabled]="(!resId && !chrono) || (resId && chrono) || !statusId" color="primary">{{lang.save}}</button> <button mat-raised-button [disabled]="(resIdList.length == 0 && chronoList.length == 0) || (resIdList.length > 0 && chronoList.length > 0) || !statusId" color="primary">{{lang.save}}</button>
</div> </div>
</div> </div>
......
...@@ -27,7 +27,8 @@ export class UpdateStatusAdministrationComponent extends AutoCompletePlugin impl ...@@ -27,7 +27,8 @@ export class UpdateStatusAdministrationComponent extends AutoCompletePlugin impl
statusId : string = ""; statusId : string = "";
resId : string = ""; resId : string = "";
chrono : string = ""; chrono : string = "";
resIdList : string[] = [];
chronoList : string[] = [];
constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, public http: HttpClient, private notify: NotificationService) { constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, public http: HttpClient, private notify: NotificationService) {
super(http, ['statuses']); super(http, ['statuses']);
...@@ -51,23 +52,45 @@ export class UpdateStatusAdministrationComponent extends AutoCompletePlugin impl ...@@ -51,23 +52,45 @@ export class UpdateStatusAdministrationComponent extends AutoCompletePlugin impl
var body = { var body = {
"status": this.statusId "status": this.statusId
}; };
if (this.resId != "") { if (this.resIdList.length > 0) {
body["resId"] = [this.resId]; body["resId"] = this.resIdList;
} else if (this.chrono != "") { } else if (this.chronoList.length > 0) {
body["chrono"] = [this.chrono]; body["chrono"] = this.chronoList;
} }
this.http.put(this.coreUrl + "rest/res/resource/status", body) this.http.put(this.coreUrl + "rest/res/resource/status", body)
.subscribe(() => { .subscribe(() => {
this.resId = ""; this.resId = "";
this.chrono = ""; this.chrono = "";
this.statusId = ""; this.statusId = "";
this.resIdList = [];
this.chronoList = [];
this.notify.success(this.lang.modificationSaved); this.notify.success(this.lang.modificationSaved);
}, (err) => { }, (err) => {
this.notify.error(err.error.errors); this.notify.error(err.error.errors);
}); });
} }
addResId() :void {
this.resIdList.push(this.resId);
this.resId = ""
}
addChrono() :void {
this.chronoList.push(this.chrono);
this.chrono = "";
}
removeResId(resId: string) :void {
var resIdIndex = this.resIdList.indexOf(resId);
this.resIdList.splice(resIdIndex,1);
}
removeChrono(chrono: string) :void {
var chronoIndex = this.chronoList.indexOf(chrono);
this.chronoList.splice(chronoIndex,1);
}
resetInput(e: any) { resetInput(e: any) {
if (e.index == 0) { if (e.index == 0) {
this.resId = ""; this.resId = "";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment