-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f84947b
commit 4cf8ea8
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
.../EVA-186-le-superadmin-peut-parametrer-un-masque-des-zones-deposables/readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- 📄 Standard : https://www.notion.so/captive/Le-cadrage-technique-dbb611e45f114737a6b14745caa584e9?pvs=4 --> | ||
# Le superadmin peut paramétrer une question glisser deposer | ||
|
||
> [EVA-186](https://captive-team.atlassian.net/browse/EVA-186) | ||
## Backend | ||
|
||
1. Rajouter une `has_many_attached :zones_depot_url` de type svg dans `QuestionGlisserDeposer` | ||
2. Rajouter une validation de presence sur ce model pour la zone sur ce model | ||
3. Vérifier que le svg contient la class `bonne-reponse` avant sa sauvegarde en bdd | ||
```ruby | ||
def valide_zones_depot_url_avec_reponse | ||
return unless zones_depot_url.attached? | ||
return if attachment_changes['zones_depot_url'].nil? | ||
|
||
attachment_changes['zones_depot_url'].attachable.each do |file| | ||
doc = Nokogiri::XML(file.download, nil, 'UTF-8') | ||
|
||
elements_zone_depot = doc.css(".zone-depot") | ||
elements_technique = doc.css(".zone-depot--#{reponse.nom_technique}") | ||
|
||
if elements_zone_depot.empty? || elements_technique.empty? | ||
errors.add(:zones_depot_url, "doit contenir les classes 'zone-depot' et 'zone-depot--#{reponse.nom_technique}'") | ||
throw(:abort) | ||
end | ||
end | ||
end | ||
``` | ||
5. Ajouter un `supprimer_zones_depot_url` de la même manière que zone cliquable | ||
6. Afficher un preview du svg dans la show de `QuestionGlisserDeposer` + un hint pour le format | ||
'' |