Skip to content

Commit

Permalink
Some forms only have one HTML template
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xylo04 authored and martinhpedersen committed Jul 16, 2021
1 parent eb00df2 commit 3246c2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/forms/forms.go
Expand Up @@ -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:")))
Expand Down
2 changes: 1 addition & 1 deletion res/js/index.js
Expand Up @@ -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 =
`
Expand Down

0 comments on commit 3246c2e

Please sign in to comment.