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

232: Details dont get pre-filled using the "Update FROM info" modal o… #273

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions backend/api/base/modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ def open_modal(request: HttpRequest, modal_name, context_type=None, context_valu
# context["to_city"] = invoice.client_city
# context["to_county"] = invoice.client_county
# context["to_country"] = invoice.client_country
elif context_type == "edit_invoice_from":
invoice = context_value
try:
invoice = Invoice.objects.get(user=request.user, id=invoice)
except Invoice.DoesNotExist:
return render(request, template_name, context)

context["from_name"] = invoice.self_name
context["from_company"] = invoice.self_company
context["from_address"] = invoice.self_address
context["from_city"] = invoice.self_city
context["from_county"] = invoice.self_county
context["from_country"] = invoice.self_country
elif context_type == "invoice":
try:
invoice = Invoice.objects.get(id=context_value)
Expand Down
12 changes: 6 additions & 6 deletions frontend/templates/modals/invoices_from_destination.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,47 @@
<input type="text"
name="name"
placeholder="John Smith"
value=""
value="{{ from_name }}"
class="input input-bordered max-w-full">
</div>
<div class="form-control">
<label class="label">Company</label>
<input type="text"
name="company"
placeholder="Google"
value=""
value="{{ from_company }}"
class="input input-bordered max-w-full">
</div>
<div class="form-control">
<label class="label">Address</label>
<input type="text"
name="address"
placeholder="128 Road"
value=""
value="{{ from_address }}"
class="input input-bordered max-w-full">
</div>
<div class="form-control">
<label class="label">City</label>
<input type="text"
name="city"
placeholder="Oxford"
value=""
value="{{ from_city }}"
class="input input-bordered max-w-full">
</div>
<div class="form-control">
<label class="label">County</label>
<input type="text"
name="county"
placeholder="Oxfordshire"
value=""
value="{{ from_county }}"
class="input input-bordered max-w-full">
</div>
<div class="form-control">
<label class="label">Country</label>
<input type="text"
name="country"
placeholder="England"
value=""
value="{{ from_country }}"
class="input input-bordered max-w-full">
</div>
<div class="modal-action">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
hx-trigger="click once"
hx-swap="beforeend"
hx-target="#modal_container"
hx-get="{% url "api:base:modal retrieve" modal_name="invoices_from_destination" %}">
hx-get="{% url 'api:base:modal retrieve with context' modal_name='invoices_from_destination' context_type='edit_invoice_from' context_value=invoice_object.id %}">
{% endif %}
<!-- *Need to replace the default values with attributes from data_to_populate dict* -->
<!-- PRE-POPULATE FIELDS WITH EXISTING DATA OF THE INVOICE-->
Expand Down
Loading