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

Option pour remplacer un ingrédient demandé par un ingrédient existant #1334

Merged
merged 32 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dab1c7e
Move alert handling to separate file
hfroot Nov 26, 2024
b4594b1
Add first elements of UI for search of ingredient
hfroot Nov 26, 2024
ad3dd7c
Fetch element detail, display synonyms
hfroot Nov 26, 2024
e569633
Activate replace button when ingredient selected
hfroot Nov 26, 2024
fbc13dc
Ability to add an existing ingredient to a declared one
hfroot Nov 28, 2024
803d024
Add success replace alert with element link
hfroot Nov 28, 2024
3449deb
Proper alignment when showing label of autocomplete as well as search…
hfroot Dec 3, 2024
459cc1c
Front: prevent demand being replaced with ingredient of different type
hfroot Dec 3, 2024
567f87f
Merge branch 'staging' into replace-ingredient-request
hfroot Dec 5, 2024
d595bb7
Add merge migration
hfroot Dec 5, 2024
93fac1d
Refactor API to reduce code repetition
hfroot Dec 19, 2024
58246dc
Refactor from REST to RPC
hfroot Dec 19, 2024
7a081f0
Require passing replacement element type to avoid accidentally replac…
hfroot Dec 19, 2024
f88a103
Prevent the replacement cross-type
hfroot Dec 19, 2024
705bdc1
Update front with new API and add request info and notes to response
hfroot Dec 19, 2024
60c77b3
When a demand is replaced, it is no longer new
hfroot Dec 19, 2024
c1371e4
Minimal solution for explaining the ingredient name change in declara…
hfroot Dec 19, 2024
8863961
Recommend instructor to return declaration to recalculate substances
hfroot Dec 19, 2024
b5a217a
Only show warning if replacement adds substances to composition
hfroot Dec 19, 2024
5786381
Merge branch 'staging' into replace-ingredient-request
hfroot Dec 19, 2024
e554e92
Merge migration
hfroot Dec 19, 2024
9f8b2ff
Merge branch 'staging' into replace-ingredient-request
alemangui Dec 27, 2024
1e2566e
Adds merge migration
alemangui Dec 27, 2024
4a07319
Merge branch 'staging' into replace-ingredient-request
hfroot Jan 6, 2025
198532d
Update warning message
hfroot Jan 6, 2025
1601c52
Change autocomplete API to use 'required' for consistency
hfroot Jan 6, 2025
db5169f
Add permissions checks on info and reject endpoints
hfroot Jan 6, 2025
0073130
Fix error handling
hfroot Jan 6, 2025
f986101
Update frontend/src/views/DeclaredElementPage/index.vue
hfroot Jan 6, 2025
6251920
Move comment to GH
hfroot Jan 6, 2025
84fa063
Add id to declared element error message
hfroot Jan 6, 2025
450c030
Update frontend/src/components/DeclarationSummary/index.vue
alemangui Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update front with new API and add request info and notes to response
  • Loading branch information
hfroot committed Dec 19, 2024
commit 705bdc10c5d713636541cf00bf60f7337beeb7ac
1 change: 1 addition & 0 deletions api/tests/test_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,7 @@ def test_request_info_declared_element(self):
format="json",
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()["requestStatus"], DeclaredMicroorganism.AddableStatus.INFORMATION)
microorganism.refresh_from_db()
self.assertEqual(microorganism.request_private_notes, "some notes")
self.assertEqual(microorganism.request_status, DeclaredMicroorganism.AddableStatus.INFORMATION)
Expand Down
2 changes: 1 addition & 1 deletion api/views/declaration/declared_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def post(self, request, pk, type):
self._update_element(element, request)
element.save()

return Response(self.type_serializer(element).data)
return Response(self.type_serializer(element, context={"request": request}).data)

@abc.abstractmethod
def _update_element(self, element, request):
Expand Down
17 changes: 7 additions & 10 deletions frontend/src/views/DeclaredElementPage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ const actionButtons = computed(() => [
},
])

const updateElement = async (payload) => {
const { data, response } = await useFetch(url, {
const updateElement = async (action, payload) => {
const { data, response } = await useFetch(`${url.value}/${action}`, {
headers: headers(),
})
.patch(payload)
.post(payload)
.json()
// TODO: is this handling errors nicely?
alemangui marked this conversation as resolved.
Show resolved Hide resolved
handleError(response)
Expand All @@ -135,11 +135,10 @@ const modals = computed(() => {
label: "Remplacer",
onClick() {
const payload = {
requestStatus: "REPLACED",
element: { id: replacement.value?.id },
element: { id: replacement.value?.id, type: replacement.value?.objectType },
}
// TODO: clear search if we stay on page
updateElement(payload).then(closeModal)
updateElement("replace", payload).then(closeModal)
},
disabled: cannotReplace.value,
},
Expand All @@ -151,8 +150,7 @@ const modals = computed(() => {
{
label: "Enregistrer",
onClick() {
updateElement({
requestStatus: "INFORMATION",
updateElement("request-info", {
requestPrivateNotes: notes.value,
}).then(closeModal)
},
Expand All @@ -165,8 +163,7 @@ const modals = computed(() => {
{
label: "Refuser",
onClick() {
updateElement({
requestStatus: "REJECTED",
updateElement("reject", {
requestPrivateNotes: notes.value,
}).then(closeModal)
},
Expand Down
Loading