From 9729678320a89d7cef0b25f467811662b7beaac2 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Tue, 21 Aug 2018 14:15:01 +0200
Subject: [PATCH] FEAT #7965 improve ergo contact group

---
 .../Views/profile.component.html              | 386 +++++++++---------
 .../js/angular/app/profile.component.ts       |  20 +-
 .../js/angular/lang/lang-en.ts                |   4 +-
 .../js/angular/lang/lang-fr.ts                |   4 +-
 4 files changed, 229 insertions(+), 185 deletions(-)

diff --git a/apps/maarch_entreprise/Views/profile.component.html b/apps/maarch_entreprise/Views/profile.component.html
index f2881eb7e73..b4c6ff61b92 100755
--- a/apps/maarch_entreprise/Views/profile.component.html
+++ b/apps/maarch_entreprise/Views/profile.component.html
@@ -82,7 +82,7 @@
                                 <div *ngIf="passwordRules.renewal.enabled || passwordRules.historyLastUse.enabled" class="form-group">
                                     <div class="col-sm-12" style="padding-left:0px;padding-right:0px;">
                                         <div class="alert alert-warning" role="alert" [innerHTML]="otherRuleText" style="text-align:center;"></div>
-                                    </div>      
+                                    </div>
                                 </div>
                                 <div class="form-group">
                                     <div style="text-align:center;">
@@ -220,7 +220,7 @@
                                                 </span>
                                                 <mat-form-field *ngIf="selectionBaskets.hasValue()">
                                                     <input matTooltip="{{lang.redirectWhenAbscence}}" matTooltipPosition="above" type="text" placeholder="{{ lang.redirectBaskets }}"
-                                                       matInput [matAutocomplete]="auto" [formControl]="userCtrl">
+                                                        matInput [matAutocomplete]="auto" [formControl]="userCtrl">
                                                     <mat-autocomplete #auto="matAutocomplete">
                                                         <mat-option *ngFor="let user of filteredUsers | async" [value]="user.id" (click)="addBasketRedirection(user.id)">
                                                             <p mat-line matTooltip="{{ user.otherInfo }}">
@@ -246,7 +246,8 @@
                                                         color="primary"></mat-checkbox>
                                                 </mat-icon>
                                                 <h4 mat-line [attr.color]="basket.userToDisplay != '' ? 'primary': ''" style="display: flex;align-items: center;">
-                                                    <span (click)="selectionBaskets.toggle(basket);" matTooltip="{{basket.basket_name}} [{{basket.group_desc}}]" [ngStyle]="{'opacity': basket.allowed ? '1' : '0.5'}" style="flex: 2;overflow: hidden;text-overflow: ellipsis;">
+                                                    <span (click)="selectionBaskets.toggle(basket);" matTooltip="{{basket.basket_name}} [{{basket.group_desc}}]" [ngStyle]="{'opacity': basket.allowed ? '1' : '0.5'}"
+                                                        style="flex: 2;overflow: hidden;text-overflow: ellipsis;">
                                                         {{basket.basket_name}}
                                                         <span class="label label-primary" style="font-weight:normal">{{basket.group_desc}}</span>
                                                     </span>
@@ -453,204 +454,225 @@
                                         {{lang.myContactsGroupsDesc}}
                                     </mat-panel-description>
                                 </mat-expansion-panel-header>
-                                <div class="col-sm-6">
-                                    <form *ngIf="!contactsListMode" class="form-horizontal" (ngSubmit)="contactsGroupSubmit()" #contactsGroupFormUp="ngForm">
-                                        <div class="form-group">
-                                            <div class="col-sm-12">
-                                                <mat-form-field>
-                                                    <input matInput [(ngModel)]="contactsGroup.label" required name="label" id="label" title="{{lang.label}}" type="text" placeholder="{{lang.label}}"
-                                                        maxlength="32">
-                                                </mat-form-field>
-                                            </div>
-                                        </div>
-                                        <div class="form-group">
-                                            <div class="col-sm-12">
-                                                <mat-form-field>
-                                                    <input matInput [(ngModel)]="contactsGroup.description" required name="description" id="description" title="{{lang.description}}"
-                                                        type="text" placeholder="{{lang.description}}" maxlength="255">
-                                                </mat-form-field>
-                                            </div>
-                                        </div>
-                                        <div class="form-group">
-                                            <div class="col-sm-12" style="text-align:center;">
-                                                <button mat-raised-button color="primary" type="submit" [disabled]="!contactsGroupFormUp.form.valid">{{lang.save}}</button>
-                                            </div>
-                                        </div>
-                                    </form>
-                                    <mat-tab-group *ngIf="contactsListMode" [(selectedIndex)]="selectedTabIndex_1">
-                                        <mat-tab label="{{lang.informations}}">
-                                            <form class="form-horizontal" (ngSubmit)="updateGroupSubmit()" #contactsGroupFormUp="ngForm">
-                                                <div class="form-group">
-                                                    <div class="col-sm-12">
-                                                        <mat-form-field>
-                                                            <input matInput [(ngModel)]="contactsGroup.label" required name="label" id="label" title="{{lang.label}}" type="text" placeholder="{{lang.label}}"
-                                                                maxlength="32">
-                                                        </mat-form-field>
-                                                    </div>
-                                                </div>
-                                                <div class="form-group">
-                                                    <div class="col-sm-12">
-                                                        <mat-form-field>
-                                                            <input matInput [(ngModel)]="contactsGroup.description" required name="description" id="description" title="{{lang.description}}"
-                                                                type="text" placeholder="{{lang.description}}" maxlength="255">
-                                                        </mat-form-field>
-                                                    </div>
-                                                </div>
-                                                <div class="form-group">
-                                                    <div class="col-sm-12" style="text-align:center;">
-                                                        <button mat-raised-button color="primary" type="submit" [disabled]="!contactsGroupFormUp.form.valid">{{lang.update}}</button>
-                                                        <button mat-raised-button color="default" type="button" (click)="initGroupsContact()">{{lang.back}}</button>
-                                                    </div>
-                                                </div>
-                                            </form>
-                                        </mat-tab>
-                                        <mat-tab label="{{lang.addContacts}}">
-                                            <div class="row" style="margin:0px;">
-                                                <div class="col-sm-4">
+                                <mat-tab-group (selectedIndexChange)="changeTabContactGrp($event)" [selectedIndex]="selectedIndexContactsGrp">
+                                    <mat-tab label="Liste des groupements">
+                                        <mat-accordion (click)="initGroupsContact();">
+                                            <mat-expansion-panel>
+                                                <mat-expansion-panel-header>
+                                                    <mat-panel-title color="primary" style="justify-content: right;">
+                                                        <span style="margin-top:5px;">{{lang.contactGroupCreate}}</span>
+                                                    </mat-panel-title>
+                                                </mat-expansion-panel-header>
+                                                <form id="contactsGroupFormUp" class="form-horizontal" (ngSubmit)="contactsGroupSubmit()" #contactsGroupFormUp="ngForm">
+                                                        <div class="form-group">
+                                                            <div class="col-sm-12">
+                                                                <mat-form-field>
+                                                                    <input matInput [(ngModel)]="contactsGroup.label" required name="label" id="label" title="{{lang.label}}" type="text" placeholder="{{lang.label}}"
+                                                                        maxlength="32">
+                                                                </mat-form-field>
+                                                            </div>
+                                                        </div>
+                                                        <div class="form-group">
+                                                            <div class="col-sm-12">
+                                                                <mat-form-field>
+                                                                    <input matInput [(ngModel)]="contactsGroup.description" required name="description" id="description" title="{{lang.description}}"
+                                                                        type="text" placeholder="{{lang.description}}" maxlength="255">
+                                                                </mat-form-field>
+                                                            </div>
+                                                        </div>
+                                                        <div class="form-group">
+                                                            <div class="col-sm-12" style="text-align:center;">
+                                                                <button mat-raised-button color="primary" type="submit" [disabled]="!contactsGroupFormUp.form.valid">{{lang.save}}</button>
+                                                            </div>
+                                                        </div>
+                                                    </form>
+                                            </mat-expansion-panel>
+                                        </mat-accordion>
+                                        <div id="contactsGroupList" style="margin-top: 10px;">
+                                            <div class="row">
+                                                <div class="col-md-6 col-xs-6">
                                                     <mat-form-field>
-                                                        <mat-select [(ngModel)]="contactTypeSearch" placeholder="{{lang.chooseContactType}}" id="contactTypeSearch" name="contactTypeSearch">
-                                                            <mat-option value="all">{{lang.all}}</mat-option>
-                                                            <mat-option *ngFor="let contactType of contactTypes" [value]="contactType.id">
-                                                                {{contactType.label}}
-                                                            </mat-option>
-                                                        </mat-select>
-                                                    </mat-form-field>
-                                                </div>
-                                                <div class="col-md-8" style="padding:5px;">
-                                                    <mat-form-field hintLabel="3 caractères minium">
-                                                        <span matPrefix>
-                                                            <mat-icon class="fa fa-user-plus" color="primary"></mat-icon>&nbsp;&nbsp;</span>
-                                                        <input class="autocompleteSearch" type="text" placeholder="{{lang.linkContact}}" matInput [formControl]="searchTerm" autocomplete="off"
-                                                            (keyup)="launchLoading();" minlength="3">
+                                                        <input matInput (keyup)="applyFilterGroupsList($event.target.value)" placeholder="{{lang.filterBy}}">
                                                     </mat-form-field>
                                                 </div>
                                                 <div class="col-md-6 col-xs-6">
-                                                    <div class="alert alert-danger" *ngIf="dataSourceContactsListAutocomplete && dataSourceContactsListAutocomplete.data.length == 1000"
-                                                        [innerHTML]="lang.limitDataReached_1000"></div>
-                                                </div>
-                                                <div class="col-md-6 col-xs-6">
-                                                    <mat-paginator #paginatorContactList [length]="0" [pageSize]="10">
+                                                    <mat-paginator #paginatorGroupsList [length]="100" [pageSize]="5">
                                                     </mat-paginator>
                                                 </div>
                                             </div>
-                                            <mat-progress-bar mode="indeterminate" *ngIf="!dataSourceContactsListAutocomplete && !initAutoCompleteContact"></mat-progress-bar>
-                                            <mat-table #tableContactList [dataSource]="dataSourceContactsListAutocomplete" *ngIf="dataSourceContactsListAutocomplete">
-                                                <ng-container matColumnDef="select">
-                                                    <mat-header-cell *matHeaderCellDef style="flex:1;">
-                                                        <mat-checkbox color="primary" (change)="$event ? masterToggle($event) : null" [checked]="selection.hasValue()">
-                                                        </mat-checkbox>
-                                                    </mat-header-cell>
-                                                    <mat-cell *matCellDef="let element" style="flex:1;">
-                                                        <mat-checkbox id="check_{{element.addressId}}" color="primary" (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(element.addressId) : null"
-                                                            [disabled]="isInGrp(element)" [checked]="selection.isSelected(element.addressId)">
-                                                        </mat-checkbox>
-                                                    </mat-cell>
-                                                </ng-container>
-                                                <ng-container matColumnDef="contact">
-                                                    <mat-header-cell *matHeaderCellDef style="flex:3;">{{lang.contact}}</mat-header-cell>
-                                                    <mat-cell *matCellDef="let element" style="flex:3;"> {{element.contact}} </mat-cell>
+                                            <mat-table #tableGroupsListSort="matSort" [dataSource]="dataSourceGroupsList" matSort matSortActive="label" matSortDirection="asc">
+                                                <ng-container matColumnDef="label">
+                                                    <mat-header-cell *matHeaderCellDef mat-sort-header [class.hide-for-mobile]="mobileQuery.matches" style="flex:2;">{{lang.label}}</mat-header-cell>
+                                                    <mat-cell *matCellDef="let element" [class.hide-for-mobile]="mobileQuery.matches" style="flex:2;"> {{element.label}} </mat-cell>
                                                 </ng-container>
-                                                <ng-container matColumnDef="address">
-                                                    <mat-header-cell *matHeaderCellDef style="flex:3;">{{lang.address}}</mat-header-cell>
-                                                    <mat-cell *matCellDef="let element" style="flex:3;"> {{element.address}} </mat-cell>
+                                                <ng-container matColumnDef="description">
+                                                    <mat-header-cell *matHeaderCellDef mat-sort-header style="flex:2;">{{lang.description}}</mat-header-cell>
+                                                    <mat-cell *matCellDef="let element" style="flex:2;"> {{element.description}} </mat-cell>
                                                 </ng-container>
-                                                <mat-header-row *matHeaderRowDef="displayedColumnsContactsListAutocomplete"></mat-header-row>
-                                                <mat-row *matRowDef="let element; columns: displayedColumnsContactsListAutocomplete;" (click)="selectAddress(element.addressId);"
-                                                    [ngStyle]="{'opacity': !isInGrp(element) ? '' : '0.5'}" style="cursor: pointer;"></mat-row>
-                                            </mat-table>
-                                            <div class="form-group">
-                                                <div class="col-sm-12" style="text-align:center;margin-top:30px">
-                                                    <button mat-raised-button color="primary" type="button" (click)="saveContactsList($event.target)" [disabled]="this.selection.selected.length == 0">{{lang.add}}</button>
-                                                </div>
-                                            </div>
-                                        </mat-tab>
-                                    </mat-tab-group>
-                                </div>
-                                <div class="col-sm-6">
-                                    <mat-tab-group *ngIf="contactsListMode" [(selectedIndex)]="selectedTabIndex_1">
-                                        <mat-tab label="{{lang.relatedContacts}}">
-                                            <div class="row" style="margin:0px;">
-                                                <div class="col-md-6 col-xs-6">
-                                                    <mat-form-field>
-                                                        <input matInput (keyup)="applyFilterContactsList($event.target.value)" placeholder="{{lang.filterBy}}">
-                                                    </mat-form-field>
-                                                </div>
-                                                <div class="col-md-6 col-xs-6">
-                                                    <mat-paginator #paginatorContactsList [length]="0" [pageSize]="10">
-                                                    </mat-paginator>
-                                                </div>
-                                            </div>
-                                            <mat-table *ngIf="contactsListMode" #tableContactsListSort="matSort" [dataSource]="dataSourceContactsList" matSort matSortActive="contact"
-                                                matSortDirection="asc">
-                                                <ng-container matColumnDef="contact">
-                                                    <mat-header-cell *matHeaderCellDef mat-sort-header style="flex:3;">{{lang.contact}}</mat-header-cell>
-                                                    <mat-cell *matCellDef="let element" style="flex:3;"> {{element.contact}} </mat-cell>
+                                                <ng-container matColumnDef="public">
+                                                    <mat-header-cell *matHeaderCellDef mat-sort-header [class.hide-for-mobile]="mobileQuery.matches" style="flex:1;">{{lang.public}}</mat-header-cell>
+                                                    <mat-cell *matCellDef="let element" [class.hide-for-mobile]="mobileQuery.matches" style="flex:1;">
+                                                        <span *ngIf="!element.public"> {{lang.no}} </span>
+                                                        <span *ngIf="element.public"> {{lang.yes}} </span>
+                                                    </mat-cell>
                                                 </ng-container>
-                                                <ng-container matColumnDef="address">
-                                                    <mat-header-cell *matHeaderCellDef mat-sort-header style="flex:3;">{{lang.address}}</mat-header-cell>
-                                                    <mat-cell *matCellDef="let element" style="flex:3;"> {{element.address}} </mat-cell>
+                                                <ng-container matColumnDef="owner">
+                                                    <mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;">{{lang.createdBy}}</mat-header-cell>
+                                                    <mat-cell *matCellDef="let element" style="flex:1;"> {{element.labelledOwner}} </mat-cell>
                                                 </ng-container>
                                                 <ng-container matColumnDef="actions">
-                                                    <mat-header-cell *matHeaderCellDef style="flex:1;"></mat-header-cell>
-                                                    <mat-cell *matCellDef="let element;let i = index" style="justify-content: flex-end;flex:1;">
-                                                        <button mat-icon-button color="warn" matTooltip="{{lang.delete}}" (click)="$event.stopPropagation();preDelete(i)">
+                                                    <mat-header-cell *matHeaderCellDef></mat-header-cell>
+                                                    <mat-cell *matCellDef="let element" style="justify-content: flex-end;">
+                                                        <button mat-icon-button color="warn" matTooltip="{{lang.delete}}" (click)="$event.stopPropagation();deleteContactsGroup(element.position)">
                                                             <mat-icon class="fa fa-trash-alt fa-2x" aria-hidden="true"></mat-icon>
                                                         </button>
                                                     </mat-cell>
                                                 </ng-container>
-                                                <mat-header-row *matHeaderRowDef="displayedColumnsContactsList"></mat-header-row>
-                                                <mat-row *matRowDef="let element; columns: displayedColumnsContactsList;"></mat-row>
+                                                <mat-header-row *matHeaderRowDef="displayedColumnsGroupsList"></mat-header-row>
+                                                <mat-row *matRowDef="let row; columns: displayedColumnsGroupsList;" (click)="loadContactsGroup(row)" style="cursor:pointer;"
+                                                    matTooltip="{{lang.view}}"></mat-row>
                                             </mat-table>
-                                        </mat-tab>
-                                    </mat-tab-group>
-                                    <div *ngIf="!contactsListMode" class="row">
-                                        <div class="col-md-6 col-xs-6">
-                                            <mat-form-field>
-                                                <input matInput (keyup)="applyFilterGroupsList($event.target.value)" placeholder="{{lang.filterBy}}">
-                                            </mat-form-field>
                                         </div>
-                                        <div class="col-md-6 col-xs-6">
-                                            <mat-paginator #paginatorGroupsList [length]="100" [pageSize]="5">
-                                            </mat-paginator>
-                                        </div>
-                                    </div>
-                                    <mat-table *ngIf="!contactsListMode" #tableGroupsListSort="matSort" [dataSource]="dataSourceGroupsList" matSort matSortActive="label"
-                                        matSortDirection="asc">
-                                        <ng-container matColumnDef="label">
-                                            <mat-header-cell *matHeaderCellDef mat-sort-header [class.hide-for-mobile]="mobileQuery.matches" style="flex:2;">{{lang.label}}</mat-header-cell>
-                                            <mat-cell *matCellDef="let element" [class.hide-for-mobile]="mobileQuery.matches" style="flex:2;"> {{element.label}} </mat-cell>
-                                        </ng-container>
-                                        <ng-container matColumnDef="description">
-                                            <mat-header-cell *matHeaderCellDef mat-sort-header style="flex:2;">{{lang.description}}</mat-header-cell>
-                                            <mat-cell *matCellDef="let element" style="flex:2;"> {{element.description}} </mat-cell>
-                                        </ng-container>
-                                        <ng-container matColumnDef="public">
-                                            <mat-header-cell *matHeaderCellDef mat-sort-header [class.hide-for-mobile]="mobileQuery.matches" style="flex:1;">{{lang.public}}</mat-header-cell>
-                                            <mat-cell *matCellDef="let element" [class.hide-for-mobile]="mobileQuery.matches" style="flex:1;">
-                                                <span *ngIf="!element.public"> {{lang.no}} </span>
-                                                <span *ngIf="element.public"> {{lang.yes}} </span>
-                                            </mat-cell>
-                                        </ng-container>
-                                        <ng-container matColumnDef="owner">
-                                            <mat-header-cell *matHeaderCellDef mat-sort-header style="flex:1;">{{lang.createdBy}}</mat-header-cell>
-                                            <mat-cell *matCellDef="let element" style="flex:1;"> {{element.labelledOwner}} </mat-cell>
-                                        </ng-container>
-                                        <ng-container matColumnDef="actions">
-                                            <mat-header-cell *matHeaderCellDef></mat-header-cell>
-                                            <mat-cell *matCellDef="let element" style="justify-content: flex-end;">
-                                                <button mat-icon-button color="warn" matTooltip="{{lang.delete}}" (click)="$event.stopPropagation();deleteContactsGroup(element.position)">
-                                                    <mat-icon class="fa fa-trash-alt fa-2x" aria-hidden="true"></mat-icon>
-                                                </button>
-                                            </mat-cell>
-                                        </ng-container>
-                                        <mat-header-row *matHeaderRowDef="displayedColumnsGroupsList"></mat-header-row>
-                                        <mat-row *matRowDef="let row; columns: displayedColumnsGroupsList;" (click)="loadContactsGroup(row)" style="cursor:pointer;"
-                                            matTooltip="{{lang.view}}"></mat-row>
-                                    </mat-table>
-                                </div>
-                                <div>
 
-                                </div>
+                                    </mat-tab>
+                                    <mat-tab label="Groupement : {{contactsGroup.label}}" *ngIf="contactsListMode">
+                                        <mat-accordion>
+                                            <mat-expansion-panel>
+                                                <mat-expansion-panel-header>
+                                                    <mat-panel-title color="primary" style="justify-content: right;">
+                                                        <span style="margin-top:5px;">{{lang.contactLink}}</span>
+                                                    </mat-panel-title>
+                                                </mat-expansion-panel-header>
+                                                <div id="contactsGroupFormAdd">
+                                                    <div class="row" style="margin:0px;">
+                                                        <div class="col-sm-4">
+                                                            <mat-form-field>
+                                                                <mat-select [(ngModel)]="contactTypeSearch" placeholder="{{lang.chooseContactType}}" id="contactTypeSearch" name="contactTypeSearch">
+                                                                    <mat-option value="all">{{lang.all}}</mat-option>
+                                                                    <mat-option *ngFor="let contactType of contactTypes" [value]="contactType.id">
+                                                                        {{contactType.label}}
+                                                                    </mat-option>
+                                                                </mat-select>
+                                                            </mat-form-field>
+                                                        </div>
+                                                        <div class="col-md-8" style="padding:5px;">
+                                                            <mat-form-field hintLabel="3 caractères minium">
+                                                                <span matPrefix>
+                                                                    <mat-icon class="fa fa-user-plus" color="primary"></mat-icon>&nbsp;&nbsp;</span>
+                                                                <input class="autocompleteSearch" type="text" placeholder="{{lang.linkContact}}" matInput [formControl]="searchTerm" autocomplete="off"
+                                                                    (keyup)="launchLoading();" minlength="3">
+                                                            </mat-form-field>
+                                                        </div>
+                                                        <div class="col-md-6 col-xs-6">
+                                                            <div class="alert alert-danger" *ngIf="dataSourceContactsListAutocomplete && dataSourceContactsListAutocomplete.data.length == 1000"
+                                                                [innerHTML]="lang.limitDataReached_1000"></div>
+                                                        </div>
+                                                        <div class="col-md-6 col-xs-6">
+                                                            <mat-paginator #paginatorContactList [length]="0" [pageSize]="10">
+                                                            </mat-paginator>
+                                                        </div>
+                                                    </div>
+                                                    <mat-progress-bar mode="indeterminate" *ngIf="!dataSourceContactsListAutocomplete && !initAutoCompleteContact"></mat-progress-bar>
+                                                    <mat-table #tableContactList [dataSource]="dataSourceContactsListAutocomplete" *ngIf="dataSourceContactsListAutocomplete">
+                                                        <ng-container matColumnDef="select">
+                                                            <mat-header-cell *matHeaderCellDef style="flex:1;">
+                                                                <mat-checkbox color="primary" (change)="$event ? masterToggle($event) : null" [checked]="selection.hasValue()">
+                                                                </mat-checkbox>
+                                                            </mat-header-cell>
+                                                            <mat-cell *matCellDef="let element" style="flex:1;">
+                                                                <mat-checkbox id="check_{{element.addressId}}" color="primary" (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(element.addressId) : null"
+                                                                    [disabled]="isInGrp(element)" [checked]="selection.isSelected(element.addressId)">
+                                                                </mat-checkbox>
+                                                            </mat-cell>
+                                                        </ng-container>
+                                                        <ng-container matColumnDef="contact">
+                                                            <mat-header-cell *matHeaderCellDef style="flex:3;">{{lang.contact}}</mat-header-cell>
+                                                            <mat-cell *matCellDef="let element" style="flex:3;"> {{element.contact}} </mat-cell>
+                                                        </ng-container>
+                                                        <ng-container matColumnDef="address">
+                                                            <mat-header-cell *matHeaderCellDef style="flex:3;">{{lang.address}}</mat-header-cell>
+                                                            <mat-cell *matCellDef="let element" style="flex:3;"> {{element.address}} </mat-cell>
+                                                        </ng-container>
+                                                        <mat-header-row *matHeaderRowDef="displayedColumnsContactsListAutocomplete"></mat-header-row>
+                                                        <mat-row *matRowDef="let element; columns: displayedColumnsContactsListAutocomplete;" (click)="selectAddress(element.addressId);"
+                                                            [ngStyle]="{'opacity': !isInGrp(element) ? '' : '0.5'}" style="cursor: pointer;"></mat-row>
+                                                    </mat-table>
+                                                    <div class="form-group">
+                                                        <div style="text-align:center;margin-top:30px">
+                                                            <button mat-raised-button color="primary" type="button" (click)="saveContactsList($event.target)" [disabled]="this.selection.selected.length == 0">{{lang.add}}</button>
+                                                        </div>
+                                                    </div>
+                                                </div>
+                                            </mat-expansion-panel>
+                                        </mat-accordion>
+                                        <div id="contactsGroup" style="margin-top:20px;">
+                                            <div class="col-sm-6">
+                                                <form class="form-horizontal" (ngSubmit)="updateGroupSubmit()" #contactsGroupFormUp="ngForm">
+                                                    <div class="form-group">
+                                                        <div class="col-sm-12">
+                                                            <mat-form-field>
+                                                                <input matInput [(ngModel)]="contactsGroup.label" required name="label" id="label" title="{{lang.label}}" type="text" placeholder="{{lang.label}}"
+                                                                    maxlength="32">
+                                                            </mat-form-field>
+                                                        </div>
+                                                    </div>
+                                                    <div class="form-group">
+                                                        <div class="col-sm-12">
+                                                            <mat-form-field>
+                                                                <input matInput [(ngModel)]="contactsGroup.description" required name="description" id="description" title="{{lang.description}}"
+                                                                    type="text" placeholder="{{lang.description}}" maxlength="255">
+                                                            </mat-form-field>
+                                                        </div>
+                                                    </div>
+                                                    <div class="form-group">
+                                                        <div class="col-sm-12" style="text-align:center;">
+                                                            <button mat-raised-button color="primary" type="submit" [disabled]="!contactsGroupFormUp.form.valid">{{lang.update}}</button>
+                                                            <button mat-raised-button color="default" type="button" (click)="initGroupsContact()">{{lang.close}}</button>
+                                                        </div>
+                                                    </div>
+                                                </form>
+                                            </div>
+                                            <div class="col-sm-6" *ngIf="contactsListMode">
+                                                <mat-tab-group [(selectedIndex)]="selectedTabIndex_1">
+                                                    <mat-tab label="{{lang.relatedContacts}}">
+                                                        <div class="row" style="margin:0px;">
+                                                            <div class="col-md-6 col-xs-6">
+                                                                <mat-form-field>
+                                                                    <input matInput (keyup)="applyFilterContactsList($event.target.value)" placeholder="{{lang.filterBy}}">
+                                                                </mat-form-field>
+                                                            </div>
+                                                            <div class="col-md-6 col-xs-6">
+                                                                <mat-paginator #paginatorContactsList [length]="0" [pageSize]="10">
+                                                                </mat-paginator>
+                                                            </div>
+                                                        </div>
+                                                        <mat-table *ngIf="contactsListMode" #tableContactsListSort="matSort" [dataSource]="dataSourceContactsList" matSort matSortActive="contact"
+                                                            matSortDirection="asc">
+                                                            <ng-container matColumnDef="contact">
+                                                                <mat-header-cell *matHeaderCellDef mat-sort-header style="flex:3;">{{lang.contact}}</mat-header-cell>
+                                                                <mat-cell *matCellDef="let element" style="flex:3;"> {{element.contact}} </mat-cell>
+                                                            </ng-container>
+                                                            <ng-container matColumnDef="address">
+                                                                <mat-header-cell *matHeaderCellDef mat-sort-header style="flex:3;">{{lang.address}}</mat-header-cell>
+                                                                <mat-cell *matCellDef="let element" style="flex:3;"> {{element.address}} </mat-cell>
+                                                            </ng-container>
+                                                            <ng-container matColumnDef="actions">
+                                                                <mat-header-cell *matHeaderCellDef style="flex:1;"></mat-header-cell>
+                                                                <mat-cell *matCellDef="let element;let i = index" style="justify-content: flex-end;flex:1;">
+                                                                    <button mat-icon-button color="warn" matTooltip="{{lang.delete}}" (click)="$event.stopPropagation();preDelete(i)">
+                                                                        <mat-icon class="fa fa-trash-alt fa-2x" aria-hidden="true"></mat-icon>
+                                                                    </button>
+                                                                </mat-cell>
+                                                            </ng-container>
+                                                            <mat-header-row *matHeaderRowDef="displayedColumnsContactsList"></mat-header-row>
+                                                            <mat-row *matRowDef="let element; columns: displayedColumnsContactsList;"></mat-row>
+                                                        </mat-table>
+                                                    </mat-tab>
+                                                </mat-tab-group>
+                                            </div>
+                                        </div>
+                                    </mat-tab>
+                                </mat-tab-group>
                                 <div style="clear:both;"></div>
                             </mat-expansion-panel>
                         </mat-accordion>
diff --git a/apps/maarch_entreprise/js/angular/app/profile.component.ts b/apps/maarch_entreprise/js/angular/app/profile.component.ts
index d08c6fffdd6..1c335fc04e9 100755
--- a/apps/maarch_entreprise/js/angular/app/profile.component.ts
+++ b/apps/maarch_entreprise/js/angular/app/profile.component.ts
@@ -74,6 +74,7 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit {
     selectedSignatureLabel: string = "";
     loading: boolean = false;
     selectedIndex: number = 0;
+    selectedIndexContactsGrp: number = 0;
 
     @ViewChild('snav2') sidenav: MatSidenav;
 
@@ -255,6 +256,7 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit {
 
     initGroupsContact() {
         this.contactsListMode = false;
+        this.selectedIndexContactsGrp = 0;
         this.http.get(this.coreUrl + 'rest/contactsGroups')
             .subscribe((data) => {
                 this.contactsGroups = [];
@@ -282,6 +284,7 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit {
         this.http.post(this.coreUrl + 'rest/contactsGroups', this.contactsGroup)
             .subscribe((data: any) => {
                 this.initGroupsContact();
+                this.toggleAddGrp();
                 this.notify.success(this.lang.contactsGroupAdded);
             }, (err) => {
                 this.notify.error(err.error.errors);
@@ -303,6 +306,7 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit {
         if (r) {
             this.http.delete(this.coreUrl + 'rest/contactsGroups/' + contactsGroup.id)
                 .subscribe(() => {
+                    this.contactsListMode = false;
                     var lastElement = this.contactsGroups.length - 1;
                     this.contactsGroups[row] = this.contactsGroups[lastElement];
                     this.contactsGroups[row].position = row;
@@ -332,8 +336,8 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit {
                     this.dataSourceContactsList = new MatTableDataSource(this.contactsGroup.contacts);
                     this.dataSourceContactsList.paginator = this.paginatorContactsList;
                     this.dataSourceContactsList.sort = this.sortContactsList;
+                    this.selectedIndexContactsGrp = 1;
                 }, 0);
-
             });
     }
 
@@ -877,4 +881,18 @@ export class ProfileComponent extends AutoCompletePlugin implements OnInit {
     hideActions(basket:any){
         $j('#'+basket.basket_id+'_'+basket.group_id).hide();
     }
+
+    toggleAddGrp() {
+        this.initGroupsContact();
+        $j('#contactsGroupFormUp').toggle();
+        $j('#contactsGroupList').toggle();
+    }
+    toggleAddContactGrp() {
+        $j('#contactsGroupFormAdd').toggle();
+        //$j('#contactsGroup').toggle();
+    }
+
+    changeTabContactGrp(event:any) {
+        this.selectedIndexContactsGrp = event;
+    }
 }
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-en.ts b/apps/maarch_entreprise/js/angular/lang/lang-en.ts
index 78f9c50c442..ea6a27af5ed 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-en.ts
+++ b/apps/maarch_entreprise/js/angular/lang/lang-en.ts
@@ -609,5 +609,7 @@ export const LANG_EN = {
     "searchMails"                       : "Search mails",
     "noAvailableBasket"                 : "No available basket",
     "othersBaskets"                     : "Others baskets",
-
+    "close"                             : "Close",
+    "contactGroupCreate"                : "Create contact group",
+    "contactLink"                       : "Link contact",
 };
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
index f89663a3976..d66c948f644 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
+++ b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
@@ -636,5 +636,7 @@ export const LANG_FR = {
     "searchMails"                       : "Rechercher des courriers",
     "noAvailableBasket"                 : "Aucune bannette disponible",
     "othersBaskets"                     : "Autres bannettes",
-
+    "close"                             : "Fermer",
+    "contactGroupCreate"                : "Créer un groupement de contact",
+    "contactLink"                       : "Associer un contact",
 };
-- 
GitLab