From ab135f49664a93b186ae344dcd0de4006d24c369 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Wed, 27 Jun 2018 12:17:22 +0000 Subject: [PATCH] FIX #7968 redirect baskets before to be absent --- .../Views/profile.component.html | 2 +- .../js/angular/app/profile.component.ts | 26 ++++++++++++------- .../js/angular/lang/lang-en.ts | 6 ++++- .../js/angular/lang/lang-fr.ts | 6 ++++- package.json | 4 +-- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/apps/maarch_entreprise/Views/profile.component.html b/apps/maarch_entreprise/Views/profile.component.html index cb5e0bcac55..3108f45ea11 100755 --- a/apps/maarch_entreprise/Views/profile.component.html +++ b/apps/maarch_entreprise/Views/profile.component.html @@ -170,7 +170,7 @@ </ng-container> </mat-list> </mat-expansion-panel> - <mat-expansion-panel> + <mat-expansion-panel [expanded]="myBasketExpansionPanel"> <mat-expansion-panel-header> <mat-panel-title> <mat-icon color="primary" class="fa fa-inbox" style="font-size:25px;width:50px;"></mat-icon> diff --git a/apps/maarch_entreprise/js/angular/app/profile.component.ts b/apps/maarch_entreprise/js/angular/app/profile.component.ts index a99c9dff262..f4d317830c4 100755 --- a/apps/maarch_entreprise/js/angular/app/profile.component.ts +++ b/apps/maarch_entreprise/js/angular/app/profile.component.ts @@ -1,10 +1,10 @@ -import { ChangeDetectorRef, Component, OnInit, NgZone, ViewChild } from '@angular/core'; +import { ChangeDetectorRef, Component, OnInit, NgZone, ViewChild, QueryList, ViewChildren } from '@angular/core'; import { MediaMatcher } from '@angular/cdk/layout'; import { HttpClient } from '@angular/common/http'; import { LANG } from './translate.component'; import { NotificationService } from './notification.service'; import { debounceTime, switchMap, distinctUntilChanged, filter } from 'rxjs/operators'; -import { MatPaginator, MatTableDataSource, MatSort, MatDialog, MatDialogRef, MatSidenav } from '@angular/material'; +import { MatPaginator, MatTableDataSource, MatSort, MatDialog, MatDialogRef, MatSidenav, MatExpansionPanel } from '@angular/material'; import { AutoCompletePlugin } from '../plugins/autocomplete.plugin'; import { SelectionModel } from '@angular/cdk/collections'; @@ -65,6 +65,7 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit { //Redirect Baskets selectionBaskets = new SelectionModel<Element>(true, []); + myBasketExpansionPanel: boolean = false; masterToggleBaskets(event: any) { if (event.checked) { this.user.baskets.forEach((basket: any) => { @@ -75,6 +76,8 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit { } } + @ViewChildren(MatExpansionPanel) viewPanels: QueryList<MatExpansionPanel>; + //Groups contacts contactsGroups: any[] = []; displayedColumnsGroupsList: string[] = ['label', 'description', 'actions']; @@ -179,6 +182,7 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit { } initComponents(event: any) { + this.selectedIndex = event.index; if (event.index == 2) { this.sidenav.open(); //if (this.histories.length == 0) { @@ -258,7 +262,6 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit { } contactsGroupSubmit() { - this.http.post(this.coreUrl + 'rest/contactsGroups', this.contactsGroup) .subscribe((data: any) => { this.initGroupsContact(); @@ -557,7 +560,7 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit { } activateAbsence() { - let r = confirm('Voulez-vous vraiment activer votre absence ? Vous serez automatiquement déconnecté.'); + let r = confirm(this.lang.confirmToBeAbsent); if (r) { this.http.put(this.coreUrl + 'rest/users/' + this.user.id + '/status', { "status": "ABS" }) @@ -571,11 +574,14 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit { } askRedirectBasket() { - let r = confirm('Voulez-vous rediriger vos bannettes avant de vous mettre en absence ?'); - + this.myBasketExpansionPanel = false; + this.viewPanels.forEach(p => p.close()); + let r = confirm(this.lang.askRedirectBasketBeforeAbsence); if (r) { - this.selectedIndex = 2; - $j('#redirectBasketCard').click(); + this.selectedIndex = 1; + setTimeout(() => { + this.myBasketExpansionPanel = true; + }, 0); } else { this.activateAbsence(); } @@ -633,7 +639,7 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit { } deleteEmailSignature() { - let r = confirm('Voulez-vous vraiment supprimer la signature de mail ?'); + let r = confirm(this.lang.confirmDeleteMailSignature); if (r) { var id = this.user.emailSignatures[this.mailSignatureModel.selected].id; @@ -684,7 +690,7 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit { } deleteSignature(id: number) { - let r = confirm('Voulez-vous vraiment supprimer la signature ?'); + let r = confirm(this.lang.confirmDeleteSignature); if (r) { this.http.delete(this.coreUrl + "rest/users/" + this.user.id + "/signatures/" + id) diff --git a/apps/maarch_entreprise/js/angular/lang/lang-en.ts b/apps/maarch_entreprise/js/angular/lang/lang-en.ts index eee9d2b0ea1..eb51588cb3c 100755 --- a/apps/maarch_entreprise/js/angular/lang/lang-en.ts +++ b/apps/maarch_entreprise/js/angular/lang/lang-en.ts @@ -552,5 +552,9 @@ export const LANG_EN = { "importFile" : "Import a file", "allAttachments" : "All attachments", "editModelFirst" : "Please edit model first", - "visa" : "Visa" + "visa" : "Visa", + "askRedirectBasketBeforeAbsence" : "Do you want to redirect your baskets before to be absent ?", + "confirmToBeAbsent" : "Do you really want to be absent ? You will be automatically logout", + "confirmDeleteMailSignature" : "Do you really want to delete mail signature ?", + "confirmDeleteSignature" : "Do you really want to delete signature ?" }; diff --git a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts index de4abfa135d..bf050be3c64 100755 --- a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts +++ b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts @@ -574,5 +574,9 @@ export const LANG_FR = { "importFile" : "Importer un fichier", "allAttachments" : "Tous les attachements", "editModelFirst" : "Veuillez éditer le modèle avant de valider", - "visa" : "Visa" + "visa" : "Visa", + "askRedirectBasketBeforeAbsence" : "Voulez-vous rediriger vos bannettes avant de vous mettre en absence ?", + "confirmToBeAbsent" : "Voulez-vous vraiment activer votre absence ? Vous serez automatiquement déconnecté", + "confirmDeleteMailSignature" : "Voulez-vous vraiment supprimer la signature de mail ?", + "confirmDeleteSignature" : "Voulez-vous vraiment supprimer la signature ?" }; diff --git a/package.json b/package.json index affd5f84281..24013eeef65 100755 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "devDependencies": { "@angular-devkit/build-angular": "^0.6.7", "@angular/animations": "^6.0.6", - "@angular/cdk": "^6.3.0", + "@angular/cdk": "^6.3.1", "@angular/cli": "^6.0.8", "@angular/common": "^6.0.6", "@angular/compiler": "^6.0.6", @@ -36,7 +36,7 @@ "@angular/core": "^6.0.6", "@angular/forms": "^6.0.6", "@angular/http": "^6.0.6", - "@angular/material": "^6.3.0", + "@angular/material": "^6.3.1", "@angular/platform-browser": "^6.0.6", "@angular/platform-browser-dynamic": "^6.0.6", "@angular/platform-server": "^6.0.6", -- GitLab