Skip to content

Commit

Permalink
v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Jan 7, 2024
1 parent dca7da8 commit e8ed786
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 181 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.5.0'
ModuleVersion = '1.7.0'
CompatiblePSEditions = 'Core'
GUID = '4d3ff215-69ea-4fe6-8ad6-97ffc3a15bfb'
Author = 'Jeff Hicks'
Expand Down
2 changes: 2 additions & 0 deletions PSWorkItem.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class PSWorkItemDatabase {
[String]$Encoding
[int32]$PageCount
[int32]$PageSize
[string]$SQLiteVersion
[string]$CreatedBy
}

#endregion
Expand Down
18 changes: 17 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions en-us/PSWorkItem.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 46 additions & 10 deletions formats/psworkitem.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ https://github.com/jdhitsolutions/PSScriptTools
"{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $_.name, $psstyle.reset
}
else {
<!--use the PSWorkItemCategory hastable to add custom highlights-->
<!--use the PSWorkItemCategory hastable to add custom highlights-->
"$($PSWorkItemCategory["$($_.category)"])$($_.name)$($PSStyle.Reset)"
}
}
Expand Down Expand Up @@ -100,20 +100,28 @@ https://github.com/jdhitsolutions/PSScriptTools
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
<!--format the due date with leading zeros and no seconds-->
$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
}
</ScriptBlock>
</TableColumnItem>
Expand Down Expand Up @@ -190,7 +198,17 @@ https://github.com/jdhitsolutions/PSScriptTools
<PropertyName>Description</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>DueDate</PropertyName>
<ScriptBlock>
<!--format the due date with leading zeros and no seconds-->
$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
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<!--this is the simplest way to handle negative values-->
Expand Down Expand Up @@ -334,16 +352,24 @@ https://github.com/jdhitsolutions/PSScriptTools
</TableColumnItem>
<TableColumnItem>
<ScriptBlock>
<!--format the due date with leading zeros and no seconds-->
$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 {
Expand Down Expand Up @@ -406,7 +432,17 @@ https://github.com/jdhitsolutions/PSScriptTools
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>TaskCreated</PropertyName>
<ScriptBlock>
<!--format the creation date with leading zeros and no seconds-->
$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
</ScriptBlock>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
Expand Down
75 changes: 71 additions & 4 deletions functions/private/tui-helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Function ConvertTo-DataTable {
[cmdletbinding()]
[OutputType('System.Data.DataTable')]
[alias('alias')]
Param(
[Parameter(
Mandatory,
Expand Down Expand Up @@ -158,33 +157,101 @@ 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]@{
Alignment = 'Right'
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)"
}
Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions functions/public/Get-PSWorkItemDatabase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit e8ed786

Please sign in to comment.