Skip to content
This repository was archived by the owner on Nov 23, 2024. It is now read-only.
Open
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
23 changes: 15 additions & 8 deletions sw-admin/templates/addpoll.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h3 class="mb-5">Dodawanie nowego głosowania</h3>
<br />

Głosujacy (adresy email w nowych liniach): <br/>
<textarea class="form-control" id="pollRecipients" placeholder="1@student.pwr.edu.pl&#10;2@student.pwr.edu.pl&#10;..." rows=10></textarea>
<textarea class="form-control" id="pollRecipients" placeholder="1@student.pwr.edu.pl&#10;2@student.pwr.edu.pl&#10;123456&#10;..." rows=10></textarea>
<br /> <br />
<div class="d-flex justify-content-left align-items-center">
Data zakończenia głosowania:
Expand Down Expand Up @@ -110,12 +110,12 @@ <h3 class="mb-5">Dodawanie nowego głosowania</h3>

<script>
function deleteRow(el) {
var row = el.parentNode.parentNode;
const row = el.parentNode.parentNode;
document.getElementById('pollOptionsTBody').removeChild(row);
}
function addRow(el) {
var row = el.parentNode.parentNode;
var tr = document.createElement('tr');
const row = el.parentNode.parentNode;
const tr = document.createElement('tr');
tr.innerHTML = '<td><input class="form-control" type="text" placeholder="Jan Kowalski"></td>';
tr.innerHTML += '<td><input class="form-control" type="text" placeholder="Wydział Architektury"></td>';
tr.innerHTML += '<td><button class="btn btn-danger" onclick="deleteRow(this)"><i class="fas fa-trash-alt"></i></button></td>';
Expand All @@ -125,7 +125,7 @@ <h3 class="mb-5">Dodawanie nowego głosowania</h3>
return document.getElementById(elName).value;
}
function sendForm(data) {
let form = document.createElement('form');
const form = document.createElement('form');
form.method = "POST";
form.action = "";
form.style.display = 'none';
Expand All @@ -140,17 +140,24 @@ <h3 class="mb-5">Dodawanie nowego głosowania</h3>
form.submit();
}
function send() {
let options = Array.from(document.getElementById('pollOptionsTBody').rows)
const options = Array.from(document.getElementById('pollOptionsTBody').rows)
.filter(row => row.childElementCount != 1) // filter out the last row with the add button
.map(row => ({
name: row.children[0].getElementsByTagName('input')[0].value,
description: row.children[1].getElementsByTagName('input')[0].value,
}));
let data = {
const createPollRecipient = (recipient) => {
recipient = recipient.trim();
if (recipient.split('@').length === 1 && /^\d+$/.test(recipient.split('@')[0])) {
return recipient.concat('@student.pwr.edu.pl');
}
return recipient;
}
const data = {
name: val('pollName'),
options: JSON.stringify(options),
choiceType: 'multiple-choice',
recipients: JSON.stringify(pollRecipients.value.split('\n').filter(email => email.length != 0).map(email => email.trim())),
recipients: JSON.stringify(pollRecipients.value.split('\n').filter(email => email.length != 0).map(recipient => createPollRecipient(recipient))),
closesOnDate: val('pollClosesOnDate') + ' ' + val('pollClosesOnTime'),
visibility: 'private',
mailTemplate: val('pollMailTemplate'),
Expand Down
23 changes: 15 additions & 8 deletions sw-admin/templates/editpoll.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
<br /> <br />

Głosujacy (adresy email w nowych liniach): <br/>
<textarea class="form-control" id="pollRecipients" placeholder="1@student.pwr.edu.pl&#10;2@student.pwr.edu.pl&#10;..." rows=10 {{should_disable}}>{{ "\n".join(possible_recipients) }}</textarea>
<textarea class="form-control" id="pollRecipients" placeholder="1@student.pwr.edu.pl&#10;2@student.pwr.edu.pl&#10;123456&#10;..." rows=10 {{should_disable}}>{{ "\n".join(possible_recipients) }}</textarea>
<br /> <br />
<div class="d-flex justify-content-left align-items-center">
Data zakończenia głosowania:
Expand All @@ -81,12 +81,12 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</

<script>
function deleteRow(el) {
var row = el.parentNode.parentNode;
const row = el.parentNode.parentNode;
document.getElementById('pollOptionsTBody').removeChild(row);
}
function addRow(el) {
var row = el.parentNode.parentNode;
var tr = document.createElement('tr');
const row = el.parentNode.parentNode;
const tr = document.createElement('tr');
tr.innerHTML = '<td><input class="form-control" type="text" placeholder="Jan Kowalski"></td>';
tr.innerHTML += '<td><input class="form-control" type="text" placeholder="Wydział Architektury"></td>';
tr.innerHTML += '<td><button class="btn btn-danger" onclick="deleteRow(this)"><i class="fas fa-trash-alt"></i></button></td>';
Expand All @@ -96,7 +96,7 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
return document.getElementById(elName).value;
}
function sendForm(data) {
let form = document.createElement('form');
const form = document.createElement('form');
form.method = "POST";
form.action = "{% block formactionpath %}?id={{poll_id}}{% endblock %}";
form.style.display = 'none';
Expand All @@ -111,17 +111,24 @@ <h3 class="mb-5">{% block header %}Edycja głosowania "{{name}}"{% endblock %}</
form.submit();
}
function send() {
let options = Array.from(document.getElementById('pollOptionsTBody').rows)
const options = Array.from(document.getElementById('pollOptionsTBody').rows)
.filter(row => row.childElementCount != 1) // filter out the last row with the add button
.map(row => ({
name: row.children[0].getElementsByTagName('input')[0].value,
description: row.children[1].getElementsByTagName('input')[0].value,
}));
let data = {
const createPollRecipient = (recipient) => {
recipient = recipient.trim();
if (recipient.split('@').length === 1 && /^\d+$/.test(recipient.split('@')[0])) {
return recipient.concat('@student.pwr.edu.pl');
}
return recipient;
}
const data = {
name: val('pollName'),
options: JSON.stringify(options),
choiceType: 'multiple-choice',
recipients: JSON.stringify(pollRecipients.value.split('\n').filter(email => email.length != 0).map(email => email.trim())),
recipients: JSON.stringify(pollRecipients.value.split('\n').filter(email => email.length != 0).map(recipient => createPollRecipient(recipient))),
closesOnDate: val('pollClosesOnDate') + ' ' + val('pollClosesOnTime'),
visibility: 'private',
mailTemplate: val('pollMailTemplate'),
Expand Down