Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: gestion des labels #11201

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

colinux
Copy link
Member

@colinux colinux commented Jan 13, 2025

  • liste des labels du dossier
  • associer un label à un dossier
  • suppression d'un label à un dossier
  • liste des labels de la démarche (pour récup les ids)
  • ajouter des labels à une démarche: on verra plus tard si c'est demandé
  • doc

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 96.87500% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.60%. Comparing base (2bfd51e) to head (e1c7672).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
app/graphql/mutations/dossier_ajouter_label.rb 94.73% 1 Missing ⚠️
app/graphql/mutations/dossier_supprimer_label.rb 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11201      +/-   ##
==========================================
+ Coverage   84.55%   84.60%   +0.04%     
==========================================
  Files        1196     1200       +4     
  Lines       26300    26362      +62     
  Branches     4962     4972      +10     
==========================================
+ Hits        22239    22303      +64     
+ Misses       4061     4059       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


def color
object.label.color
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ajouterai bien un authorized? :

def self.authorized?(object, context)
    context.authorized_demarche?(object.procedure)
end

Ça ne coûte rien et ça garantit que l'objet ne sera jamais visible s'il n'est pas autorisé

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi expose-t-on ici DossierLabel et pas Label ? Je n'ai pas l'impression que DossierLabel contient des informations utiles. Je sais que tu m'as posé la question et je crois que j'ai mal compris. On peut en parler à l'occasion. Ce n'est pas bloquant pour merger non plus – on peut toujours changer plus tard. Le nom du type GraphQL est bon, je pense – DossierLabel.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah mais non, tu as exposé les deux sur l'API... Je voudrais qu'on en parle

def authorized?(dossier:, label:, **_args)
if dossier.labels.include?(label)
[false, { errors: ["Ce label est déjà associé au dossier"] }]
elsif dossier.procedure != label.procedure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avec authorized? sur le label, ça ne devrait pas être utile

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'ai rajouté le authorized sur les types, mais c'est insuffisant car si l'admin a plusieurs démarches on veut éviter qu'il associe le label d'une autre démarche

@@ -79,6 +79,7 @@ class ConnectionUsager < Types::BaseEnum
argument :id, ID, required: false
end
field :traitements, [Types::TraitementType], null: false
field :labels, [Types::DossierLabelType], "Labels associés au dossier", null: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
field :labels, [Types::DossierLabelType], "Labels associés au dossier", null: false
field :labels, [Types::LabelType], "Labels associés au dossier", null: false

@@ -210,6 +211,10 @@ def attestation
end
end

def labels
Loaders::Association.for(object.class, dossier_labels: [:label]).load(object)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Loaders::Association.for(object.class, dossier_labels: [:label]).load(object)
Loaders::Association.for(object.class, dossier_labels: [:label]).load(object).then { _1.map(:label) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants