Skip to content

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

[#44856] Add submit action and upload functionality

Eric Schubertfcd0b3aba031
diff --git a/frontend/src/app/shared/components/storages/file-picker-base-modal.component.ts/file-picker-base-modal.component.ts b/frontend/src/app/shared/components/storages/file-picker-base-modal.component.ts/file-picker-base-modal.component.ts
index 7134941d318..a1db65ad28e 100644
--- a/frontend/src/app/shared/components/storages/file-picker-base-modal.component.ts/file-picker-base-modal.component.ts
+++ b/frontend/src/app/shared/components/storages/file-picker-base-modal.component.ts/file-picker-base-modal.component.ts
@@ -132,7 +132,7 @@ export abstract class FilePickerBaseModalComponent extends OpModalComponent impl
};
}
- private changeLevel(parent:string|null, crumbs:Breadcrumb[]):void {
+ protected changeLevel(parent:string|null, crumbs:Breadcrumb[]):void {
this.cancelCurrentLoading();
this.loading$.next(true);
this.breadcrumbs = new BreadcrumbsContent(crumbs);
diff --git a/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.ts b/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.ts
index 451d564b6ff..629399699ba 100644
--- a/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.ts
+++ b/frontend/src/app/shared/components/storages/location-picker-modal/location-picker-modal.component.ts
@@ -39,9 +39,10 @@ import { TimezoneService } from 'core-app/core/datetime/timezone.service';
import { IStorageFile } from 'core-app/core/state/storage-files/storage-file.model';
import { OpModalLocalsMap } from 'core-app/shared/components/modal/modal.types';
import { OpModalLocalsToken } from 'core-app/shared/components/modal/modal.service';
-import { StorageFilesResourceService } from 'core-app/core/state/storage-files/storage-files.service';
+import { Breadcrumb } from 'core-app/spot/components/breadcrumbs/breadcrumbs-content';
import { SortFilesPipe } from 'core-app/shared/components/storages/pipes/sort-files.pipe';
import { isDirectory } from 'core-app/shared/components/storages/functions/storages.functions';
+import { StorageFilesResourceService } from 'core-app/core/state/storage-files/storage-files.service';
import {
StorageFileListItem,
} from 'core-app/shared/components/storages/storage-file-list-item/storage-file-list-item';
@@ -69,6 +70,8 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {
return this.breadcrumbs.crumbs.length > 1;
}
+ public location = '/';
+
constructor(
@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
readonly elementRef:ElementRef,
@@ -88,6 +91,7 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {
}
public chooseLocation():void {
+ this.closingEvent.emit(this);
this.service.close();
}
@@ -105,4 +109,9 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {
enterDirectoryCallback,
);
}
+
+ protected changeLevel(parent:string|null, crumbs:Breadcrumb[]):void {
+ this.location = parent === null ? '/' : parent;
+ super.changeLevel(parent, crumbs);
+ }
}
diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.html b/frontend/src/app/shared/components/storages/storage/storage.component.html
index 745069fe973..c878cc32915 100644
--- a/frontend/src/app/shared/components/storages/storage/storage.component.html
+++ b/frontend/src/app/shared/components/storages/storage/storage.component.html
@@ -38,6 +38,17 @@
></li>
</ul>
+ <input
+ *ngIf="storageFileUploadEnabled"
+ #hiddenFileInput
+ type="file"
+ id="upload_files"
+ name="upload_files"
+ (change)="onFilePickerChanged()"
+ hidden
+ multiple
+ />
+
<p
*ngIf="(showLinkFilesAction | async) && (allowEditing$ | async)"
class="spot-body-small op-file-list--actions"
@@ -57,7 +68,7 @@
type="button"
class="spot-link op-file-list--action-button"
data-qa-selector="op-file-list--upload-file-button"
- (click)="openSelectLocationDialog()"
+ (click)="triggerFileInput()"
>
<span class="spot-icon spot-icon_upload-arrow"></span>
<span [textContent]="text.actions.uploadFile"></span>
diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.ts
index e4de7699c1e..818d89cfc5c 100644
--- a/frontend/src/app/shared/components/storages/storage/storage.component.ts
+++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts
@@ -29,8 +29,10 @@
import {
ChangeDetectionStrategy,
Component,
+ ElementRef,
Input,
OnInit,
+ ViewChild,
} from '@angular/core';
import {
BehaviorSubject,
@@ -79,6 +81,8 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {
@Input() public storage:IStorage;
+ @ViewChild('hiddenFileInput') public filePicker:ElementRef<HTMLInputElement>;
+
fileLinks$:Observable<IFileLink[]>;
allowEditing$:Observable<boolean>;
@@ -189,7 +193,18 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {
});
}
- public openSelectLocationDialog():void {
+ public triggerFileInput():void {
+ this.filePicker.nativeElement.click();
+ }
+
+ public onFilePickerChanged():void {
+ const fileList = this.filePicker.nativeElement.files;
+ if (fileList === null) return;
+
+ this.openSelectLocationDialog(fileList);
+ }
+
+ private openSelectLocationDialog(files:FileList|null):void {
const locals = {
storageType: this.storage._links.type.href,
storageTypeName: this.storageType,
@@ -197,7 +212,12 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {
storageLocation: this.storageFilesLocation,
storageLink: this.storage._links.self,
};
- this.opModalService.show<LocationPickerModalComponent>(LocationPickerModalComponent, 'global', locals);
+ this.opModalService.show<LocationPickerModalComponent>(LocationPickerModalComponent, 'global', locals)
+ .subscribe((modal) => {
+ modal.closingEvent.subscribe((data) => {
+ console.log(`Uploading ${files?.length || 0} files to ${data.location}`);
+ });
+ });
}
private instantiateStorageInformation(fileLinks:IFileLink[]):StorageInformationBox[] {