Initial commit

This commit is contained in:
2022-03-22 09:21:55 +01:00
commit ada7f18e36
49 changed files with 2635 additions and 0 deletions

View 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}}

View 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}}

View 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 }}

View 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}}

View File

@ -0,0 +1,3 @@
{{define "form_input_integer"}}
{{template "form_input_number" .}}
{{end}}

View File

@ -0,0 +1 @@
{{define "form_input_null"}}{{end}}

View File

@ -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}}

View File

@ -0,0 +1,5 @@
{{define "form_input_object"}}
<br />
{{ $formItemData := formItemData . "" .Schema }}
{{template "form_item" $formItemData}}
{{end}}

View File

@ -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}}

View 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}}

View 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}}

View File

@ -0,0 +1,10 @@
{{define "head"}}
<head>
<title>Formidable</title>
<style>
body {
padding: 10px;
}
</style>
</head>
{{end}}