From 9f0e209fdb7e57d897594ebf2b1d73bf72e698a2 Mon Sep 17 00:00:00 2001 From: Alex Orluc <alex.orluc@maarch.org> Date: Fri, 2 Mar 2018 22:10:38 +0100 Subject: [PATCH] FEAT #143 fix mat-icon + copy actions for new group + remove stepper --- .../Views/administration.component.html | 20 ++- ...inistration-groupList-modal.component.html | 100 +------------ .../basket-administration.component.html | 138 +++++++++--------- .../baskets-administration.component.html | 3 - apps/maarch_entreprise/css/engine.css | 3 +- .../basket-administration.component.js | 92 ++++-------- .../basket-administration.component.ts | 91 ++++-------- 7 files changed, 159 insertions(+), 288 deletions(-) diff --git a/apps/maarch_entreprise/Views/administration.component.html b/apps/maarch_entreprise/Views/administration.component.html index 8a9c61c9de2..2863711c894 100755 --- a/apps/maarch_entreprise/Views/administration.component.html +++ b/apps/maarch_entreprise/Views/administration.component.html @@ -30,7 +30,10 @@ <mat-card *ngIf="!loading"> <div class="row adminArea"> <div class="col-md-6 adminArea_1"> - <div style="position: absolute;font-size: 40px;font-weight: bolder;margin: auto;top: 0;right: 0;bottom: 0;left: 0;width: 342px;height: 53px;opacity: 0.09;">ORGANISATION</div> + <div style="font-size: 20px; + font-weight: bolder; + opacity: 0.09; + text-align: center">ORGANISATION</div> <button class="col-md-4 col-xs-6" mat-button color="primary" matTooltip="{{modService.comment}}" *ngFor="let modService of organisationServices" (click)="goToSpecifiedAdministration(modService)"> <i class="{{modService.style}} fa-4x"></i> @@ -38,14 +41,20 @@ </div> <div class="col-md-6 adminArea_2"> - <div style="position: absolute;font-size: 40px;font-weight: bolder;margin: auto;top: 0;right: 0;bottom: 0;left: 0;width: 250px;height: 53px;opacity: 0.09;">PRODUCTION</div> + <div style="font-size: 20px; + font-weight: bolder; + opacity: 0.09; + text-align: center">PRODUCTION</div> <button class="col-md-4 col-xs-6" mat-button color="primary" matTooltip="{{modService.comment}}" *ngFor="let modService of productionServices" (click)="goToSpecifiedAdministration(modService)"> <i class="{{modService.style}} fa-4x"></i> <br/>{{modService.name}}</button> </div> <div class="col-md-6 adminArea_3"> - <div style="position: absolute;font-size: 40px;font-weight: bolder;margin: auto;top: 0;right: 0;bottom: 0;left: 0;width: 300px;height: 53px;opacity: 0.09;">CLASSEMENT</div> + <div style="font-size: 20px; + font-weight: bolder; + opacity: 0.09; + text-align: center">CLASSEMENT</div> <button class="col-md-4 col-xs-6" mat-button color="primary" matTooltip="{{modService.comment}}" *ngFor="let modService of classementServices" (click)="goToSpecifiedAdministration(modService)"> <i class="{{modService.style}} fa-4x"></i> @@ -53,7 +62,10 @@ </div> <div class="col-md-6 adminArea_4"> - <div style="position: absolute;font-size: 40px;font-weight: bolder;margin: auto;top: 0;right: 0;bottom: 0;left: 0;width: 300px;height: 53px;opacity: 0.09;">SUPERVISION</div> + <div style="font-size: 20px; + font-weight: bolder; + opacity: 0.09; + text-align: center">SUPERVISION</div> <button class="col-md-4 col-xs-6" mat-button color="primary" matTooltip="{{modService.comment}}" *ngFor="let modService of supervisionServices" (click)="goToSpecifiedAdministration(modService)"> <i class="{{modService.style}} fa-4x"></i> diff --git a/apps/maarch_entreprise/Views/basket-administration-groupList-modal.component.html b/apps/maarch_entreprise/Views/basket-administration-groupList-modal.component.html index e98b5bdb231..2467a88471e 100644 --- a/apps/maarch_entreprise/Views/basket-administration-groupList-modal.component.html +++ b/apps/maarch_entreprise/Views/basket-administration-groupList-modal.component.html @@ -1,96 +1,12 @@ <h2 mat-dialog-title color="primary">{{lang.linkGroup}}</h2> <mat-dialog-content> - <mat-horizontal-stepper linear="true" #stepper="matHorizontalStepper"> - <ng-template matStepperIcon="create"> - <mat-icon class="fa fa-paw"></mat-icon> - </ng-template> - <ng-template matStepperIcon="edit"> - <mat-icon class="fa fa-paw"></mat-icon> - </ng-template> - <mat-step [stepControl]="firstFormGroup"> - <form> - <ng-template matStepLabel>{{lang.chooseGroup}}</ng-template> - <mat-form-field [formGroup]="firstFormGroup"> - <mat-select placeholder="{{lang.availableGroups}}" [(ngModel)]="this.groupId" formControlName="firstCtrl" required> - <span *ngFor="let group of data.groups"> - <mat-option *ngIf="group.isUsed == false" [value]="group.group_id"> - {{group.group_desc}} - </mat-option> - </span> - </mat-select> - </mat-form-field> - <div style="margin-top:10px;"> - <button style="float:right;" mat-raised-button color="primary" matStepperNext>{{lang.next}} <mat-icon class="fa fa-chevron-right"></mat-icon></button> - </div> - </form> - </mat-step> - <mat-step> - <form #defaultActionForm="ngForm"> - <ng-template matStepLabel>{{lang.chooseDefaultAction}}</ng-template> - <div class="example-container"> - <mat-paginator #paginator [length]="100" [pageSize]="5"></mat-paginator> - <div class="col-md-6"> - <mat-button-toggle-group (change)="initAction($event)"> - <mat-button-toggle name="filterType" value="process" matTooltip="{{lang.processAction}}"> - <mat-icon class="fa fa-check fa-2x"></mat-icon> - </mat-button-toggle> - <mat-button-toggle name="filterType" value="validate_mail" matTooltip="{{lang.validateAction}}"> - <mat-icon class="fa fa-edit fa-2x"></mat-icon> - </mat-button-toggle> - <mat-button-toggle name="filterType" value="" matTooltip="{{lang.allActions}}" checked="true"> - <mat-icon class="fa fa-list fa-2x"></mat-icon> - </mat-button-toggle> - </mat-button-toggle-group> - </div> - <div class="col-md-6"> - <mat-form-field> - <input matInput (keyup)="applyFilter($event.target.value)" placeholder="{{lang.filterBy}}"> - </mat-form-field> - </div> - <mat-table #table [dataSource]="dataSource" matSort matSortActive="label_action" matSortDirection="asc"> - <ng-container matColumnDef="label_action"> - <mat-header-cell *matHeaderCellDef></mat-header-cell> - <mat-cell *matCellDef="let element" style="flex:6;"> - <mat-radio-button name="actionsList" color="primary" required (change)="selectDefaultAction(element)">{{element.label_action}}</mat-radio-button> - <small>({{element.origin}})</small> - </mat-cell> - </ng-container> - <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> - </mat-table> - </div> - <div style="margin-top:10px;"> - <button style="float:left;" color="primary" mat-raised-button matStepperPrevious><mat-icon class="fa fa-chevron-left"></mat-icon> {{lang.previous}}</button> - <button style="float:right;" color="primary" mat-raised-button matStepperNext [disabled]="!defaultActionForm.form.valid">{{lang.next}} <mat-icon class="fa fa-chevron-right"></mat-icon></button> - </div> - </form> - </mat-step> - <mat-step> - <ng-template matStepLabel>{{lang.otherActions}}</ng-template> - <div class="example-container"> - <div class="col-md-6"> - <mat-paginator #paginator2 [length]="100" [pageSize]="5"></mat-paginator> - </div> - <div class="col-md-6"> - <mat-form-field> - <input matInput (keyup)="applyFilter2($event.target.value)" placeholder="{{lang.filterBy}}"> - </mat-form-field> - </div> - <mat-table #table [dataSource]="dataSource2" matSort matSortActive="label_action" matSortDirection="asc"> - <ng-container matColumnDef="label_action"> - <mat-header-cell *matHeaderCellDef></mat-header-cell> - <mat-cell *matCellDef="let element" style="flex:6;"> - <mat-checkbox name="actionsList" color="primary" required (change)="selectAction($event,element)" [disabled]="element.action_page == 'process' || element.action_page == 'validate_mail' || element.action_page == 'index_mlb' || element.default_action_list == true">{{element.label_action}}</mat-checkbox> - <small>({{element.origin}})</small> - </mat-cell> - </ng-container> - <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> - </mat-table> - </div> - <div style="margin-top:10px;"> - <button style="float:left;" color="primary" mat-raised-button matStepperPrevious><mat-icon class="fa fa-chevron-left"></mat-icon> {{lang.previous}}</button> - <button style="float:right;" color="primary" mat-raised-button (click)="validateForm();">{{lang.validate}}</button> - </div> - </mat-step> - </mat-horizontal-stepper> + <mat-nav-list> + <span *ngFor="let group of data.groups"> + <mat-list-item *ngIf="group.isUsed == false" (click)="validateForm(group);"> + {{group.group_desc}} + </mat-list-item> + </span> + + </mat-nav-list> </mat-dialog-content> \ No newline at end of file diff --git a/apps/maarch_entreprise/Views/basket-administration.component.html b/apps/maarch_entreprise/Views/basket-administration.component.html index 82b0a4cf7a7..aac56013bcc 100644 --- a/apps/maarch_entreprise/Views/basket-administration.component.html +++ b/apps/maarch_entreprise/Views/basket-administration.component.html @@ -32,11 +32,11 @@ <mat-nav-list> <h3 mat-subheader>{{lang.tools}}</h3> <a mat-list-item *ngIf="!creationMode" (click)="linkGroup()"> - <mat-icon color="primary" mat-list-icon class="fa fa-link"></mat-icon> - <p mat-line> - {{lang.linkGroup}} - </p> - </a> + <mat-icon color="primary" mat-list-icon class="fa fa-link"></mat-icon> + <p mat-line> + {{lang.linkGroup}} + </p> + </a> </mat-nav-list> </mat-sidenav> <mat-sidenav-content> @@ -48,8 +48,8 @@ <mat-tab label="{{lang.informations}}"> <form class="form-horizontal" (ngSubmit)="onSubmit()" #basketForm="ngForm"> <mat-form-field> - <input matInput *ngIf="creationMode" name="identifier" placeholder="{{lang.id}}" [(ngModel)]="basket.id" (blur)="isAvailable()" maxlength="32" - pattern="^[\w.-]*$" required> + <input matInput *ngIf="creationMode" name="identifier" placeholder="{{lang.id}}" [(ngModel)]="basket.id" (blur)="isAvailable()" + maxlength="32" pattern="^[\w.-]*$" required> <i *ngIf="creationMode" class="fa fa-circle-o" aria-hidden="true" [ngStyle]="{'color': basketIdAvailable ? 'green' : 'red'}"></i> <input matInput *ngIf="!creationMode" name="identifier" placeholder="{{lang.id}}" title="{{lang.id}}" [(ngModel)]="basket.id" required disabled> @@ -73,25 +73,25 @@ <textarea matInput name="clause" title="{{lang.clause}}" placeholder="{{lang.clause}}" [(ngModel)]="basket.clause" matTextareaAutosize matAutosizeMinRows="1" required></textarea> <mat-icon style="cursor:pointer;" color="primary" matSuffix class="fa fa-info-circle" matTooltip="{{lang.keywordHelper}}" - (click)="snav2.toggle()"></mat-icon> + (click)="snav2.toggle()"></mat-icon> </mat-form-field> <div class="col-md-4 col-xs-4 text-center"> <mat-slide-toggle color="primary" matTooltip="{{lang.isSearchBasket}}" name="isSearchBasket" [(ngModel)]="basket.isSearchBasket"> - <mat-icon color="primary" [ngStyle]="{'opacity': basket.isSearchBasket ? '' : '0.5'}" class="fa fa-search fa-2x"></mat-icon> + <mat-icon color="primary" [ngStyle]="{'opacity': basket.isSearchBasket ? '' : '0.5'}" style="width: auto;" class="fa fa-search fa-2x"></mat-icon> </mat-slide-toggle> </div> <div class="col-md-4 col-xs-4 text-center"> <mat-slide-toggle color="primary" matTooltip="{{lang.isFolderBasket}}" name="isFolderBasket" [(ngModel)]="basket.isFolderBasket"> - <mat-icon [ngStyle]="{'opacity': basket.isFolderBasket ? '' : '0.5'}" class="fa fa-folder fa-2x"></mat-icon> + <mat-icon [ngStyle]="{'opacity': basket.isFolderBasket ? '' : '0.5'}" style="width: auto;" class="fa fa-folder fa-2x"></mat-icon> </mat-slide-toggle> </div> <div class="col-md-4 col-xs-4 text-center"> <mat-slide-toggle color="primary" matTooltip="{{lang.basketNotification}}" name="flagNotif" [(ngModel)]="basket.flagNotif"> - <mat-icon [ngStyle]="{'opacity': basket.flagNotif ? '' : '0.5'}" class="fa fa-bell fa-2x"></mat-icon> + <mat-icon [ngStyle]="{'opacity': basket.flagNotif ? '' : '0.5'}" style="width: auto;" class="fa fa-bell fa-2x"></mat-icon> </mat-slide-toggle> </div> <div class="col-md-12 text-center" style="padding:10px;"> @@ -104,63 +104,71 @@ <span>{{group.group_id}}</span> <mat-icon color="warn" class="fa fa-unlink" matTooltip="dissocier le groupe de la bannette" (click)="unlinkGroup(i)"></mat-icon> </ng-template> - <mat-form-field class="demo-chip-list"> - <mat-chip-list #chipList> - <span *ngFor="let action of group.groupActions"> - <mat-chip color="primary" [ngStyle]="{'font-weight': action.default_action_list == true ? 'bold' : ''}" style="cursor:pointer;margin:5px;" - matTooltip="accéder aux paramètres" *ngIf="action.checked == true" selectable="false" - removable="false" (click)="openSettings(group,action)"> - {{action.id}} - <i class="fa fa-circle" style="font-size:4px;padding:0 5px"></i> {{action.label_action}} - <small *ngIf="action.default_action_list == true">({{lang.default}})</small> - </mat-chip> - </span> + <div class="col-md-6"> + <mat-form-field> + <mat-chip-list #chipList class="mat-chip-list-stacked"> + <span *ngFor="let action of group.groupActions"> + <mat-chip color="primary" [ngStyle]="{'font-weight': action.default_action_list == true ? 'bold' : ''}" style="cursor:pointer;margin:5px;border-radius:0px;display:flex;" + *ngIf="action.checked == true" selectable="true" removable="true" (remove)="unlinkAction(group,action)"> + <mat-checkbox color="primary" [checked]="action.default_action_list == true" (click)="setDefaultAction(group,action)"></mat-checkbox> + + <span matTooltip="accéder aux paramètres" (click)="openSettings(group,action)">{{action.label_action}}</span> + <small *ngIf="action.default_action_list == true">({{lang.default}})</small> + <span style="flex: 1 1 auto;"></span> + <mat-icon matTooltip="{{lang.delete}}" matChipRemove color="warn" *ngIf="action.default_action_list != true" class="fa fa-times"></mat-icon> + </mat-chip> + </span> + </mat-chip-list> + <input placeholder="Action(s) choisie(s)" [matChipInputFor]="chipList" disabled /> + </mat-form-field> - <input placeholder="Action choisie" [matChipInputFor]="chipList" disabled /> - </mat-chip-list> - </mat-form-field> - <mat-accordion> - <mat-expansion-panel (opened)="initAction(i)"> - <mat-expansion-panel-header> - <mat-panel-title> - {{lang.actionAvailable}} - </mat-panel-title> - </mat-expansion-panel-header> - <div class="example-container"> - <mat-form-field> - <input matInput (keyup)="applyFilter($event.target.value)" placeholder="{{lang.filterBy}}"> - </mat-form-field> + </div> + <div class="col-md-6"> + <mat-accordion> + <mat-expansion-panel (opened)="initAction(i)"> + <mat-expansion-panel-header> + <mat-panel-title> + {{lang.actionAvailable}} + </mat-panel-title> + </mat-expansion-panel-header> + <div class="example-container"> + <mat-form-field> + <input matInput (keyup)="applyFilter($event.target.value)" placeholder="{{lang.filterBy}}"> + </mat-form-field> - <mat-table #table [dataSource]="dataSource" matSort matSortActive="label_action" matSortDirection="asc"> - <ng-container matColumnDef="label_action"> - <mat-header-cell *matHeaderCellDef></mat-header-cell> - <mat-cell *matCellDef="let element" style="flex:6;"> - <mat-checkbox color="primary" (change)="addAction(group)" [(ngModel)]="element.checked">{{element.label_action}}</mat-checkbox> - </mat-cell> - </ng-container> - <ng-container matColumnDef="actions"> - <mat-header-cell *matHeaderCellDef></mat-header-cell> - <mat-cell *matCellDef="let element" style="text-align:right"> - <button mat-icon-button [matMenuTriggerFor]="menu" [disabled]="!element.checked"> - <mat-icon class="fa fa-bars"></mat-icon> - </button> - <mat-menu #menu="matMenu"> - <button mat-menu-item [disabled]="element.default_action_list==true" (click)="setDefaultAction(group,element)"> - <mat-icon class="fa fa-check-circle"></mat-icon> - <span>{{lang.defaultAction}}</span> - </button> - <button mat-menu-item (click)="openSettings(group,element)"> - <mat-icon class="fa fa-cogs"></mat-icon> - <span>{{lang.moreOptions}}</span> + <mat-table #table [dataSource]="dataSource" matSort matSortActive="label_action" matSortDirection="asc"> + <ng-container matColumnDef="label_action"> + <mat-header-cell *matHeaderCellDef></mat-header-cell> + <mat-cell *matCellDef="let element" style="flex:6;"> + <mat-checkbox color="primary" (change)="addAction(group)" [(ngModel)]="element.checked">{{element.label_action}}</mat-checkbox> + </mat-cell> + </ng-container> + <ng-container matColumnDef="actions"> + <mat-header-cell *matHeaderCellDef></mat-header-cell> + <mat-cell *matCellDef="let element" style="text-align:right"> + <button mat-icon-button [matMenuTriggerFor]="menu" [disabled]="!element.checked"> + <mat-icon class="fa fa-bars"></mat-icon> </button> - </mat-menu> - </mat-cell> - </ng-container> - <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> - </mat-table> - </div> - </mat-expansion-panel> - </mat-accordion> + <mat-menu #menu="matMenu"> + <button mat-menu-item [disabled]="element.default_action_list==true" (click)="setDefaultAction(group,element)"> + <mat-icon class="fa fa-check-circle"></mat-icon> + <span>{{lang.defaultAction}}</span> + </button> + <button mat-menu-item (click)="openSettings(group,element)"> + <mat-icon class="fa fa-cogs"></mat-icon> + <span>{{lang.moreOptions}}</span> + </button> + </mat-menu> + </mat-cell> + </ng-container> + <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> + </mat-table> + </div> + </mat-expansion-panel> + </mat-accordion> + </div> + + </mat-tab> </mat-tab-group> </mat-card> diff --git a/apps/maarch_entreprise/Views/baskets-administration.component.html b/apps/maarch_entreprise/Views/baskets-administration.component.html index c856f2a2f83..3f80247f44e 100644 --- a/apps/maarch_entreprise/Views/baskets-administration.component.html +++ b/apps/maarch_entreprise/Views/baskets-administration.component.html @@ -7,9 +7,6 @@ <small [class.hide-for-mobile]="mobileQuery.matches">{{baskets.length}} {{lang.baskets}}</small> </h1> <span style="flex: 1 1 auto;"></span> - <button mat-icon-button (click)="snav2.toggle()"> - <mat-icon class="fa fa-gear fa-2x"></mat-icon> - </button> </mat-toolbar> <mat-sidenav-container class="admin-sidenav-container" [style.marginTop.px]="mobileQuery.matches ? 56 : 0"> <mat-sidenav #snav [mode]="mobileQuery.matches ? 'over' : 'side'" [fixedInViewport]="mobileQuery.matches" fixedTopGap="56" diff --git a/apps/maarch_entreprise/css/engine.css b/apps/maarch_entreprise/css/engine.css index 9074c6e7fbe..7f1eb40c75f 100755 --- a/apps/maarch_entreprise/css/engine.css +++ b/apps/maarch_entreprise/css/engine.css @@ -294,7 +294,8 @@ h1.admin-app-name { min-width: initial; } .admin-toolbar .maarchLogo { - transform: scale(1.5); + height: 100%; + width: 50px; } .admin-toolbar-title { margin-left: 0px !important; diff --git a/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.js b/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.js index f88e5768fec..5b1442052e9 100644 --- a/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.js +++ b/apps/maarch_entreprise/js/angular/app/administration/basket-administration.component.js @@ -193,6 +193,7 @@ var BasketAdministrationComponent = /** @class */ (function () { tmpAction.default_action_list = false; } }); + this.addAction(group); }; BasketAdministrationComponent.prototype.unlinkGroup = function (groupIndex) { var _this = this; @@ -236,6 +237,7 @@ var BasketAdministrationComponent = /** @class */ (function () { }; BasketAdministrationComponent.prototype.addAction = function (group) { var _this = this; + console.log(group); this.http.put(this.coreUrl + "rest/baskets/" + this.id + "/groups/" + group.group_id, { 'result_page': group.result_page, 'groupActions': group.groupActions }) .subscribe(function (data) { //this.basketGroups.push(data); @@ -244,6 +246,20 @@ var BasketAdministrationComponent = /** @class */ (function () { _this.notify.error(err.error.errors); }); }; + BasketAdministrationComponent.prototype.unlinkAction = function (group, action) { + var _this = this; + var r = confirm(this.lang.unlinkAction + ' ?'); + if (r) { + action.checked = false; + this.http.put(this.coreUrl + "rest/baskets/" + this.id + "/groups/" + group.group_id, { 'result_page': group.result_page, 'groupActions': group.groupActions }) + .subscribe(function (data) { + //this.basketGroups.push(data); + _this.notify.success(_this.lang.basketUpdated); + }, function (err) { + _this.notify.error(err.error.errors); + }); + } + }; __decorate([ core_1.ViewChild(material_1.MatPaginator), __metadata("design:type", material_1.MatPaginator) @@ -470,28 +486,15 @@ var BasketAdministrationSettingsModalComponent = /** @class */ (function (_super return BasketAdministrationSettingsModalComponent; }(autocomplete_plugin_1.AutoCompletePlugin)); exports.BasketAdministrationSettingsModalComponent = BasketAdministrationSettingsModalComponent; -var forms_1 = require("@angular/forms"); var BasketAdministrationGroupListModalComponent = /** @class */ (function () { - function BasketAdministrationGroupListModalComponent(http, data, dialogRef, _formBuilder) { + function BasketAdministrationGroupListModalComponent(http, data, dialogRef) { this.http = http; this.data = data; this.dialogRef = dialogRef; - this._formBuilder = _formBuilder; this.lang = translate_component_1.LANG; - this.displayedColumns = ['label_action']; this.actionAll = []; this.newBasketGroup = {}; } - BasketAdministrationGroupListModalComponent.prototype.applyFilter = function (filterValue) { - filterValue = filterValue.trim(); // Remove whitespace - filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches - this.dataSource.filter = filterValue; - }; - BasketAdministrationGroupListModalComponent.prototype.applyFilter2 = function (filterValue) { - filterValue = filterValue.trim(); // Remove whitespace - filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches - this.dataSource2.filter = filterValue; - }; BasketAdministrationGroupListModalComponent.prototype.ngOnInit = function () { var _this = this; this.coreUrl = angularGlobals.coreUrl; @@ -507,21 +510,9 @@ var BasketAdministrationGroupListModalComponent = /** @class */ (function () { tmpAction.checked = false; _this.actionAll.push(tmpAction); }); - _this.dataSource = new material_1.MatTableDataSource(_this.actionAll); - _this.dataSource.sort = _this.sort; - _this.dataSource.paginator = _this.paginator; - _this.dataSource2 = new material_1.MatTableDataSource(_this.actionAll); - _this.dataSource2.sort = _this.sort; - _this.dataSource2.paginator = _this.paginator2; }, function (err) { location.href = "index.php"; }); - this.firstFormGroup = this._formBuilder.group({ - firstCtrl: ['', forms_1.Validators.required] - }); - this.secondFormGroup = this._formBuilder.group({ - secondCtrl: ['', forms_1.Validators.required] - }); this.data.groups.forEach(function (tmpGroup) { _this.data.linkedGroups.forEach(function (tmpLinkedGroup) { if (tmpGroup.group_id == tmpLinkedGroup.group_id) { @@ -531,50 +522,27 @@ var BasketAdministrationGroupListModalComponent = /** @class */ (function () { }); }); }; - BasketAdministrationGroupListModalComponent.prototype.initAction = function (actionType) { - this.dataSource.filter = actionType.value; - }; - BasketAdministrationGroupListModalComponent.prototype.selectDefaultAction = function (action) { - this.actionAll.forEach(function (tmpAction) { - if (action.id == tmpAction.id) { - tmpAction.checked = true; - tmpAction.default_action_list = true; - } - else { - tmpAction.checked = false; - tmpAction.default_action_list = false; - } - }); - }; - BasketAdministrationGroupListModalComponent.prototype.selectAction = function (e, action) { - action.checked = e.checked; - }; - BasketAdministrationGroupListModalComponent.prototype.validateForm = function () { - this.newBasketGroup.group_id = this.groupId; - this.newBasketGroup.basket_id = this.data.basketId; - this.newBasketGroup.result_page = 'list_with_attachments'; - this.newBasketGroup.groupActions = this.actionAll; + BasketAdministrationGroupListModalComponent.prototype.validateForm = function (group) { + if (this.data.linkedGroups.length == 0) { + this.newBasketGroup.result_page = 'list_with_attachments'; + this.actionAll[0].used_in_action_page = true; + this.actionAll[0].default_action_list = true; + this.actionAll[0].checked = true; + this.newBasketGroup.groupActions = this.actionAll; + } + else { + this.newBasketGroup = JSON.parse(JSON.stringify(this.data.linkedGroups[this.data.linkedGroups.length - 1])); + } + this.newBasketGroup.group_id = group.group_id; this.dialogRef.close(this.newBasketGroup); }; - __decorate([ - core_1.ViewChild(material_1.MatSort), - __metadata("design:type", material_1.MatSort) - ], BasketAdministrationGroupListModalComponent.prototype, "sort", void 0); - __decorate([ - core_1.ViewChild('paginator'), - __metadata("design:type", material_1.MatPaginator) - ], BasketAdministrationGroupListModalComponent.prototype, "paginator", void 0); - __decorate([ - core_1.ViewChild('paginator2'), - __metadata("design:type", material_1.MatPaginator) - ], BasketAdministrationGroupListModalComponent.prototype, "paginator2", void 0); BasketAdministrationGroupListModalComponent = __decorate([ core_1.Component({ templateUrl: angularGlobals["basket-administration-groupList-modalView"], styles: [".mat-dialog-content{height: 65vh;}"] }), __param(1, core_1.Inject(material_1.MAT_DIALOG_DATA)), - __metadata("design:paramtypes", [http_1.HttpClient, Object, material_1.MatDialogRef, forms_1.FormBuilder]) + __metadata("design:paramtypes", [http_1.HttpClient, Object, material_1.MatDialogRef]) ], BasketAdministrationGroupListModalComponent); return BasketAdministrationGroupListModalComponent; }()); 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 fe279d97299..bd212ed1fea 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 @@ -195,6 +195,7 @@ export class BasketAdministrationComponent implements OnInit { tmpAction.default_action_list = false; } }); + this.addAction(group); } unlinkGroup(groupIndex: any) { @@ -239,6 +240,7 @@ export class BasketAdministrationComponent implements OnInit { } addAction(group: any) { + console.log(group); this.http.put(this.coreUrl + "rest/baskets/" + this.id + "/groups/" + group.group_id, { 'result_page': group.result_page, 'groupActions': group.groupActions }) .subscribe((data: any) => { //this.basketGroups.push(data); @@ -248,6 +250,21 @@ export class BasketAdministrationComponent implements OnInit { }); } + unlinkAction(group: any, action: any) { + + let r = confirm(this.lang.unlinkAction + ' ?'); + + if (r) { + action.checked = false; + this.http.put(this.coreUrl + "rest/baskets/" + this.id + "/groups/" + group.group_id, { 'result_page': group.result_page, 'groupActions': group.groupActions }) + .subscribe((data: any) => { + //this.basketGroups.push(data); + this.notify.success(this.lang.basketUpdated); + }, (err) => { + this.notify.error(err.error.errors); + }); + } + } } @Component({ templateUrl: angularGlobals["basket-administration-settings-modalView"], @@ -452,7 +469,7 @@ export class BasketAdministrationSettingsModalComponent extends AutoCompletePlug } } -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { FormGroup, Validators } from '@angular/forms'; @Component({ templateUrl: angularGlobals["basket-administration-groupList-modalView"], styles: [".mat-dialog-content{height: 65vh;}"] @@ -460,32 +477,10 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; export class BasketAdministrationGroupListModalComponent { lang: any = LANG; coreUrl: string; - groupId: any; - firstFormGroup: FormGroup; - secondFormGroup: FormGroup; - displayedColumns = ['label_action']; - dataSource: any; - dataSource2: any; actionAll: any = []; newBasketGroup: any = {}; - - @ViewChild(MatSort) sort: MatSort; - @ViewChild('paginator') paginator: MatPaginator; - @ViewChild('paginator2') paginator2: MatPaginator; - applyFilter(filterValue: string) { - filterValue = filterValue.trim(); // Remove whitespace - filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches - this.dataSource.filter = filterValue; - } - applyFilter2(filterValue: string) { - filterValue = filterValue.trim(); // Remove whitespace - filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches - this.dataSource2.filter = filterValue; - } - - - constructor(public http: HttpClient, @Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef<BasketAdministrationGroupListModalComponent>, private _formBuilder: FormBuilder) { } + constructor(public http: HttpClient, @Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef<BasketAdministrationGroupListModalComponent>) { } ngOnInit(): void { this.coreUrl = angularGlobals.coreUrl; this.http.get(this.coreUrl + "rest/actions") @@ -500,24 +495,11 @@ export class BasketAdministrationGroupListModalComponent { tmpAction.checked = false; this.actionAll.push(tmpAction); }); - this.dataSource = new MatTableDataSource(this.actionAll); - this.dataSource.sort = this.sort; - this.dataSource.paginator = this.paginator; - - this.dataSource2 = new MatTableDataSource(this.actionAll); - this.dataSource2.sort = this.sort; - this.dataSource2.paginator = this.paginator2; }, (err) => { location.href = "index.php"; }); - this.firstFormGroup = this._formBuilder.group({ - firstCtrl: ['', Validators.required] - }); - this.secondFormGroup = this._formBuilder.group({ - secondCtrl: ['', Validators.required] - }); this.data.groups.forEach((tmpGroup: any) => { this.data.linkedGroups.forEach((tmpLinkedGroup: any) => { if (tmpGroup.group_id == tmpLinkedGroup.group_id) { @@ -528,30 +510,17 @@ export class BasketAdministrationGroupListModalComponent { }); } - initAction(actionType: any) { - this.dataSource.filter = actionType.value; - } - - selectDefaultAction(action: any) { - this.actionAll.forEach((tmpAction: any) => { - if (action.id == tmpAction.id) { - tmpAction.checked = true; - tmpAction.default_action_list = true - } else { - tmpAction.checked = false; - tmpAction.default_action_list = false - } - }); - } - selectAction(e: any, action: any) { - action.checked = e.checked; - } - - validateForm() { - this.newBasketGroup.group_id = this.groupId; - this.newBasketGroup.basket_id = this.data.basketId; - this.newBasketGroup.result_page = 'list_with_attachments'; - this.newBasketGroup.groupActions = this.actionAll; + validateForm(group:any) { + if(this.data.linkedGroups.length == 0) { + this.newBasketGroup.result_page = 'list_with_attachments'; + this.actionAll[0].used_in_action_page = true; + this.actionAll[0].default_action_list = true; + this.actionAll[0].checked = true; + this.newBasketGroup.groupActions = this.actionAll; + } else { + this.newBasketGroup = JSON.parse(JSON.stringify(this.data.linkedGroups[this.data.linkedGroups.length-1])); + } + this.newBasketGroup.group_id = group.group_id; this.dialogRef.close(this.newBasketGroup); } } \ No newline at end of file -- GitLab