Skip to content

Commit

Permalink
feat(api): list labels of procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
colinux committed Jan 15, 2025
1 parent 31f495a commit e1c7672
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,11 @@ type Demarche {
groupeInstructeurs(closed: Boolean): [GroupeInstructeur!]!
id: ID!

"""
Liste des labels associables aux dossiers
"""
labels: [Label!]!

"""
Numero de la démarche.
"""
Expand Down
1 change: 1 addition & 0 deletions app/graphql/types/demarche_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class DossierDeclarativeState < Types::BaseEnum
field :published_revision, Types::RevisionType, null: true
field :revisions, [Types::RevisionType], null: false
field :chorus_configuration, Types::ChorusConfigurationType, null: true, description: "Cadre budgétaire Chorus"
field :labels, [Types::LabelType], null: false, description: 'Liste des labels associables aux dossiers'

def state
object.aasm.current_state
Expand Down
13 changes: 11 additions & 2 deletions spec/controllers/api/v2/graphql_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ def compute_checksum_in_chunks(io)
id
}
}
labels {
id
color
name
}
}
}"
end
Expand Down Expand Up @@ -177,7 +182,10 @@ def compute_checksum_in_chunks(io)

describe "demarche" do
describe "query a demarche" do
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_all_champs, :with_all_annotations, administrateurs: [admin]) }
let(:label) { build(:label) }
let(:procedure) {
create(:procedure, :published, :for_individual, :with_service, :with_all_champs, :with_all_annotations, administrateurs: [admin], labels: [label])
}

def format_type_champ(type_champ)
"#{type_champ.gsub('regions', 'region').gsub('departements', 'departement').gsub('communes', 'commune').camelcase}ChampDescriptor"
Expand Down Expand Up @@ -224,7 +232,8 @@ def format_type_champ(type_champ)
end,
dossiers: {
nodes: dossiers.map { { id: _1.to_typed_id } }
}
},
labels: [{ id: label.to_typed_id, color: label.color, name: label.name }]
})
end
end
Expand Down

0 comments on commit e1c7672

Please sign in to comment.