From 0bb27001b186e3cab339547bcd48e8b500ee5539 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Fri, 13 Jul 2018 11:02:07 +0200 Subject: [PATCH] FEAT #8031 fix order priority column --- .../basket-administration.component.html | 6 ++--- .../basket-administration.component.ts | 27 +++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/apps/maarch_entreprise/Views/basket-administration.component.html b/apps/maarch_entreprise/Views/basket-administration.component.html index 375afe67a62..b0f24bc5c65 100644 --- a/apps/maarch_entreprise/Views/basket-administration.component.html +++ b/apps/maarch_entreprise/Views/basket-administration.component.html @@ -67,8 +67,8 @@ <div class="row"> <div class="col-md-6 col-xs-6 text-center"> <mat-form-field > - <mat-select placeholder="{{lang.defaultSort}}" [(ngModel)]="orderColumnsSelected" (selectionChange)="onOrderChange()" [formControl]="columnsFormControl" name="basket_res_order" multiple> - <mat-option *ngFor="let column of orderColumns" [value]="column">{{langVarName[orderColumns.indexOf(column)]}}</mat-option> + <mat-select #columnPrio placeholder="{{lang.defaultSort}}" [formControl]="columnsFormControl" name="basket_res_order" multiple required> + <mat-option #columnTargeted *ngFor="let column of orderColumns" (click)="onOrderChange(column,columnTargeted.selected)" [value] ="column" [disabled]="columnPrio.selected.length == 2 && !columnTargeted.selected" >{{langVarName[orderColumns.indexOf(column)]}}</mat-option> </mat-select> </mat-form-field> </div> @@ -94,7 +94,7 @@ </mat-slide-toggle> </div> <div class="col-md-12 text-center" style="padding:10px;"> - <button class="enableAtionBottomCenterSmarpthone" mat-raised-button [disabled]="!basketForm.form.valid" color="primary">{{lang.save}}</button> + <button class="enableAtionBottomCenterSmarpthone" mat-raised-button [disabled]="!basketForm.form.valid || orderColumnsSelected.length == 0" color="primary">{{lang.save}}</button> </div> </form> </mat-tab> diff --git a/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.ts index ff1968d5c23..25cbce8e695 100644 --- a/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.ts +++ b/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.ts @@ -90,11 +90,17 @@ export class BasketAdministrationComponent implements OnInit { this.basket.isSearchBasket = data.basket.is_visible != "Y"; this.basket.flagNotif = data.basket.flag_notif == "Y"; if(this.basket.basket_res_order == '' || this.basket.basket_res_order == null){ - this.orderColumnsSelected = null; + this.orderColumnsSelected = []; } else{ - this.basket.basket_res_order = this.basket.basket_res_order.substring(0,this.basket.basket_res_order.indexOf(" DESC")); + + //this.basket.basket_res_order = this.basket.basket_res_order.substring(0,this.basket.basket_res_order.indexOf(" DESC")); this.orderColumnsSelected = this.basket.basket_res_order.split(','); + + this.orderColumnsSelected.forEach((column: any, i: number) => { + this.orderColumnsSelected[i] = this.orderColumnsSelected[i].substring(0,this.orderColumnsSelected[i].indexOf(" DESC")); + }); + this.columnsFormControl.setValue(this.orderColumnsSelected); this.selection = this.orderColumnsSelected; } @@ -168,8 +174,10 @@ export class BasketAdministrationComponent implements OnInit { onSubmit() { if(this.orderColumnsSelected !== null && this.orderColumnsSelected.length > 0){ + this.orderColumnsSelected.forEach((column: any, i: number) => { + this.orderColumnsSelected[i] += ' DESC' + }); this.basket.basket_res_order = this.orderColumnsSelected.join(',') - this.basket.basket_res_order += ' DESC'; } else { this.basket.basket_res_order = ''; } @@ -198,13 +206,16 @@ export class BasketAdministrationComponent implements OnInit { this.orderColumnsSelected.splice(index, 1); } this.columnsFormControl.setValue(this.orderColumnsSelected); - } + } - onOrderChange(){ - if (this.columnsFormControl.value.length < 3) { - this.selection = this.columnsFormControl.value; + onOrderChange(column:any, state: boolean){ + if (state) { + this.orderColumnsSelected.push(column); } else { - this.columnsFormControl.setValue(this.selection); + var index = this.orderColumnsSelected.indexOf(column); + if (index >= 0) { + this.orderColumnsSelected.splice(index, 1); + } } } -- GitLab