factoring out some of the special case "amsterdam_" page variables

This commit is contained in:
2026-02-10 21:19:50 -07:00
parent f2b8b829aa
commit be5255b4e7
4 changed files with 24 additions and 24 deletions
+4 -4
View File
@@ -316,8 +316,8 @@ func (d *Dialog) Render(ctxt AmContext) (string, any) {
if d.MenuSelector != "" && d.MenuSelector != "nochange" { if d.MenuSelector != "" && d.MenuSelector != "nochange" {
ctxt.SetLeftMenu(d.MenuSelector) ctxt.SetLeftMenu(d.MenuSelector)
} }
ctxt.VarMap().Set("amsterdam_required", required) ctxt.VarMap().Set("__required", required)
ctxt.VarMap().Set("amsterdam_dialog", d) ctxt.VarMap().Set("__dialog", d)
ctxt.SetFrameTitle(d.Title) ctxt.SetFrameTitle(d.Title)
if strings.Contains(d.Options, "suppresslogin") { if strings.Contains(d.Options, "suppresslogin") {
ctxt.VarMap().Set("amsterdam_suppressLogin", true) ctxt.VarMap().Set("amsterdam_suppressLogin", true)
@@ -334,7 +334,7 @@ func (d *Dialog) Render(ctxt AmContext) (string, any) {
* Data as a parameter for the command string. * Data as a parameter for the command string.
*/ */
func (d *Dialog) RenderError(ctxt AmContext, errormessage string) (string, any) { func (d *Dialog) RenderError(ctxt AmContext, errormessage string) (string, any) {
ctxt.VarMap().Set("amsterdam_errorMessage", errormessage) ctxt.VarMap().Set("__errorMessage", errormessage)
return d.Render(ctxt) return d.Render(ctxt)
} }
@@ -347,7 +347,7 @@ func (d *Dialog) RenderError(ctxt AmContext, errormessage string) (string, any)
* Data as a parameter for the command string. * Data as a parameter for the command string.
*/ */
func (d *Dialog) RenderInfo(ctxt AmContext, infoMessage string) (string, any) { func (d *Dialog) RenderInfo(ctxt AmContext, infoMessage string) (string, any) {
ctxt.VarMap().Set("amsterdam_infoMessage", infoMessage) ctxt.VarMap().Set("__infoMessage", infoMessage)
return d.Render(ctxt) return d.Render(ctxt)
} }
+2 -2
View File
@@ -96,7 +96,7 @@ func AmSendPageData(ctxt echo.Context, amctxt AmContext, command string, data an
ctxt.Logger().Errorf("*** NO FRAME TITLE set for path %s", amctxt.URLPath()) ctxt.Logger().Errorf("*** NO FRAME TITLE set for path %s", amctxt.URLPath())
amctxt.SetFrameTitle("<<< NO FRAME TITLE >>>") amctxt.SetFrameTitle("<<< NO FRAME TITLE >>>")
} }
amctxt.VarMap().Set("amsterdam_innerPage", data) amctxt.VarMap().Set("__innerPage", data)
menus := make([]*MenuDefinition, 2) menus := make([]*MenuDefinition, 2)
switch amctxt.LeftMenu() { switch amctxt.LeftMenu() {
case "top": case "top":
@@ -111,7 +111,7 @@ func AmSendPageData(ctxt echo.Context, amctxt AmContext, command string, data an
return fmt.Errorf("AmSendPageData(): unknown left menu context: %s", amctxt.LeftMenu()) return fmt.Errorf("AmSendPageData(): unknown left menu context: %s", amctxt.LeftMenu())
} }
menus[1] = AmMenu("fixed") menus[1] = AmMenu("fixed")
amctxt.VarMap().Set("amsterdam_leftMenus", menus) amctxt.VarMap().Set("__leftMenus", menus)
err = ctxt.Render(httprc, "frame.jet", amctxt) err = ctxt.Render(httprc, "frame.jet", amctxt)
default: default:
err = fmt.Errorf("AmSendPageData(): unknown rendering type: %s", command) err = fmt.Errorf("AmSendPageData(): unknown rendering type: %s", command)
+16 -16
View File
@@ -6,32 +6,32 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*} *}
<!-- BEGIN DIALOG {{ amsterdam_dialog.Name }} --> <!-- BEGIN DIALOG {{ __dialog.Name }} -->
<div class="p-4"> <div class="p-4">
<div class="mb-6"> <div class="mb-6">
<div class=" flex items-baseline gap-2"> <div class=" flex items-baseline gap-2">
<h1 class="text-blue-800 text-4xl font-bold mb-2">{{ amsterdam_dialog.Title }}</h1> <h1 class="text-blue-800 text-4xl font-bold mb-2">{{ __dialog.Title }}</h1>
{{ if amsterdam_dialog.Subtitle != "" }} {{ if __dialog.Subtitle != "" }}
<span class="text-blue-800 text-2xl font-bold ml-2">{{ amsterdam_dialog.Subtitle }}</span> <span class="text-blue-800 text-2xl font-bold ml-2">{{ __dialog.Subtitle }}</span>
{{ end }} {{ end }}
</div> </div>
<hr class="border-2 border-gray-400 w-4/5 mb-4"> <hr class="border-2 border-gray-400 w-4/5 mb-4">
</div> </div>
<form name="{{ amsterdam_dialog.FormName }}" method="POST" action="{{ amsterdam_dialog.Action }}" class="max-w-2xl"> <form name="{{ __dialog.FormName }}" method="POST" action="{{ __dialog.Action }}" class="max-w-2xl">
{{ range amsterdam_dialog.Fields }} {{ range __dialog.Fields }}
{{ if .Type == "hidden" }} {{ if .Type == "hidden" }}
<input type="hidden" name="{{ .Name }}" value="{{ .Value }}" /> <input type="hidden" name="{{ .Name }}" value="{{ .Value }}" />
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if amsterdam_dialog.Instructions != "" }} {{ if __dialog.Instructions != "" }}
<p class="text-black text-sm mb-6">{{ amsterdam_dialog.Instructions | raw }}</p> <p class="text-black text-sm mb-6">{{ __dialog.Instructions | raw }}</p>
{{ end }} {{ end }}
{{ if amsterdam_required }} {{ if __required }}
<p class="text-black text-sm mb-6">Required fields are marked with a <span class="text-red-600">*</span>.</p> <p class="text-black text-sm mb-6">Required fields are marked with a <span class="text-red-600">*</span>.</p>
{{ end }} {{ end }}
{{ if isset(amsterdam_errorMessage) }} {{ if isset(__errorMessage) }}
<!-- Error Message Banner --> <!-- Error Message Banner -->
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-6" id="error-banner"> <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-6" id="error-banner">
<div class="flex items-center"> <div class="flex items-center">
@@ -39,12 +39,12 @@
<span class="text-red-500 text-xl">⚠️</span> <span class="text-red-500 text-xl">⚠️</span>
</div> </div>
<div class="ml-3"> <div class="ml-3">
<p class="text-sm font-medium" id="error-message">{{ CapitalizeString(amsterdam_errorMessage) }}.</p> <p class="text-sm font-medium" id="error-message">{{ CapitalizeString(__errorMessage) }}.</p>
</div> </div>
</div> </div>
</div> </div>
{{ end }} {{ end }}
{{ if isset(amsterdam_infoMessage) }} {{ if isset(__infoMessage) }}
<!-- Info Message Banner --> <!-- Info Message Banner -->
<div class="bg-blue-100 border border-blue-400 text-blue-700 px-4 py-3 rounded mb-6" id="info-banner"> <div class="bg-blue-100 border border-blue-400 text-blue-700 px-4 py-3 rounded mb-6" id="info-banner">
<div class="flex items-center"> <div class="flex items-center">
@@ -52,7 +52,7 @@
<span class="text-blue-500 text-xl">️</span> <span class="text-blue-500 text-xl">️</span>
</div> </div>
<div class="ml-3"> <div class="ml-3">
<p class="text-sm font-medium" id="info-message">{{ amsterdam_infoMessage }}.</p> <p class="text-sm font-medium" id="info-message">{{ __infoMessage }}.</p>
</div> </div>
</div> </div>
</div> </div>
@@ -60,7 +60,7 @@
<div class="bg-gray-50 p-6 rounded-lg"> <div class="bg-gray-50 p-6 rounded-lg">
<div class="space-y-4"> <div class="space-y-4">
{{ range amsterdam_dialog.Fields }} {{ range __dialog.Fields }}
{{ if .Type == "text" || .Type == "ams_id" || .Type == "email" }} {{ if .Type == "text" || .Type == "ams_id" || .Type == "email" }}
<div class="flex items-center"> <div class="flex items-center">
<label for="{{ .Name }}" <label for="{{ .Name }}"
@@ -261,7 +261,7 @@
{{ end }} {{ end }}
</div> </div>
<div class="flex justify-center gap-4 mt-6"> <div class="flex justify-center gap-4 mt-6">
{{ range amsterdam_dialog.Fields }} {{ range __dialog.Fields }}
{{ if .Type == "button" }} {{ if .Type == "button" }}
{{ clstmp := "bg-" + .Param + "-600 hover:bg-" + .Param + "-700" }} {{ clstmp := "bg-" + .Param + "-600 hover:bg-" + .Param + "-700" }}
<button type="submit" name="{{ .Name }}" {{ if .Disabled }}disabled{{ end }} <button type="submit" name="{{ .Name }}" {{ if .Disabled }}disabled{{ end }}
@@ -272,4 +272,4 @@
</div> </div>
</form> </form>
</div> </div>
<!-- END DIALOG {{ amsterdam_dialog.Name }} --> <!-- END DIALOG {{ __dialog.Name }} -->
+2 -2
View File
@@ -84,7 +84,7 @@
<div class="flex"> <div class="flex">
<!-- LEFT SIDEBAR --> <!-- LEFT SIDEBAR -->
<div class="w-48 bg-blue-400 p-2"> <div class="w-48 bg-blue-400 p-2">
{{ range i, m := amsterdam_leftMenus }} {{ range i, m := __leftMenus }}
{{ if i > 0 }} {{ if i > 0 }}
<div class="mb-2 mt-2">&nbsp;</div> <div class="mb-2 mt-2">&nbsp;</div>
{{ end }} {{ end }}
@@ -99,7 +99,7 @@
<!-- MAIN CONTENT --> <!-- MAIN CONTENT -->
<div class="flex-1 bg-white"> <div class="flex-1 bg-white">
{{ include amsterdam_innerPage }} {{ include __innerPage }}
</div> </div>
</div> </div>