diff --git a/config/locales/en.yml b/config/locales/en.yml index d82b4ca79f..f04dbbe35d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -587,6 +587,7 @@ en: parent_work_package: "Parent" priority: "Priority" progress: "Progress (%)" + readonly: "Read only" schedule_manually: "Manual scheduling" spent_hours: "Spent time" spent_time: "Spent time" 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 b42dbe1baf..37eea02855 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 @@ -176,6 +176,12 @@ module API show_if: ->(*) { Setting.work_package_done_ratio != 'disabled' }, required: false + schema :readonly, + type: 'Boolean', + show_if: ->(*) { Status.can_readonly? }, + required: false, + has_default: true + schema :created_at, type: 'DateTime' diff --git a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb index 1e6382424c..6bd9292560 100644 --- a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb @@ -661,6 +661,25 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do end end + describe 'readonly' do + context 'with the enterprise feature enabled', with_ee: %i[readonly_work_packages] do + it_behaves_like 'has basic schema properties' do + let(:path) { 'readonly' } + let(:type) { 'Boolean' } + let(:name) { I18n.t('activerecord.attributes.work_package.readonly') } + let(:required) { false } + let(:has_default) { true } + let(:writable) { false } + end + end + + context 'without the enterprise feature' do + it 'has no such property' do + expect(subject).not_to have_json_path('readonly') + end + end + end + describe 'createdAt' do it_behaves_like 'has basic schema properties' do let(:path) { 'createdAt' }