-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Ajout d'un attribut pour filtrer l'envoi des besoins d'achat (#…
- Loading branch information
Showing
8 changed files
with
193 additions
and
4 deletions.
There are no files selected for viewing
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
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,55 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const modal = document.getElementById('tender-send-confirmation-modal'); | ||
const confirmBtn = document.getElementById('submit-button'); | ||
const cancelBtn = document.getElementById('cancel-button'); | ||
|
||
function openModal(recipient, title) { | ||
const messageElement = document.getElementById('tender-send-message'); | ||
|
||
// Set an attribute 'name' depending on the recipient | ||
if (recipient === 'siaes') { | ||
messageElement.textContent = `Le besoin « ${title} » sera envoyé aux structures.`; | ||
confirmBtn.setAttribute('name', '_validate_send_to_siaes'); | ||
} else if (recipient === 'partners') { | ||
const message = `Le besoin « ${title} » sera envoyé uniquement aux partenaires commerciaux.`; | ||
messageElement.textContent = message; | ||
confirmBtn.setAttribute('name', '_validate_send_to_commercial_partners'); | ||
} | ||
modal.style.display = 'block'; | ||
} | ||
// data-recipent attribute determines the recipient of the tender | ||
const buttons = document.querySelectorAll('input[data-recipient]'); | ||
buttons.forEach(function(button) { | ||
button.addEventListener('click', function(e) { | ||
e.preventDefault(); // Prevent instant form submission | ||
const recipient = button.dataset.recipient; | ||
const title = button.dataset.title; | ||
openModal(recipient, title); | ||
}); | ||
}); | ||
|
||
function closeModal() { | ||
modal.style.display = 'none'; | ||
} | ||
|
||
// Two different ways to close the modal: | ||
// click on the cancel button | ||
cancelBtn.addEventListener('click', function(e) { | ||
e.preventDefault(); // Prevent page from scrolling up | ||
closeModal(); | ||
}); | ||
|
||
// click outside the modal | ||
window.addEventListener('click', function (e) { | ||
if (e.target === modal) { | ||
closeModal(); | ||
} | ||
}); | ||
|
||
// Action confirmation | ||
confirmBtn.addEventListener('click', function () { | ||
if (formToSubmit) { | ||
formToSubmit.submit(); | ||
} | ||
}); | ||
}); |
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
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
17 changes: 17 additions & 0 deletions
17
lemarche/tenders/migrations/0092_tender_send_to_commercial_partners_only.py
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,17 @@ | ||
# Generated by Django 4.2.15 on 2024-09-27 12:50 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("tenders", "0091_tender_is_followed_by_us_tender_is_reserved_tender_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="tender", | ||
name="send_to_commercial_partners_only", | ||
field=models.BooleanField(default=False, verbose_name="Envoyer uniquement aux partenaires externes"), | ||
), | ||
] |
17 changes: 17 additions & 0 deletions
17
lemarche/tenders/migrations/0093_alter_tender_send_to_commercial_partners_only.py
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,17 @@ | ||
# Generated by Django 4.2.15 on 2024-10-03 16:05 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("tenders", "0092_tender_send_to_commercial_partners_only"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="tender", | ||
name="send_to_commercial_partners_only", | ||
field=models.BooleanField(default=False, verbose_name="Envoyer uniquement aux partenaires commerciaux"), | ||
), | ||
] |
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
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