chore: update version to 2.0.1 and enhance Classic functionality with dynamic field discovery
This commit is contained in:
@@ -27,9 +27,11 @@ try {
|
||||
$list = $context.Web.Lists.GetByTitle($ListTitle)
|
||||
$field = $list.Fields.GetByInternalNameOrTitle($ExpiryFieldInternalName)
|
||||
$customActions = $list.UserCustomActions
|
||||
$webCustomActions = $context.Web.UserCustomActions
|
||||
$context.Load($list)
|
||||
$context.Load($field)
|
||||
$context.Load($customActions)
|
||||
$context.Load($webCustomActions)
|
||||
$context.ExecuteQuery()
|
||||
|
||||
if ($field.InternalName -ne $ExpiryFieldInternalName) {
|
||||
@@ -55,15 +57,25 @@ try {
|
||||
$_.DeleteObject()
|
||||
}
|
||||
|
||||
if (-not $SkipClassic) {
|
||||
$webCustomActions | Where-Object {
|
||||
$_.Name -eq 'ExpiryIndicator.Classic.ScriptLink'
|
||||
} | ForEach-Object {
|
||||
$_.DeleteObject()
|
||||
}
|
||||
}
|
||||
|
||||
$context.ExecuteQuery()
|
||||
|
||||
if (-not $SkipClassic) {
|
||||
$scriptAction = $list.UserCustomActions.Add()
|
||||
# SharePoint permits Location=ScriptLink only on Web/Site custom
|
||||
# actions, not on List.UserCustomActions. The runtime detects the
|
||||
# current list and its bound expiry field by itself.
|
||||
$scriptAction = $context.Web.UserCustomActions.Add()
|
||||
$scriptAction.Name = 'ExpiryIndicator.Classic.ScriptLink'
|
||||
$scriptAction.Title = 'ExpiryIndicator Classic runtime'
|
||||
$scriptAction.Location = 'ScriptLink'
|
||||
$separator = if ($ClassicScriptUrl.Contains('?')) { '&' } else { '?' }
|
||||
$scriptAction.ScriptSrc = $ClassicScriptUrl + $separator + 'expiryField=' + [Uri]::EscapeDataString($field.InternalName)
|
||||
$scriptAction.ScriptSrc = $ClassicScriptUrl
|
||||
$scriptAction.Sequence = 650
|
||||
$scriptAction.Update()
|
||||
|
||||
@@ -103,7 +115,7 @@ try {
|
||||
$ribbonAction.Update()
|
||||
|
||||
$context.ExecuteQuery()
|
||||
Write-Host 'Classic-Ansicht: CSR/JSLink und Ribbon-Befehl wurden registriert.'
|
||||
Write-Host 'Classic-Ansicht: Web-ScriptLink und listenspezifischer Ribbon-Befehl wurden registriert.'
|
||||
}
|
||||
|
||||
Write-Host "ExpiryIndicator wurde für '$($list.Title)' an '$($field.InternalName)' gebunden."
|
||||
|
||||
Reference in New Issue
Block a user