From c63353f5b9b8e56f06a3f9d319b43d7d1ee22a15 Mon Sep 17 00:00:00 2001
From: Alex Orluc <alex.orluc@maarch.org>
Date: Fri, 30 Mar 2018 23:41:08 +0200
Subject: [PATCH] improve display difflist in entities

---
 .../Views/entities-administration.component.html  | 14 ++++++++------
 .../css/entities-administration.component.css     | 15 +++++++++++++++
 .../entities-administration.component.ts          |  1 +
 apps/maarch_entreprise/js/angular/lang/lang-en.ts |  3 +++
 apps/maarch_entreprise/js/angular/lang/lang-fr.ts |  3 +++
 5 files changed, 30 insertions(+), 6 deletions(-)
 create mode 100755 apps/maarch_entreprise/css/entities-administration.component.css

diff --git a/apps/maarch_entreprise/Views/entities-administration.component.html b/apps/maarch_entreprise/Views/entities-administration.component.html
index 38235a3177a..b37e946b290 100644
--- a/apps/maarch_entreprise/Views/entities-administration.component.html
+++ b/apps/maarch_entreprise/Views/entities-administration.component.html
@@ -48,6 +48,8 @@
 
                 <mat-form-field>
                     <input matInput id="jstree_search" name="jstree_search" type="text" placeholder="{{lang.searchEntities}}">
+                    <mat-hint *ngIf="!creationMode">{{lang.entityTreeInfo}}</mat-hint>
+                    <mat-hint *ngIf="creationMode">{{lang.entityTreeInfoCreation}}</mat-hint>
                 </mat-form-field>
                 <div id="jstree"></div>
 
@@ -215,8 +217,8 @@
                                     <input #autocompleteFilter type="text" placeholder="{{lang.addUserOrEntity}}" matInput [matAutocomplete]="auto" [formControl]="elementCtrl">
                                     <mat-autocomplete #auto="matAutocomplete">
                                         <mat-option *ngFor="let elem of filteredElements | async" [value]="elem.id" (click)="addElemListModel(elem)">
-                                            <p mat-line>
-                                                <span class="col-xm-1">
+                                            <p mat-line style="margin:0;">
+                                                <span class="col-xm-1" style="padding-right:5px;">
                                                     <mat-icon color="primary" [class]="elem.type == 'entity' ? 'fa fa-sitemap fa-2x' : 'fa fa-user fa-2x'" style="margin-right:0px;"></mat-icon>
                                                 </span>
                                                 <span class="col-xm-11">
@@ -232,10 +234,10 @@
                                         <h3 *ngIf="role.available" mat-subheader style="font-weight:bold;" color="primary">{{role.label}}</h3>
                                         <span *ngIf="role.available" dnd-sortable-container [dropZones]="['boxers-zone']" [sortableData]="currentEntity.listTemplate[role.id]">
                                             <div style="min-height:30px;">
-                                                <mat-list-item disableRipple="true" *ngFor="let template of currentEntity.listTemplate[role.id]; let i = index" title="{{lang.move}}"
+                                                <mat-list-item class="roleDiffList" disableRipple="true" *ngFor="let template of currentEntity.listTemplate[role.id]; let i = index"
                                                     dnd-sortable (onDropSuccess)="updateDiffList(template,role.id)" [sortableIndex]="i"
                                                     [dragEnabled]="role.id != 'dest' && template.item_type != 'entity_id'">
-                                                    <mat-icon color="primary" mat-list-icon [class]="template.item_type == 'entity_id' ? 'fa fa-sitemap' : 'fa fa-user'"></mat-icon>
+                                                    <mat-icon color="primary" mat-list-icon [class]="template.item_type == 'entity_id' ? 'fa fa-sitemap' : 'fa fa-user'" [title]="role.id != 'dest' && template.item_type != 'entity_id' ? lang.move : lang.noMove"></mat-icon>
                                                     <p mat-line>{{template.labelToDisplay}}
                                                         <small style="opacity:0.5;">{{template.descriptionToDisplay}}</small>
                                                     </p>
@@ -263,8 +265,8 @@
                                     <input #autocompleteFilter type="text"  placeholder="{{lang.addVisaSignUser}}" matInput [matAutocomplete]="auto" [formControl]="userCtrl">
                                     <mat-autocomplete #auto="matAutocomplete">
                                         <mat-option *ngFor="let elem of filteredUsers | async" [value]="elem.id" (click)="addElemListModelVisa(elem);autocompleteFilter.isOpen=true">
-                                            <p mat-line *ngIf="elem.type == 'user'">
-                                                <span class="col-xm-1">
+                                            <p mat-line *ngIf="elem.type == 'user'" style="margin:0;">
+                                                <span class="col-xm-1" style="padding-right:5px;">
                                                     <mat-icon color="primary" class="fa fa-user fa-2x" style="margin-right:0px;"></mat-icon>
                                                 </span>
                                                 <span class="col-xm-11">
diff --git a/apps/maarch_entreprise/css/entities-administration.component.css b/apps/maarch_entreprise/css/entities-administration.component.css
new file mode 100755
index 00000000000..bd3247a5c48
--- /dev/null
+++ b/apps/maarch_entreprise/css/entities-administration.component.css
@@ -0,0 +1,15 @@
+.mat-list-item[draggable="false"]:hover{
+    background: inherit;
+}
+
+.mat-list-item[draggable="false"]{
+    cursor: not-allowed !important;
+}
+
+.mat-list-item[draggable="true"]{
+    cursor: pointer;
+}
+
+.mat-list-item[draggable="true"] mat-icon{
+    cursor: move;
+}
\ No newline at end of file
diff --git a/apps/maarch_entreprise/js/angular/app/administration/entities-administration.component.ts b/apps/maarch_entreprise/js/angular/app/administration/entities-administration.component.ts
index d3230ab4f59..bc28a631402 100644
--- a/apps/maarch_entreprise/js/angular/app/administration/entities-administration.component.ts
+++ b/apps/maarch_entreprise/js/angular/app/administration/entities-administration.component.ts
@@ -15,6 +15,7 @@ declare var angularGlobals: any;
 
 @Component({
     templateUrl: "../../../../Views/entities-administration.component.html",
+    styleUrls: ['../../../../css/entities-administration.component.css'],
     providers: [NotificationService]
 })
 export class EntitiesAdministrationComponent extends AutoCompletePlugin implements OnInit {
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-en.ts b/apps/maarch_entreprise/js/angular/lang/lang-en.ts
index 1f30fa77c39..e214d18bd2d 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-en.ts
+++ b/apps/maarch_entreprise/js/angular/lang/lang-en.ts
@@ -108,6 +108,8 @@ export const LANG_EN = {
     "entityDeleted"                     : "Entité deleted",
     "entityFullName"                    : "Full name",
     "entityTooglePrimary"               : "Pass to primary entity",
+    "entityTreeInfo"                    : "Click on entity tree to access entity informations",
+    "entityTreeInfoCreation"            : "Click on entity tree to link the new entity to this",
     "entityType"                        : "Entity type",
     "entityUpdated"                     : "Entité updated",
     "entityReplacement"                 : "Entity replacement",
@@ -202,6 +204,7 @@ export const LANG_EN = {
     "no"                                : "No",
     "noAttachment"                      : "No attachment",
     "noEntity"                          : "No entity",
+    "noMove"                            : "This entity / user cannot be moved",
     "noReplacement"                     : "No replacement",
     "notes"                             : "Notes",
     "notificationAdded"                 : "Notification added",
diff --git a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
index ea82a7144d6..bd48a4b1768 100755
--- a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
+++ b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts
@@ -115,6 +115,8 @@ export const LANG_FR = {
     "entityDeleted"                     : "Entité supprimée",
     "entityFullName"                    : "Bloc arborescence",
     "entityTooglePrimary"               : "Passage en entité primaire",
+    "entityTreeInfo"                    : "Cliquez sur une entité de l'arborescence pour accéder à ses informations",
+    "entityTreeInfoCreation"            : "Cliquez sur une entité de l'arborescence pour associer la nouvelle entité à celle-ci",
     "entityType"                        : "Type d'entité",
     "entityUpdated"                     : "Entité modifiée",
     "entityReplacement"                 : "Remplacement de l'entité",
@@ -217,6 +219,7 @@ export const LANG_FR = {
     "no"                                : "Non",
     "noAttachment"                      : "Sans pièce jointe",
     "noEntity"                          : "Aucune entité",
+    "noMove"                            : "Cette entité / utilisateur ne peut pas être déplacé",
     "noRecord"                          : "Aucun élément",
     "noReplacement"                     : "Aucun remplacement",
     "noResult"                          : "Aucun résultat",
-- 
GitLab