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
[#53672] add poc for adding attachments to work package form schema
Eric Schubertd26e2eca0a2c
diff --git a/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts b/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.tsindex 179ce5fc4e3..e3796add8e3 100644--- a/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts+++ b/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts@@ -37,7 +37,9 @@ import {} from 'rxjs';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { HookService } from 'core-app/features/plugins/hook-service';-import { WorkPackageFilterValues } from 'core-app/features/work-packages/components/wp-edit-form/work-package-filter-values';+import {+ WorkPackageFilterValues,+} from 'core-app/features/work-packages/components/wp-edit-form/work-package-filter-values';import {HalResourceEditingService,ResourceChangesetCommit,@@ -61,6 +63,7 @@ import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';import { AttachmentsResourceService } from 'core-app/core/state/attachments/attachments.service';+import { AttachmentCollectionResource } from 'core-app/features/hal/resources/attachment-collection-resource';export const newWorkPackageHref = '/api/v3/work_packages/new';@@ -400,6 +403,10 @@ export class WorkPackageCreateService extends UntilDestroyedMixin {wp.updateImmediately = (data:object) => firstValueFrom(this.apiV3Service.work_packages.post(data));wp.$links.updateImmediately = (data:object) => firstValueFrom(this.apiV3Service.work_packages.post(data));+ if (form.schema.attachments) {+ wp.$links.attachments = { elements: [] } as unknown as AttachmentCollectionResource;+ }+// We need to provide the schema to the cache so that it is available in the html form to e.g. determine// the editability.// It would be better if the edit field could simply rely on the changeset if it exists.diff --git a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb b/lib/api/v3/work_packages/schema/work_package_schema_representer.rbindex 67f7202d26f..4944fd97420 100644--- a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb+++ b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb@@ -181,9 +181,9 @@ module APItype: "Duration",required: false,show_if: ->(*) {- current_user.allowed_in_project?(:view_time_entries, represented.project) ||- current_user.allowed_in_any_work_package?(:view_own_time_entries, in_project: represented.project)- }+ current_user.allowed_in_project?(:view_time_entries, represented.project) ||+ current_user.allowed_in_any_work_package?(:view_own_time_entries, in_project: represented.project)+ }schema :percentage_done,type: "Integer",@@ -224,6 +224,12 @@ module APIend}+ schema_with_allowed_link :attachments,+ type: "AttachmentCollection",+ required: false,+ writable: false,+ href_callback: -> {}+schema_with_allowed_link :parent,type: "WorkPackage",required: false,