From 2b2aa6955b2862596c497ae61d32a5f9882a0473 Mon Sep 17 00:00:00 2001 From: Matt Selle Date: Wed, 4 Dec 2019 20:37:07 -0600 Subject: [PATCH 1/8] Fix label overlap issue when value is provided https://github.com/ironmansoftware/universal-dashboard/issues/1330 --- .../Tests/textbox.tests.ps1 | 20 +++++++++++++++++++ .../Controls/src/textbox.ps1 | 8 +++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 diff --git a/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 new file mode 100644 index 00000000..1ea52902 --- /dev/null +++ b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 @@ -0,0 +1,20 @@ +Describe "Textbox" { + + Context "textbox no value" { + Set-TestDashboard -Content { + New-UDTextbox -Id 'EndTimestamp' -Label 'EndTimestamp' + } + It "should not be active" { + Find-SeElement -ClassName 'active' -Driver $Driver | should be $null + } + } + + Context "textbox value" { + Set-TestDashboard -Content { + New-UDTextbox -Id 'EndTimestamp' -Label 'EndTimestamp' -Value (Get-Date).ToString('yyyy.MM.dd HH:mm:ss.fff') + } + It "should be active" { + Find-SeElement -ClassName 'active' -Driver $Driver | should be $true + } + } +} \ No newline at end of file diff --git a/src/UniversalDashboard/Controls/src/textbox.ps1 b/src/UniversalDashboard/Controls/src/textbox.ps1 index 90d729c8..b3a55ea4 100644 --- a/src/UniversalDashboard/Controls/src/textbox.ps1 +++ b/src/UniversalDashboard/Controls/src/textbox.ps1 @@ -39,6 +39,11 @@ function New-UDTextbox { $Attributes.disabled = $true } + $LabelClassName = "" + if($Value){ + $LabelClassName = "active" + } + New-UDElement -Tag "div" -Attributes @{ className = 'input-field'} -Content { if ($PSBoundParameters.ContainsKey('Icon')) { @@ -50,8 +55,9 @@ function New-UDTextbox { New-UDElement -Id $Id -Tag "input" -Attributes $Attributes if ($PSBoundParameters.ContainsKey('Label')) { - New-UDElement -Tag "label" -Attributes @{ + New-UDElement -Tag "label" -Attributes @{ 'for' = $Id + className = $LabelClassName } -Content { $Label } } } From 938fd373c10974c19a1aaa203a1fd953733dd53e Mon Sep 17 00:00:00 2001 From: Matt Selle Date: Mon, 9 Dec 2019 19:39:39 -0600 Subject: [PATCH 2/8] Placeholder should be active label and not overlap https://github.com/ironmansoftware/universal-dashboard/issues/921 --- .../Tests/textbox.tests.ps1 | 9 +++++++++ src/UniversalDashboard/Controls/src/textbox.ps1 | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 index 1ea52902..ce55a5c6 100644 --- a/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 +++ b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 @@ -17,4 +17,13 @@ Describe "Textbox" { Find-SeElement -ClassName 'active' -Driver $Driver | should be $true } } + + Context "textbox placeholder" { + Set-TestDashboard -Content { + New-UDTextbox -Id 'EndTimestamp' -Label 'EndTimestamp' -Placeholder (Get-Date).ToString('yyyy.MM.dd HH:mm:ss.fff') + } + It "should be active" { + Find-SeElement -ClassName 'active' -Driver $Driver | should be $true + } + } } \ No newline at end of file diff --git a/src/UniversalDashboard/Controls/src/textbox.ps1 b/src/UniversalDashboard/Controls/src/textbox.ps1 index b3a55ea4..f7e7e3bd 100644 --- a/src/UniversalDashboard/Controls/src/textbox.ps1 +++ b/src/UniversalDashboard/Controls/src/textbox.ps1 @@ -40,7 +40,7 @@ function New-UDTextbox { } $LabelClassName = "" - if($Value){ + if($Value -Or $Placeholder){ $LabelClassName = "active" } From ef9a28363c13c2a6f50a3bc44870132e94ff77dc Mon Sep 17 00:00:00 2001 From: Matt Selle Date: Mon, 9 Dec 2019 19:39:39 -0600 Subject: [PATCH 3/8] Revert "Placeholder should be active label and not overlap" This reverts commit 938fd373c10974c19a1aaa203a1fd953733dd53e. From cb65d0b3f4c3d24949ffd67a70b087b860f64265 Mon Sep 17 00:00:00 2001 From: Matt Selle Date: Tue, 10 Dec 2019 21:18:47 -0600 Subject: [PATCH 4/8] UpdateTabIndicator so we dont get a scroll Models have issues trying to figure out how wide they are so we need to tell materialize to update the tabIndicator so we dont get a scroll bar. https://github.com/ironmansoftware/universal-dashboard/issues/1221 --- .../Components/tabs.jsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/UniversalDashboard.Materialize/Components/tabs.jsx b/src/UniversalDashboard.Materialize/Components/tabs.jsx index 2bb0c54c..c8982c55 100644 --- a/src/UniversalDashboard.Materialize/Components/tabs.jsx +++ b/src/UniversalDashboard.Materialize/Components/tabs.jsx @@ -1,10 +1,12 @@ -import React, {Fragment} from 'react'; +import React, { Fragment } from 'react'; import M from 'materialize-css'; export default class TabContainer extends React.Component { componentDidMount() { M.Tabs.init(this.element); + var instance = M.Tabs.getInstance(this.element); + instance.updateTabIndicator(); } renderTabHeaders() { @@ -38,13 +40,13 @@ export default class TabContainer extends React.Component { return ( -
-
    this.element = x}> - {headers} -
-
- {content} -
+
+
    this.element = x}> + {headers} +
+
+ {content} + ) } From ccfdb7898d5596639de0c679dcde77806fb54c12 Mon Sep 17 00:00:00 2001 From: Matt Selle Date: Mon, 30 Dec 2019 19:55:36 -0600 Subject: [PATCH 5/8] Add test for disabled textbox https://github.com/ironmansoftware/universal-dashboard/issues/1380 --- .../Tests/textbox.tests.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 index 95c9f6c1..7906b6e3 100644 --- a/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 +++ b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 @@ -1,5 +1,15 @@ Describe "Textbox" { + Context "textbox disabled" { + Set-TestDashboard -Content { + New-UDTextbox -Id 'EndTimestamp' -Label 'EndTimestamp' -Disabled + } + It "should be disabled" { + $textbox = Find-SeElement -Id 'EndTimestamp' -Driver $Driver + $textbox.Enabled | should be $false + } + } + Context "textbox no value" { Set-TestDashboard -Content { New-UDTextbox -Id 'EndTimestamp' -Label 'EndTimestamp' From 68a5c2eeef53b1a2cf34c4ea35ef0e69291f82cf Mon Sep 17 00:00:00 2001 From: Matt Selle Date: Mon, 6 Jan 2020 19:43:10 -0600 Subject: [PATCH 6/8] Disabled InputField Adding Disabled to new-inputfield https://github.com/ironmansoftware/universal-dashboard/issues/1380 --- .../Components/ud-input-field.jsx | 14 +++++++----- .../Tests/textbox.tests.ps1 | 22 +++++++++++++++++++ .../Cmdlets/Inputs/NewInputFieldCommand.cs | 4 ++++ src/UniversalDashboard/Models/Input.cs | 2 ++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/UniversalDashboard.Materialize/Components/ud-input-field.jsx b/src/UniversalDashboard.Materialize/Components/ud-input-field.jsx index 67589909..767d541a 100644 --- a/src/UniversalDashboard.Materialize/Components/ud-input-field.jsx +++ b/src/UniversalDashboard.Materialize/Components/ud-input-field.jsx @@ -75,6 +75,7 @@ export default class UdInputField extends React.Component { name: this.props.name, type: this.props.type, value: this.props.value, + disabled: this.props.disabled, placeholder: this.props.placeholder, validOptions: this.props.validOptions, validating: this.props.validating, @@ -121,6 +122,7 @@ export default class UdInputField extends React.Component { id={field.name} name={field.name} onChange={e => this.onTextFieldChange(field, e) } value={field.value} + disabled={field.disabled} onBlur={e => this.onValidateField(field, e)} onKeyDown={this.onKeyDown.bind(this)} label={field.placeholder ? field.placeholder[0] : field.name} @@ -134,6 +136,7 @@ export default class UdInputField extends React.Component { name={field.name} onChange={e => this.onTextFieldChange(field, e) } value={field.value} + disabled={field.disabled} label={field.placeholder ? field.placeholder[0] : field.name} /> } @@ -145,7 +148,7 @@ export default class UdInputField extends React.Component { value = String(field.value).toLowerCase() === "true"; } - return this.onCheckboxChanged(field, e) } checked={value} label={field.placeholder ? field.placeholder[0] : field.name} /> + return this.onCheckboxChanged(field, e) } checked={value} label={field.placeholder ? field.placeholder[0] : field.name} /> } if (field.type === 'date') { @@ -165,6 +168,7 @@ export default class UdInputField extends React.Component { className="ud-input">{field.placeholder ? field.placeholder[0] : field.name}, {field.placeholder ? field.placeholder[0] : field.name}, - - ] + ] } if (field.type == 'switch') { @@ -207,7 +211,7 @@ export default class UdInputField extends React.Component { value = String(field.value).toLowerCase() === "true"; } - return this.onCheckboxChanged(field, e) } checked={value} offLabel={off} onLabel={on} /> + return this.onCheckboxChanged(field, e) } checked={value} offLabel={off} onLabel={on} /> } if (field.type == 'select') { @@ -218,7 +222,7 @@ export default class UdInputField extends React.Component { }); } - return this.onSelectChanged(field, e) } value={field.value}> {options} } diff --git a/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 index 7906b6e3..29587c85 100644 --- a/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 +++ b/src/UniversalDashboard.Materialize/Tests/textbox.tests.ps1 @@ -1,5 +1,27 @@ Describe "Textbox" { + Context "textbox disabled UDInput" { + Set-TestDashboard -Content { + New-UDInput -Title "Simple Form" -Id "Form" -Content { + New-UDInputField -Name 'checkbox' -Type 'checkbox' -Disabled + New-UDInputField -Name 'textbox' -Type 'textbox' -Disabled + New-UDInputField -Name 'checkboxEnabled' -Type 'checkbox' + New-UDInputField -Name 'textboxEnabled' -Type 'textbox' + } -Endpoint { + param($checkbox, $textbox) + + $Cache:Data = @{ + checkbox = $checkbox + textbox = $textbox + } + } + } + It "should be disabled" { + $textbox = Find-SeElement -Name 'textbox' -Driver $Driver + $textbox.Enabled | should be $false + } + } + Context "textbox disabled" { Set-TestDashboard -Content { New-UDTextbox -Id 'EndTimestamp' -Label 'EndTimestamp' -Disabled diff --git a/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs b/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs index dcf31eff..15447991 100644 --- a/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs +++ b/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs @@ -27,6 +27,9 @@ public class NewInputFieldCommand : PSCmdlet [Parameter()] public string[] Placeholder { get; set; } + [Parameter()] + public SwitchParameter Disabled { get; set; } = false; + [Parameter()] [ValidateSet("textbox", "checkbox", "select", "radioButtons", "password", "textarea", "switch", "date", "file", "time", "binaryFile")] public string Type { get; set; } @@ -67,6 +70,7 @@ protected override void EndProcessing() ValidOptions = Values, Value = DefaultValue, Placeholder = Placeholder, + Disabled = Disabled.IsPresent, Type = Type, OkText = OkText, CancelText = CancelText, diff --git a/src/UniversalDashboard/Models/Input.cs b/src/UniversalDashboard/Models/Input.cs index 5093c689..8d16ab14 100644 --- a/src/UniversalDashboard/Models/Input.cs +++ b/src/UniversalDashboard/Models/Input.cs @@ -65,6 +65,8 @@ public class Field [JsonProperty("value")] public object Value { get; set; } + [JsonProperty("disabled")] + public object Disabled { get; set; } [JsonProperty("links")] public Hashtable[] Links { get;set;} [JsonProperty("okText")] From fb88aed4d5cf19643ec23af003b913d093203770 Mon Sep 17 00:00:00 2001 From: Matt Selle Date: Mon, 6 Jan 2020 20:38:56 -0600 Subject: [PATCH 7/8] Remove false --- src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs b/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs index 15447991..c761cdf1 100644 --- a/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs +++ b/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs @@ -28,7 +28,7 @@ public class NewInputFieldCommand : PSCmdlet public string[] Placeholder { get; set; } [Parameter()] - public SwitchParameter Disabled { get; set; } = false; + public SwitchParameter Disabled { get; set; }; [Parameter()] [ValidateSet("textbox", "checkbox", "select", "radioButtons", "password", "textarea", "switch", "date", "file", "time", "binaryFile")] From 857920bcaa5a57914a467cd975f8a54ea9a05424 Mon Sep 17 00:00:00 2001 From: Adam Driscoll Date: Mon, 6 Jan 2020 19:57:49 -0700 Subject: [PATCH 8/8] Update NewInputFieldCommand.cs --- src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs b/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs index c761cdf1..ada5162c 100644 --- a/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs +++ b/src/UniversalDashboard/Cmdlets/Inputs/NewInputFieldCommand.cs @@ -28,7 +28,7 @@ public class NewInputFieldCommand : PSCmdlet public string[] Placeholder { get; set; } [Parameter()] - public SwitchParameter Disabled { get; set; }; + public SwitchParameter Disabled { get; set; } [Parameter()] [ValidateSet("textbox", "checkbox", "select", "radioButtons", "password", "textarea", "switch", "date", "file", "time", "binaryFile")]