Commit 577f0c7f authored by Mark Boas's avatar Mark Boas
Browse files

generate top level rsml

parent 40b94ec7
......@@ -281,12 +281,16 @@
<ul id="sortlist">
</ul>
<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>
<button onclick="saveAgreement(); return false">Save agreement<i class="gg-check-r"></i></button>&nbsp;<button onclick="generateAgreement(); return false" 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>
</div>
<div id="agreement" class="container margin-top" style="display:none">
<h4>RSML Agreement</h4>
<pre><code id="js-rsml"></code></pre>
</div>
<!-- <div id="agreement" class="container margin-top">
......
......@@ -579,6 +579,66 @@ function populateFromLocalStorage(){
}
}
}
function generateAgreement(){
console.log("here");
let agreement = JSON.parse(localStorage.getItem(localStorageId));
if (agreement !== null) {
console.log("here");
let rsml = document.querySelector("#js-rsml");
rsml.append(`name: ${agreement.name}\n`);
rsml.append(`description: ${agreement.description}\n`);
rsml.append(`address: ${agreement.address}\n`);
rsml.append(`currency: ${agreement.currency}\n`);
rsml.append(`contactName: ${agreement.contactName}\n`);
rsml.append(`repeatFor: ${agreement.repeatFor}\n`);
rsml.append(`unit: ${agreement.unit}\n`);
rsml.append(`startDate: ${agreement.startDate}\n`);
rsml.append(`endDate: ${agreement.endDate}\n`);
document.querySelector("#agreement").style.display = "block";
/*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;
if (step.type === "fixed") {
form.querySelector(".js-step-cap").setAttribute("disabled", true);
} else {
form.querySelector(".js-step-cap").value = step.cap;
}
step.payees.forEach(payee => {
addPayee(form.querySelector(".js-add-payee"));
const payeeForm = document.querySelectorAll(".js-payeerow")[payeeIndex];
payeeIndex++;
payeeForm.querySelector(".js-payee-name").value = payee.name;
payeeForm.querySelector(".js-payee-ac").value = payee.paymentAddress;
let select = payeeForm.querySelector(".js-payee-type");
let selectedIndex = getOptionIndex(select, payee.paymentType);
select.options[selectedIndex].setAttribute('selected', "true");
payeeForm.querySelector(".js-payee-amount").value = payee.paymentAmount;
});
saveStep(form.querySelector(".js-save-step"));
});
}*/
}
}
function showAlert(message, container) {
......
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