diff --git a/src/app/resource/controllers/UserFollowedResourceController.php b/src/app/resource/controllers/UserFollowedResourceController.php index c0ba07a34314f1e642a08018f6823358c04804a0..580fb000c445bbe5ea0d23f0da08d6d074ac6f03 100644 --- a/src/app/resource/controllers/UserFollowedResourceController.php +++ b/src/app/resource/controllers/UserFollowedResourceController.php @@ -62,6 +62,8 @@ class UserFollowedResourceController return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } + $nbUnFollowed = 0; + foreach ($body['resources'] as $resId) { $following = UserFollowedResourceModel::get([ 'where' => ['user_id = ?', 'res_id = ?'], @@ -76,10 +78,12 @@ class UserFollowedResourceController 'userId' => $GLOBALS['id'], 'resId' => $resId ]); + + $nbUnFollowed++; } - return $response->withStatus(204); + return $response->withJson(['unFollowed' => $nbUnFollowed]); } public function getFollowedResources(Request $request, Response $response) diff --git a/src/frontend/app/actions/actions-list.component.html b/src/frontend/app/actions/actions-list.component.html index e41d68a7b7a289f392906338b2beab6f609c8003..ad2e4b1620dcd2cc6be7721a92a5ea3060fc5105 100644 --- a/src/frontend/app/actions/actions-list.component.html +++ b/src/frontend/app/actions/actions-list.component.html @@ -14,5 +14,10 @@ <span>{{action.label}}</span> </button> <mat-divider></mat-divider> + <button mat-menu-item class="followAction" (click)="unFollow()" [disabled]="selectedRes.length === 0"> + <mat-icon class="far fa-star fa-2x"></mat-icon> + <span>{{lang.untrackThisMail}}</span> + </button> + <mat-divider></mat-divider> <folder-menu [resIds]="selectedRes" [currentFolders]="folderList" (refreshList)="refreshList()" (refreshFolders)="refreshFolders()"></folder-menu> -</mat-menu> \ No newline at end of file +</mat-menu> diff --git a/src/frontend/app/actions/actions-list.component.scss b/src/frontend/app/actions/actions-list.component.scss index 2a110d93138f6a6586e4643d1bf045d08c78c2ce..cf1fdb503f3414457bfacae18af7f70bd0a1be9f 100644 --- a/src/frontend/app/actions/actions-list.component.scss +++ b/src/frontend/app/actions/actions-list.component.scss @@ -15,4 +15,11 @@ padding-top: 0; padding-bottom: 0; } -} \ No newline at end of file +} + +.followAction { + .mat-icon { + font-size:20px; + color: $warn; + } +} diff --git a/src/frontend/app/actions/actions-list.component.ts b/src/frontend/app/actions/actions-list.component.ts index 2323cf3a0b7ce549b1af3fc437c52f6d3a29df73..0e505fbcd24fbd1edca7b25ec6254a50a13487bb 100644 --- a/src/frontend/app/actions/actions-list.component.ts +++ b/src/frontend/app/actions/actions-list.component.ts @@ -7,6 +7,9 @@ import { MatMenuTrigger } from '@angular/material/menu'; import { Router } from '@angular/router'; import { ActionsService } from './actions.service'; import { Subscription } from 'rxjs'; +import {ConfirmComponent} from "../../plugins/modal/confirm.component"; +import {exhaustMap, filter, tap} from "rxjs/operators"; +import {HeaderService} from "../../service/header.service"; @Component({ selector: 'app-actions-list', @@ -47,7 +50,8 @@ export class ActionsListComponent implements OnInit { private notify: NotificationService, public dialog: MatDialog, private router: Router, - private actionService: ActionsService + private actionService: ActionsService, + private headerService: HeaderService ) { } dialogRef: MatDialogRef<any>; @@ -126,4 +130,18 @@ export class ActionsListComponent implements OnInit { refreshFolders() { this.refreshPanelFolders.emit(); } + + unFollow() { + this.dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.lang.delete, msg: this.lang.stopFollowingAlert } }); + + this.dialogRef.afterClosed().pipe( + filter((data: string) => data === 'ok'), + exhaustMap(() => this.http.request('DELETE', '../../rest/resources/unfollow' , { body: { resources: this.selectedRes } })), + tap((data: any) => { + this.notify.success(this.lang.removedFromFolder); + this.headerService.nbResourcesFollowed -= data.unFollowed; + this.refreshList(); + }) + ).subscribe(); + } } 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 700eb239dee8b4af57bbdd92e3568840645f57ff..a72beae853f0ce2e490b715c589d90754847326d 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 @@ -26,9 +26,14 @@ </div> </mat-menu> <mat-divider></mat-divider> + <button mat-menu-item class="followAction" (click)="unFollow()" [disabled]="selectedRes.length === 0"> + <mat-icon class="far fa-star fa-2x"></mat-icon> + <span>{{lang.untrackThisMail}}</span> + </button> + <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>{{lang.removeFromFolder}}</span> </button> <folder-menu [resIds]="selectedRes" (refreshList)="refreshDaoAfterAction()" (refreshFolders)="refreshFolders()"></folder-menu> -</mat-menu> \ No newline at end of file +</mat-menu> diff --git a/src/frontend/app/folder/folder-action-list/folder-action-list.component.scss b/src/frontend/app/folder/folder-action-list/folder-action-list.component.scss index e2674ba8da98f541d26e543ff22b3d42a756b838..6c5e7ef5661338fa076e55a2e77b2a4e0dec6c76 100644 --- a/src/frontend/app/folder/folder-action-list/folder-action-list.component.scss +++ b/src/frontend/app/folder/folder-action-list/folder-action-list.component.scss @@ -17,7 +17,7 @@ } } -.folderAction { +.folderAction, .followAction { .mat-icon { font-size:20px; color: $warn; @@ -42,4 +42,4 @@ opacity: 0.5; font-style: italic; padding: 22px; -} \ No newline at end of file +} diff --git a/src/frontend/app/folder/folder-action-list/folder-action-list.component.ts b/src/frontend/app/folder/folder-action-list/folder-action-list.component.ts index f86edbb38d6345e8ec907c2199e9a6d6c2c5ff17..c8051b40775e97cfc30db9bf60b1cbc5ef3c81ee 100644 --- a/src/frontend/app/folder/folder-action-list/folder-action-list.component.ts +++ b/src/frontend/app/folder/folder-action-list/folder-action-list.component.ts @@ -116,4 +116,18 @@ export class FolderActionListComponent implements OnInit { this.router.navigate(['/basketList/users/' + this.headerService.user.id + '/groups/' + basket.groupId + '/baskets/' + basket.basketId]); } } + + unFollow() { + this.dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.lang.delete, msg: this.lang.stopFollowingAlert } }); + + this.dialogRef.afterClosed().pipe( + filter((data: string) => data === 'ok'), + exhaustMap(() => this.http.request('DELETE', '../../rest/resources/unfollow' , { body: { resources: this.selectedRes } })), + tap((data: any) => { + this.notify.success(this.lang.removedFromFolder); + this.headerService.nbResourcesFollowed -= data.unFollowed; + this.refreshDaoAfterAction(); + }) + ).subscribe(); + } } diff --git a/src/frontend/app/home/followed-action-list/followed-action-list.component.html b/src/frontend/app/home/followed-action-list/followed-action-list.component.html index 001e268eb0735ccaf934e3dc3437735b1780203b..d70c83016a1f348d0562284ecbbcbaf61510673b 100644 --- a/src/frontend/app/home/followed-action-list/followed-action-list.component.html +++ b/src/frontend/app/home/followed-action-list/followed-action-list.component.html @@ -26,7 +26,7 @@ </div> </mat-menu> <mat-divider></mat-divider> - <button mat-menu-item class="folderAction" (click)="unFollow()" [disabled]="selectedRes.length === 0"> + <button mat-menu-item class="followAction" (click)="unFollow()" [disabled]="selectedRes.length === 0"> <mat-icon class="far fa-star fa-2x"></mat-icon> <span>{{lang.untrackThisMail}}</span> </button> diff --git a/src/frontend/app/home/followed-action-list/followed-action-list.component.scss b/src/frontend/app/home/followed-action-list/followed-action-list.component.scss index e2674ba8da98f541d26e543ff22b3d42a756b838..8b9a4c21fb4afe82651e7c308e5cde0c3ca08793 100644 --- a/src/frontend/app/home/followed-action-list/followed-action-list.component.scss +++ b/src/frontend/app/home/followed-action-list/followed-action-list.component.scss @@ -17,7 +17,7 @@ } } -.folderAction { +.followAction { .mat-icon { font-size:20px; color: $warn; @@ -42,4 +42,4 @@ opacity: 0.5; font-style: italic; padding: 22px; -} \ No newline at end of file +} diff --git a/src/frontend/app/home/followed-action-list/followed-action-list.component.ts b/src/frontend/app/home/followed-action-list/followed-action-list.component.ts index 520e3b0a2b373f3296d5693198c21918b3cbf6fe..a0987700c55059020812682ab59d985547aadd1c 100644 --- a/src/frontend/app/home/followed-action-list/followed-action-list.component.ts +++ b/src/frontend/app/home/followed-action-list/followed-action-list.component.ts @@ -94,7 +94,7 @@ export class FollowedActionListComponent implements OnInit { exhaustMap(() => this.http.request('DELETE', '../../rest/resources/unfollow' , { body: { resources: this.selectedRes } })), tap((data: any) => { this.notify.success(this.lang.removedFromFolder); - this.headerService.nbResourcesFollowed -= this.selectedRes.length; + this.headerService.nbResourcesFollowed -= data.unFollowed; this.refreshDaoAfterAction(); }) ).subscribe(); diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 319e36eb582cd625851205016342bfd0891071dd..b66ff2dc735ab0d5dd8d6f62232897c3bc446f13 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1290,7 +1290,7 @@ export const LANG_EN = { "removeSignature": "Remove signature", "removeUserRedirect": "Remove the user from the diffusion lists", "removeUserRedirectInformations": "<em>The user will be removed from the mails and entity's diffusion lists <b>except in the case where it is assignee</b></em>", - "removedFromFolder": "Mail removed from folder", + "removedFromFolder": "Mail(s) removed", "renewPsw": "Enter the password again", "reports": "Reports", "reportsAdmin": "Reports administration",