diff --git a/apps/maarch_entreprise/Views/update-status-administration.component.html b/apps/maarch_entreprise/Views/update-status-administration.component.html index aa15f00592f7ab9f05ca6ff18b1ff3bfe270e101..105916be3ba03add1d4e97aebe77a6d868783516 100644 --- a/apps/maarch_entreprise/Views/update-status-administration.component.html +++ b/apps/maarch_entreprise/Views/update-status-administration.component.html @@ -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> {{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> {{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> diff --git a/apps/maarch_entreprise/js/angular/app/administration/update-status-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/update-status-administration.component.ts index f422bf3ddc0b7c1a87d3a4bf24af3462524cc8f4..d02111a2bf17bc76ce2bd60d421d609f79f9449a 100644 --- a/apps/maarch_entreprise/js/angular/app/administration/update-status-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/administration/update-status-administration.component.ts @@ -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 = "";