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 @@
<mat-spinner style="margin:auto;"></mat-spinner>
</div>
<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 label="{{lang.chronoNumber}}">
<div class="alert alert-info" role="alert">
{{lang.updateStatusInformationsChrono}}
</div>
<mat-form-field>
<input matInput name="chrono" title="{{lang.chronoNumber}}" placeholder="{{lang.chronoNumber}}" [(ngModel)]="chrono">
</mat-form-field>
<input matInput name="chrono" title="{{lang.chronoNumber}}" placeholder="{{lang.chronoNumber}}" [(ngModel)]="chrono">
</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 label="{{lang.resId}}">
<div class="alert alert-info" role="alert">
{{lang.updateStatusInformationsGed}}
</div>
<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>
<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-group>
<mat-form-field>
<input matInput [formControl]="statusCtrl" name="statusesList" placeholder="{{lang.availableStatuses}}" [(ngModel)]="this.statusId"
[matAutocomplete]="auto" required>
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let status of filteredStatuses | async" [value]="status.id">
{{status.idToDisplay}}
<small style="opacity:0.3;">{{status.id}}</small>
</mat-option>
</mat-autocomplete>
<input matInput [formControl]="statusCtrl" name="statusesList" placeholder="{{lang.availableStatuses}}" [(ngModel)]="this.statusId"
[matAutocomplete]="auto" required>
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let status of filteredStatuses | async" [value]="status.id">
{{status.idToDisplay}}
<small style="opacity:0.3;">{{status.id}}</small>
</mat-option>
</mat-autocomplete>
</mat-form-field>
<div class="form-group">
<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>
......
......@@ -27,7 +27,8 @@ export class UpdateStatusAdministrationComponent extends AutoCompletePlugin impl
statusId : string = "";
resId : string = "";
chrono : string = "";
resIdList : string[] = [];
chronoList : string[] = [];
constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, public http: HttpClient, private notify: NotificationService) {
super(http, ['statuses']);
......@@ -51,23 +52,45 @@ export class UpdateStatusAdministrationComponent extends AutoCompletePlugin impl
var body = {
"status": this.statusId
};
if (this.resId != "") {
body["resId"] = [this.resId];
} else if (this.chrono != "") {
body["chrono"] = [this.chrono];
}
if (this.resIdList.length > 0) {
body["resId"] = this.resIdList;
} else if (this.chronoList.length > 0) {
body["chrono"] = this.chronoList;
}
this.http.put(this.coreUrl + "rest/res/resource/status", body)
.subscribe(() => {
this.resId = "";
this.chrono = "";
this.statusId = "";
this.resIdList = [];
this.chronoList = [];
this.notify.success(this.lang.modificationSaved);
}, (err) => {
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) {
if (e.index == 0) {
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