Add wounded checkbox

This commit is contained in:
Paul Mathieu 2022-09-11 15:33:51 +02:00
parent 023e7767f2
commit f569707ab1
2 changed files with 15 additions and 5 deletions

View File

@ -54,14 +54,14 @@ $(document).ready(() => {
$('<select>') $('<select>')
.append('<option disabled selected>Choose a band</option>') .append('<option disabled selected>Choose a band</option>')
) )
.append('<label>Band</label>'); .append('<label>band</label>');
const block = $('<div class="section">'); const block = $('<div class="section">');
block block
.append(bandSelect) .append(bandSelect)
.append($('<div class="input-field col s12">') .append($('<div class="input-field col s12">')
.append('<input type="text" class="datepicker">') .append('<input type="text" class="datepicker">')
.append('<label>Date of wrapping</label>') .append('<label>date of wrapping</label>')
); );
const loader = $('<div class="progress"><div class="indeterminate"></div></div>') const loader = $('<div class="progress"><div class="indeterminate"></div></div>')
@ -78,6 +78,7 @@ $(document).ready(() => {
bandId: $('select').val(), bandId: $('select').val(),
wrapDate: $('.datepicker').val(), wrapDate: $('.datepicker').val(),
weight: $('#weight').val(), weight: $('#weight').val(),
wounded: $('#wounded').prop('checked'),
}; };
try { try {
@ -87,6 +88,7 @@ $(document).ready(() => {
} finally { } finally {
loader.hide(); loader.hide();
$('#weight').val(''); $('#weight').val('');
$('#wounded').prop('checked', false);
$('#send').removeClass('disabled'); $('#send').removeClass('disabled');
} }
}) })
@ -98,6 +100,10 @@ $(document).ready(() => {
.append('<input type="text" inputmode="decimal" id="weight">') .append('<input type="text" inputmode="decimal" id="weight">')
.append('<label>weight (g)</label>') .append('<label>weight (g)</label>')
) )
.append(
$('<div class="input-field col s12">')
.append('<label><input type="checkbox" class="filled-in" id="wounded" /><span>wounded</span></label>')
)
.append( .append(
$('<div class="input-field col s12">') $('<div class="input-field col s12">')
.append(action) .append(action)

View File

@ -44,10 +44,14 @@ CREATE TABLE IF NOT EXISTS Bandz (
);`); );`);
function addChikin(db, chikin) { function addChikin(db, chikin) {
const sql_insert = 'INSERT INTO Chikinz (bandId, weight, killDate, wrapDate) VALUES (?, ?, ?, ?);'; const sql_insert = 'INSERT INTO Chikinz '+
const {bandId, weight, killDate, wrapDate} = chikin; '(bandId, weight, killDate, wrapDate, wounded) ' +
'VALUES (?, ?, ?, ?, ?);';
const {bandId, weight, killDate, wrapDate, wounded} = chikin;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
db.run(sql_insert, [bandId, weight, killDate, wrapDate], function(err) { db.run(sql_insert,
[bandId, weight, killDate, wrapDate, wounded],
function(err) {
if (err) { if (err) {
return reject(err); return reject(err);
} }