OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Update counter of files tab
Henriette Dargead9a31d6216a
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.htmlindex c063526da05..ae007c7afac 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.html+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.html@@ -15,7 +15,11 @@<span class="op-tab-content--header-text" [textContent]="text.attachments.label"></span></div>- <op-attachments [resource]="workPackage"></op-attachments>+ <op-attachments+ [resource]="workPackage"+ (attachmentRemoved)="attachmentRemoved()"+ (attachmentAdded)="attachmentAdded()"+ ></op-attachments></section><section@@ -28,6 +32,8 @@[projectStorage]="storage"[allowUploading]="allowManageFileLinks$ | async"[allowLinking]="allowManageFileLinks$ | async"+ (fileRemoved)="attachmentRemoved()"+ (fileAdded)="attachmentAdded()"></op-storage></section></div>diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.tsindex a36203364fe..b37ea1ba78a 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts@@ -1,4 +1,4 @@-//-- copyright+// -- copyright// OpenProject is an open source project management software.// Copyright (C) the OpenProject GmbH//@@ -41,6 +41,8 @@ import { CurrentUserService } from 'core-app/core/current-user/current-user.servimport { HalResource } from 'core-app/features/hal/resources/hal-resource';import { ProjectStoragesResourceService } from 'core-app/core/state/project-storages/project-storages.service';import { IProjectStorage } from 'core-app/core/state/project-storages/project-storage.model';+import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';+import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';@Component({selector: 'op-files-tab',@@ -68,6 +70,8 @@ export class WorkPackageFilesTabComponent implements OnInit {private readonly i18n:I18nService,private readonly currentUserService:CurrentUserService,private readonly projectStoragesResourceService:ProjectStoragesResourceService,+ private readonly pathHelper:PathHelperService,+ private readonly turboRequests:TurboRequestsService,) { }ngOnInit():void {@@ -96,4 +100,19 @@ export class WorkPackageFilesTabComponent implements OnInit {map(([storages, viewPermission]) => storages.length > 0 && viewPermission),);}++ attachmentRemoved() {+ this.updateCounter();+ }++ attachmentAdded() {+ this.updateCounter();+ }++ private updateCounter() {+ if (this.workPackage.id) {+ const url = this.pathHelper.workPackageUpdateCounterPath(this.workPackage.id, 'files');+ void this.turboRequests.request(url);+ }+ }}diff --git a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list.component.ts b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list.component.tsindex f8ce4505196..d5dd582204f 100644--- a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list.component.ts+++ b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list.component.ts@@ -1,4 +1,4 @@-//-- copyright+// -- copyright// OpenProject is an open source project management software.// Copyright (C) the OpenProject GmbH//@@ -26,7 +26,14 @@// See COPYRIGHT and LICENSE files for more details.//++-import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';+import {+ ChangeDetectionStrategy,+ Component,+ EventEmitter,+ Input,+ OnInit,+ Output,+} from '@angular/core';import { IAttachment } from 'core-app/core/state/attachments/attachment.model';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { AttachmentsResourceService } from 'core-app/core/state/attachments/attachments.service';@@ -43,6 +50,8 @@ export class OpAttachmentListComponent extends UntilDestroyedMixin implements On@Input() public showTimestamp = true;+ @Output() public attachmentRemoved = new EventEmitter<void>();+constructor(private readonly attachmentsResourceService:AttachmentsResourceService,) {@@ -54,5 +63,6 @@ export class OpAttachmentListComponent extends UntilDestroyedMixin implements Onpublic removeAttachment(attachment:IAttachment):void {this.attachmentsResourceService.removeAttachment(this.collectionKey, attachment).subscribe();+ this.attachmentRemoved.emit();}}diff --git a/frontend/src/app/shared/components/attachments/attachments.component.html b/frontend/src/app/shared/components/attachments/attachments.component.htmlindex 3c7dccbb6be..6df36c5761b 100644--- a/frontend/src/app/shared/components/attachments/attachments.component.html+++ b/frontend/src/app/shared/components/attachments/attachments.component.html@@ -7,6 +7,7 @@[attachments]="attachments$ | async"[collectionKey]="collectionKey"[showTimestamp]="showTimestamp"+ (attachmentRemoved)="attachmentRemoved.emit()"></op-attachment-list><inputdiff --git a/frontend/src/app/shared/components/attachments/attachments.component.ts b/frontend/src/app/shared/components/attachments/attachments.component.tsindex 1af76eb043b..d4dee4b1430 100644--- a/frontend/src/app/shared/components/attachments/attachments.component.ts+++ b/frontend/src/app/shared/components/attachments/attachments.component.ts@@ -1,4 +1,4 @@-//-- copyright+// -- copyright// OpenProject is an open source project management software.// Copyright (C) the OpenProject GmbH//@@ -31,10 +31,12 @@ import {ChangeDetectorRef,Component,ElementRef,+ EventEmitter,HostBinding,Input,OnDestroy,OnInit,+ Output,ViewChild,ViewEncapsulation,} from '@angular/core';@@ -80,6 +82,10 @@ export class OpAttachmentsComponent extends UntilDestroyedMixin implements OnIni@Input() public showTimestamp = true;+ @Output() public attachmentRemoved = new EventEmitter<void>();++ @Output() public attachmentAdded = new EventEmitter<void>();+public attachments$:Observable<IAttachment[]>;public draggingOverDropZone = false;@@ -258,7 +264,7 @@ export class OpAttachmentsComponent extends UntilDestroyedMixin implements OnIni.attachmentsResourceService.attachFiles(this.resource, filesWithoutFolders).subscribe({- next: () => {},+ next: () => { this.attachmentAdded.emit(); },error: (error:HttpErrorResponse) => this.toastService.addError(error),});}diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.tsindex 2a123187355..cc7ca74d77c 100644--- a/frontend/src/app/shared/components/storages/storage/storage.component.ts+++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts@@ -1,4 +1,4 @@-//-- copyright+// -- copyright// OpenProject is an open source project management software.// Copyright (C) the OpenProject GmbH//@@ -31,9 +31,11 @@ import {ChangeDetectorRef,Component,ElementRef,+ EventEmitter,Input,OnDestroy,OnInit,+ Output,ViewChild,} from '@angular/core';import { HttpErrorResponse } from '@angular/common/http';@@ -121,6 +123,10 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD@ViewChild('hiddenFileInput') public filePicker:ElementRef<HTMLInputElement>;+ @Output() public fileRemoved = new EventEmitter<void>();++ @Output() public fileAdded = new EventEmitter<void>();+fileLinks:Observable<IFileLink[]>;storage:Observable<IStorage>;@@ -291,7 +297,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnDswitchMap((key) => this.fileLinkResourceService.remove(key, fileLink)),).subscribe({- next: () => { /* Do nothing */ },+ next: () => { this.fileRemoved.emit(); },error: (error:HttpErrorResponse) => this.toastService.addError(error),});}@@ -412,6 +418,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD.subscribe({next: (collection) => {this.toastService.addSuccess(this.text.toast.successFileLinksCreated(collection.count));+ this.fileAdded.emit();},error: (error) => {if (isUploadError) {