form: New property to hide a given field in interface
continuous-integration/drone/push Build is passing Details

This commit is contained in:
nemunaire 2023-12-06 03:25:28 +01:00
parent 1bcc5253cf
commit 56e56ed75b
3 changed files with 10 additions and 1 deletions

View File

@ -155,6 +155,8 @@ func getSpecs(svcType reflect.Type) viewServiceSpec {
f.Required = true
case "secret":
f.Secret = true
case "hidden":
f.Hide = true
default:
f.Label = kv[0]
}

View File

@ -63,6 +63,9 @@ type Field struct {
// the field when not needed. When typing, it doesn't hide characters like in password input.
Secret bool `json:"secret,omitempty"`
// Hide indicates if the field should be hidden to the user.
Hide bool `json:"hide,omitempty"`
// Description stores an helpfull sentence describing the field.
Description string `json:"description,omitempty"`
}
@ -102,6 +105,8 @@ func GenField(field reflect.StructField) (f *Field) {
}
} else {
switch strings.ToLower(kv[0]) {
case "hidden":
f.Hide = true
case "required":
f.Required = true
case "secret":

View File

@ -27,7 +27,9 @@
}
</script>
{#if type.substring(0, 2) === '[]' && type !== '[]byte' && type !== '[]uint8'}
{#if specs && specs.hide}
<!-- hidden input -->
{:else if type.substring(0, 2) === '[]' && type !== '[]byte' && type !== '[]uint8'}
<TableInput
edit={edit || editToolbar}
{index}