diff --git a/src/frontend/app/actions/actions-list.component.html b/src/frontend/app/actions/actions-list.component.html index a196d2be05e478751528f52072b88f3c3d7527bd..35c2a18b49bb2ebcb3f1417908d7efbeda352eca 100644 --- a/src/frontend/app/actions/actions-list.component.html +++ b/src/frontend/app/actions/actions-list.component.html @@ -14,5 +14,5 @@ <span>{{action.label_action}}</span> </button> <mat-divider></mat-divider> - <folder-menu [resIds]="selectedRes" (refreshList)="refreshList()" (refreshFolders)="refreshFolders()"></folder-menu> + <folder-menu [resIds]="selectedRes" [currentFolders]="folderList" (refreshList)="refreshList()" (refreshFolders)="refreshFolders()"></folder-menu> </mat-menu> \ No newline at end of file diff --git a/src/frontend/app/actions/actions-list.component.ts b/src/frontend/app/actions/actions-list.component.ts index 72d43f38eb23da1cf7f6f05d73c76884350babd7..3d0d7372abade00f2c407f7e0c2c1107f9ab2301 100644 --- a/src/frontend/app/actions/actions-list.component.ts +++ b/src/frontend/app/actions/actions-list.component.ts @@ -45,6 +45,7 @@ export class ActionsListComponent implements OnInit { contextResId = 0; currentLock: any = null; arrRes: any[] = []; + folderList: any [] = []; actionsList: any[] = []; @@ -72,6 +73,8 @@ export class ActionsListComponent implements OnInit { this.contextMenuTitle = row.alt_identifier; this.contextResId = row.res_id; + this.folderList = row.folders !== undefined ? row.folders : []; + // Opens the menu this.contextMenu.openMenu(); diff --git a/src/frontend/app/folder/folder-action-list/folder-action-list.component.html b/src/frontend/app/folder/folder-action-list/folder-action-list.component.html index e9eb561dd0bfe4ca3e5d3dedb6755a19fc5d0348..5a8fa8bf3b1f8657e352dcbba644837a15ba8ac7 100644 --- a/src/frontend/app/folder/folder-action-list/folder-action-list.component.html +++ b/src/frontend/app/folder/folder-action-list/folder-action-list.component.html @@ -16,7 +16,7 @@ <mat-divider></mat-divider>--> <button mat-menu-item class="folderAction" (click)="unclassify()" [disabled]="selectedRes.length === 0"> <mat-icon class="fa fa-folder-minus fa-2x"></mat-icon> - <span>Retirer du dossier</span> + <span>{{lang.removeFromFolder}}</span> </button> <folder-menu [resIds]="selectedRes" (refreshFolders)="refreshFolders()"></folder-menu> </mat-menu> \ No newline at end of file diff --git a/src/frontend/app/folder/folder-menu/folder-menu.component.html b/src/frontend/app/folder/folder-menu/folder-menu.component.html index ad81d93c858e51baa644b88137b1b25467515f59..908e66b50e754a6d99959b9234524406d8af907f 100644 --- a/src/frontend/app/folder/folder-menu/folder-menu.component.html +++ b/src/frontend/app/folder/folder-menu/folder-menu.component.html @@ -1,7 +1,15 @@ +<button mat-menu-item [matMenuTriggerFor]="currentFolders" *ngIf="currentFoldersList !== undefined && currentFoldersList.length > 0" class="folderAction"> + <mat-icon color="warn" class="fa fa-folder-minus fa-2x"></mat-icon> + <span>{{lang.removeFromFolder}}...</span> +</button> +<mat-menu #currentFolders="matMenu" [class]="'folderListMenu'"> + <button mat-menu-item *ngFor="let currentfolder of currentFoldersList | sortBy : 'label'" class="labelFolder" (click)="unclassifyDocuments(currentfolder)" [title]="currentfolder.label"><i class="fa fa-users private" *ngIf="currentfolder.public" title="{{lang.sharedFolder}}"></i> {{currentfolder.label}}</button> +</mat-menu> <button mat-menu-item [matMenuTriggerFor]="folders" class="folderAction" (menuOpened)="getFolders()" [disabled]="resIds.length === 0"> - <mat-icon class="fa fa-folder-open fa-2x"></mat-icon> + <mat-icon color="primary" class="fa fa-folder-open fa-2x"></mat-icon> <span>{{lang.classifyIn}}</span> </button> <mat-menu #folders="matMenu" [class]="'folderListMenu'"> + <button *ngIf="foldersList.length === 0" mat-menu-item class="noFolder" disabled>{{lang.noAvailableFolder}}</button> <button mat-menu-item *ngFor="let folder of foldersList | sortBy : 'label'" class="labelFolder" (click)="classifyDocuments(folder)" [title]="folder.label"><i class="fa fa-users private" *ngIf="folder.public" title="{{lang.sharedFolder}}"></i> {{folder.label}}</button> </mat-menu> \ No newline at end of file diff --git a/src/frontend/app/folder/folder-menu/folder-menu.component.scss b/src/frontend/app/folder/folder-menu/folder-menu.component.scss index f56b9f085e46f08286e601216891fe7af462c3c4..5ec433d5b41c78a98397c2aba666895e9a8155c0 100644 --- a/src/frontend/app/folder/folder-menu/folder-menu.component.scss +++ b/src/frontend/app/folder/folder-menu/folder-menu.component.scss @@ -5,7 +5,6 @@ .mat-icon { font-size:20px; - color: $primary; } } @@ -21,4 +20,11 @@ ::ng-deep.folderListMenu { width: auto; +} + +.noFolder { + font-size: 12px; + color: rgb(102, 102, 102); + text-align: center; + font-style: italic; } \ No newline at end of file diff --git a/src/frontend/app/folder/folder-menu/folder-menu.component.ts b/src/frontend/app/folder/folder-menu/folder-menu.component.ts index ec2201468fed0f36adc031d042ba844a113a8746..c77708ba78f6aca1e4a12e7a4821e599a9319392 100644 --- a/src/frontend/app/folder/folder-menu/folder-menu.component.ts +++ b/src/frontend/app/folder/folder-menu/folder-menu.component.ts @@ -1,9 +1,11 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { LANG } from '../../translate.component'; import { HttpClient } from '@angular/common/http'; -import { map, tap, catchError } from 'rxjs/operators'; +import { map, tap, catchError, filter, exhaustMap } from 'rxjs/operators'; import { of } from 'rxjs'; import { NotificationService } from '../../notification.service'; +import { ConfirmComponent } from '../../../plugins/modal/confirm.component'; +import { MatDialogRef, MatDialog } from '@angular/material/dialog'; @Component({ selector: 'folder-menu', @@ -17,13 +19,17 @@ export class FolderMenuComponent implements OnInit { foldersList: any[] = []; @Input('resIds') resIds: number[]; + @Input('currentFolders') currentFoldersList: any[]; @Output('refreshFolders') refreshFolders = new EventEmitter<string>(); @Output('refreshList') refreshList = new EventEmitter<string>(); + dialogRef: MatDialogRef<any>; + constructor( public http: HttpClient, - private notify: NotificationService + private notify: NotificationService, + public dialog: MatDialog ) { } ngOnInit(): void { } @@ -52,4 +58,17 @@ export class FolderMenuComponent implements OnInit { ).subscribe(); } + unclassifyDocuments(folder: any) { + this.dialogRef = this.dialog.open(ConfirmComponent, { autoFocus: false, disableClose: true, data: { title: this.lang.delete, msg: 'Voulez-vous enlever <b>' + this.resIds.length + '</b> document(s) du classement ?' } }); + + this.dialogRef.afterClosed().pipe( + filter((data: string) => data === 'ok'), + exhaustMap(() => this.http.request('DELETE', '../../rest/folders/' + folder.id + '/resources', { body: { resources: this.resIds } })), + tap((data: any) => { + this.notify.success(this.lang.removedFromFolder); + this.refreshFolders.emit(); + this.refreshList.emit(); + }) + ).subscribe(); + } } diff --git a/src/frontend/app/folder/folder-tree.component.html b/src/frontend/app/folder/folder-tree.component.html index 475477856f07e9f0efc668132d05d50c72667242..03c7e446cb267d851062751bee105116a96dc88e 100644 --- a/src/frontend/app/folder/folder-tree.component.html +++ b/src/frontend/app/folder/folder-tree.component.html @@ -1,4 +1,4 @@ -<div class="folderTools"> +<div *ngIf="dataSource.data.length > 0" class="folderTools"> <div class="filter"> <plugin-autocomplete [size]="'small'" [labelPlaceholder]="lang.searchFolder" [routeDatas]="['/rest/autocomplete/folders']" [targetSearchKey]="'idToDisplay'" @@ -10,6 +10,9 @@ </button> </div> </div> +<div *ngIf="dataSource.data.length === 0" class="noFolder"> + {{lang.noAvailableFolder}}<br/><a (click)="toggleInput()">{{lang.addFolder}}</a> +</div> <mat-list *ngIf="createRootNode"> <mat-list-item role="listitem" class="rootFolder"> <form> @@ -24,7 +27,7 @@ </form> </mat-list-item> </mat-list> -<mat-nav-list> +<mat-nav-list *ngIf="dataSource.data.length > 0"> <mat-tree [dataSource]="dataSource" [treeControl]="treeControl"> <!-- This is the tree node template for leaf nodes --> <mat-tree-node cdkDropList [id]="'folder-list-'+node.id" diff --git a/src/frontend/app/folder/folder-tree.component.scss b/src/frontend/app/folder/folder-tree.component.scss index 994b277b761d0bf90cc90d01290515c2b36a9b3d..6cb108bbae64214ab259863d3effa9fde3a42b27 100644 --- a/src/frontend/app/folder/folder-tree.component.scss +++ b/src/frontend/app/folder/folder-tree.component.scss @@ -124,4 +124,15 @@ button:disabled { .filter { flex: 1; } +} + +.noFolder { + font-size: 12px; + color: rgb(102, 102, 102); + text-align: center; + font-style: italic; + + a { + cursor: pointer; + } } \ No newline at end of file diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index c04005049b7b783721df825e32478554ec3ac9e5..48fafd8cfa1ba7ec40d21e535954c26ce744c209 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1070,4 +1070,5 @@ export const LANG_EN = { "moveQuestion" : "Do you want move", "classify" : "Classify", "mailClassified" : "Mail(s) classified", + "noAvailableFolder" : "No available folder", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 388be320a80e07ab6aae85ba027933fc7dff7913..8cf2c5f03ce500b9891e70568364aa71a3de2077 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1107,4 +1107,5 @@ export const LANG_FR = { "moveQuestion" : "Voulez-vous déplacer", "classify" : "Classer", "mailClassified" : "Courrier(s) classé(s)", + "noAvailableFolder" : "Aucun dossier disponible", }; diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 303c76202ceedf238e76a4da8290fb3ab24e06fe..e18884e7b75df1db6156f80c5a3afefffce1de9f 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1096,4 +1096,5 @@ export const LANG_NL = { "moveQuestion" : "Do you want move", //_TO_TRANSLATE "classify" : "Classify", //_TO_TRANSLATE "mailClassified" : "Mail(s) classified", //_TO_TRANSLATE + "noAvailableFolder" : "No available folder", //_TO_TRANSLATE }; diff --git a/src/frontend/plugins/sorting.pipe.ts b/src/frontend/plugins/sorting.pipe.ts index acd1a157b9b12d9eb3db3b498867e05a498eb1f4..3689b286e16911ab60a2ba1a0621107cda7e089e 100755 --- a/src/frontend/plugins/sorting.pipe.ts +++ b/src/frontend/plugins/sorting.pipe.ts @@ -10,7 +10,7 @@ export class SortPipe { transform(array: Array<string>, args: string): Array<string> { let normA = ''; let normB = ''; - if (array !== undefined) { + if (array !== undefined && array.length > 0) { array.sort((a: any, b: any) => { if (args === undefined) { normA = this.latinisePipe.transform(a).toLocaleLowerCase();