Commit fe2f9206 authored by Mark Boas's avatar Mark Boas
Browse files

Merge branch '50-42-agreement-issues' into 'main'

Resolve "Two generate agreement improvements…"

Closes #50, #41, and #42

See merge request mova/waterfall!28
parents 66b41675 bb80e5d3
......@@ -73,6 +73,10 @@ class WaterfallAgreement {
selects.forEach(el => {
el.selectedIndex = 0;
});
document.querySelector("#sortlist").innerHTML = "";
document.querySelector("#js-rsml").innerHTML = "";
document.querySelector("#agreement").style.display = "none";
}
checkCap = (el) => {
......@@ -437,7 +441,7 @@ class WaterfallAgreement {
}
}
saveAgreement = (el) => {
saveAgreement = () => {
const currencyIndex = document.querySelector("#currency").selectedIndex;
let saveable = true;
......@@ -578,14 +582,27 @@ class WaterfallAgreement {
}
sanitise = (str) => {
const charsToEscape = [':','{','}','[',']','&','*','#','?','|','-','<','>','=','!','%','@','\\'];
const specialChars = [':','{','}','[',']','&','*','#','?','|','-','<','>','=','!','%','@','\\'];
let quoteWrap = false;
charsToEscape.forEach(char => {
specialChars.forEach(char => {
if(str.indexOf(char) > -1) {
quoteWrap = true;
}
});
const booleanStrings = ['yes','no','true','false'];
booleanStrings.forEach(string => {
if(str.toLowerCase() === string) {
quoteWrap = true;
}
});
str = str.replaceAll("'","''");
str = str.replaceAll('"','\\"');
if (quoteWrap === true) {
return `'${str}'`;
} else {
......@@ -594,10 +611,15 @@ class WaterfallAgreement {
}
generateAgreement = () => {
let agreement = JSON.parse(localStorage.getItem(this.localStorageId));
// save agreement first, just in case
this.saveAgreement();
const agreement = JSON.parse(localStorage.getItem(this.localStorageId));
if (agreement !== null) {
let rsml = document.querySelector("#js-rsml");
rsml.innerHTML = "";
rsml.append(`name: ${this.sanitise(agreement.name)}\n`);
......
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