Răsfoiți Sursa

Add execute template function

Andrea Fazzi 5 ani în urmă
părinte
comite
9cd50ec127
2 a modificat fișierele cu 10 adăugiri și 1 ștergeri
  1. 9 0
      renderer/funcmap.go
  2. 1 1
      templates/documents_show.html.tpl

+ 9 - 0
renderer/funcmap.go

@@ -25,6 +25,7 @@ var (
 		"delete":      delete,
 		"show":        show,
 		"all":         all,
+		"execute":     execute,
 		"isSlice":     isSlice,
 		"toSlice":     toSlice,
 		"string":      callString,
@@ -186,6 +187,14 @@ func show(model string, id uint) string {
 	return fmt.Sprintf("/%s/%d?%s", plural, id, q)
 }
 
+func execute(model string, id uint) string {
+	action := "execute"
+	plural := inflection.Plural(strings.ToLower(model))
+	q := query("tpl_layout", "base", "tpl_content", fmt.Sprintf("%s_%s", plural, action))
+
+	return fmt.Sprintf("/%s/%d/%s?%s", plural, id, action, q)
+}
+
 func update(model string, id uint) string {
 	action := "update"
 	plural := inflection.Plural(strings.ToLower(model))

+ 1 - 1
templates/documents_show.html.tpl

@@ -14,7 +14,7 @@
       icon: "fa fa-file-alt"
       `}}
       
-      {{$noElements := "Nessun lavoro in esecuzione."}}
+      {{$noElements := (printf "Nessun lavoro in esecuzione. Clicca %s per eseguire un nuovo lavoro." ((.Data.ID|execute "Document")|anchor "qui"))|html}}
       {{template "relation_list" dict "options" ($options|yaml) "data" .Data.RunningJobs "noElements" $noElements}}
     
     </div>