diff --git a/apps/maarch_entreprise/Views/basket-administration.component.html b/apps/maarch_entreprise/Views/basket-administration.component.html index 375afe67a6266edb4ed6c5f85ff6b3bce7efca14..b0f24bc5c6540f386cdacf04b776b2d0b256ed04 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 ff1968d5c2316998122f704ff48d88c0b0e9130b..25cbce8e695e2ce0bf32839e0cc5b6a0baeacf5c 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); + } } }