api(mutation.dossier_modifier_annotation_drop_down_list): add mutation to change drop_down_list annotations value

This commit is contained in:
mfo 2024-07-24 14:43:50 +02:00
parent bf1a057ac3
commit 8e6c5d1567
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
6 changed files with 132 additions and 1 deletions

View file

@ -894,6 +894,20 @@ class API::V2::StoredQuery
}
}
mutation dossierModifierAnnotationDropDownList(
$input: DossierModifierAnnotationDropDownListInput!
) {
dossierModifierAnnotationDropDownList(input: $input) {
annotation {
id
value: stringValue
}
errors {
message
}
}
}
mutation dossierModifierAnnotationIntegerNumber(
$input: DossierModifierAnnotationIntegerNumberInput!
) {

View file

@ -65,6 +65,8 @@ module Mutations
TypeDeChamp.type_champs.fetch(:datetime)
when :integer_number
TypeDeChamp.type_champs.fetch(:integer_number)
when :drop_down_list
TypeDeChamp.type_champs.fetch(:drop_down_list)
end
end
end

View file

@ -0,0 +1,17 @@
module Mutations
class DossierModifierAnnotationDropDownList < Mutations::DossierModifierAnnotation
description "Modifier lannotation d'un champs de type dropdown list."
argument :value, GraphQL::Types::String, required: true
def resolve(dossier:, annotation_id:, instructeur:, value:)
resolve_with_type(dossier:, annotation_id:, instructeur:, value:)
end
private
def input_type
:drop_down_list
end
end
end

View file

@ -1937,6 +1937,45 @@ type DossierModifierAnnotationDatetimePayload {
errors: [ValidationError!]
}
"""
Autogenerated input type of DossierModifierAnnotationDropDownList
"""
input DossierModifierAnnotationDropDownListInput {
"""
Annotation ID
"""
annotationId: ID!
"""
A unique identifier for the client performing the mutation.
"""
clientMutationId: String
"""
Dossier ID
"""
dossierId: ID!
"""
Instructeur qui demande la modification.
"""
instructeurId: ID!
value: String!
}
"""
Autogenerated return type of DossierModifierAnnotationDropDownList.
"""
type DossierModifierAnnotationDropDownListPayload {
annotation: Champ
"""
A unique identifier for the client performing the mutation.
"""
clientMutationId: String
errors: [ValidationError!]
}
"""
Autogenerated input type of DossierModifierAnnotationIntegerNumber
"""
@ -3278,6 +3317,16 @@ type Mutation {
input: DossierModifierAnnotationDatetimeInput!
): DossierModifierAnnotationDatetimePayload
"""
Modifier lannotation d'un champs de type dropdown list.
"""
dossierModifierAnnotationDropDownList(
"""
Parameters for DossierModifierAnnotationDropDownList
"""
input: DossierModifierAnnotationDropDownListInput!
): DossierModifierAnnotationDropDownListPayload
"""
Modifier lannotation au format nombre entier.
"""

View file

@ -19,6 +19,7 @@ module Types
field :dossier_modifier_annotation_datetime, mutation: Mutations::DossierModifierAnnotationDatetime
field :dossier_modifier_annotation_integer_number, mutation: Mutations::DossierModifierAnnotationIntegerNumber
field :dossier_modifier_annotation_ajouter_ligne, mutation: Mutations::DossierModifierAnnotationAjouterLigne
field :dossier_modifier_annotation_drop_down_list, mutation: Mutations::DossierModifierAnnotationDropDownList
field :groupe_instructeur_modifier, mutation: Mutations::GroupeInstructeurModifier
field :groupe_instructeur_creer, mutation: Mutations::GroupeInstructeurCreer

View file

@ -1230,9 +1230,13 @@ describe API::V2::GraphqlController do
end
describe 'dossierModifierAnnotation' do
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_all_annotations, administrateurs: [admin]) }
let(:procedure) do
create(:procedure, :published, :for_individual, :with_service, administrateurs: [admin], types_de_champ_private:)
end
describe 'text' do
let(:types_de_champ_private) { [{ type: :text }] }
let(:query) do
"mutation {
dossierModifierAnnotationText(input: {
@ -1266,6 +1270,8 @@ describe API::V2::GraphqlController do
end
describe 'checkbox' do
let(:types_de_champ_private) { [{ type: :checkbox }] }
let(:value) { 'true' }
let(:query) do
@ -1316,6 +1322,7 @@ describe API::V2::GraphqlController do
end
describe 'yes_no' do
let(:types_de_champ_private) { [{ type: :yes_no }] }
let(:value) { 'true' }
let(:query) do
@ -1366,6 +1373,8 @@ describe API::V2::GraphqlController do
end
describe 'date' do
let(:types_de_champ_private) { [{ type: :date }] }
let(:query) do
"mutation {
dossierModifierAnnotationDate(input: {
@ -1399,6 +1408,8 @@ describe API::V2::GraphqlController do
end
describe 'datetime' do
let(:types_de_champ_private) { [{ type: :datetime }] }
let(:query) do
"mutation {
dossierModifierAnnotationDatetime(input: {
@ -1431,7 +1442,44 @@ describe API::V2::GraphqlController do
end
end
describe 'drop_down_list' do
let(:drop_down_list_options) { ['bijour'] }
let(:types_de_champ_private) { [{ type: :drop_down_list, options: drop_down_list_options }] }
let(:query) do
"mutation {
dossierModifierAnnotationDropDownList(input: {
dossierId: \"#{dossier.to_typed_id}\",
annotationId: \"#{dossier.champs_private.find { |c| c.type_champ == 'drop_down_list' }.to_typed_id}\",
instructeurId: \"#{instructeur.to_typed_id}\",
value: \"#{value}\"
}) {
annotation {
stringValue
}
errors {
message
}
}
}"
end
context "success" do
let(:value) { drop_down_list_options.first }
it 'should be a success' do
expect(gql_errors).to eq(nil)
expect(gql_data).to eq(dossierModifierAnnotationDropDownList: {
annotation: {
stringValue: dossier.reload.champs_private.find { |c| c.type_champ == 'drop_down_list' }.to_s
},
errors: nil
})
end
end
end
describe 'integer_number' do
let(:types_de_champ_private) { [{ type: :integer_number }] }
let(:query) do
"mutation {
dossierModifierAnnotationIntegerNumber(input: {