Commit c05201d7 authored by Alex ORLUC's avatar Alex ORLUC

FEAT #11641 TIME 2 add handle empty folder + add var lang

parent e24b7d38
......@@ -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
......@@ -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();
......
......@@ -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
<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
......@@ -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
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();
}
}
<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"
......
......@@ -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
......@@ -1070,4 +1070,5 @@ export const LANG_EN = {
"moveQuestion" : "Do you want move",
"classify" : "Classify",
"mailClassified" : "Mail(s) classified",
"noAvailableFolder" : "No available folder",
};
......@@ -1107,4 +1107,5 @@ export const LANG_FR = {
"moveQuestion" : "Voulez-vous déplacer",
"classify" : "Classer",
"mailClassified" : "Courrier(s) classé(s)",
"noAvailableFolder" : "Aucun dossier disponible",
};
......@@ -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
};
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment