-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathtextbox.pode
More file actions
84 lines (68 loc) · 3.65 KB
/
textbox.pode
File metadata and controls
84 lines (68 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<div class="$(if (!$data.NoForm) { 'form-group row' } else { 'no-form' }) pode-form-textbox $($data.CssClasses)">
$(if (!$data.NoForm) {
"<label for='$($data.ID)' class='col-sm-2 col-form-label'>$($data.DisplayName)</label>"
})
<div class="col-sm-10">
$(
$element = [string]::Empty
$describedBy = [string]::Empty
if (![string]::IsNullOrWhiteSpace($data.HelpText)) {
$describedBy = "aria-describedby='$($data.ID)_help'"
}
$readOnly = [string]::Empty
if ($data.ReadOnly) {
$readOnly = "readonly"
}
$required = [string]::Empty
if ($data.Required) {
$required = "required"
}
$value = [string]::Empty
if (![string]::IsNullOrWhiteSpace($data.Value)) {
$value = "value='$($data.Value)'"
}
$width = "width: $($data.Width);"
$events = ConvertTo-PodeWebEvents -Events $data.Events
if ($data.Multiline) {
$element = "<textarea class='form-control $(if ($data.NoForm) { 'no-form' })' id='$($data.ID)' name='$($data.Name)' pode-object='$($data.ObjectType)' placeholder='$($data.Placeholder)' rows='$($data.Size)' style='$($width) $($data.CssStyles)' $($describedBy) $($readOnly) $($required) $($events)>$($data.Value)</textarea>"
}
else {
if ($data.Prepend.Enabled -or $data.Append.Enabled) {
$element = "<div class='input-group mb-2'>"
}
if ($data.Prepend.Enabled) {
if (![string]::IsNullOrWhiteSpace($data.Prepend.Text)) {
$element += "<div class='input-group-prepend'><div class='input-group-text'>$($data.Prepend.Text)</div></div>"
}
else {
$element += "<div class='input-group-prepend'><div class='input-group-text'><span class='mdi mdi-$($data.Prepend.Icon.ToLowerInvariant())'></span></div></div>"
}
}
$_type = $data.Type
if ($_type -ieq 'datetime') {
$_type = 'datetime-local'
}
$element += "<input type='$($_type.ToLowerInvariant())' class='form-control $(if ($data.NoForm) { 'no-form' })' id='$($data.ID)' name='$($data.Name)' pode-object='$($data.ObjectType)' style='$($width) $($data.CssStyles)' placeholder='$($data.Placeholder)' pode-autocomplete='$($data.IsAutoComplete)' $($describedBy) $($readOnly) $($required) $($value) $($events)>"
if ($data.Append.Enabled) {
if (![string]::IsNullOrWhiteSpace($data.Append.Text)) {
$element += "<div class='input-group-append'><div class='input-group-text'>$($data.Append.Text)</div></div>"
}
else {
$element += "<div class='input-group-append'><div class='input-group-text'><span class='mdi mdi-$($data.Append.Icon.ToLowerInvariant())'></span></div></div>"
}
}
if ($data.Prepend.Enabled -or $data.Append.Enabled) {
$element += "</div>"
}
}
if ($data.Preformat) {
$element = "<pre>$($element)</pre>"
}
$element
)
$(if (![string]::IsNullOrWhiteSpace($data.HelpText)) {
"<small id='$($data.ID)_help' class='form-text text-muted'>$($data.HelpText)</small>"
})
<div id="$($data.ID)_validation" class="invalid-feedback"></div>
</div>
</div>