Added schema indications for writability of start & due date

pull/2693/head
Alexander Bach 10 years ago
parent ff4c8f0c59
commit f48972d570
  1. 8
      lib/api/v3/work_packages/schema/work_package_schema.rb
  2. 26
      lib/api/v3/work_packages/schema/work_package_schema_representer.rb

@ -96,6 +96,14 @@ module API
nil_or_leaf?(@work_package)
end
def start_date_writable?
nil_or_leaf?(@work_package)
end
def due_date_writable?
nil_or_leaf?(@work_package)
end
def nil_or_leaf?(work_package)
work_package.nil? || work_package.leaf?
end

@ -76,13 +76,27 @@ module API
schema :description,
type: 'Formattable'
schema :start_date,
type: 'Date',
required: false
property :start_date,
exec_context: :decorator,
getter: -> (*) do
representer = ::API::Decorators::PropertySchemaRepresenter
.new(type: 'Date',
name: WorkPackage.human_attribute_name(:start_date))
representer.writable = represented.due_date_writable?
representer.required = false
representer
end
schema :due_date,
type: 'Date',
required: false
property :due_date,
exec_context: :decorator,
getter: -> (*) do
representer = ::API::Decorators::PropertySchemaRepresenter
.new(type: 'Date',
name: WorkPackage.human_attribute_name(:due_date))
representer.writable = represented.due_date_writable?
representer.required = false
representer
end
property :estimated_time,
exec_context: :decorator,

Loading…
Cancel
Save