add default option
This commit is contained in:
parent
1c3264f9cb
commit
caa299bfb0
|
|
@ -74,6 +74,17 @@
|
|||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<label class = "form-check-label" for="default">
|
||||
This should be the default preparation setup
|
||||
</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input class="form-check-input" type="checkbox" id = "Default" name="default">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary float-end" type="submit">submit</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -98,6 +109,9 @@
|
|||
|
||||
function add(event){
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
let prep_protocol = {
|
||||
"name" : document.getElementById("name").value,
|
||||
"Sample_Size" : document.getElementById("Sample_Size").value,
|
||||
|
|
@ -108,16 +122,30 @@
|
|||
let transaction = db.transaction(["prep_protocol"], "readwrite");
|
||||
let objectStore = transaction.objectStore("prep_protocol");
|
||||
let add_request = objectStore.add(prep_protocol); // (3)
|
||||
|
||||
transaction.oncomplete = (event) => {
|
||||
let id_of_setup = 0;
|
||||
add_request.onsuccess = (event) => {
|
||||
console.log("All done!");
|
||||
id_of_setup = event.target.result;
|
||||
if (document.getElementById("Default").checked){
|
||||
let my_default = {"id" : 1, "prep_setup" : id_of_setup};
|
||||
let next_transaction = db.transaction(["defaults"], "readwrite");
|
||||
let next_objectStore = next_transaction.objectStore("defaults");
|
||||
let add_next_request = next_objectStore.put(my_default);
|
||||
transaction.oncomplete = () => {
|
||||
console.log("All done!");
|
||||
};
|
||||
transaction.onerror = () => {
|
||||
console.log("something went wrong");
|
||||
// Don't forget to handle errors!
|
||||
};
|
||||
}
|
||||
};
|
||||
transaction.onerror = (event) => {
|
||||
console.log("something went wrong");
|
||||
// Don't forget to handle errors!
|
||||
};
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue