allow plugins to provide own wp attachment upload component

pull/6934/head
Jens Ulferts 6 years ago
parent ce426f29e0
commit 81c17d32d8
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 6
      frontend/src/app/components/work-packages/wp-single-view/wp-single-view.component.ts
  2. 4
      frontend/src/app/components/work-packages/wp-single-view/wp-single-view.html
  3. 6
      frontend/src/app/modules/attachments/attachments-upload/attachments-upload.component.ts
  4. 1
      frontend/src/app/modules/attachments/openproject-attachments.module.ts
  5. 6
      frontend/src/app/modules/work_packages/openproject-work-packages.module.ts

@ -203,6 +203,12 @@ export class WorkPackageSingleViewComponent implements OnInit, OnDestroy {
return this.hook.call('attributeGroupComponent', group, this.workPackage).pop() || null;
}
public attachmentUploadComponent() {
// we take the last registered group component which means that
// plugins will have their say if they register for it.
return this.hook.call('workPackageAttachmentUploadComponent', this.workPackage).pop() || null;
}
/*
* Returns the work package label
*/

@ -119,6 +119,8 @@
</div>
<attachment-list [resource]="workPackage" [selfDestroy]="true"></attachment-list>
<attachments-upload [resource]="workPackage" class="hide-when-print"></attachments-upload>
<ndc-dynamic [ndcDynamicComponent]="attachmentUploadComponent()"
[ndcDynamicInputs]="{ resource: workPackage }">
</ndc-dynamic>
</div>
</div>

@ -124,10 +124,10 @@ export class AttachmentsUploadComponent implements OnInit {
}
}
private uploadFiles(files:UploadFile[]):void {
protected uploadFiles(files:UploadFile[]):void {
files = files || [];
const countBefore = files.length;
files = this.filterFolders(files)
files = this.filterFolders(files);
if (files.length === 0) {
@ -147,7 +147,7 @@ export class AttachmentsUploadComponent implements OnInit {
* or empty file sizes.
* @param files
*/
private filterFolders(files:UploadFile[]) {
protected filterFolders(files:UploadFile[]) {
return files.filter((file) => {
// Folders never have a mime type

@ -46,6 +46,7 @@ import {AttachmentsUploadComponent} from "core-app/modules/attachments/attachmen
],
entryComponents: [
AttachmentsComponent,
AttachmentsUploadComponent
],
exports: [
AttachmentsUploadComponent,

@ -184,7 +184,7 @@ import {WorkPackagesBaseComponent} from "core-app/modules/work_packages/routing/
import {WorkPackagesListComponent} from "core-app/modules/work_packages/routing/wp-list/wp-list.component";
import {WorkPackageSplitViewComponent} from "core-app/modules/work_packages/routing/wp-split-view/wp-split-view.component";
import {WorkPackagesFullViewComponent} from "core-app/modules/work_packages/routing/wp-full-view/wp-full-view.component";
import {OpenprojectCalendarModule} from "core-app/modules/calendar/openproject-calendar.module";
import {AttachmentsUploadComponent} from 'core-app/modules/attachments/attachments-upload/attachments-upload.component';
@NgModule({
imports: [
@ -525,6 +525,10 @@ export class OpenprojectWorkPackagesModule {
return null;
}
});
hookService.register('workPackageAttachmentUploadComponent', (workPackage:WorkPackageResource) => {
return AttachmentsUploadComponent;
});
};
}
}

Loading…
Cancel
Save