scinote-web/app/serializers/api/v1/step_orderable_element_serializer.rb
artoscinote dd27fadd98
Add step reordering and step element reordering service endpoints to API [SCI-6891][SCI-6892] (#4179)
* Add step reordering service endpoint to API [SCI-6891]

* Generalize reorder validation [SCI-6891]

* Add endpoint for reordering step elements, fix issues [SCI-6892]

* Add appropriate serializers [SCI-6891][SCI-6892]

* Add step elements to step serializer [SCI-6891]

* Simplify routes, add locking [SCI-6891]
2022-07-12 10:13:47 +02:00

20 lines
507 B
Ruby

# frozen_string_literal: true
module Api
module V1
class StepOrderableElementSerializer < ActiveModel::Serializer
attributes :position, :element
def element
case object.orderable_type
when 'Checklist'
ChecklistSerializer.new(object.orderable).as_json
when 'StepTable'
TableSerializer.new(object.orderable.table).as_json
when 'StepText'
StepTextSerializer.new(object.orderable).as_json
end
end
end
end
end