Skip to content

Commit

Permalink
v1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Feb 24, 2024
1 parent b0f9d6b commit 576a5e3
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 23 deletions.
2 changes: 1 addition & 1 deletion PSWorkItem.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@{
RootModule = 'PSWorkItem.psm1'
ModuleVersion = '1.8.0'
ModuleVersion = '1.9.0'
CompatiblePSEditions = 'Core'
GUID = '4d3ff215-69ea-4fe6-8ad6-97ffc3a15bfb'
Author = 'Jeff Hicks'
Expand Down
1 change: 0 additions & 1 deletion PSWorkItem.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# used for culture debugging
# write-host "Importing with culture $(Get-Culture)"

Expand Down
15 changes: 14 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## [Unreleased]

## [1.9.0] - 2024-02-24

### Changed

- Update TUI to allow filtering table by the number of days dues.
- Updated TUI to show about information using a dialog instead of a message box to allow for better formatting.
- Update TUI-based console so that selected category is always in view.

### Fixed

- Fixed hard-coded references in private functions that were pointing to `C:\temp`.

## [1.8.0] - 2024-02-23

### Added
Expand Down Expand Up @@ -299,7 +311,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.8.0..HEAD
[Unreleased]: https://github.com/jdhitsolutions/PSWorkItem/compare/v1.9.0..HEAD
[1.9.0]: https://github.com/jdhitsolutions/PSWorkItem/compare/v1.8.0..v1.9.0
[1.8.0]: https://github.com/jdhitsolutions/PSWorkItem/compare/v1.7.0..v1.8.0
[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
Expand Down
1 change: 1 addition & 0 deletions en-us/PSWorkItem.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ ConvertFrom-StringData @'
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
tipFilterDays = Filter the table by the number of days due. Clear to reset.
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. Required.
Expand Down
75 changes: 57 additions & 18 deletions functions/private/tui-helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,19 @@ Function ClearForm {
[CmdletBinding()]
Param()
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Starting $($MyInvocation.MyCommand)"

$txtTaskName.Text = ''
$txtDescription.Text = ''
$chkWhatIf.Checked = $False
$txtProgress.Text = ''
$dropCategory.SelectedItem = 0
$dropCategory.SelectedItem = $script:DefaultCategoryIndex
$txtDays.Text = 30
$txtDueDate.Text = ''
$radioGrp.SelectedItem = 0
$lblOverDue.Visible = $False
$StatusBar.Items[0].Title = Get-Date -Format g
$StatusBar.Items[3].Title = 'Ready'
$FilterDays.Text = ''
$txtTaskName.SetFocus()
[Terminal.Gui.Application]::Refresh()
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Ending $($MyInvocation.MyCommand)"
Expand All @@ -76,7 +78,7 @@ Function ResetForm {
$txtDescription.Text = ''
$chkWhatIf.Checked = $False
$txtProgress.Text = ''
$dropCategory.SelectedItem = 0
$dropCategory.SelectedItem = $script:DefaultCategoryIndex
$txtDays.Text = 30
$txtDueDate.Text = ''
$radioGrp.SelectedItem = 0
Expand All @@ -86,6 +88,7 @@ Function ResetForm {
$chkFilterTable.Checked = $False
$txtTaskName.SetFocus()
$txtPath.Text = $PSWorkItemPath
$FilterDays.Text = ''

RefreshCategoryList
RefreshTable
Expand Down Expand Up @@ -152,15 +155,22 @@ Function ShowHelp {
Function RefreshTable {
[CmdletBinding()]
Param(
[string]$FilterCategory = '*'
[string]$FilterCategory = '*',
[int]$DaysDue
)
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 } |
if ($DaysDue -gt 0) {
$Items = Get-PSWorkItem -Path $txtPath.Text.ToString() -DaysDue $DaysDue
}
else {
$items = Get-PSWorkItem -Path $txtPath.Text.ToString() -All
}
$Data = $Items | Where-Object { $_.Category -Like $FilterCategory } |
Select-Object ID, Name, Description,
@{Name = 'Due'; Expression = {
if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") {
Expand Down Expand Up @@ -262,14 +272,24 @@ Function RefreshCategoryList {
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Starting $($MyInvocation.MyCommand)"
$src = (Get-PSWorkItemCategory -Path $txtPath.Text.ToString()).Category | Sort-Object
$src | Write-Verbose
#create a lookup list
$script:CatList = [System.Collections.Generic.List[string]]::New()
$script:CatList.AddRange([string[]]$src)
if ($global:PSDefaultParameterValues.ContainsKey("New-PSWorkItem:Category")) {
$DefaultCategory = $global:PSDefaultParameterValues["New-PSWorkItem:Category"]
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Default category is $DefaultCategory"
$script:DefaultCategoryIndex = $script:CatList.FindIndex({$args[0] -eq $DefaultCategory})
}
else {
$script:DefaultCategoryIndex = 0
}
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Using default category index $($script:DefaultCategoryIndex)"
$dropCategory.Clear()
$dropCategory.SetSource($src)
$dropCategory.SelectedItem = $script:DefaultCategoryIndex
$dropCategory.EnsureSelectedItemVisible()
$dropCategory.SetNeedsDisplay()
[Terminal.Gui.Application]::Refresh()
$dropCategory.SelectedItem = 0
#create a lookup list
$script:CatList = [System.Collections.Generic.List[string]]::New()
$script:CatList.AddRange([string[]]$src)
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Ending $($MyInvocation.MyCommand)"
}

Expand Down Expand Up @@ -384,15 +404,32 @@ Function ShowAbout {

$about = @"
PSWorkItem $scriptVer
mySQLite $((Get-Module mySQLite).version.ToString())
PSVersion $($PSVersionTable.PSVersion)
Terminal.Gui $TerminalGuiVersion
NStack $NStackVersion
System.Data.SQLite $SQLiteVersion
PSWorkItem: $scriptVer
mySQLite: $((Get-Module mySQLite).version.ToString())
PSVersion: $($PSVersionTable.PSVersion)
Terminal.Gui: $TerminalGuiVersion
NStack: $NStackVersion
System.Data.SQLite: $SQLiteVersion
"@
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Show message box"
[Terminal.Gui.MessageBox]::Query('About Open-PSWorkItemConsole', $About, @('Ok'))

$dialog = [Terminal.Gui.Dialog]@{
Title = 'About Open-PSWorkItemConsole'
TextAlignment = 'Left'
Width = 40
Height = 12
Text = $about
}
$ok = [Terminal.Gui.Button]@{
Text = 'OK'
}
$ok.Add_Clicked({ $dialog.RequestStop() })
$dialog.AddButton($ok)
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Invoking dialog"
[Terminal.Gui.Application]::Run($dialog)

#Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Show message box"
# Replaced 24 Feb 2024 with a dialog which allows for better formatting
#[Terminal.Gui.MessageBox]::Query('About Open-PSWorkItemConsole', $About, @('Ok'))
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Ending $($MyInvocation.MyCommand)"
}

Expand Down Expand Up @@ -441,6 +478,7 @@ Function Populate {
$txtDays.Enabled = $False
$txtDescription.Text = $item.Description
$dropCategory.SelectedItem = $script:CatList.FindIndex({ $args -eq $item.Category })
$dropCategory.EnsureSelectedItemVisible()
$txtProgress.Text = $item.Progress
Write-Verbose "[$((Get-Date).TimeOfDay) PRIVATE] Ending $($MyInvocation.MyCommand)"
}
Expand Down Expand Up @@ -840,8 +878,9 @@ Path = $($txtPath.Text.ToString())
}

Try {
$splat | out-string | out-file c:\temp\v.txt
Set-PSWorkItemCategory @splat -verbose 4>>c:\temp\v.txt
$tmpfile = [System.IO.Path]::GetTempFileName()
$splat | Out-String | Out-File -FilePath $tmpFile
Set-PSWorkItemCategory @splat -verbose 4>>$tmpfile
if ($warn) {
[Terminal.Gui.MessageBox]::ErrorQuery('Warning', $warn.message)
}
Expand Down
37 changes: 35 additions & 2 deletions functions/public/Open-PSWorkItemConsole.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ Function Open-PSWorkItemConsole {

$controls += $lblCategory = [Terminal.Gui.Label]@{
Text = 'Category:'
X = $txtDescription.Frame.Right + 4
X = $txtDescription.Frame.Right + 6
Y = $lblTaskName.Y
TabStop = $false
CanFocus = $False
Expand Down Expand Up @@ -316,9 +316,9 @@ Function Open-PSWorkItemConsole {
}
})

#Updated 23 Feb 2024 to use the $PSWorkItemDefaultDays variable
$controls += $txtDays = [Terminal.Gui.TextField]@{
Width = 4
#Updated 23 Feb 2024 to use the $PSWorkItemDefaultDays variable
Text = $global:PSWorkItemDefaultDays
Y = $txtDescription.Y + 2
X = $radioGrp.Frame.Width + 2
Expand Down Expand Up @@ -386,6 +386,39 @@ Function Open-PSWorkItemConsole {
}
})

$controls += $FilterDays = [Terminal.Gui.TextField]@{
Width = 3
Y = $chkFilterTable.Y
X = $chkFilterTable.Frame.Right + 2
TabStop = $False
}

$FilterDays.Add_MouseEnter({
$tip = $strings.tipFilterDays
$StatusBar.Items[3].Title = $tip
[Terminal.Gui.Application]::Refresh()
})
$FilterDays.Add_MouseLeave({
$StatusBar.Items[3].Title = 'Ready'
[Terminal.Gui.Application]::Refresh()
})

$FilterDays.Add_TextChanged({
if ($FilterDays.Text.ToString() -match '\d') {
RefreshTable -DaysDue $FilterDays.Text.ToString()
}
else {
RefreshTable
}
})

$controls += $lblFilterDays = [Terminal.Gui.Label]@{
Text = 'Filter by number of days due'
X = $FilterDays.Frame.Right + 1
Y = $chkFilterTable.Y
TabStop = $False
}

#endregion

#region buttons
Expand Down

0 comments on commit 576a5e3

Please sign in to comment.