From 3246c2e5ff975f1b1b8e1e6d29e449982c2d53fe Mon Sep 17 00:00:00 2001 From: Chris Keller Date: Wed, 14 Jul 2021 22:23:17 -0600 Subject: [PATCH] Some forms only have one HTML template When a form .txt file only specifies one HTML template, it's supposed to be used for both compose and view. Also fix a Javascript error. Now that "RADIOGRAM & RRI Forms" is coming through, we can't have ampersand in an HTML element ID. --- internal/forms/forms.go | 6 +++++- res/js/index.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/forms/forms.go b/internal/forms/forms.go index cf939ab7..1e53952b 100644 --- a/internal/forms/forms.go +++ b/internal/forms/forms.go @@ -652,11 +652,15 @@ func (m *Manager) buildFormFromTxt(txtPath string) (Form, error) { case strings.HasPrefix(l, "Form:"): trimmed := strings.TrimSpace(strings.TrimPrefix(l, "Form:")) fileNames := strings.Split(trimmed, ",") - if fileNames != nil && len(fileNames) >= 2 { + if len(fileNames) >= 2 { initial := strings.TrimSpace(fileNames[0]) viewer := strings.TrimSpace(fileNames[1]) retVal.InitialURI = path.Join(baseURI, initial) retVal.ViewerURI = path.Join(baseURI, viewer) + } else { + view := strings.TrimSpace(fileNames[0]) + retVal.InitialURI = path.Join(baseURI, view) + retVal.ViewerURI = path.Join(baseURI, view) } case strings.HasPrefix(l, "ReplyTemplate:"): retVal.ReplyTxtFileURI = path.Join(baseURI, strings.TrimSpace(strings.TrimPrefix(l, "ReplyTemplate:"))) diff --git a/res/js/index.js b/res/js/index.js index 710449da..61b04efc 100644 --- a/res/js/index.js +++ b/res/js/index.js @@ -352,7 +352,7 @@ function appendFormFolder(rootId, data) { `); data.folders.forEach(function (folder) { if (folder.form_count > 0) { - var folderNameId = rootId + folder.name.replace( /\s/g, "_" ); + var folderNameId = rootId + folder.name.replace( /\s/g, "_" ).replace(/&/g, "and"); var cardBodyId = folderNameId+"Body"; var card = `