feat: add ExpiryIndicatorClassic functionality with configuration and rendering
- Implemented ExpiryIndicatorClassic.js for managing expiry dates in SharePoint lists. - Created classic-elements.xml to define the module for ExpiryIndicator assets. - Added upgrade-actions-v2.xml to apply the new element manifests. - Introduced ExpiryModels.test.ts for unit testing the expiry configuration and rules validation.
This commit is contained in:
@@ -9,7 +9,11 @@ param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$ExpiryFieldInternalName,
|
||||
|
||||
[Guid]$FieldCustomizerComponentId = 'a555f4fc-d6a6-4421-8189-457449d9bbde'
|
||||
[Guid]$FieldCustomizerComponentId = 'a555f4fc-d6a6-4421-8189-457449d9bbde',
|
||||
|
||||
[string]$ClassicScriptUrl = '~site/SiteAssets/ExpiryIndicator/ExpiryIndicatorClassic.js',
|
||||
|
||||
[switch]$SkipClassic
|
||||
)
|
||||
|
||||
$isapiPath = Join-Path ([Environment]::GetFolderPath('CommonProgramFiles')) 'microsoft shared\Web Server Extensions\16\ISAPI'
|
||||
@@ -41,16 +45,67 @@ try {
|
||||
}
|
||||
$field.Update()
|
||||
|
||||
# Remove the temporary list-scoped command registration used by older
|
||||
# diagnostic scripts. The app feature owns the production registration.
|
||||
# Remove old diagnostic registrations and make the V2 Classic
|
||||
# registrations idempotent.
|
||||
$customActions | Where-Object {
|
||||
$_.Name -eq 'ExpiryIndicator.CommandSet'
|
||||
$_.Name -eq 'ExpiryIndicator.CommandSet' -or
|
||||
$_.Name -eq 'ExpiryIndicator.Classic.ScriptLink' -or
|
||||
$_.Name -eq 'ExpiryIndicator.Classic.Ribbon'
|
||||
} | ForEach-Object {
|
||||
$_.DeleteObject()
|
||||
}
|
||||
|
||||
$context.ExecuteQuery()
|
||||
|
||||
if (-not $SkipClassic) {
|
||||
$scriptAction = $list.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.Sequence = 650
|
||||
$scriptAction.Update()
|
||||
|
||||
$ribbonLocation = if ($list.BaseType -eq [Microsoft.SharePoint.Client.BaseType]::DocumentLibrary) {
|
||||
'Ribbon.Library.Actions.Controls._children'
|
||||
}
|
||||
else {
|
||||
'Ribbon.List.Actions.Controls._children'
|
||||
}
|
||||
|
||||
$ribbonXml = @"
|
||||
<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
|
||||
<CommandUIDefinitions>
|
||||
<CommandUIDefinition Location="$ribbonLocation">
|
||||
<Button Id="ExpiryIndicator.Classic.ExtendOneYear.Button"
|
||||
Command="ExpiryIndicator.Classic.ExtendOneYear"
|
||||
Sequence="90"
|
||||
LabelText="Ablaufdatum +1 Jahr"
|
||||
Description="Verlängert das Ablaufdatum der ausgewählten Elemente um ein Kalenderjahr."
|
||||
TemplateAlias="o1" />
|
||||
</CommandUIDefinition>
|
||||
</CommandUIDefinitions>
|
||||
<CommandUIHandlers>
|
||||
<CommandUIHandler Command="ExpiryIndicator.Classic.ExtendOneYear"
|
||||
CommandAction="javascript:ExpiryIndicatorClassic.extendSelected();"
|
||||
EnabledScript="javascript:ExpiryIndicatorClassic.canExtend();" />
|
||||
</CommandUIHandlers>
|
||||
</CommandUIExtension>
|
||||
"@
|
||||
|
||||
$ribbonAction = $list.UserCustomActions.Add()
|
||||
$ribbonAction.Name = 'ExpiryIndicator.Classic.Ribbon'
|
||||
$ribbonAction.Title = 'ExpiryIndicator Classic ribbon command'
|
||||
$ribbonAction.Location = 'CommandUI.Ribbon'
|
||||
$ribbonAction.CommandUIExtension = $ribbonXml
|
||||
$ribbonAction.Sequence = 651
|
||||
$ribbonAction.Update()
|
||||
|
||||
$context.ExecuteQuery()
|
||||
Write-Host 'Classic-Ansicht: CSR/JSLink und Ribbon-Befehl wurden registriert.'
|
||||
}
|
||||
|
||||
Write-Host "ExpiryIndicator wurde für '$($list.Title)' an '$($field.InternalName)' gebunden."
|
||||
}
|
||||
finally {
|
||||
|
||||
Reference in New Issue
Block a user