From e8ed786c55342a6b9fc0fccdd11a0dbb503caab8 Mon Sep 17 00:00:00 2001 From: jdhitsolutions Date: Sun, 7 Jan 2024 12:40:28 -0500 Subject: [PATCH] v1.7.0 --- PSWorkItem.psd1 | 2 +- PSWorkItem.psm1 | 2 + changelog.md | 18 +- en-us/PSWorkItem.psd1 | 5 +- formats/psworkitem.format.ps1xml | 56 +++- functions/private/tui-helpers.ps1 | 75 ++++- functions/public/Get-PSWorkItemDatabase.ps1 | 10 +- functions/public/Open-PSWorkItemConsole.ps1 | 319 ++++++++++---------- samples/PSWorkItem.db | Bin 32768 -> 32768 bytes 9 files changed, 306 insertions(+), 181 deletions(-) diff --git a/PSWorkItem.psd1 b/PSWorkItem.psd1 index 5469f44..67fd928 100644 --- a/PSWorkItem.psd1 +++ b/PSWorkItem.psd1 @@ -4,7 +4,7 @@ @{ RootModule = 'PSWorkItem.psm1' - ModuleVersion = '1.5.0' + ModuleVersion = '1.7.0' CompatiblePSEditions = 'Core' GUID = '4d3ff215-69ea-4fe6-8ad6-97ffc3a15bfb' Author = 'Jeff Hicks' diff --git a/PSWorkItem.psm1 b/PSWorkItem.psm1 index 60dafc4..3fb91ba 100644 --- a/PSWorkItem.psm1 +++ b/PSWorkItem.psm1 @@ -124,6 +124,8 @@ class PSWorkItemDatabase { [String]$Encoding [int32]$PageCount [int32]$PageSize + [string]$SQLiteVersion + [string]$CreatedBy } #endregion diff --git a/changelog.md b/changelog.md index b9a9e77..a50a840 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,21 @@ ## [Unreleased] +## [1.7.0] - 2024-01-07 + +### Changed + +- Updated the sample PSWorkItem database. +- Revised format file for PSWorkItems to show due date with leading zeros and no seconds. +- Updated `Open-PSWorkItemConsole` to format due dates with leading zeros and no seconds. +- Updated `Open-PSWorkItemConsole` to display overdue items in the table in Red and items due within 5 days in Cyan. +- Updated table layout in `Open-PSWorkItemConsole`. Added a RepresentationGetter to display progress value with a % sign. Hiding the `Overdue` column to give more space to the `Name` and `Description` columns. + +### Fixed + +- Update the TUI form which was hiding the `Clear` checkbox +- Fixed missing properties in the PSWorkItemDatabase class. + ## [1.5.0] - 2023-10-06 ### Added @@ -265,7 +280,8 @@ This is a major update with significant changes. If this is your first time inst - Initial files - Created Module outline -[Unreleased]: https://github.com/jdhitsolutions/PSWorkItem/compare/v1.5.0..HEAD +[Unreleased]: https://github.com/jdhitsolutions/PSWorkItem/compare/v1.7.0..HEAD +[1.7.0]: https://github.com/jdhitsolutions/PSWorkItem/compare/v1.5.0..v1.7.0 [1.5.0]: https://github.com/jdhitsolutions/PSWorkItem/compare/v1.4.0..v1.5.0 [1.4.0]: https://github.com/jdhitsolutions/PSWorkItem/compare/v1.3.1..v1.4.0 [1.3.1]: https://github.com/jdhitsolutions/PSWorkItem/compare/v1.3.0..v1.3.1 diff --git a/en-us/PSWorkItem.psd1 b/en-us/PSWorkItem.psd1 index 2fa1d32..59f6711 100644 --- a/en-us/PSWorkItem.psd1 +++ b/en-us/PSWorkItem.psd1 @@ -68,13 +68,14 @@ ConvertFrom-StringData @' Starting = Starting command TaskCount = Getting a PSWorkItem count TaskCreated = PSWorkItem {0} created - tipCategory = Select a category for the PSWorkItem + tipCategory = Select a category for the PSWorkItem. Not required but recommended. + tipClear = Clear the description tipDatabasePath = Specify the path to the SQLite file. It must end in .db tipDescription = Enter a brief description or comment for the PSWorkItem tipFilterTable = Filter the table by the selected category tipProgress = Specify a progress percentage for the PSWorkItem as an integer tipReport = A report of open items by category. You might need to scroll. - tipTaskName = Enter the name for the new PSWorkItem + tipTaskName = Enter the name for the new PSWorkItem. Required. Testing = I am a localized message TestingColumnID = Testing database for ID column UpdateArchiveTable = Updating archive table value diff --git a/formats/psworkitem.format.ps1xml b/formats/psworkitem.format.ps1xml index 4cfe674..38ed51e 100644 --- a/formats/psworkitem.format.ps1xml +++ b/formats/psworkitem.format.ps1xml @@ -70,7 +70,7 @@ https://github.com/jdhitsolutions/PSScriptTools "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $_.name, $psstyle.reset } else { - + "$($PSWorkItemCategory["$($_.category)"])$($_.name)$($PSStyle.Reset)" } } @@ -100,20 +100,28 @@ https://github.com/jdhitsolutions/PSScriptTools + + $cult = Get-Culture + if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") { + $dd = "{0:MM/dd/yyyy hh:mm tt}" -f $_.DueDate + } + else { + $dd = "{0:$($cult.DateTimeFormat.ShortDatePattern) $($cult.DateTimeFormat.LongTimePattern)}" -f $_.DueDate + } if ($host.name -match "console|code") { $ts = New-TimeSpan -Start (Get-Date) -End $_.duedate If ($ts.TotalDays -le 0) { - "{0}{1}{2}" -f $psstyle.Foreground.brightred, $_.DueDate, $psstyle.reset + "{0}{1}{2}" -f $psstyle.Foreground.brightred, $dd, $psstyle.reset } ElseIf ($ts.totaldays -le 3) { - "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $_.DueDate, $psstyle.reset + "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $dd, $psstyle.reset } else { - "$($PSWorkItemCategory["$($_.category)"])$($_.duedate)$($PSStyle.Reset)" + "$($PSWorkItemCategory["$($_.category)"])$($dd)$($PSStyle.Reset)" } } else { - $_.DueDate + $dd } @@ -190,7 +198,17 @@ https://github.com/jdhitsolutions/PSScriptTools Description - DueDate + + + $cult = Get-Culture + if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") { + $dd = "{0:MM/dd/yyyy hh:mm tt}" -f $_.DueDate + } + else { + $dd = "{0:$($cult.DateTimeFormat.ShortDatePattern) $($cult.DateTimeFormat.LongTimePattern)}" -f $_.DueDate + } + $dd + @@ -334,16 +352,24 @@ https://github.com/jdhitsolutions/PSScriptTools + + $cult = Get-Culture + if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") { + $dd = "{0:MM/dd/yyyy hh:mm tt}" -f $_.DueDate + } + else { + $dd = "{0:$($cult.DateTimeFormat.ShortDatePattern) $($cult.DateTimeFormat.LongTimePattern)}" -f $_.DueDate + } if ($host.name -match "console|code") { $ts = New-TimeSpan -Start (Get-Date) -End $_.duedate If ($ts.TotalDays -le 0) { - "{0}{1}{2}" -f $psstyle.Foreground.brightred, $_.DueDate, $psstyle.reset + "{0}{1}{2}" -f $psstyle.Foreground.brightred, $dd, $psstyle.reset } ElseIf ($ts.totaldays -le 3) { - "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $_.DueDate, $psstyle.reset + "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $dd, $psstyle.reset } else { - $_.DueDate + $dd } } else { @@ -406,7 +432,17 @@ https://github.com/jdhitsolutions/PSScriptTools - TaskCreated + + + $cult = Get-Culture + if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") { + $dd = "{0:MM/dd/yyyy hh:mm tt}" -f $_.TaskCreated + } + else { + $dd = "{0:$($cult.DateTimeFormat.ShortDatePattern) $($cult.DateTimeFormat.LongTimePattern)}" -f $_.TaskCreated + } + $dd + diff --git a/functions/private/tui-helpers.ps1 b/functions/private/tui-helpers.ps1 index 95bd592..c8187db 100644 --- a/functions/private/tui-helpers.ps1 +++ b/functions/private/tui-helpers.ps1 @@ -3,7 +3,6 @@ Function ConvertTo-DataTable { [cmdletbinding()] [OutputType('System.Data.DataTable')] - [alias('alias')] Param( [Parameter( Mandatory, @@ -158,10 +157,49 @@ Function RefreshTable { Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Starting $($MyInvocation.MyCommand)" $TableView.RemoveAll() $TableView.Clear() + #4 Jan 2024 format due date with leading zeros and no seconds + $cult = Get-Culture + $Data = Get-PSWorkItem -Path $txtPath.Text.ToString() -All | Where-Object { $_.Category -Like $FilterCategory } | - Select-Object ID, Name, Description, DueDate, Progress, Category, OverDue | + Select-Object ID, Name, Description, + @{Name = 'Due'; Expression = { + if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") { + "{0:MM/dd/yyyy hh:mm tt}" -f $_.DueDate + } + else { + "{0:$($cult.DateTimeFormat.ShortDatePattern) $($cult.DateTimeFormat.LongTimePattern)}" -f $_.DueDate + } + }}, + Progress, Category, OverDue | ConvertTo-DataTable + $TableView.Table = $Data + <# + Black Blue Green Cyan + Red Magenta Brown Gray + DarkGray BrightBlue BrightGreen + BrightCyan BrightRed BrightMagenta + BrightYellow White + #> + + $TableView.Style.RowColorGetter = { + Param ($Table) + $item = $table.Table.Rows[$Table.RowIndex] + $due = $item.Due -as [DateTime] + $ts = New-TimeSpan -Start (Get-Date) -End $due + $cs = [Terminal.Gui.ColorScheme]::new() + $bg =$window.ColorScheme.Normal.Background + if ($Item.OverDue) { + $cs.Normal = [Terminal.Gui.Attribute]::new("BrightRed", $bg) + $cs + } + elseif ($ts.TotalDays -le 5 ) { + #highlight tasks due in the next 5 days + $cs.Normal = [Terminal.Gui.Attribute]::new("Cyan", $bg) + $cs + } + } + $TableView.Style.ColumnStyles.Add( $TableView.Table.Columns['ID'], [Terminal.Gui.TableView+ColumnStyle]@{ @@ -169,22 +207,51 @@ Function RefreshTable { MinWidth = 4 } ) + $TableView.Style.ColumnStyles.Add( + $TableView.Table.Columns['Name'], + [Terminal.Gui.TableView+ColumnStyle]@{ + Alignment = 'Left' + MinWidth =30 + } + ) + + $TableView.Style.ColumnStyles.Add( + $TableView.Table.Columns['Description'], + [Terminal.Gui.TableView+ColumnStyle]@{ + Alignment = 'Left' + MinWidth =35 + } + ) $TableView.Style.ColumnStyles.Add( $TableView.Table.Columns['Progress'], [Terminal.Gui.TableView+ColumnStyle]@{ Alignment = 'Right' + RepresentationGetter = { + Param($item) + "{0}% " -f $item + } } ) $TableView.Style.ColumnStyles.Add( - $TableView.Table.Columns['DueDate'], + $TableView.Table.Columns['Due'], [Terminal.Gui.TableView+ColumnStyle]@{ Alignment = 'Justified' MinWidth = 22 } ) + #hide the OverDue column since it is represented in Red + #this allows more space for other columns + $TableView.Style.ColumnStyles.Add( + $TableView.Table.Columns['OverDue'], + [Terminal.Gui.TableView+ColumnStyle]@{ + Alignment = 'Right' + Visible = $False + } + ) + $TableView.SetNeedsDisplay() Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Ending $($MyInvocation.MyCommand)" } @@ -368,7 +435,7 @@ Function Populate { $chkClearDescription.Visible = $False } $txtTaskName.Text = $item.Name - $txtDueDate.Text = '{0:g}' -f $item.DueDate + $txtDueDate.Text = '{0:g}' -f $item.Due $radioGrp.SelectedItem = 1 $txtDays.Enabled = $False $txtDescription.Text = $item.Description diff --git a/functions/public/Get-PSWorkItemDatabase.ps1 b/functions/public/Get-PSWorkItemDatabase.ps1 index 0af28ea..15476ef 100644 --- a/functions/public/Get-PSWorkItemDatabase.ps1 +++ b/functions/public/Get-PSWorkItemDatabase.ps1 @@ -19,21 +19,23 @@ Function Get-PSWorkItemDatabase { _verbose -message $strings.Starting _verbose -message ($strings.PSVersion -f $PSVersionTable.PSVersion) _verbose -message ($strings.UsingModule -f (Get-Command -name $MyInvocation.MyCommand).Version) - _verbose -message ($strings.UsingDB -f $path) + #convert path + $cPath = Convert-Path $path + _verbose -message ($strings.UsingDB -f $cPath) } #begin Process { $PSDefaultParameterValues["_verbose:block"] = "Process" - _verbose -message ($strings.GetData -f $Path) + _verbose -message ($strings.GetData -f $cPath) Try { - $db = Get-MySQLiteDB -Path $Path -ErrorAction Stop + $db = Get-MySQLiteDB -Path $cPath -ErrorAction Stop } Catch { Throw $_ } if ($db) { _verbose -message $strings.OpenDBConnection - $conn = Open-MySQLiteDB -Path $path + $conn = Open-MySQLiteDB -Path $cPath _verbose -message $strings.TaskCount $tasks = Invoke-MySQLiteQuery -Connection $conn -KeepAlive -Query "Select Count() from tasks" -ErrorAction Stop _verbose -message $strings.ArchiveCount diff --git a/functions/public/Open-PSWorkItemConsole.ps1 b/functions/public/Open-PSWorkItemConsole.ps1 index e85b9eb..8974f0f 100644 --- a/functions/public/Open-PSWorkItemConsole.ps1 +++ b/functions/public/Open-PSWorkItemConsole.ps1 @@ -95,7 +95,7 @@ Function Open-PSWorkItemConsole { $controls += $txtDescription = [Terminal.Gui.TextField]@{ X = $lblDescription.Frame.Width + 2 - Width = 40 + Width = 30 Y = 4 TabStop = $True } @@ -103,6 +103,7 @@ Function Open-PSWorkItemConsole { $txtDescription.Add_MouseEnter({ $tip = $strings.tipDescription $StatusBar.Items[3].Title = $tip + [Terminal.Gui.Application]::Refresh() }) $txtDescription.Add_MouseLeave({ @@ -112,12 +113,23 @@ Function Open-PSWorkItemConsole { $controls += $chkClearDescription = [Terminal.Gui.CheckBox]@{ Text = 'C_lear' - X = $txtDescription.X + $txtDescription.Frame.Width + 2 + X = $txtDescription.X + ($txtDescription.Frame.Width + 2) Y = 4 TabStop = $False Visible = $False } + $chkClearDescription.Add_MouseEnter({ + $tip = $strings.tipClear + $StatusBar.Items[3].Title = $tip + [Terminal.Gui.Application]::Refresh() + }) + + $chkClearDescription.Add_MouseLeave({ + $StatusBar.Items[3].Title = 'Ready' + [Terminal.Gui.Application]::Refresh() + }) + $controls += $lblPath = [Terminal.Gui.Label]@{ Text = 'Database:' X = 1 @@ -156,7 +168,7 @@ Function Open-PSWorkItemConsole { #4 Jan 2024 Show required fields in a different color $cs = [Terminal.Gui.ColorScheme]::new() - $cs.Normal = [Terminal.Gui.Attribute]::new('BrightMagenta', 'Blue') + $cs.Normal = [Terminal.Gui.Attribute]::new('BrightYellow', 'Blue') $controls += $lblTaskName = [Terminal.Gui.Label]@{ Text = '*Name:' X = 1 @@ -167,7 +179,7 @@ Function Open-PSWorkItemConsole { $controls += $txtTaskName = [Terminal.Gui.TextField]@{ X = $lblDescription.Frame.Width + 2 - Width = 31 + Width = 25 Y = 2 TabIndex = 0 TabStop = $True @@ -236,22 +248,11 @@ Function Open-PSWorkItemConsole { $cs = [Terminal.Gui.ColorScheme]::new() <# - Black - Blue - Green - Cyan - Red - Magenta - Brown - Gray - DarkGray - BrightBlue - BrightGreen - BrightCyan - BrightRed - BrightMagenta - BrightYellow - White + Black Blue Green Cyan + Red Magenta Brown Gray + DarkGray BrightBlue BrightGreen + BrightCyan BrightRed BrightMagenta + BrightYellow White #> $fg= "BrightYellow" $bg = $window.ColorScheme.Normal.Background #"Blue" @@ -395,52 +396,52 @@ Function Open-PSWorkItemConsole { } $btnAdd.Add_Clicked({ - if ($txtTaskName.Text.ToString() -match '\w+') { - if ($chkWhatIf.Checked) { - ShowWhatIf -Command New - Return - } - $r = @{ - Name = $txtTaskName.Text.ToString() - Category = $dropCategory.Source.ToList()[$dropCategory.SelectedItem] - Path = $txtPath.Text.ToString() - ErrorAction = 'Stop' - } - if ($txtDescription.text.ToString() -match '\w+') { - $r.Add('Description', $txtDescription.text.ToString()) - } - - if ($txtDays.Enabled) { - $r.Add('DaysDue', $txtDays.Text.ToString()) - } - else { - $r.Add('DueDate', $txtDueDate.Text.ToString()) - } + if ($txtTaskName.Text.ToString() -match '\w+') { + if ($chkWhatIf.Checked) { + ShowWhatIf -Command New + Return + } + $r = @{ + Name = $txtTaskName.Text.ToString() + Category = $dropCategory.Source.ToList()[$dropCategory.SelectedItem] + Path = $txtPath.Text.ToString() + ErrorAction = 'Stop' + } + if ($txtDescription.text.ToString() -match '\w+') { + $r.Add('Description', $txtDescription.text.ToString()) + } - $StatusBar.Items[3].Title = "Creating PSWorkItem $($txtTaskName.Text.ToString()) in $($r.Path)" - $StatusBar.SetChildNeedsDisplay() - [Terminal.Gui.Application]::Refresh() - Start-Sleep -Milliseconds 1000 - Try { - New-PSWorkItem @r - ClearForm - UpdateReport - RefreshTable - [Terminal.Gui.Application]::Refresh() - } - Catch { - [Terminal.Gui.MessageBox]::ErrorQuery('Error', $_.Exception.Message) - } + if ($txtDays.Enabled) { + $r.Add('DaysDue', $txtDays.Text.ToString()) } else { - $StatusBar.Items[3].Title = $strings.MissingName - $StatusBar.SetChildNeedsDisplay() - [Terminal.Gui.Application]::Refresh() - Start-Sleep -Milliseconds 2000 - $StatusBar.Items[3].Title = 'Ready' + $r.Add('DueDate', $txtDueDate.Text.ToString()) + } + + $StatusBar.Items[3].Title = "Creating PSWorkItem $($txtTaskName.Text.ToString()) in $($r.Path)" + $StatusBar.SetChildNeedsDisplay() + [Terminal.Gui.Application]::Refresh() + Start-Sleep -Milliseconds 1000 + Try { + New-PSWorkItem @r + ClearForm + UpdateReport + RefreshTable [Terminal.Gui.Application]::Refresh() } - }) + Catch { + [Terminal.Gui.MessageBox]::ErrorQuery('Error', $_.Exception.Message) + } + } + else { + $StatusBar.Items[3].Title = $strings.MissingName + $StatusBar.SetChildNeedsDisplay() + [Terminal.Gui.Application]::Refresh() + Start-Sleep -Milliseconds 2000 + $StatusBar.Items[3].Title = 'Ready' + [Terminal.Gui.Application]::Refresh() + } + }) $controls += $btnSet = [Terminal.Gui.Button]@{ X = $btnAdd.Frame.Width + 2 @@ -449,81 +450,81 @@ Function Open-PSWorkItemConsole { } $btnSet.Add_Clicked({ - if ($txtTaskName.Text.ToString() -match '\w+') { - if ($chkWhatIf.Checked -AND $chkClearDescription.Checked) { - #save the current description - $SavedDescription = $txtDescription.Text.ToString() - #clear the field for the ShowWhatIt function - $txtDescription.Text = '' - [Terminal.Gui.Application]::Refresh() - ShowWhatIf -command Set -id $TableView.table.rows[$TableView.SelectedRow].ID - #reset the text field - $txtDescription.Text = $SavedDescription - [Terminal.Gui.Application]::Refresh() - Return + if ($txtTaskName.Text.ToString() -match '\w+') { + if ($chkWhatIf.Checked -AND $chkClearDescription.Checked) { + #save the current description + $SavedDescription = $txtDescription.Text.ToString() + #clear the field for the ShowWhatIF function + $txtDescription.Text = '' + [Terminal.Gui.Application]::Refresh() + ShowWhatIf -command Set -id $TableView.table.rows[$TableView.SelectedRow].ID + #reset the text field + $txtDescription.Text = $SavedDescription + [Terminal.Gui.Application]::Refresh() + Return + } + elseif ($chkWhatIf.Checked) { + ShowWhatIf -command Set -id $TableView.table.rows[$TableView.SelectedRow].ID + Return + } + + if ($chkClearDescription.Checked) { + $r = @{ + ID = $TableView.table.rows[$TableView.SelectedRow].ID + Path = $txtPath.Text.ToString() + ClearDescription = $True + ErrorAction = 'Stop' } - elseif ($chkWhatIf.Checked) { - ShowWhatIf -command Set -id $TableView.table.rows[$TableView.SelectedRow].ID - Return + } + else { + $r = @{ + ID = $TableView.table.rows[$TableView.SelectedRow].ID + Name = $txtTaskName.Text.ToString() + Category = $dropCategory.Source.ToList()[$dropCategory.SelectedItem] + Path = $txtPath.Text.ToString() + ErrorAction = 'Stop' } - - if ($chkClearDescription.Checked) { - $r = @{ - ID = $TableView.table.rows[$TableView.SelectedRow].ID - Path = $txtPath.Text.ToString() - ClearDescription = $True - ErrorAction = 'Stop' - } + if ($txtDescription.text.ToString() -match '\w+') { + $r.Add('Description', $txtDescription.text.ToString()) } - else { - $r = @{ - ID = $TableView.table.rows[$TableView.SelectedRow].ID - Name = $txtTaskName.Text.ToString() - Category = $dropCategory.Source.ToList()[$dropCategory.SelectedItem] - Path = $txtPath.Text.ToString() - ErrorAction = 'Stop' - } - if ($txtDescription.text.ToString() -match '\w+') { - $r.Add('Description', $txtDescription.text.ToString()) - } - if ($txtProgress.text.ToString() -match '\d') { - $r.Add('Progress', $txtProgress.text.ToString()) - } - if ($txtDays.Enabled) { - #calculate Date - $due = (Get-Date).AddDays( $txtDays.Text.ToString()) - $r.Add('DueDate', $due) - } - else { - $r.Add('DueDate', $txtDueDate.Text.ToString()) - } - } #else normal set - $StatusBar.Items[3].Title = "Updating PSWorkItem $($r.ID) in $($r.Path)" - $StatusBar.SetChildNeedsDisplay() - [Terminal.Gui.Application]::Refresh() - Start-Sleep -Milliseconds 1000 - Try { - Set-PSWorkItem @r - Populate - RefreshTable - UpdateReport - $StatusBar.Items[3].Title = 'Ready' - $StatusBar.SetChildNeedsDisplay() - [Terminal.Gui.Application]::Refresh() + if ($txtProgress.text.ToString() -match '\d') { + $r.Add('Progress', $txtProgress.text.ToString()) } - Catch { - [Terminal.Gui.MessageBox]::ErrorQuery('Error', $_.Exception.Message) + if ($txtDays.Enabled) { + #calculate Date + $due = (Get-Date).AddDays( $txtDays.Text.ToString()) + $r.Add('DueDate', $due) } - } - else { - $StatusBar.Items[3].Title = $strings.MissingName - $StatusBar.SetChildNeedsDisplay() - [Terminal.Gui.Application]::Refresh() - Start-Sleep -Milliseconds 2000 + else { + $r.Add('DueDate', $txtDueDate.Text.ToString()) + } + } #else normal set + $StatusBar.Items[3].Title = "Updating PSWorkItem $($r.ID) in $($r.Path)" + $StatusBar.SetChildNeedsDisplay() + [Terminal.Gui.Application]::Refresh() + Start-Sleep -Milliseconds 1000 + Try { + Set-PSWorkItem @r + Populate + RefreshTable + UpdateReport $StatusBar.Items[3].Title = 'Ready' + $StatusBar.SetChildNeedsDisplay() [Terminal.Gui.Application]::Refresh() } - }) + Catch { + [Terminal.Gui.MessageBox]::ErrorQuery('Error', $_.Exception.Message) + } + } + else { + $StatusBar.Items[3].Title = $strings.MissingName + $StatusBar.SetChildNeedsDisplay() + [Terminal.Gui.Application]::Refresh() + Start-Sleep -Milliseconds 2000 + $StatusBar.Items[3].Title = 'Ready' + [Terminal.Gui.Application]::Refresh() + } +}) $controls += $btnComplete = [Terminal.Gui.Button]@{ X = $btnSet.Frame.Width + 25 @@ -533,41 +534,41 @@ Function Open-PSWorkItemConsole { } $btnComplete.Add_Clicked({ - if ($txtTaskName.Text.ToString() -match '\w+') { - if ($chkWhatIf.Checked) { - ShowWhatIf -Command Complete -id $TableView.table.rows[$TableView.SelectedRow].ID - Return - } - $r = @{ - ID = $TableView.table.rows[$TableView.SelectedRow].ID - Path = $txtPath.Text.ToString() - ErrorAction = 'Stop' - } + if ($txtTaskName.Text.ToString() -match '\w+') { + if ($chkWhatIf.Checked) { + ShowWhatIf -Command Complete -id $TableView.table.rows[$TableView.SelectedRow].ID + Return + } + $r = @{ + ID = $TableView.table.rows[$TableView.SelectedRow].ID + Path = $txtPath.Text.ToString() + ErrorAction = 'Stop' + } - $StatusBar.Items[3].Title = "Completing PSWorkItem $($r.ID) in $($r.Path)" - $StatusBar.SetChildNeedsDisplay() - [Terminal.Gui.Application]::Refresh() - Start-Sleep -Milliseconds 1000 + $StatusBar.Items[3].Title = "Completing PSWorkItem $($r.ID) in $($r.Path)" + $StatusBar.SetChildNeedsDisplay() + [Terminal.Gui.Application]::Refresh() + Start-Sleep -Milliseconds 1000 - Try { - Complete-PSWorkItem @r - ClearForm - UpdateReport - RefreshTable - [Terminal.Gui.Application]::Refresh() - } - Catch { - [Terminal.Gui.MessageBox]::ErrorQuery('Error', $_.Exception.Message) - } - } - else { - $StatusBar.Items[3].Title = $strings.NoWorkItemSelected - $StatusBar.SetChildNeedsDisplay() - [Terminal.Gui.Application]::Refresh() - Start-Sleep -Milliseconds 2000 - $StatusBar.Items[3].Title = 'Ready' + Try { + Complete-PSWorkItem @r + ClearForm + UpdateReport + RefreshTable [Terminal.Gui.Application]::Refresh() } + Catch { + [Terminal.Gui.MessageBox]::ErrorQuery('Error', $_.Exception.Message) + } + } + else { + $StatusBar.Items[3].Title = $strings.NoWorkItemSelected + $StatusBar.SetChildNeedsDisplay() + [Terminal.Gui.Application]::Refresh() + Start-Sleep -Milliseconds 2000 + $StatusBar.Items[3].Title = 'Ready' + [Terminal.Gui.Application]::Refresh() + } }) $controls += $btnRemove = [Terminal.Gui.Button]@{ diff --git a/samples/PSWorkItem.db b/samples/PSWorkItem.db index 69baf1bea27da400efb38e31986ccd4101df60e1..3fe6dd1a0c1bc847896896b28f24ec33456dff45 100644 GIT binary patch literal 32768 zcmeI*&u`mQ8~|`T&aeJR&81jX7xAVEt<~x^&p%>k2#IbhXk*<%+5!`x=-Ga5y(Mw6 zopn2A2M&k>8h-$P0EbEZ2fK3O0MZT!?r=hy1V`R;;+29oAJsm1%3iPv1V8`;KmY_l00ck)1V8`;{viQct|%u@ilfDZI6dl; zgzkk=K;xrQ<|V zdl8Le6bzUhjn>?-f6$}+I9Y_{GbygBrLwZI{3M4-ExLG8D32}|DvF|rcjHum=gdm% zO*&TlH1yopeN`$euPaZgds>GsPCt0hI_+)u#EMd{i=#7X^|xq3STm69vv3R{i=vf{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