Commit 40b94ec7 authored by Mark Boas's avatar Mark Boas
Browse files

fix for #40

parent 81da60f3
......@@ -281,7 +281,7 @@
<ul id="sortlist">
</ul>
<button onclick="saveAgreement(); return false">Save agreement<i class="gg-check-r"></i></button>&nbsp;<button class="button-secondary" disabled>Generate agreement</button><button class="button-secondary float-right clear-button" onclick="if(confirm('Are you sure you want to delete this agreement')) { clearAgreement();} return false;">Clear</button>
<button onclick="saveAgreement(); return false">Save agreement<i class="gg-check-r"></i></button>&nbsp;<button class="button-secondary">Generate agreement</button><button class="button-secondary float-right clear-button" onclick="if(confirm('Are you sure you want to delete this agreement')) { clearAgreement();} return false;">Clear</button>
</fieldset>
</form>
......
......@@ -9,9 +9,15 @@ function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
// A function we use when we have the actual text (not value)
// of a select box, and we want to grab the index to set it
function getOptionIndex(selectElement, value) {
let options = selectElement.options;
index = 0;
//TODO - check that options are not null or undefined
for (let option of options) {
if (option.textContent === value) {
return index;
......@@ -535,10 +541,13 @@ function populateFromLocalStorage(){
document.querySelector("#start").value = agreement.startDate;
document.querySelector("#end").value = agreement.endDate;
let payeeIndex = 0;
if (agreement.steps.length > 0) {
agreement.steps.forEach((step, index) => {
//create step
addStepForm(index);
const form = document.querySelector(`#js-step${index}`);
form.querySelector(".js-step").value = step.description;
form.querySelector(".js-step-type").value = step.type;
......@@ -546,14 +555,14 @@ function populateFromLocalStorage(){
if (step.type === "fixed") {
form.querySelector(".js-step-cap").setAttribute("disabled", true);
} else {
//form.querySelector(".js-step-cap").setAttribute('value', Number(step.cap.replace(/[^0-9.-]+/g,"")));
form.querySelector(".js-step-cap").setAttribute('value', step.cap);
form.querySelector(".js-step-cap").value = step.cap;
}
step.payees.forEach((payee, index) => {
step.payees.forEach(payee => {
addPayee(form.querySelector(".js-add-payee"));
const payeeForm = document.querySelectorAll(".js-payeerow")[index];
const payeeForm = document.querySelectorAll(".js-payeerow")[payeeIndex];
payeeIndex++;
payeeForm.querySelector(".js-payee-name").value = payee.name;
payeeForm.querySelector(".js-payee-ac").value = payee.paymentAddress;
......
Supports Markdown
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