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

[#53672] Use link instead of schema in schema_api.

Pavel Balashou5b3c2fbbb082
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.ts
index e3796add8e3..b5fc5ac7c80 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
@@ -403,7 +403,7 @@ 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) {
+ if (form.schema.$links.attachments) {
wp.$links.attachments = { elements: [] } as unknown as AttachmentCollectionResource;
}
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.rb
index cfe89c1ba81..2c396ac2d35 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
@@ -91,6 +91,11 @@ module API
{ href: @base_schema_link } if @base_schema_link
end
+ link :attachments do
+ next if represented.work_package.hide_attachments?
+ { href: nil }
+ end
+
# Needs to not be cached as the queries in the attribute
# groups might contain information (e.g. project names) whose
# visibility needs to be checked per user
@@ -212,12 +217,6 @@ module API
location: :link,
writable: false
- schema :attachments,
- type: "AttachmentCollection",
- required: false,
- writable: false,
- show_if: ->(*) { !represented.work_package.hide_attachments? }
-
schema_with_allowed_link :project,
type: "Project",
required: true,
diff --git a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
index 23e9f01bafb..f6fd8f60c8d 100644
--- a/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
+++ b/spec/models/work_packages/pdf_export/work_package_to_pdf_spec.rb
@@ -125,7 +125,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageToPdf do
end
describe "with a request for a PDF" do
- xit "contains correct data" do
+ it "contains correct data" do
details = exporter.send(:attributes_data_by_wp, work_package)
.flat_map do |item|
value = get_column_value(item[:name])