mirror of
https://github.com/Bornholm/formidable.git
synced 2025-08-30 07:38:27 +02:00
Initial commit
This commit is contained in:
19
internal/server/template/blocks/form.html.tmpl
Normal file
19
internal/server/template/blocks/form.html.tmpl
Normal file
@ -0,0 +1,19 @@
|
||||
{{define "form"}}
|
||||
<form method="post">
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left" nowrap=""></td>
|
||||
<td align="right" nowrap="">
|
||||
<input type="submit" name="submit" value="Enregistrer" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr />
|
||||
<strong>{{ .Schema.Title }}</strong>
|
||||
<em>{{ .Schema.Description }}</em>
|
||||
<hr />
|
||||
{{template "form_item" .}}
|
||||
</form>
|
||||
{{end}}
|
10
internal/server/template/blocks/form_input.html.tmpl
Normal file
10
internal/server/template/blocks/form_input.html.tmpl
Normal file
@ -0,0 +1,10 @@
|
||||
{{define "form_input"}}
|
||||
{{ if .Schema.Types }}
|
||||
{{ $root := . }}
|
||||
{{range .Schema.Types}}
|
||||
{{ $inputBlock := printf "%s_%s" "form_input" . }}
|
||||
{{ include $inputBlock $root }}
|
||||
{{end}}
|
||||
{{ else }}
|
||||
{{ end }}
|
||||
{{end}}
|
31
internal/server/template/blocks/form_input_array.html.tmpl
Normal file
31
internal/server/template/blocks/form_input_array.html.tmpl
Normal file
@ -0,0 +1,31 @@
|
||||
{{ define "form_input_array" }}
|
||||
{{ $root := . }}
|
||||
{{ $fullProperty := getFullProperty .Parent .Property }}
|
||||
{{ $values := getValue .Defaults .Values $fullProperty }}
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
{{ range $index, $value := $values }}
|
||||
{{ $itemFullProperty := printf "%s/%d" $fullProperty $index }}
|
||||
{{ $itemProperty := printf "%d" $index }}
|
||||
{{ $itemSchema := getItemSchema $root.Schema }}
|
||||
{{ $formItemData := formItemData $root $itemProperty $itemSchema }}
|
||||
|
||||
<tr>
|
||||
{{ template "form_row" $formItemData }}
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<input type="submit" name="del:{{ $fullProperty }}/{{$index}}" value="Supprimer" />
|
||||
<hr />
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td align="right">
|
||||
<input type="submit" name="add:{{ $fullProperty }}/-" value="Ajouter" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{ end }}
|
12
internal/server/template/blocks/form_input_boolean.html.tmpl
Normal file
12
internal/server/template/blocks/form_input_boolean.html.tmpl
Normal file
@ -0,0 +1,12 @@
|
||||
{{define "form_input_boolean"}}
|
||||
{{ $fullProperty := getFullProperty .Parent .Property }}
|
||||
{{ $checked := getValue .Defaults .Values $fullProperty }}
|
||||
<label for="yes:{{ $fullProperty }}">
|
||||
Yes
|
||||
<input type="radio" id="yes:{{ $fullProperty }}" name="bool:{{ $fullProperty }}" value="yes" {{if $checked}}checked="yes"{{end}} />
|
||||
</label>
|
||||
<label for="no:{{ $fullProperty }}">
|
||||
No
|
||||
<input type="radio" id="no:{{ $fullProperty }}" name="bool:{{ $fullProperty }}" value="no" {{if not $checked}}checked{{end}} />
|
||||
</label>
|
||||
{{end}}
|
@ -0,0 +1,3 @@
|
||||
{{define "form_input_integer"}}
|
||||
{{template "form_input_number" .}}
|
||||
{{end}}
|
@ -0,0 +1 @@
|
||||
{{define "form_input_null"}}{{end}}
|
@ -0,0 +1,5 @@
|
||||
{{define "form_input_number"}}
|
||||
{{ $fullProperty := getFullProperty .Parent .Property }}
|
||||
{{ $value := getValue .Defaults .Values $fullProperty }}
|
||||
<input type="number" name="{{ $fullProperty }}" value="{{ $value }}" />
|
||||
{{end}}
|
@ -0,0 +1,5 @@
|
||||
{{define "form_input_object"}}
|
||||
<br />
|
||||
{{ $formItemData := formItemData . "" .Schema }}
|
||||
{{template "form_item" $formItemData}}
|
||||
{{end}}
|
@ -0,0 +1,5 @@
|
||||
{{define "form_input_string"}}
|
||||
{{ $fullProperty := getFullProperty .Parent .Property }}
|
||||
{{ $value := getValue .Defaults .Values $fullProperty }}
|
||||
<input type="text" name="{{ $fullProperty }}" id="{{ $fullProperty }}" value="{{ $value }}" />
|
||||
{{end}}
|
11
internal/server/template/blocks/form_item.html.tmpl
Normal file
11
internal/server/template/blocks/form_item.html.tmpl
Normal file
@ -0,0 +1,11 @@
|
||||
{{define "form_item"}}
|
||||
<table width="100%">
|
||||
<tbody>
|
||||
{{ $root := .}}
|
||||
{{ range $property, $schema := .Schema.Properties}}
|
||||
{{ $formItemData := formItemData $root $property $schema }}
|
||||
{{template "form_row" $formItemData}}
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{end}}
|
23
internal/server/template/blocks/form_row.html.tmpl
Normal file
23
internal/server/template/blocks/form_row.html.tmpl
Normal file
@ -0,0 +1,23 @@
|
||||
{{define "form_row"}}
|
||||
{{ $fullProperty := getFullProperty .Parent .Property }}
|
||||
<tr>
|
||||
<td align="left" nowrap="">
|
||||
<label for="{{ $fullProperty }}">
|
||||
<strong>
|
||||
{{ if .Schema.Title }}{{ .Schema.Title }}{{ else }}{{ .Property }}{{ end }}
|
||||
</strong>
|
||||
<br />
|
||||
<span>{{ .Schema.Description }}</span>
|
||||
</label>
|
||||
</td>
|
||||
<td align="left" nowrap="">
|
||||
{{template "form_input" .}}
|
||||
</td>
|
||||
<td>
|
||||
{{ $err := getPropertyError .Error $fullProperty }}
|
||||
{{if $err}}
|
||||
<em>{{ $err.Message }}</em>
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
10
internal/server/template/blocks/head.html.tmpl
Normal file
10
internal/server/template/blocks/head.html.tmpl
Normal file
@ -0,0 +1,10 @@
|
||||
{{define "head"}}
|
||||
<head>
|
||||
<title>Formidable</title>
|
||||
<style>
|
||||
body {
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
{{end}}
|
Reference in New Issue
Block a user