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

View File

@ -44,10 +44,14 @@ CREATE TABLE IF NOT EXISTS Bandz (
);`);
function addChikin(db, chikin) {
const sql_insert = 'INSERT INTO Chikinz (bandId, weight, killDate, wrapDate) VALUES (?, ?, ?, ?);';
const {bandId, weight, killDate, wrapDate} = chikin;
const sql_insert = 'INSERT INTO Chikinz '+
'(bandId, weight, killDate, wrapDate, wounded) ' +
'VALUES (?, ?, ?, ?, ?);';
const {bandId, weight, killDate, wrapDate, wounded} = chikin;
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) {
return reject(err);
}