Commit 4e92b873 authored by Hayat's avatar Hayat
Browse files

Merge branch 'add-empty' into 'main'

allow to add unchecked checkboxes

See merge request !35
parents 85d987aa b11845b5
Pipeline #12703 passed with stages
in 1 minute and 42 seconds
......@@ -111,6 +111,11 @@ msgstr "Neuen Terminplan erstellen"
msgid "Timeslots"
msgstr "Termine"
#: scheduler/main/templates/main/schedule_form.html:30
#: scheduler/main/templates/main/schedule_form.html:42
msgid "Check new checkboxes"
msgstr "Neue Checkboxen ankreuzen"
#: scheduler/main/templates/main/schedule_form.html:30
msgid "Add date"
msgstr "Datum hinzufügen"
......
......@@ -30,13 +30,13 @@
return i;
};
var createCell = function(date, time) {
var createCell = function(date, time, checked) {
var td = document.createElement('td');
var checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.name = 'timeslots';
checkbox.value = date + ' ' + time;
checkbox.checked = true;
checkbox.checked = checked;
td.append(checkbox);
return td;
};
......@@ -60,7 +60,7 @@
return i;
};
var addDate = function(table, date) {
var addDate = function(table, date, checked) {
var tbody = table.querySelector('tbody');
var index = getInsertIndex(tbody.children, date, 0);
......@@ -75,7 +75,7 @@
td.textContent = formatDate(date) + ' ';
td.append(createDeleteButton(rmRow));
} else {
td = createCell(date, time);
td = createCell(date, time, checked);
}
tr.append(td);
}
......@@ -87,7 +87,7 @@
}
};
var addTime = function(table, time) {
var addTime = function(table, time, checked) {
var index = getInsertIndex(table.querySelectorAll('thead th'), time, 1);
for (let tr of table.querySelectorAll('tr')) {
......@@ -99,7 +99,7 @@
td.textContent = formatTime(time) + ' ';
td.append(createDeleteButton(rmCol));
} else {
td = createCell(date, time);
td = createCell(date, time, checked);
}
if (index < tr.children.length) {
......@@ -125,12 +125,12 @@
document.getElementById('add_date').addEventListener('submit', function(event) {
event.preventDefault();
addDate(table, event.target.input.value);
addDate(table, event.target.input.value, event.target.checked.checked);
});
document.getElementById('add_time').addEventListener('submit', function(event) {
event.preventDefault();
addTime(table, event.target.input.value);
addTime(table, event.target.input.value, event.target.checked.checked);
});
for (let th of table.querySelectorAll('thead th')) {
......
......@@ -24,18 +24,26 @@
<fieldset>
<legend>{% translate 'Timeslots' %}</legend>
<div class="mb-3 row gx-2">
<div class="mb-3 row gx-2 align-items-center">
<div class="col col-sm-4">
<input type="date" form="add_date" name="input" class="form-control" required>
</div>
<label class="col flex-grow-0">
<span class="visually-hidden">{% translate 'Check new checkboxes' %}</span>
<input type="checkbox" form="add_date" name="checked" title="{% translate 'Check new checkboxes' %}" checked>
</label>
<div class="col">
<button form="add_date" class="btn btn-secondary">{% translate 'Add date' %}</button>
</div>
</div>
<div class="mb-3 row gx-2">
<div class="mb-3 row gx-2 align-items-center">
<div class="col col-sm-4">
<input type="time" form="add_time" name="input" class="form-control" required>
</div>
<label class="col flex-grow-0">
<span class="visually-hidden">{% translate 'Check new checkboxes' %}</span>
<input type="checkbox" form="add_time" name="checked" title="{% translate 'Check new checkboxes' %}" checked>
</label>
<div class="col">
<button form="add_time" class="btn btn-secondary">{% translate 'Add time' %}</button>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment