diff --git a/.gitignore b/.gitignore index c81013c90..b0fed95c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ Install/SiteScripts/*.txt Install/InstallLog.txt +Install/Scripts/UpgradeSites_Log* release/* SharePointFramework/**/.vscode/launch.json SharePointFramework/**/pnpm-lock.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 46ce88211..5323a0f3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,10 @@ Every change is marked with issue ID. - Example: Trigger API's, Flows, Logic Apps, Azure Functions, etc... - Improvements to styling, sorting and information messages for the Document Template Selector #711 +### Fixed + +- Fixed issue with resource allocation percentage not showing #610. NB: The script UpgradeAllSitesToLatest.ps1 needs to be run to fix the issue for old sites! + ## 1.5.0 - 01.04.2022 ### Added diff --git a/Install/Scripts/PostInstallUpgrade.ps1 b/Install/Scripts/PostInstallUpgrade.ps1 index 6b271dbfc..1d16e6f79 100644 --- a/Install/Scripts/PostInstallUpgrade.ps1 +++ b/Install/Scripts/PostInstallUpgrade.ps1 @@ -7,6 +7,11 @@ if ($null -ne $LastInstall) { Write-Host "[INFO] In version v1.2.7 we added 'Prosjekttidslinje' to the top navigation. Adding this navigation item now as part of the upgrade" Add-PnPNavigationNode -Location TopNavigationBar -Title "Prosjekttidslinje" -Url "$($Uri.LocalPath)/SitePages/Prosjekttidslinje.aspx" } + if ($PreviousVersion -lt "1.5.0") { + Write-Host "[INFO] Applying PnP template [1.5.0] to [$Url]" + Apply-PnPProvisioningTemplate "$BasePath\1.5.0.pnp" -ErrorAction Stop + Write-Host "[SUCCESS] Successfully applied PnP template [1.5.0] to [$Url]" -ForegroundColor Green + } if ($PreviousVersion -lt "1.5.5") { Write-Host "[INFO] In version v1.5.5 we added Project timeline configuration and reworked the TimelineContent list. Merging data now as part of the upgrade" @@ -34,10 +39,5 @@ if ($null -ne $LastInstall) { Invoke-PnPQuery } } - if ($PreviousVersion -lt "1.5.0") { - Write-Host "[INFO] Applying PnP template [1.5.0] to [$Url]" - Apply-PnPProvisioningTemplate "$BasePath\1.5.0.pnp" -ErrorAction Stop - Write-Host "[SUCCESS] Successfully applied PnP template [1.5.0] to [$Url]" -ForegroundColor Green - } } \ No newline at end of file diff --git a/Install/Scripts/UpgradeAllSitesToLatest.ps1 b/Install/Scripts/UpgradeAllSitesToLatest.ps1 index de41aaf73..e322e644f 100644 --- a/Install/Scripts/UpgradeAllSitesToLatest.ps1 +++ b/Install/Scripts/UpgradeAllSitesToLatest.ps1 @@ -14,37 +14,99 @@ function EnsureProjectTimelinePage($Url) { Write-Host "`t`tCannot connect to site. Do you have access?" -ForegroundColor Red } else { - $existingNode = $existingNodes | Where-Object { $_.Title -eq "Prosjekttidslinje" } -ErrorAction SilentlyContinue + $existingNode = $existingNodes | Where-Object { $_.Title -eq "Prosjekttidslinje" -or $_.Title -eq "Programtidslinje" } -ErrorAction SilentlyContinue if ($null -eq $existingNode) { - Write-Host "`t`tAdding project timeline page" + Write-Host "`t`tAdding project timeline to site" + Write-Host "`t`t`tAdding project timeline page" $page = Add-PnPClientSidePage -Name "Prosjekttidslinje.aspx" -PromoteAs None -LayoutType SingleWebPartAppPage -CommentsEnabled:$false -Publish - Write-Host "`t`tAdding project timeline app" + Write-Host "`t`t`tAdding project timeline app" $webpart = Add-PnPClientSideWebPart -Page "Prosjekttidslinje" -Component "Prosjekttidslinje" -WebPartProperties '{"listName":"Tidslinjeinnhold","showFilterButton":true,"showTimeline":true,"showInfoMessage":true,"showCmdTimelineList":true,"showTimelineList":true,"title":"Prosjekttidslinje"}' $page = Set-PnPClientSidePage -Identity "Prosjekttidslinje" -LayoutType SingleWebPartAppPage -HeaderType None -Publish - Write-Host "`t`tAdding project timeline navigation item" + Write-Host "`t`t`tAdding project timeline navigation item" $node = Add-PnPNavigationNode -Location QuickLaunch -Title "Prosjekttidslinje" -Url "SitePages/Prosjekttidslinje.aspx" } else { - Write-Host "`t`tThe project already has the project timeline page. " -ForegroundColor Yellow + Write-Host "`t`tThe site already has the project timeline page" -ForegroundColor Green } } } +function EnsureResourceLoadIsSiteColumn($Url) { + Connect-PnPOnline -Url $Url -UseWebLogin + + $ResourceAllocation = Get-PnPList -Identity "Ressursallokering" -ErrorAction SilentlyContinue + if ($null -ne $ResourceAllocation) { + $ResourceLoadSiteColumn = Get-PnPField -Identity "GtResourceLoad" + $ResourceLoadListColumn = Get-PnPField -Identity "GtResourceLoad" -List $ResourceAllocation + if ($null -ne $ResourceLoadSiteColumn) { + Write-Host "`t`tReplacing GtResourceLoad field" + $PreviousValues = Get-PnPListItem -List $ResourceAllocation -Fields "ID", "GtResourceLoad" | ForEach-Object { + @{Id = $_.Id; GtResourceLoad = $_.FieldValues["GtResourceLoad"] } + } + + if ($PreviousValues.length -gt 0) { + Write-Host "`t`t`t" (ConvertTo-Json $PreviousValues -Compress) + } + + $ResourceAllocationContentType = Get-PnPContentType -Identity "Ressursallokering" -List "Ressursallokering" -ErrorAction SilentlyContinue + if ($null -ne $ResourceAllocationContentType) { + Write-Host "`t`t`tRemoving old field" + $RemovedColumn = Remove-PnPField -Identity $ResourceLoadListColumn -List $ResourceAllocation -Force + + + Write-Host "`t`t`tAdding the site field" + $FieldLink = New-Object Microsoft.SharePoint.Client.FieldLinkCreationInformation + $FieldLink.Field = $ResourceLoadSiteColumn + $Output = $ResourceAllocationContentType.FieldLinks.Add($FieldLink) + $ResourceAllocationContentType.Update($false) + $ResourceAllocationContentType.Context.ExecuteQuery() + + Write-Host "`t`t`tAdding the site field to default view" + $DefaultView = Get-PnPView -List $ResourceAllocation -Identity "Alle elementer" -ErrorAction SilentlyContinue + if ($null -ne $DefaultView) { + $DefaultView.ViewFields.Add("GtResourceLoad") + $DefaultView.Update() + $DefaultView.Context.ExecuteQuery() + } + + + if ($PreviousValues.length -gt 0) { + Write-Host "`t`t`tRestoring previous values" + $PreviousValues | ForEach-Object { + $ResourceLoad = $_.GtResourceLoad + + if ($ResourceLoad -gt 2 ) { + # Assuming that noone had more than 200% previously + $ResourceLoad = ($ResourceLoad / 100) # Convert to percentage if it wasn't previously + } + $NewValue = Set-PnPListItem -List $ResourceAllocation -Identity $_.Id -Values @{"GtResourceLoad" = $ResourceLoad } -SystemUpdate + } + } + + Write-Host "`t`t`tField swap completed" -ForegroundColor Green + } + } + else { + Write-Host "`t`tThe site already has the correct GtResourceLoad field" -ForegroundColor Green + } + } +} + function UpgradeSite($Url) { EnsureProjectTimelinePage -Url $Url + EnsureResourceLoadIsSiteColumn -Url $Url } Write-Host "This script will update all existing sites in a Prosjektportalen installation. This requires you to have the SharePoint admin role" +Set-PnPTraceLog -Off +Start-Transcript -Path "$PSScriptRoot\UpgradeSites_Log-$((Get-Date).ToString('yyyy-MM-dd-HH-mm')).txt" + [System.Uri]$Uri = $PortfolioUrl $AdminSiteUrl = (@($Uri.Scheme, "://", $Uri.Authority) -join "").Replace(".sharepoint.com", "-admin.sharepoint.com") -Connect-PnPOnline -Url $AdminSiteUrl -UseWebLogin - -$PPHubSite = Get-PnPHubSite -Identity $PortfolioUrl - -$ProjectsInHub = Get-PP365HubSiteChild -Identity $PPHubSite +Connect-PnPOnline -Url $AdminSiteUrl -UseWebLogin -WarningAction Ignore # Get current logged in user $ctx = Get-PnPContext @@ -52,6 +114,9 @@ $ctx.Load($ctx.Web.CurrentUser) $ctx.ExecuteQuery() $UserName = $ctx.Web.CurrentUser.LoginName +$PPHubSite = Get-PnPHubSite -Identity $PortfolioUrl +$ProjectsInHub = Get-PP365HubSiteChild -Identity $PPHubSite + Write-Host "The following sites were found to be part of the Project Portal hub:" $ProjectsInHub | ForEach-Object { Write-Host "`t$_" } @@ -59,7 +124,7 @@ Write-Host "We can grant $UserName admin access to existing projects. This will do { $YesOrNo = Read-Host "Do you want to grant $UserName access to all sites in the hub (listed above)? (y/n)" } -while ("y","n" -notcontains $YesOrNo) +while ("y", "n" -notcontains $YesOrNo) if ($YesOrNo -eq "y") { $ProjectsInHub | ForEach-Object { @@ -79,7 +144,7 @@ Write-Host "We can remove $UserName's admin access from existing projects." do { $YesOrNo = Read-Host "Do you want to remove $UserName's admin access from all sites in the hub? (y/n)" } -while ("y","n" -notcontains $YesOrNo) +while ("y", "n" -notcontains $YesOrNo) if ($YesOrNo -eq "y") { $ProjectsInHub | ForEach-Object { @@ -90,5 +155,4 @@ if ($YesOrNo -eq "y") { } - - +Stop-Transcript diff --git a/Templates/JsonTemplates/_JsonTemplateProgram.json b/Templates/JsonTemplates/_JsonTemplateProgram.json index a2e94b87c..082835978 100644 --- a/Templates/JsonTemplates/_JsonTemplateProgram.json +++ b/Templates/JsonTemplates/_JsonTemplateProgram.json @@ -410,7 +410,10 @@ ], "SiteFields": [ "=GtRiskProbability*GtRiskConsequence", - "=GtRiskProbabilityPostAction*GtRiskConsequencePostAction" + "=GtRiskProbabilityPostAction*GtRiskConsequencePostAction", + "", + "", + "" ], "Navigation": { "QuickLaunch": [{ @@ -1048,9 +1051,6 @@ "AdditionalSettings": { "EnableVersioning": true }, - "Fields": [ - "" - ], "Views": [{ "Title": "{{View_AllItems_DisplayName}}", "ViewFields": [ @@ -1442,10 +1442,6 @@ "ContentTypeBindings": [{ "ContentTypeID": "0x010004EAFF7AFCC94C2680042E6881264120" }], - "Fields": [ - "", - "" - ], "Views": [{ "Title": "{{View_AllItems_DisplayName}}", "ViewFields": [ diff --git a/Templates/JsonTemplates/_JsonTemplateProject.json b/Templates/JsonTemplates/_JsonTemplateProject.json index 0709096bb..31b828c17 100644 --- a/Templates/JsonTemplates/_JsonTemplateProject.json +++ b/Templates/JsonTemplates/_JsonTemplateProject.json @@ -410,7 +410,10 @@ ], "SiteFields": [ "=GtRiskProbability*GtRiskConsequence", - "=GtRiskProbabilityPostAction*GtRiskConsequencePostAction" + "=GtRiskProbabilityPostAction*GtRiskConsequencePostAction", + "", + "", + "" ], "Navigation": { "QuickLaunch": [{ @@ -852,9 +855,6 @@ "AdditionalSettings": { "EnableVersioning": true }, - "Fields": [ - "" - ], "Views": [{ "Title": "{{View_AllItems_DisplayName}}", "ViewFields": [ @@ -1246,10 +1246,6 @@ "ContentTypeBindings": [{ "ContentTypeID": "0x010004EAFF7AFCC94C2680042E6881264120" }], - "Fields": [ - "", - "" - ], "Views": [{ "Title": "{{View_AllItems_DisplayName}}", "ViewFields": [