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 69baf1b..3fe6dd1 100644
Binary files a/samples/PSWorkItem.db and b/samples/PSWorkItem.db differ