implement lineup send to gamechanger
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
<tbody>
|
||||
<tr class="align-top mx-1">
|
||||
{% for event_data in contexts %}
|
||||
|
||||
<td class="px-1">
|
||||
{% include "lineup/widgets/lineup.html" with event=event_data.event event_id=event_data.event.data.id formset=event_data.formset formset_startinglineup=event_data.formset_startinglineup formset_bench=event_data.formset_bench formset_out=event_data.formset_out formset_startingpositionalonly=event_data.formset_startingpositionalonly %}
|
||||
</td>
|
||||
@@ -41,25 +40,24 @@
|
||||
{% block inline_javascript %}
|
||||
{{ block.super }}
|
||||
<script src="{% static 'js/Sortable.js' %}"></script>
|
||||
<script src="{% static 'js/lineup-table.js' %}"></script>
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
/* Run whatever you want */
|
||||
const postForms = document.querySelectorAll("[id^=form-lineup]");
|
||||
for (postForm of postForms) {
|
||||
function handleSubmit(postForm) {
|
||||
postForm.addEventListener("submit", e => {
|
||||
const postSubmits = document.querySelectorAll("[id^=submit-lineup]");
|
||||
for (postSubmit of postSubmits) {
|
||||
function handleSubmit(postSubmit) {
|
||||
postSubmit.addEventListener("click", e => {
|
||||
e.preventDefault();
|
||||
formData = new FormData(postForm);
|
||||
fetch(postForm.action, {
|
||||
formData = new FormData(postSubmit.form);
|
||||
fetch(postSubmit.formAction, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(response => response)
|
||||
.then(data => {
|
||||
{#postForm.reset();#}
|
||||
document.querySelector("#popup-messages-content").innerHTML = `<div class="alert alert-dismissible alert-success" role="alert">
|
||||
<strong>Success!</strong> ${data.formatted_title} <strong>saved</strong>.
|
||||
<strong>Success!</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div> `
|
||||
})
|
||||
@@ -69,7 +67,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
handleSubmit(postForm)
|
||||
handleSubmit(postSubmit)
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% load static %}
|
||||
<div class="card mx-auto benchcoach-lineup" style="max-width: 455px" id="benchcoach-lineup-{{ event_id }}">
|
||||
<form method="post" action='{% url 'teamsnap_submit_lineup' team_id=event.data.team_id event_id=event.data.id %}' id="form-lineup-{{ event.data.id }}">
|
||||
<form method="post" id="form-lineup-{{ event.data.id }}">
|
||||
{{ formset.management_form }}
|
||||
{% csrf_token %}
|
||||
<div class="border-bottom p-2">
|
||||
@@ -34,11 +34,17 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-teamsnap btn-sm py-0 m-1" type="submit">
|
||||
<button type="Submit" class="btn btn-teamsnap btn-sm py-0 m-1" formaction="{% url 'teamsnap_submit_lineup' team_id=event.data.team_id event_id=event.data.id %}" form="form-lineup-{{ event.data.id }}" id="submit-lineup-gamechanger-{{ event.data.id }}">
|
||||
<i class="bi bi-arrow-right"></i>
|
||||
TeamSnap
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button type="Submit" class="btn btn-gamechanger btn-sm py-0 m-1 text-nowrap" formaction="{% url 'gamechanger_lineup_submit' %}" form="form-lineup-{{ event.data.id }}" id="submit-lineup-gamechanger-{{ event.data.id }}">
|
||||
<i class="bi bi-arrow-right"></i>
|
||||
GameChanger
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
data-player-name="{{ form.member.data.last_name }}, {{ form.member.data.first_name }}"
|
||||
data-availability-statuscode="{{ form.availability.data.status_code }}"
|
||||
>
|
||||
{{ form.gamechanger_player_id.as_hidden }}
|
||||
{{ form.event_lineup_entry_id.as_hidden }}
|
||||
{{ form.event_lineup_id.as_hidden }}
|
||||
{{ form.event_id.as_hidden }}
|
||||
|
||||
Reference in New Issue
Block a user