Module: Ecoportal::API::GraphQL::Input::WorkflowCommand::MoveViewableField

Defined in:
lib/ecoportal/api/graphql/input/workflow_command/move_viewable_field.rb

Overview

WorkflowMoveViewableFieldInput — reorders a viewable field on a People data field. Same shape as AddViewableField minus schemaFieldType (the field already exists, so its type is known server-side). See AddViewableField for why these three commands replaced the removed people.add/removeViewableFields arrays.

Constant Summary collapse

SCHEMA_VERSION =
'20260725'.freeze
VALID_KEYS =
%i[dataFieldId schemaFieldId anchorId anchorPosition].freeze
ANCHOR_POSITIONS =
AddViewableField::ANCHOR_POSITIONS

Class Method Summary collapse

Class Method Details

.build(data_field_id:, schema_field_id:, **kwargs) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ecoportal/api/graphql/input/workflow_command/move_viewable_field.rb', line 15

def self.build(data_field_id:, schema_field_id:, **kwargs)
  position = kwargs[:anchorPosition]
  unless position.nil? || ANCHOR_POSITIONS.include?(position.to_s)
    raise ArgumentError,
          "Invalid anchorPosition #{position.inspect}: " \
          "expected one of #{ANCHOR_POSITIONS.join(', ')}"
  end

  {
    dataFieldId:   data_field_id,
    schemaFieldId: schema_field_id
  }.merge(kwargs.slice(:anchorId, :anchorPosition).compact)
end