Skip to content

Commit

Permalink
Fix email editor for other email types
Browse files Browse the repository at this point in the history
  • Loading branch information
hrfee committed Apr 22, 2021
1 parent d772e43 commit 90a2c1f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
3 changes: 1 addition & 2 deletions template.go
Expand Up @@ -47,8 +47,7 @@ func templateEmail(content string, variables []string, conditionals []string, va
}
ifEnd = i - 1
if ifTrue {
b := templateEmail(content[ifStart:ifEnd+1], variables, conditionals, values)
out += b
out += templateEmail(content[ifStart:ifEnd+1], variables, conditionals, values)
ifTrue = false
}
} else if c == '}' {
Expand Down
29 changes: 14 additions & 15 deletions ts/modules/settings.ts
Expand Up @@ -859,26 +859,25 @@ class EmailEditor {
}

innerHTML = '';
for (let i = this._templ.conditionals.length-1; i >= 0; i--) {
let ci = i % colors.length;
innerHTML += '<span class="button ~' + colors[ci] +' !normal mb-1" style="margin-left: 0.25rem; margin-right: 0.25rem;"></span>'
}
if (this._templ.conditionals.length == 0) {
if (this._templ.conditionals == null || this._templ.conditionals.length == 0) {
this._conditionalsLabel.classList.add("unfocused");
} else {
for (let i = this._templ.conditionals.length-1; i >= 0; i--) {
let ci = i % colors.length;
innerHTML += '<span class="button ~' + colors[ci] +' !normal mb-1" style="margin-left: 0.25rem; margin-right: 0.25rem;"></span>'
}
this._conditionalsLabel.classList.remove("unfocused");
}
this._conditionals.innerHTML = innerHTML
buttons = this._conditionals.querySelectorAll("span.button") as NodeListOf<HTMLSpanElement>;
for (let i = 0; i < this._templ.conditionals.length; i++) {
buttons[i].innerHTML = `<span class="monospace">{if ` + this._templ.conditionals[i].slice(1) + `</span>`;
buttons[i].onclick = () => {
this.insert(this._textArea, "{if " + this._templ.conditionals[i].slice(1) + "{endif}");
this.loadPreview();
// this._timeout = setTimeout(this.loadPreview, this._finishInterval);
this._conditionals.innerHTML = innerHTML
buttons = this._conditionals.querySelectorAll("span.button") as NodeListOf<HTMLSpanElement>;
for (let i = 0; i < this._templ.conditionals.length; i++) {
buttons[i].innerHTML = `<span class="monospace">{if ` + this._templ.conditionals[i].slice(1) + `</span>`;
buttons[i].onclick = () => {
this.insert(this._textArea, "{if " + this._templ.conditionals[i].slice(1) + "{endif}");
this.loadPreview();
// this._timeout = setTimeout(this.loadPreview, this._finishInterval);
}
}
}

window.modals.editor.show();
}
})
Expand Down

0 comments on commit 90a2c1f

Please sign in to comment.