diff --git a/scipost_django/colleges/templates/colleges/_hx_nomination_li_contents.html b/scipost_django/colleges/templates/colleges/_hx_nomination_li_contents.html index 20d95ccdc06528a773bc460223fe4ca174def562..77186605913b003ffe0b9cf2439052fc5067ac97 100644 --- a/scipost_django/colleges/templates/colleges/_hx_nomination_li_contents.html +++ b/scipost_django/colleges/templates/colleges/_hx_nomination_li_contents.html @@ -1,5 +1,9 @@ <div class="p-4"> <div class="row mb-0"> + + <div id="profile-{{ nomination.profile.id }}-specialties" + class="border border-danger mb-4 d-none-empty"></div> + <div class="col-12 col-md mb-3"> <div class="card"> <div class="card-header">Details</div> @@ -11,17 +15,9 @@ </tr> <tr> <td>Specialties</td> - <td> + <td id="profile-{{ nomination.profile.id }}-specialties-code-display"> - {% for specialty in nomination.profile.specialties.all %} - <div class="single d-inline" - data-specialty="{{ specialty }}" - data-bs-toggle="tooltip" - data-bs-placement="bottom" - title="{{ specialty }}">{{ specialty.code }}</div> - {% empty %} - undefined - {% endfor %} + {% include "profiles/_hx_profile_specialty_codes_edit.html" with profile=nomination.profile %} </td> </tr> diff --git a/scipost_django/profiles/templates/profiles/_hx_profile_specialties.html b/scipost_django/profiles/templates/profiles/_hx_profile_specialties.html index e695a1b549269a0fdcd43a6449f0040005c8c554..1168855e42c3eb14c8a92a05050f0b41ef43dd21 100644 --- a/scipost_django/profiles/templates/profiles/_hx_profile_specialties.html +++ b/scipost_django/profiles/templates/profiles/_hx_profile_specialties.html @@ -2,49 +2,63 @@ <div class="col"> <table class="table"> <caption style="caption-side: top;">Specialties (current)</caption> + {% for spec in profile.specialties.all %} - <tr> - <td>{{ spec }}</td> - <td> - <form hx-post="{% url 'profiles:_hx_profile_specialties' profile_id=profile.id %}" - hx-target="#profile-{{ profile.id }}-specialties" - > - {% csrf_token %} - <input type="hidden" name="action" value="remove"> - <input type="hidden" name="spec_slug" value="{{ spec.slug }}"> - <button class="btn btn-sm btn-danger">Remove</button> - </form> - </td> - </tr> + <tr> + <td>{{ spec }}</td> + <td> + <form hx-post="{% url 'profiles:_hx_profile_specialties' profile_id=profile.id %}" + hx-target="#profile-{{ profile.id }}-specialties"> + {% csrf_token %} + <input type="hidden" name="action" value="remove" /> + <input type="hidden" name="spec_slug" value="{{ spec.slug }}" /> + <button class="btn btn-sm btn-danger">Remove</button> + </form> + </td> + </tr> {% empty %} - <tr> - <td colspan="2">None defined</td> - </tr> + <tr> + <td colspan="2">None defined</td> + </tr> {% endfor %} + </table> </div> <div class="col"> <table class="table"> <caption style="caption-side: top;">Other specialties</caption> + {% for spec in other_specialties.all %} - <tr> - <td>{{ spec }}</td> - <td> - <form hx-post="{% url 'profiles:_hx_profile_specialties' profile_id=profile.id %}" - hx-target="#profile-{{ profile.id }}-specialties" - > - {% csrf_token %} - <input type="hidden" name="action" value="add"> - <input type="hidden" name="spec_slug" value="{{ spec.slug }}"> - <button class="btn btn-sm btn-primary">Add</button> - </form> - </td> - </tr> + <tr> + <td>{{ spec }}</td> + <td> + <form hx-post="{% url 'profiles:_hx_profile_specialties' profile_id=profile.id %}" + hx-target="#profile-{{ profile.id }}-specialties"> + {% csrf_token %} + <input type="hidden" name="action" value="add" /> + <input type="hidden" name="spec_slug" value="{{ spec.slug }}" /> + <button class="btn btn-sm btn-primary">Add</button> + </form> + </td> + </tr> {% empty %} - <tr> - <td colspan="2">None defined</td> - </tr> + <tr> + <td colspan="2">None defined</td> + </tr> {% endfor %} + </table> </div> </div> + +<button class="btn btn-success mb-2 text-white" + hx-get="{% url "common:empty" %}" + hx-swap="innerHTML" + hx-target="#profile-{{ profile.id }}-specialties">Done</button> + + +<div hx-swap-oob="innerHTML:#profile-{{ profile.id }}-specialties-code-display"> + + {% include "profiles/_hx_profile_specialty_codes_edit.html" with profile=profile %} + +</div> diff --git a/scipost_django/profiles/templates/profiles/_hx_profile_specialty_codes_edit.html b/scipost_django/profiles/templates/profiles/_hx_profile_specialty_codes_edit.html new file mode 100644 index 0000000000000000000000000000000000000000..ce66b675f0ddc601652c03ef09d7f84cbf56836d --- /dev/null +++ b/scipost_django/profiles/templates/profiles/_hx_profile_specialty_codes_edit.html @@ -0,0 +1,13 @@ +{% for specialty in profile.specialties.all %} + <div class="single d-inline" + data-specialty="{{ specialty }}" + data-bs-toggle="tooltip" + data-bs-placement="bottom" + title="{{ specialty }}">{{ specialty.code }}</div> +{% empty %} + <span class="badge bg-danger">unknown</span> +{% endfor %} + +<a class="p-2 mt-2" + hx-get="{% url 'profiles:_hx_profile_specialties' profile_id=profile.id %}" + hx-target="#profile-{{ profile.id }}-specialties">edit</a>