-
Notifications
You must be signed in to change notification settings - Fork 91
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
base: main
Are you sure you want to change the base?
API: gestion des labels #11201
Conversation
colinux
commented
Jan 13, 2025
•
edited
Loading
edited
- 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
Codecov ReportAttention: Patch coverage is
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. |
|
||
def color | ||
object.label.color | ||
end |
There was a problem hiding this comment.
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é
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loaders::Association.for(object.class, dossier_labels: [:label]).load(object) | |
Loaders::Association.for(object.class, dossier_labels: [:label]).load(object).then { _1.map(:label) } |