Compare commits
3 Commits
c83f66c38d
...
c94bc35573
Author | SHA1 | Date |
---|---|---|
|
c94bc35573 | |
|
55532c2e35 | |
|
fec3812ab7 |
|
@ -8,8 +8,10 @@ document.getElementById('luokat-uusi').addEventListener('submit', (e) => {
|
|||
e.preventDefault();
|
||||
suorita(_tietokanta.transaktio((t) => {
|
||||
const luokanNimi = document.getElementById('luokat-uusi-nimi').value;
|
||||
if (luokanNimi !== '') {
|
||||
t.lisää(taulut.luokat, luokanNimi)
|
||||
document.getElementById('luokat-uusi-nimi').value = '';
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
|
@ -49,6 +51,15 @@ function vertaa(a, b) {
|
|||
function luoLuokka(id, nimi) {
|
||||
const li = document.createElement('li');
|
||||
li.id = `luokka-${id}`;
|
||||
li.textContent = nimi;
|
||||
const poistoPainike = document.createElement('input');
|
||||
poistoPainike.type = 'button';
|
||||
poistoPainike.value = '-';
|
||||
poistoPainike.addEventListener('click', () => {
|
||||
suorita(_tietokanta.transaktio((t) => {
|
||||
t.poista(taulut.luokat, id);
|
||||
}));
|
||||
});
|
||||
li.appendChild(poistoPainike);
|
||||
li.appendChild(document.createTextNode(nimi));
|
||||
return li;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class Tietokanta {
|
|||
}
|
||||
|
||||
suorita(transaktio) {
|
||||
if (transaktio.peruttu) {
|
||||
if (transaktio.peruttu || transaktio.muutokset.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue