From 2b2f481523141c6a022b8b35d55c28c481083ff2 Mon Sep 17 00:00:00 2001 From: Alex Orluc <alex.orluc@maarch.org> Date: Fri, 25 May 2018 23:46:30 +0200 Subject: [PATCH] FEAT #7738 update profil with material front --- .../Views/profile.component.html | 762 +++++++++--------- .../css/profile.component.css | 59 +- .../administration/administration.module.ts | 25 +- .../js/angular/app/app-common.module.ts | 50 ++ .../js/angular/app/app.module.ts | 13 +- .../js/angular/app/profile.component.ts | 252 +++--- 6 files changed, 580 insertions(+), 581 deletions(-) create mode 100644 apps/maarch_entreprise/js/angular/app/app-common.module.ts diff --git a/apps/maarch_entreprise/Views/profile.component.html b/apps/maarch_entreprise/Views/profile.component.html index d628a3e050c..2b32012e1aa 100755 --- a/apps/maarch_entreprise/Views/profile.component.html +++ b/apps/maarch_entreprise/Views/profile.component.html @@ -1,350 +1,339 @@ -<div *ngIf="loading"> - <i class="fa fa-spinner fa-spin fa-5x" style="margin-left: 50%;margin-top: 16%;font-size: 8em"></i> -</div> -<div *ngIf="!loading" class="container-fluid"> - <h1 style="margin-top: 0"> - <i class="fa fa-user fa-2x"></i> {{lang.myProfile}}</h1> - <nav class="navbar navbar-default" id="toolBox"> - <div class="container-fluid"> - <div class="navbar-header"> - <a class="navbar-brand" href="index.php" style="cursor: pointer"> - <i class="fa fa-arrow-circle-left" title="{{lang.back}}"></i> +<div class="admin-container" [class.admin-is-mobile]="mobileQuery.matches"> + <mat-toolbar color="primary" class="admin-toolbar"> + <button mat-button (click)="snav.toggle()"> + <mat-icon class="maarchLogo" [svgIcon]="mobileQuery.matches ? 'maarchLogoOnly' : 'maarchLogo'"></mat-icon> + </button> + <h1 class="admin-toolbar-title">{{lang.myProfile}} + <small [class.hide-for-mobile]="mobileQuery.matches">{{user.firstname}} {{user.lastname}}</small> + </h1> + <span style="flex: 1 1 auto;"></span> + <menu-top></menu-top> + <button mat-icon-button (click)="snav2.toggle()" *ngIf="!creationMode"> + <mat-icon class="fa fa-cog 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" + [opened]="mobileQuery.matches ? false : true"> + <menu-nav></menu-nav> + <mat-divider></mat-divider> + <mat-nav-list> + <h3 mat-subheader>{{lang.actions}}</h3> + <a mat-list-item (click)="askRedirectBasket()"> + <mat-icon color="warn" mat-list-icon class="fa fa-plane"></mat-icon> + <p mat-line> + Activer mon absence + </p> </a> + <a mat-list-item (click)="changePasswd();"> + <mat-icon color="primary" mat-list-icon class="fa fa-key"></mat-icon> + <p mat-line> + Modifier mon mot de passe + </p> + </a> + </mat-nav-list> + <mat-divider></mat-divider> + </mat-sidenav> + <mat-sidenav-content> + <div *ngIf="loading" style="display:flex;height:100%;"> + <mat-spinner style="margin:auto;"></mat-spinner> </div> - <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> - <ul class="nav navbar-nav navbar-right"> - <li style="cursor: pointer"> - <a data-toggle="modal" data-target="#managePreferences"> - <i class="fa fa-cog"></i> Préférences </a> - </li> - <li style="cursor: pointer"> - <a data-toggle="modal" data-target="#manageSign"> - <i class="fa fa-address-card"></i> {{lang.manageSignatures}} </a> - </li> - <li style="cursor: pointer" (click)="displayAbsenceButton=false"> - <a data-toggle="modal" data-target="#manageAbs" id="redirectBasketCard"> - <i class="fa fa-share"></i> {{lang.manageAbsences}} </a> - </li> - <li style="cursor: pointer"> - <a data-toggle="modal" data-target="#manageHistory" (click)="getHistories()"> - <i class="fa fa-history"></i> {{lang.history}} </a> - </li> - <li style="cursor: pointer"> - <a (click)="askRedirectBasket()"> - <i class="fa fa-user-times"></i> Activer mon absence </a> - </li> - </ul> - </div> - </div> - </nav> - <div class="row row-eq-height"> - <div class="col-md-3" style="border-left:solid 1px white;border-right:solid 1px white;background-color: #F2F2F2;border-top: solid 2px #F99830;border-bottom: solid 2px #F99830;padding:10px;"> - <h2>{{lang.groups}}</h2> - <ul class="list-group"> - <li class="list-group-item" *ngFor="let group of user.groups"> - <i class="fa fa-users"></i> {{group.group_desc}} - </li> - </ul> - </div> - <div class="col-md-4 col-md-offset-1" style="border-left:solid 1px white;border-right:solid 1px white;background-color: #F2F2F2;border-top: solid 2px #F99830;border-bottom: solid 2px #F99830;padding:10px;"> - <h2>{{lang.informations}}</h2> - <form class="form-horizontal" (ngSubmit)="onSubmit()" #profileForm="ngForm"> - <div class="form-group"> - <div class="col-sm-5" style="font-weight:bold;"> - <input type="text" class="form-control" id="lastname" name="lastname" title="{{lang.lastname}}" placeholder="{{lang.lastname}}" - [(ngModel)]="user.lastname" required> - </div> - <div class="col-sm-5" style="font-weight:bold;"> - <input type="text" class="form-control" id="firstname" name="firstname" title="{{lang.firstname}}" placeholder="{{lang.firstname}}" - [(ngModel)]="user.firstname" required> - </div> - <div class="col-sm-2" style="font-style:italic;"> - <input type="text" class="form-control" id="initials" name="initials" title="{{lang.initials}}" placeholder="{{lang.initials}}" - [(ngModel)]="user.initials"> - </div> - </div> - <div class="form-group"> - <div class="col-sm-12"> - <div class="input-group"> - <span class="input-group-addon"> - <i class="fa fa-user" aria-hidden="true"></i> - </span> - <input type="text" class="form-control" id="userId" title="{{lang.id}}" value="{{user.user_id}}" disabled> - <span *ngIf="user.canModifyPassword" class="input-group-btn"> - <button (click)="displayPassword()" class="btn btn-success" type="button" title="{{lang.changeMyPassword}}"> - <i class="fa fa-key" aria-hidden="true"></i> - </button> - </span> - </div> - </div> - </div> - <div *ngIf="showPassword" style="margin-bottom: 5%"> - <div class="form-group"> - <div class="col-sm-12"> - <div class="input-group"> - <span class="input-group-addon"> - <i class="fa fa-key" aria-hidden="true"></i> - </span> - <input type="password" class="form-control" style="display: none"> - <input type="password" [(ngModel)]="passwordModel.currentPassword" class="form-control" name="currentPassword" placeholder="{{lang.currentPsw}}"> + <mat-card *ngIf="!loading" class="card-app-content"> + <mat-tab-group [selectedIndex]="selectedIndex" (selectedTabChange)="initComponents($event)"> + <mat-tab label="Mes informations"> + <div *ngIf="showPassword" style="margin-bottom: 5%"> + <div class="form-group"> + <mat-form-field> + <input matInput type="password" [(ngModel)]="passwordModel.currentPassword" name="currentPassword" placeholder="{{lang.currentPsw}}"> + </mat-form-field> </div> - </div> - </div> - <div class="form-group"> - <div class="col-sm-6"> - <div class="input-group"> - <span class="input-group-addon"> - <i class="fa fa-key" aria-hidden="true"></i> - </span> - <input type="password" [(ngModel)]="passwordModel.newPassword" class="form-control" name="newPassword" placeholder="{{lang.newPsw}}"> + <div class="form-group"> + <div class="col-sm-6"> + <mat-form-field> + <input matInput type="password" [(ngModel)]="passwordModel.newPassword" name="newPassword" placeholder="{{lang.newPsw}}"> + </mat-form-field> + </div> + <div class="col-sm-6"> + <mat-form-field> + <input matInput type="password" [(ngModel)]="passwordModel.reNewPassword" name="reNewPassword" placeholder="{{lang.renewPsw}}"> + </mat-form-field> + </div> </div> - </div> - <div class="col-sm-6"> - <div class="input-group"> - <span class="input-group-addon"> - <i class="fa fa-key" aria-hidden="true"></i> - </span> - <input type="password" [(ngModel)]="passwordModel.reNewPassword" class="form-control" name="reNewPassword" placeholder="{{lang.renewPsw}}"> + <div class="form-group"> + <div style="text-align:center;"> + <button mat-raised-button color="primary" type="button" (click)="updatePassword()" [disabled]="!passwordModel.currentPassword || !passwordModel.newPassword || !passwordModel.reNewPassword || (passwordModel.newPassword != passwordModel.reNewPassword)">{{lang.update}}</button> + <button mat-raised-button color="default" type="button" (click)="showPassword=false">{{lang.cancel}}</button> + </div> </div> </div> - </div> - <div class="form-group"> - <div style="text-align:center;"> - <button type="button" (click)="updatePassword()" [disabled]="!passwordModel.currentPassword || !passwordModel.newPassword || !passwordModel.reNewPassword || (passwordModel.newPassword != passwordModel.reNewPassword)" - class="btn btn-default">{{lang.changeMyPassword}}</button> - </div> - </div> - <hr style="background-color: grey; height: 1px"> - </div> - <div class="form-group"> - <div class="col-sm-12"> - <div class="input-group"> - <span class="input-group-addon"> - <i class="fa fa-phone" aria-hidden="true"></i> - </span> - <input type="tel" class="form-control" id="phone" name="phone" title="{{lang.phoneNumber}}" placeholder="{{lang.phoneNumber}}" - [(ngModel)]="user.phone" pattern="^(?:0|\+\d\d?\d?\s?)[1-9]([\.\-\s]?\d\d){4}([\.\-\s]?\d?\d?)$"> - </div> - </div> - </div> - <div class="form-group"> - <div class="col-sm-12"> - <div class="input-group"> - <span class="input-group-addon"> - <i class="fa fa-envelope" aria-hidden="true"></i> - </span> - <input type="email" class="form-control" id="mail" name="mail" title="{{lang.email}}" placeholder="{{lang.email}}" [(ngModel)]="user.mail" - pattern="(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"> - </div> - - </div> - </div> - <div class="form-group"> - <div class="col-sm-12"> - <div class="input-group"> - <span class="input-group-addon"> - <i class="fa fa-paw" aria-hidden="true"></i> - </span> - <input type="text" class="form-control" id="fingerprint" name="fingerprint" title="{{lang.fingerprint}}" placeholder="{{lang.fingerprint}}" - [(ngModel)]="user.thumbprint"> - </div> - </div> - </div> - <div class="form-group"> - <div style="text-align:center;"> - <button type="submit" class="btn btn-success" [disabled]="!profileForm.form.valid">{{lang.save}}</button> - </div> - </div> - </form> - </div> - <div class="col-md-3 col-md-offset-1" style="border-left:solid 1px white;border-right:solid 1px white;background-color: #F2F2F2;border-top: solid 2px #F99830;border-bottom: solid 2px #F99830;padding:10px;"> - <h2>{{lang.entities}}</h2> - <ul class="list-group"> - <li class="list-group-item" *ngFor="let entity of user.entities"> - <i class="fa fa-sitemap"></i> {{entity.entity_label}} - <span *ngIf="entity.primary_entity == 'Y'" class="label label-primary">{{lang.primaryEntity}}</span> - <span *ngIf="entity.primary_entity != 'Y'" class="label label-default">{{lang.secondaryEntity}}</span> - </li> - </ul> - </div> - </div> -</div> - -<div id="managePreferences" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"> - <div class="modal-dialog modal-lg" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">×</span> - </button> - <h4 class="modal-title">Préférences</h4> - </div> - <div class="modal-body"> - <ul class="nav nav-tabs" role="tablist"> - <li role="presentation" class="active"> - <a href="#manageBaskets" aria-controls="manageBaskets" role="tab" data-toggle="tab">Gérer mes bannettes</a> - </li> - </ul> - <div class="tab-content"> - <div role="tabpanel" class="tab-pane active" id="manageBaskets" style="max-height: calc(85vh - 200px);overflow-y: auto;"> - <ul class="list-group" *ngFor="let regroupedBasket of user.regroupedBaskets; let i = index"> - <h4 *ngIf="regroupedBasket.baskets[0]">{{regroupedBasket.groupDesc}}</h4> - <li class="list-group-item" *ngFor="let basket of regroupedBasket.baskets; let y = index"> - <i class="fa fa-tasks" title="{{basket.basket_id}}"></i> {{basket.basket_name}} - <span class="pull-right"> - <input name="color" type="color" style="background: none;border: none;height: 20px;width:20px;padding: 0;margin-right: 15px" - [(ngModel)]="user.regroupedBaskets[i].baskets[y].color" (change)="updateBasketColor(i, y)" - /> - <a (click)="user.regroupedBaskets[i].baskets[y].color = ''; updateBasketColor(i, y)" title="Réinitialiser la couleur" style="cursor: pointer;color: #666666"> - <i class="fa fa-magic"></i> - </a> - </span> - </li> - </ul> - </div> - </div> - </div> - </div> - </div> -</div> - -<div id="manageAbs" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"> - <div class="modal-dialog modal-lg" role="document" style="width: 55%"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">×</span> - </button> - <h4 class="modal-title" id="myModalLabel">Rediriger mes bannettes</h4> - </div> - <div class="modal-body" style="max-height: calc(100vh - 170px);overflow-y: auto;"> - <nav class="navbar navbar-default"> - <div class="container-fluid"> - <form class="navbar-form navbar-left" style="width: 100%"> - <div style="margin-left: 3%;padding-top: 15px">Ctrl + Clic pour sélectionner plusieurs bannettes</div> - <div class="form-group" style="margin-left: 3%;width: 66%;"> - <select style="height: 150px;width: 84%;" id="selectBasketAbsenceUser" class="form-control" multiple name="basketsToRedirect" - [(ngModel)]="basketsToRedirect"> - <option *ngFor="let basket of user.baskets; let i = index" [disabled]="basket.disabled" [value]="i" title="{{basket.basket_name}} {{basket.userToDisplay ? '('+basket.userToDisplay+')' : ''}}"> - {{basket.basket_name}} - <span *ngIf="basket.userToDisplay">({{basket.userToDisplay}})</span> - </option> - </select> - <span style="margin-left: 25px; margin-right: 12px">vers</span> - </div> - <div class="form-group typeahead__container" style="width: 28%"> - <div class="typeahead__field" style="width: 100%"> - <input id="absenceUser" type="text" class="form-control" placeholder="{{lang.user}}" autocomplete="off" style="width: 100%"> + <form class="form-horizontal" (ngSubmit)="onSubmit()" #profileForm="ngForm" *ngIf="!showPassword"> + <div class="form-group"> + <div class="col-sm-12"> + <div class="pull-left"> + <div class="avatar" style="font-size:90px;text-align:center;"> + <i class="fa fa-user" style="font-size:90px;padding-top:5px;"></i> + </div> + </div> + <div class="input-group"> + <mat-form-field> + <input matInput type="text" title="{{lang.id}}" value="{{user.user_id}}" placeholder="{{lang.id}}" disabled> + </mat-form-field> + </div> </div> </div> - </form> - </div> - <div style="padding: 15px;text-align: center"> - En validant, les modifications de redirection des bannettes sont automatiquement enregistrées - <br> - <br> - <button type="button" (click)="addBasketRedirection()" class="btn btn-success">Valider</button> - </div> - </nav> - <ul class="list-group"> - <li class="list-group-item" *ngFor="let basket of user.redirectedBaskets"> - <i class="fa fa-tasks" title="{{basket.basket_id}}"></i> {{basket.basket_name}} - <span class="pull-right"> - <span class="label label-primary" title="{{basket.userIdRedirection}}">{{basket.userToDisplay}}</span> - <a (click)="delBasketRedirection(basket)" style="cursor: pointer" title="Supprimer la redirection"> - <i class="fa fa-trash-alt fa-lg" style="color:red;"></i> - </a> - </span> - </li> - </ul> - <span *ngIf="displayAbsenceButton"> - <hr> - <div style="padding-bottom: 10px;text-align: center"> - <button type="button" (click)="activateAbsence()" class="btn btn-warning"> - <i class="fa fa-user-times"></i> Activer mon absence</button> - </div> - </span> - - </div> - </div> - </div> -</div> - -<div id="manageSign" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"> - <div class="modal-dialog modal-lg" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">×</span> - </button> - <h4 class="modal-title">{{lang.manageSignatures}}</h4> - </div> - <div class="modal-body"> - <ul class="nav nav-tabs" role="tablist"> - <li role="presentation" class="active"> - <a href="#mailSign" aria-controls="mailSign" role="tab" data-toggle="tab">{{lang.emailSignatures}}</a> - </li> - <li role="presentation"> - <a href="#signatureBookSign" aria-controls="signatureBookSign" role="tab" data-toggle="tab">{{lang.sbSignatures}}</a> - </li> - </ul> - <div class="tab-content"> - <div role="tabpanel" class="tab-pane active" id="mailSign"> - <form (ngSubmit)="submitEmailSignature()" #emailSignatureForm="ngForm"> - <div class="row" style="margin-top:5px;"> - <div class="col-md-5"> - <select id="emailSignaturesSelect" class="form-control" (change)="changeEmailSignature()"> - <option>{{lang.newSignature}}</option> - <option *ngFor="let emailSignature of user.emailSignatures">{{emailSignature.title}}</option> - </select> + <div class="form-group"> + <div class="col-sm-5" style="font-weight:bold;"> + <mat-form-field> + <input matInput type="text" id="lastname" name="lastname" title="{{lang.lastname}}" placeholder="{{lang.lastname}}" [(ngModel)]="user.lastname" + required> + </mat-form-field> </div> - <div class="col-md-5"> - <input type="text" [(ngModel)]="mailSignatureModel.title" name="title" placeholder="{{lang.label}}" class="form-control" - required> + <div class="col-sm-5" style="font-weight:bold;"> + <mat-form-field> + <input matInput type="text" id="firstname" name="firstname" title="{{lang.firstname}}" placeholder="{{lang.firstname}}" [(ngModel)]="user.firstname" + required> + </mat-form-field> </div> - <div class="col-md-1 col-md-offset-1" *ngIf="mailSignatureModel.selected == 0"> - <button type="submit" class="form-control btn btn-sm btn-success" [disabled]="!emailSignatureForm.form.valid"> - <i class="fa fa-plus"></i> - </button> + <div class="col-sm-2" style="font-style:italic;"> + <mat-form-field> + <input matInput type="text" id="initials" name="initials" title="{{lang.initials}}" placeholder="{{lang.initials}}" [(ngModel)]="user.initials"> + </mat-form-field> </div> - <div class="col-md-1" *ngIf="mailSignatureModel.selected > 0"> - <button type="button" class="form-control btn btn-sm btn-success" (click)="updateEmailSignature()" [disabled]="!emailSignatureForm.form.valid" - title="{{lang.update}}"> - <i class="fa fa-pencil-alt"></i> - </button> + </div> + <div class="form-group"> + <div class="col-sm-12"> + <mat-form-field> + <input matInput type="tel" id="phone" name="phone" title="{{lang.phoneNumber}}" placeholder="{{lang.phoneNumber}}" [(ngModel)]="user.phone" + pattern="^(?:0|\+\d\d?\d?\s?)[1-9]([\.\-\s]?\d\d){4}([\.\-\s]?\d?\d?)$"> + </mat-form-field> </div> - <div class="col-md-1" *ngIf="mailSignatureModel.selected > 0"> - <button type="button" class="form-control btn btn-sm btn-danger" (click)="deleteEmailSignature()" title="{{lang.delete}}"> - <i class="fa fa-trash-alt"></i> - </button> + </div> + <div class="form-group"> + <div class="col-sm-12"> + <mat-form-field> + <input matInput type="email" id="mail" name="mail" title="{{lang.email}}" placeholder="{{lang.email}}" [(ngModel)]="user.mail" + pattern="(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)" required> + </mat-form-field> </div> </div> - <div class="row" style="margin-top:5px;"> - <div class="col-md-12"> - <div id="html_mode" style="display: block; width:100%;"> - <textarea name="emailSignature" id="emailSignature" style="width:100%" rows="15" cols="60"></textarea> + <mat-accordion> + <mat-expansion-panel> + <mat-expansion-panel-header> + <mat-panel-title style="color: rgba(0,0,0,0.54);"> + {{lang.otherInformations}} + </mat-panel-title> + </mat-expansion-panel-header> + <div class="form-group"> + <div class="col-sm-12"> + <mat-form-field> + <input matInput type="text" id="fingerprint" name="fingerprint" title="{{lang.fingerprint}}" placeholder="{{lang.fingerprint}}" + [(ngModel)]="user.thumbprint"> + </mat-form-field> + </div> </div> + </mat-expansion-panel> + </mat-accordion> + <div class="form-group" style="margin-top: 10px;"> + <div style="text-align:center;"> + <button mat-raised-button color="primary" *ngIf="creationMode" type="submit" [disabled]="!profileForm.form.valid">{{lang.save}}</button> + <button mat-raised-button color="primary" *ngIf="!creationMode" type="submit" [disabled]="!profileForm.form.valid">{{lang.update}}</button> </div> </div> </form> - </div> - <div role="tabpanel" class="tab-pane" id="signatureBookSign"> - <div class="row" style="margin-top:5px;"> + </mat-tab> + <mat-tab label="Mes préférences"> + <mat-accordion> + <mat-expansion-panel [expanded]="true"> + <mat-expansion-panel-header> + <mat-panel-title> + Couleur des bannettes + </mat-panel-title> + <mat-panel-description> + Gérer vos couleurs de bannettes + </mat-panel-description> + </mat-expansion-panel-header> + + <mat-list> + <ng-container *ngFor="let regroupedBasket of user.regroupedBaskets; let i = index"> + <h3 *ngIf="regroupedBasket.baskets[0]">{{regroupedBasket.groupDesc}}</h3> + <mat-list-item *ngFor="let basket of regroupedBasket.baskets; let y = index"> + <mat-icon mat-list-icon class="fa fa-inbox" [ngStyle]="{'color': user.regroupedBaskets[i].baskets[y].color}"></mat-icon> + <h4 mat-line title="{{basket.basket_id}}">{{basket.basket_name}}</h4> + <input name="color" type="color" style="background: none;border: none;height: 20px;width:20px;padding: 0;margin-right: 15px" + [(ngModel)]="user.regroupedBaskets[i].baskets[y].color" (change)="updateBasketColor(i, y)" + /> + <a (click)="user.regroupedBaskets[i].baskets[y].color = ''; updateBasketColor(i, y)" title="Réinitialiser la couleur" style="cursor: pointer;color: #666666"> + <i class="fa fa-magic"></i> + </a> + </mat-list-item> + </ng-container> + </mat-list> + </mat-expansion-panel> + </mat-accordion> + </mat-tab> + <mat-tab label="Mes bannettes"> + <div class="col-sm-6" style="overflow:hidden;"> + <mat-list> + <ng-container *ngFor="let basket of user.baskets;let i = index"> + <mat-list-item *ngIf="basket.group_id && basket.userToDisplay == ''"> + <mat-icon mat-list-icon color="primary" *ngIf="basket.enabled" style="margin-top:-70px;"> + </mat-icon> + <h4 mat-line [ngStyle]="{'opacity': basket.allowed ? '1' : '0.5'}" [attr.color]="basket.userToDisplay != '' ? 'primary': ''">{{basket.basket_name}} + <span class="label label-primary" style="font-weight:normal">{{basket.group_desc}}</span> + </h4> + <p mat-line [ngStyle]="{'opacity': basket.allowed ? '1' : '0.5'}"> + <mat-form-field *ngIf="basket.allowed" floatLabel="never"> + <input matTooltip="{{lang.redirectWhenAbscence}}" matTooltipPosition="above" type="text" placeholder="{{ lang.userToRedirect }}" + matInput [matAutocomplete]="auto" [formControl]="userCtrl" [disabled]="!basket.allowed"> + <mat-autocomplete #auto="matAutocomplete"> + <mat-option *ngFor="let user of filteredUsers | async" [value]="user.id" (click)="addBasketRedirection(user.id,basket)"> + <p mat-line matTooltip="{{ user.otherInfo }}"> + <span class="col-xm-1"> + <mat-icon color="primary" class="fa fa-user fa-2x" style="margin-right:0px;"></mat-icon> + </span> + <span class="col-xm-11"> + {{ user.idToDisplay }} + <small>{{ user.otherInfo }}</small> + </span> + </p> + </mat-option> + </mat-autocomplete> + </mat-form-field> + <mat-form-field> + <input type="text" color="warn" matInput disabled value=""> + </mat-form-field> + </p> + </mat-list-item> + </ng-container> + </mat-list> + </div> + <div class="col-sm-6" style="overflow:hidden;"> + <mat-list> + <h4>{{lang.basketsRedirected}}</h4> + <mat-divider></mat-divider> + <div style="margin-top:40px"> + <ng-container *ngFor="let basket of user.baskets;let i = index"> + <mat-list-item *ngIf="basket.group_id && basket.userToDisplay != ''"> + <mat-icon mat-list-icon color="primary" *ngIf="basket.enabled" style="margin-top:-60px;" class="fa fa-paper-plane"> + </mat-icon> + <h4 mat-line [ngStyle]="{'opacity': basket.allowed ? '1' : '0.5'}" [attr.color]="basket.userToDisplay != '' ? 'primary': ''">{{basket.basket_name}} + <span class="label label-primary" style="font-weight:normal">{{basket.group_id}}</span> + </h4> + <p mat-line [ngStyle]="{'opacity': basket.allowed ? '1' : '0.5'}"> + <mat-form-field> + <input type="text" color="warn" matInput disabled value="{{lang.redirectedTo}} {{basket.userToDisplay}}"> + <button mat-button color="warn" matSuffix mat-icon-button aria-label="Clear" (click)="delBasketRedirection(basket)" matTooltip="Supprimer la redirection"> + <mat-icon color="warn" class="fa fa-times text-danger"></mat-icon> + </button> + </mat-form-field> + </p> + </mat-list-item> + </ng-container> + </div> + + <h4>{{lang.basketsAssigned}}</h4> + <mat-divider></mat-divider> + <div style="margin-top:40px"> + <ng-container *ngFor="let basket of user.baskets;let i = index"> + <mat-list-item *ngIf="!basket.group_id"> + <mat-icon mat-list-icon color="primary" style="margin-top:-60px;" class="fa fa-reply"> + </mat-icon> + <h4 mat-line [attr.color]="basket.userToDisplay != '' ? 'primary': ''">{{basket.basket_name}} + <span class="label label-primary" style="font-weight:normal">{{basket.group_id}}</span> + </h4> + <p mat-line> + <mat-form-field *ngIf="basket.userToDisplay == ''" floatLabel="never"> + <input matTooltip="{{lang.redirectBasket}}" matTooltipPosition="above" type="text" placeholder="{{lang.userToRedirect}}" + matInput [matAutocomplete]="auto" [formControl]="userCtrl"> + <mat-autocomplete #auto="matAutocomplete"> + <mat-option *ngFor="let user of filteredUsers | async" [value]="user.id" (click)="reassignBasketRedirection(user.id,basket)"> + <p mat-line matTooltip="{{ user.otherInfo }}"> + <span class="col-xm-1"> + <mat-icon color="primary" class="fa fa-user fa-2x" style="margin-right:0px;"></mat-icon> + </span> + <span class="col-xm-11"> + {{ user.idToDisplay }} + <small>{{ user.otherInfo }}</small> + </span> + </p> + </mat-option> + </mat-autocomplete> + </mat-form-field> + <mat-form-field> + <input type="text" color="warn" matInput disabled value="{{lang.assignBy}} {{basket.userToDisplay}}"> + <button mat-button color="warn" matSuffix mat-icon-button aria-label="Clear" (click)="basket.userToDisplay =''" matTooltip="{{lang.reassign}}"> + <mat-icon color="primary" class="fa fa-edit"></mat-icon> + </button> + <button mat-button color="warn" matSuffix mat-icon-button aria-label="Clear" (click)="delBasketRedirection(basket)" matTooltip="{{lang.deleteAssignation}}"> + <mat-icon color="warn" class="fa fa-times text-danger"></mat-icon> + </button> + </mat-form-field> + </p> + </mat-list-item> + </ng-container> + </div> + + </mat-list> + </div> + </mat-tab> + <mat-tab label="Mes signatures (courriel)"> + <div class="col-sm-6" style="overflow:hidden;"> + <form (ngSubmit)="submitEmailSignature()" #emailSignatureForm="ngForm"> + <div class="row" style="margin-top:5px;"> + <div class="col-md-12"> + <mat-form-field> + <input matInput type="text" [(ngModel)]="mailSignatureModel.title" name="title" placeholder="{{lang.label}}" required> + </mat-form-field> + </div> + </div> + <div class="row" style="margin-top:5px;"> + <div class="col-md-12"> + <div id="html_mode" style="display: block; width:100%;"> + <textarea name="emailSignature" id="emailSignature" style="width:100%" rows="15" cols="60"></textarea> + </div> + </div> + </div> + <div class="col-md-12 form-group" style="margin-top: 10px;"> + <div style="text-align:center;"> + <button mat-raised-button color="primary" type="submit" *ngIf="mailSignatureModel.selected==-1" [disabled]="!emailSignatureForm.form.valid">{{lang.save}}</button> + <button mat-raised-button color="primary" type="button" *ngIf="mailSignatureModel.selected!=-1" (click)="updateEmailSignature()" + [disabled]="!emailSignatureForm.form.valid">{{lang.update}}</button> + <button mat-raised-button color="warn" type="button" *ngIf="mailSignatureModel.selected!=-1" (click)="deleteEmailSignature()">{{lang.delete}}</button> + <button mat-raised-button color="default" type="button" *ngIf="mailSignatureModel.selected!=-1" (click)="resetEmailSignature()">{{lang.cancel}}</button> + </div> + </div> + </form> + </div> + <div class="col-sm-6" style="overflow:hidden;"> + <div class="col-md-6 col-sm-6 col-xm-12" *ngFor="let emailSignature of user.emailSignatures; let i = index"> + <mat-card style="margin-bottom:10px;"> + <mat-card-content style="text-align:center;"> + <mat-form-field floatLabel="never"> + <input matInput type="text" [(ngModel)]="emailSignature.title" name="selectedEmailSignatureLabel" placeholder="{{lang.label}}" + disabled> + </mat-form-field> + <button mat-raised-button (click)="changeEmailSignature(i)"> + <mat-icon class="fa fa-envelope fa-2x"></mat-icon> + </button> + </mat-card-content> + </mat-card> + </div> + </div> + </mat-tab> + <mat-tab label="Mes signatures (parapheur)"> + <div class="col-sm-6" style="overflow:hidden;"> <form (ngSubmit)="submitSignature()" #signatureForm="ngForm"> - <div class="col-md-11"> - <input type="text" [(ngModel)]="signatureModel.label" id="signLabel" name="label" placeholder="{{lang.label}}" class="form-control" - required> + <div class="col-md-12"> + <mat-form-field> + <input matInput type="text" id="signature_label" name="signature_label" title="{{lang.label}}" placeholder="{{lang.label}}" + [(ngModel)]="signatureModel.label" required> + </mat-form-field> <div class="form-inline hide"> <div class="form-group"> <input type="file" name="files[]" id="uploadSignFile" (change)="uploadSignatureTrigger($event)" accept="image/*"> </div> </div> </div> - <div class="col-md-1" style="margin-bottom:5px;"> - <button class="form-control btn btn-sm btn-success" type="submit" [disabled]="!signatureForm.form.valid || !signatureModel.size"> - <i class="fa fa-plus"></i> - </button> - </div> <div [ngClass]="[signatureModel.size != '' ? 'col-md-10' : 'col-md-12']"> <div class="upload-drop-zone" (click)="clickOnUploader('uploadSignFile')" style="cursor:pointer"> {{lang.clickOn}} @@ -355,67 +344,42 @@ <div class="col-md-2" *ngIf="signatureModel.size"> <img id="signaturePreview" src="{{signatureModel.base64ForJs}}" alt="Image non valide" style="width: 100%;"> </div> + <div class="col-md-12 form-group" style="margin-top: 10px;"> + <div style="text-align:center;"> + <button mat-raised-button color="primary" type="submit" [disabled]="!signatureForm.form.valid || !signatureModel.size">{{lang.save}}</button> + </div> + </div> </form> </div> - <div class="row" id="signList"> - <div *ngFor="let signature of user.signatures; let i = index" class="col-md-3"> - <div class="thumbnail"> - <img src="{{coreUrl}}rest/users/{{user.id}}/signatures/{{signature.id}}" alt="Signature" style="width:auto;height:60px;"> - <div class="caption" style="margin-bottom:0px;"> - <div *ngIf="selectedSignature != i"> - <p title="{{signature.signature_label}}" style="text-overflow: ellipsis;">{{signature.signature_label}}</p> - <a (click)="displaySignatureEditionForm(i)" class="btn btn-primary" role="button" title="{{lang.update}}"> - <i class="fa fa-edit"></i> - </a> - <a (click)="deleteSignature(signature.id)" class="btn btn-danger" role="button" title="{{lang.delete}}"> - <i class="fa fa-trash-alt"></i> - </a> - </div> - <div *ngIf="selectedSignature == i"> - <input type="text" [(ngModel)]="selectedSignatureLabel" name="selectedSignatureLabel" placeholder="{{lang.label}}" class="form-control" - style="margin-bottom: 10px; font-size: 12px;height:28px"> - <button (click)="updateSignature()" type="button" class="btn btn-success" [disabled]="!selectedSignatureLabel" title="{{lang.update}}"> - <i class="fa fa-check"></i> - </button> - <button (click)="selectedSignature = -1" type="button" class="btn btn-warning" title="{{lang.back}}"> - <i class="fa fa-times"></i> + <div class="col-sm-6" style="overflow:hidden;"> + <div class="col-md-6 col-sm-6 col-xm-12" *ngFor="let signature of user.signatures; let i = index"> + <mat-card style="margin-bottom:10px;"> + <mat-card-content style="text-align:center;"> + <mat-form-field floatLabel="never"> + <input matInput type="text" [(ngModel)]="signature.signature_label" name="selectedSignatureLabel" placeholder="{{lang.label}}" + (change)="updateSignature(signature)"> + <button mat-button matSuffix mat-icon-button (click)="deleteSignature(signature.id)" color="warn" matTooltip="{{lang.delete}}"> + <mat-icon class="fa fa-times"></mat-icon> </button> - </div> - </div> - </div> + </mat-form-field> + <img src="{{coreUrl}}rest/users/{{user.id}}/signatures/{{signature.id}}" alt="Signature" style="max-width:100%;height:60px;"> + </mat-card-content> + </mat-card> </div> </div> - </div> - </div> - </div> - </div> - </div> - </div> - - <div id="manageHistory" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"> - <div class="modal-dialog modal-lg" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">×</span> - </button> - <h4 class="modal-title">{{lang.history}}</h4> - </div> - <div class="modal-body" style="height: 70vh"> - <div class="example-container"> - <mat-grid-list cols="3" rowHeight="100px"> - <mat-grid-tile> - <mat-paginator #paginator [length]="100" [pageSize]="10"> - </mat-paginator> - </mat-grid-tile> - <mat-grid-tile> - </mat-grid-tile> - <mat-grid-tile> + </mat-tab> + <mat-tab label="Mon historique"> + <div class="row"> + <div class="col-md-6 col-xs-6"> <mat-form-field> <input matInput (keyup)="applyFilter($event.target.value)" placeholder="{{lang.filterBy}}"> </mat-form-field> - </mat-grid-tile> - </mat-grid-list> + </div> + <div class="col-md-6 col-xs-6"> + <mat-paginator #paginator [length]="100" [pageSize]="10"> + </mat-paginator> + </div> + </div> <mat-table #table [dataSource]="dataSource" matSort matSortActive="event_date" matSortDirection="desc"> <ng-container matColumnDef="event_date"> <mat-header-cell *matHeaderCellDef mat-sort-header>{{lang.date}}</mat-header-cell> @@ -428,8 +392,48 @@ <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> </mat-table> - </div> - </div> - </div> - </div> + </mat-tab> + </mat-tab-group> + </mat-card> + </mat-sidenav-content> + <mat-sidenav #snav2 [mode]="mobileQuery.matches ? 'over' : 'side'" [fixedInViewport]="mobileQuery.matches" fixedTopGap="56" + position='end' [opened]="mobileQuery.matches ? false : true" style="overflow-x:hidden;max-width:500px;"> + + <mat-list> + <h3 mat-subheader>{{lang.groups}}</h3> + <mat-list-item *ngFor="let userGroup of user.groups"> + <mat-icon color="primary" mat-list-icon class="fa fa-users"></mat-icon> + <h4 mat-line>{{userGroup.group_desc}}</h4> + <p mat-line> + <mat-form-field style="font-size:10px;"> + <input matInput type="text" id="role" name="role" title="{{lang.role}}" placeholder="{{lang.role}}" [(ngModel)]="userGroup.role" + disabled> + <mat-hint matTooltip="{{lang.perimeter}}">{{userGroup.maarch_comment}}</mat-hint> + </mat-form-field> + </p> + </mat-list-item> + <mat-divider></mat-divider> + <h3 mat-subheader>{{lang.entities}}</h3> + <mat-list-item *ngFor="let userEntity of user.entities"> + <mat-icon color="primary" *ngIf="userEntity.primary_entity == 'Y'" mat-list-icon class="fa fa-sitemap"></mat-icon> + <mat-icon color="primary" *ngIf="userEntity.primary_entity != 'Y'" mat-list-icon class="fa fa-sitemap" style="position:relative;"> + <button mat-icon-button style="cursor:pointer;position: absolute;right: -20px;top: -20px;font-size:10px;" (click)="updatePrimaryEntity(userEntity)" + matTooltip="{{lang.entityTooglePrimary}}"> + <mat-icon class="fa fa-arrow-up"></mat-icon> + </button> + </mat-icon> + <h4 mat-line [ngStyle]="{'font-weight': userEntity.primary_entity == 'Y' ? 'bold' : 'normal'}" matTooltip="{{userEntity.entity_label}}"> + {{userEntity.entity_label}} + <span *ngIf="userEntity.primary_entity == 'Y'" class="label label-primary" style="font-weight:normal">{{lang.primary}}</span> + </h4> + <p mat-line> + <mat-form-field style="font-size:10px;"> + <input matInput type="text" id="role" name="role" title="{{lang.role}}" placeholder="{{lang.role}}" [(ngModel)]="userEntity.user_role" + disabled> + </mat-form-field> + </p> + </mat-list-item> + </mat-list> + </mat-sidenav> + </mat-sidenav-container> </div> \ No newline at end of file diff --git a/apps/maarch_entreprise/css/profile.component.css b/apps/maarch_entreprise/css/profile.component.css index ec1a5e4c16c..e8b596532c7 100755 --- a/apps/maarch_entreprise/css/profile.component.css +++ b/apps/maarch_entreprise/css/profile.component.css @@ -1,28 +1,4 @@ -h1 { - margin-top:-5px !important; -} - -#toolBox { - margin-top:15px; -} - -h2{ - background-color: #135F7F !important; - color: white !important; - margin-top: -10px !important; - margin-left: -10px !important; - margin-right: -10px !important; - padding: 10px !important; - font-size: 16px !important; -} - -.col-md-4,.col-md-3{ - margin-bottom: 10px; -} -.ng-invalid:not(form) { - border-left: 5px solid #a94442; -} /* layout.css Style */ .upload-drop-zone { font-size: 16px; @@ -43,26 +19,15 @@ h2{ color: #222; border-color: #222; } - #signList { - overflow-x:scroll; - overflow-y:hidden; - white-space:nowrap; - margin-right: 0px !important; - margin-left: 0px !important; -} -#signList [class*="col-lg"], #signList [class*="col-md"], #signList [class*="col-sm"] { - float:none; - display:inline-block; - white-space:normal; - vertical-align:top; -} -.caption p{ - white-space: nowrap; - overflow: hidden; -} -.form-control.btn-success[disabled]{ - background-color: #5cb85c; -} -.form-control.btn-primary[disabled]{ - background-color: #286090; -} + +.avatar { + text-decoration:none; + background:#135f7f; + color:white; + width:100px; + height:100px; + border-radius:5px; + display:block; + overflow:hidden; + margin: 5px; +} \ No newline at end of file diff --git a/apps/maarch_entreprise/js/angular/app/administration/administration.module.ts b/apps/maarch_entreprise/js/angular/app/administration/administration.module.ts index 5c9b9d23a14..eac9eee682e 100755 --- a/apps/maarch_entreprise/js/angular/app/administration/administration.module.ts +++ b/apps/maarch_entreprise/js/angular/app/administration/administration.module.ts @@ -1,14 +1,13 @@ import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { HttpClientModule } from '@angular/common/http'; + +import { SharedModule } from '../app-common.module'; import { SortPipe } from '../../plugins/sorting.pipe'; -import { MenuComponent } from '../menu/menu.component'; -import { MenuNavComponent } from '../menu/menu-nav.component'; -import { MenuTopComponent } from '../menu/menu-top.component'; -import { AppMaterialModule } from '../app-material.module'; +//import { MenuComponent } from '../menu/menu.component'; +//import { MenuNavComponent } from '../menu/menu-nav.component'; +//import { MenuTopComponent } from '../menu/menu-top.component'; + import { AdministrationRoutingModule } from './administration-routing.module'; import { AdministrationComponent } from './administration.component'; @@ -43,17 +42,13 @@ import { DocserversAdministrationComponent } from './docservers-admin @NgModule({ imports: [ - CommonModule, - FormsModule, - ReactiveFormsModule, - HttpClientModule, - AppMaterialModule, + SharedModule, AdministrationRoutingModule ], declarations: [ - MenuComponent, - MenuNavComponent, - MenuTopComponent, + //MenuComponent, + //MenuNavComponent, + //MenuTopComponent, AdministrationComponent, UsersAdministrationComponent, UserAdministrationComponent, diff --git a/apps/maarch_entreprise/js/angular/app/app-common.module.ts b/apps/maarch_entreprise/js/angular/app/app-common.module.ts new file mode 100644 index 00000000000..47cada73d6a --- /dev/null +++ b/apps/maarch_entreprise/js/angular/app/app-common.module.ts @@ -0,0 +1,50 @@ +import { CommonModule } from '@angular/common'; + +import { NgModule } from '@angular/core'; + +/*CORE IMPORTS*/ +import { BrowserModule } from '@angular/platform-browser'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { HttpClientModule } from '@angular/common/http'; +import { RouterModule } from '@angular/router'; + +/*FRONT IMPORTS*/ +import { AppMaterialModule } from './app-material.module'; + +/*MENU COMPONENT*/ +import { MenuComponent } from './menu/menu.component'; +import { MenuNavComponent } from './menu/menu-nav.component'; +import { MenuTopComponent } from './menu/menu-top.component'; + + +@NgModule({ + imports: [ + CommonModule, + BrowserModule, + BrowserAnimationsModule, + FormsModule, + HttpClientModule, + RouterModule, + AppMaterialModule, + ], + declarations: [ + MenuComponent, + MenuNavComponent, + MenuTopComponent + ], + exports: [ + CommonModule, + MenuComponent, + MenuNavComponent, + MenuTopComponent, + BrowserModule, + BrowserAnimationsModule, + FormsModule, + ReactiveFormsModule, + HttpClientModule, + RouterModule, + AppMaterialModule + ] +}) +export class SharedModule { } diff --git a/apps/maarch_entreprise/js/angular/app/app.module.ts b/apps/maarch_entreprise/js/angular/app/app.module.ts index d4a6e49773c..71ac7c732c4 100755 --- a/apps/maarch_entreprise/js/angular/app/app.module.ts +++ b/apps/maarch_entreprise/js/angular/app/app.module.ts @@ -1,9 +1,6 @@ import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { FormsModule } from '@angular/forms'; -import { HttpClientModule } from '@angular/common/http'; -import { AppMaterialModule } from './app-material.module'; + +import { SharedModule } from './app-common.module'; import { CustomSnackbarComponent } from './notification.service'; import { ConfirmModalComponent } from './confirmModal.component'; @@ -18,13 +15,9 @@ import { SaveNumericPackageComponent } from './save-numeric-package.com @NgModule({ imports: [ - BrowserModule, - BrowserAnimationsModule, - FormsModule, - HttpClientModule, + SharedModule, AdministrationModule, AppRoutingModule, - AppMaterialModule ], declarations: [ AppComponent, diff --git a/apps/maarch_entreprise/js/angular/app/profile.component.ts b/apps/maarch_entreprise/js/angular/app/profile.component.ts index b819ebf333e..860ba12696b 100755 --- a/apps/maarch_entreprise/js/angular/app/profile.component.ts +++ b/apps/maarch_entreprise/js/angular/app/profile.component.ts @@ -1,8 +1,11 @@ -import { Component, OnInit, NgZone, ViewChild } from '@angular/core'; +import { ChangeDetectorRef, Component, OnInit, NgZone, ViewChild } 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 { MatPaginator, MatTableDataSource, MatSort } from '@angular/material'; +import { MatPaginator, MatTableDataSource, MatSort, MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; + +import { AutoCompletePlugin } from '../plugins/autocomplete.plugin'; declare function $j(selector: any) : any; @@ -15,8 +18,11 @@ declare var angularGlobals : any; styleUrls : ['../../../css/profile.component.css'], providers : [NotificationService] }) -export class ProfileComponent implements OnInit { +export class ProfileComponent extends AutoCompletePlugin implements OnInit { + private _mobileQueryListener : () => void; + mobileQuery : MediaQueryList; + dialogRef : MatDialogRef<any>; coreUrl : string; lang : any = LANG; @@ -38,7 +44,7 @@ export class ProfileComponent implements OnInit { label : "", }; mailSignatureModel : any = { - selected : 0, + selected : -1, htmlBody : "", title : "", }; @@ -49,7 +55,7 @@ export class ProfileComponent implements OnInit { selectedSignature : number = -1; selectedSignatureLabel : string = ""; loading : boolean = false; - displayAbsenceButton : boolean = false; + selectedIndex : number = 0; displayedColumns = ['event_date','info']; dataSource = new MatTableDataSource(this.histories); @@ -62,16 +68,12 @@ export class ProfileComponent implements OnInit { } - constructor(public http: HttpClient, private zone: NgZone, private notify: NotificationService) { - if ($j("link[href='merged_css.php']").length == 0) { - var head = document.getElementsByTagName('head')[0]; - var link = document.createElement('link'); - link.rel = 'stylesheet'; - link.href = 'merged_css.php'; - link.type = 'text/css'; - link.media = 'screen'; - head.insertBefore(link,head.children[5]) - } + constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, public http: HttpClient, private zone: NgZone, private notify: NotificationService, public dialog: MatDialog) { + super(http, ['users']); + $j("link[href='merged_css.php']").remove(); + this.mobileQuery = media.matchMedia('(max-width: 768px)'); + this._mobileQueryListener = () => changeDetectorRef.detectChanges(); + this.mobileQuery.addListener(this._mobileQueryListener); window['angularProfileComponent'] = { componentAfterUpload: (base64Content: any) => this.processAfterUpload(base64Content), }; @@ -88,46 +90,59 @@ export class ProfileComponent implements OnInit { if ($j('#content h1')[0] && $j('#content h1')[0] != $j('my-app h1')[0]) { $j('#content h1')[0].remove(); } - - //LOAD EDITOR TINYMCE for MAIL SIGN - tinymce.baseURL = "../../node_modules/tinymce"; - tinymce.suffix = '.min'; - tinymce.init({ - selector: "textarea#emailSignature", - statusbar : false, - language : "fr_FR", - language_url: "tools/tinymce/langs/fr_FR.js", - height : "200", - plugins: [ - "textcolor" - ], - external_plugins: { - 'bdesk_photo': "../../apps/maarch_entreprise/tools/tinymce/bdesk_photo/plugin.min.js" - }, - menubar: false, - toolbar: "undo | bold italic underline | alignleft aligncenter alignright | bdesk_photo | forecolor", - theme_buttons1_add : "fontselect,fontsizeselect", - theme_buttons2_add_before : "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator", - theme_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor", - theme_buttons3_add_before : "tablecontrols,separator", - theme_buttons3_add : "separator,print,separator,ltr,rtl,separator,fullscreen,separator,insertlayer,moveforward,movebackward,absolut", - theme_toolbar_align : "left", - theme_advanced_toolbar_location : "top", - theme_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1" - - }); - } - updateBreadcrumb(applicationName: string) { - if ($j('#ariane')[0]) { - $j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > Profil"; + initComponents(event:any) { + if (event.index == 5) { + if (this.histories.length == 0) { + this.http.get(this.coreUrl + 'rest/histories/users/' + this.user.id) + .subscribe((data : any) => { + this.histories = data.histories; + setTimeout(() => { + this.dataSource = new MatTableDataSource(this.histories); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + }, 0); + }, (err) => { + this.notify.error(err.error.errors); + }); + } + } else if (event.index == 3) { + console.log('fuck'); + tinymce.remove('textarea'); + //LOAD EDITOR TINYMCE for MAIL SIGN + tinymce.baseURL = "../../node_modules/tinymce"; + tinymce.suffix = '.min'; + tinymce.init({ + selector: "textarea#emailSignature", + statusbar : false, + language : "fr_FR", + language_url: "tools/tinymce/langs/fr_FR.js", + height : "200", + plugins: [ + "textcolor" + ], + external_plugins: { + 'bdesk_photo': "../../apps/maarch_entreprise/tools/tinymce/bdesk_photo/plugin.min.js" + }, + menubar: false, + toolbar: "undo | bold italic underline | alignleft aligncenter alignright | bdesk_photo | forecolor", + theme_buttons1_add : "fontselect,fontsizeselect", + theme_buttons2_add_before : "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator", + theme_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor", + theme_buttons3_add_before : "tablecontrols,separator", + theme_buttons3_add : "separator,print,separator,ltr,rtl,separator,fullscreen,separator,insertlayer,moveforward,movebackward,absolut", + theme_toolbar_align : "left", + theme_advanced_toolbar_location : "top", + theme_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1" + + }); } + } ngOnInit(): void { this.prepareProfile(); - this.updateBreadcrumb(angularGlobals.applicationName); this.coreUrl = angularGlobals.coreUrl; this.loading = true; @@ -144,21 +159,6 @@ export class ProfileComponent implements OnInit { } }); }); - setTimeout(() => { - $j("#absenceUser").typeahead({ - order: "asc", - display: "idToDisplay", - templateValue: "{{id}}", - source: { - ajax: { - type: "GET", - dataType: "json", - url: this.coreUrl + "rest/autocomplete/users", - } - } - }); - }, 0); - this.loading = false; }); } @@ -215,79 +215,71 @@ export class ProfileComponent implements OnInit { this.selectedSignatureLabel = this.user.signatures[index].signature_label; } - changeEmailSignature() { - var index = $j("#emailSignaturesSelect").prop("selectedIndex"); - this.mailSignatureModel.selected = index; + changeEmailSignature(i:any) { + this.mailSignatureModel.selected = i; - if (index > 0) { - tinymce.get('emailSignature').setContent(this.user.emailSignatures[index - 1].html_body); - this.mailSignatureModel.title = this.user.emailSignatures[index - 1].title; - } else { - tinymce.get('emailSignature').setContent(""); - this.mailSignatureModel.title = ""; - } + tinymce.get('emailSignature').setContent(this.user.emailSignatures[i].html_body); + this.mailSignatureModel.title = this.user.emailSignatures[i].title; } - addBasketRedirection() { - if (typeof this.basketsToRedirect[0] != 'undefined' && $j("#absenceUser")[0].value) { - var redirectModel :any[] = []; - - this.basketsToRedirect.forEach((value: any) => { - redirectModel.push({ - "basketId" : this.user.baskets[value].basket_id, - "basketName" : this.user.baskets[value].basket_name, - "virtual" : this.user.baskets[value].is_virtual, - "basketOwner" : this.user.baskets[value].basket_owner, - "newUser" : $j("#absenceUser")[0].value, - }); - }); + resetEmailSignature() { + this.mailSignatureModel.selected = -1; + + tinymce.get('emailSignature').setContent(""); + this.mailSignatureModel.title = ""; + + } - this.http.post(this.coreUrl + 'rest/users/' + this.user.id + '/redirectedBaskets', redirectModel) + addBasketRedirection(newUser:any, basket: any) { + let r = confirm(this.lang.confirmAction + ' ' + this.lang.redirectBasket); + + if (r) { + this.http.post(this.coreUrl + "rest/users/" + this.user.id + "/redirectedBaskets", [{"newUser" : newUser, "basketId":basket.basket_id, "basketOwner":this.user.user_id, "virtual": basket.is_virtual}]) .subscribe((data: any) => { - $j('#selectBasketAbsenceUser option').prop('selected', false); - $j("#absenceUser")[0].value = ""; - this.basketsToRedirect = []; - - this.user.redirectedBaskets = data["redirectedBaskets"]; - this.user.baskets.forEach((value: any, index: number) => { - this.user.baskets[index]['disabled'] = false; - this.user.redirectedBaskets.forEach((value2: any) => { - if (value.basket_id == value2.basket_id && value.basket_owner == value2.basket_owner) { - this.user.baskets[index]['disabled'] = true; - } - }); - }); + this.userCtrl.setValue(''); + this.user.baskets = data["baskets"]; + this.notify.success(this.lang.basketUpdated); }, (err) => { this.notify.error(err.error.errors); }); - } else { - this.notify.error("Veuillez sélectionner au moins une bannette et un utilisateur"); } } delBasketRedirection(basket: any) { - this.http.request('DELETE', this.coreUrl + "rest/users/" + this.user.id + "/redirectedBaskets/" + basket.basket_id, {body : {"basketOwner" : basket.basket_owner}}) - .subscribe((data: any) => { - this.user.redirectedBaskets = data["redirectedBaskets"]; - this.user.baskets.forEach((value: any, index: number) => { - this.user.baskets[index]['disabled'] = false; - this.user.redirectedBaskets.forEach((value2: any) => { - if (value.basket_id == value2.basket_id && value.basket_owner == value2.basket_owner) { - this.user.baskets[index]['disabled'] = true; - } - }); + let r = confirm(this.lang.confirmAction); + + if (r) { + this.http.request('DELETE', this.coreUrl + "rest/users/" + this.user.id + "/redirectedBaskets/"+ basket.basket_id, {body : {"basketOwner":basket.basket_owner}}) + .subscribe((data: any) => { + this.userCtrl.setValue(''); + this.user.baskets = data["baskets"]; + this.notify.success(this.lang.basketUpdated); + }, (err) => { + this.notify.error(err.error.errors); }); + } + } - this.notify.success(this.lang.modificationSaved); - }, (err) => { - this.notify.error(err.error.errors); - }); + reassignBasketRedirection(newUser:any, basket: any) { + let r = confirm(this.lang.confirmAction + ' ' + this.lang.redirectBasket); + + if (r) { + this.http.post(this.coreUrl + "rest/users/" + this.user.id + "/redirectedBaskets", [{"newUser" : newUser, "basketId":basket.basket_id, "basketOwner":basket.basket_owner, "virtual": basket.is_virtual}]) + .subscribe((data: any) => { + this.userCtrl.setValue(''); + this.user.baskets = data["baskets"]; + this.notify.success(this.lang.basketUpdated); + }, (err) => { + this.notify.error(err.error.errors); + }); + } } updateBasketColor(i: number, y: number) { this.http.put(this.coreUrl + "rest/currentUser/groups/" + this.user.regroupedBaskets[i].groupId + "/baskets/" + this.user.regroupedBaskets[i].baskets[y].basket_id, {"color" : this.user.regroupedBaskets[i].baskets[y].color}) .subscribe((data: any) => { this.user.regroupedBaskets = data.userBaskets; + this.notify.success(this.lang.modificationSaved); }, (err) => { this.notify.error(err.error.errors); }); @@ -311,7 +303,7 @@ export class ProfileComponent implements OnInit { let r = confirm('Voulez-vous rediriger vos bannettes avant de vous mettre en absence ?'); if (r) { - this.displayAbsenceButton = true; + this.selectedIndex = 2; $j('#redirectBasketCard').click(); } else { this.activateAbsence(); @@ -343,7 +335,7 @@ export class ProfileComponent implements OnInit { } else { this.user.emailSignatures = data.emailSignatures; this.mailSignatureModel = { - selected : 0, + selected : -1, htmlBody : "", title : "", }; @@ -355,15 +347,15 @@ export class ProfileComponent implements OnInit { updateEmailSignature() { this.mailSignatureModel.htmlBody = tinymce.get('emailSignature').getContent(); - var id = this.user.emailSignatures[this.mailSignatureModel.selected - 1].id; + var id = this.user.emailSignatures[this.mailSignatureModel.selected].id; this.http.put(this.coreUrl + 'rest/currentUser/emailSignature/' + id, this.mailSignatureModel) .subscribe((data : any) => { if (data.errors) { this.notify.error(data.errors); } else { - this.user.emailSignatures[this.mailSignatureModel.selected - 1].title = data.emailSignature.title; - this.user.emailSignatures[this.mailSignatureModel.selected - 1].html_body = data.emailSignature.html_body; + this.user.emailSignatures[this.mailSignatureModel.selected].title = data.emailSignature.title; + this.user.emailSignatures[this.mailSignatureModel.selected].html_body = data.emailSignature.html_body; this.notify.success(this.lang.emailSignatureUpdated); } }); @@ -373,7 +365,7 @@ export class ProfileComponent implements OnInit { let r = confirm('Voulez-vous vraiment supprimer la signature de mail ?'); if (r) { - var id = this.user.emailSignatures[this.mailSignatureModel.selected - 1].id; + var id = this.user.emailSignatures[this.mailSignatureModel.selected].id; this.http.delete(this.coreUrl + 'rest/currentUser/emailSignature/' + id) .subscribe((data : any) => { @@ -382,7 +374,7 @@ export class ProfileComponent implements OnInit { } else { this.user.emailSignatures = data.emailSignatures; this.mailSignatureModel = { - selected : 0, + selected : -1, htmlBody : "", title : "", }; @@ -411,14 +403,9 @@ export class ProfileComponent implements OnInit { }); } - updateSignature() { - var id = this.user.signatures[this.selectedSignature].id; - - this.http.put(this.coreUrl + "rest/users/" + this.user.id + "/signatures/" + id, {"label" : this.selectedSignatureLabel}) + updateSignature(signature:any) { + this.http.put(this.coreUrl + "rest/users/" + this.user.id + "/signatures/" + signature.id, {"label" : signature.signature_label}) .subscribe((data : any) => { - this.user.signatures[this.selectedSignature].signature_label = data.signature.signature_label; - this.selectedSignature = -1; - this.selectedSignatureLabel = ""; this.notify.success(this.lang.signatureUpdated); }, (err) => { this.notify.error(err.error.errors); @@ -463,4 +450,9 @@ export class ProfileComponent implements OnInit { this.notify.error(err.error.errors); }); } + + changePasswd() { + this.selectedIndex = 0; + this.showPassword=true; + } } -- GitLab