From 11229d87eb8a5a329139529e7eefa3d9d26cf8a2 Mon Sep 17 00:00:00 2001 From: Torsten Brendgen Date: Fri, 17 Jul 2026 20:57:28 +0200 Subject: [PATCH] Aktualisiere Versionsnummern auf 1.0.5 in package.json, package-solution.json, ExpiryIndicatorFieldCustomizer.manifest.json und ExpiryIndicatorCommandSet.manifest.json; verbessere die Darstellung der Ablaufdatumsspalte in ExpiryIndicatorFieldCustomizer.ts und aktualisiere die README.md mit neuen Informationen zu Farbregeln. --- README.md | 3 + ToDo.md | 2 +- config/package-solution.json | 4 +- package.json | 2 +- ...piryIndicatorFieldCustomizer.manifest.json | 2 +- .../ExpiryIndicatorFieldCustomizer.ts | 69 ++++++++++++++----- .../ExpiryIndicatorCommandSet.manifest.json | 2 +- 7 files changed, 61 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index fdf1ce3..1ba6d41 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,9 @@ In **Standard-Farbregeln** wird nur das JSON-Array für `default.columnRule` ein Die Farbregeln werden von oben nach unten ausgewertet; die erste passende Regel gewinnt. Deshalb muss `<= 0` vor `<= 30` und `<= 90` stehen. Ohne passende Farbregel wird das Datum ohne besondere Farbe angezeigt. +Eine passende Regel färbt die komplette SharePoint-Zelle mit `backgroundColor` und passt ausschließlich die +Schriftfarbe über `textColor` an. `label` bleibt aus Kompatibilitätsgründen konfigurierbar, wird in der Liste +aber nicht zusätzlich neben dem Datum dargestellt. Unterstützte Operatoren: diff --git a/ToDo.md b/ToDo.md index ba750b1..35437ea 100644 --- a/ToDo.md +++ b/ToDo.md @@ -27,7 +27,7 @@ Berechnung des effektiven Ablaufdatums: 3. Vor jeder Wertprüfung wird geprüft, ob `columnName` in der aktuellen Liste/Bibliothek existiert. Ein fehlendes Feld kann die Regel nicht erfüllen. 4. Existiert das Feld und entspricht sein Wert `columnValue`, werden `lifeTime` und `columnRule` dieser Regel verwendet. 5. Passt keine Regel oder existiert keines der Regelfelder, werden `default.lifeTime` und `default.columnRule` verwendet. -6. Die erste passende `columnRule` bestimmt Hintergrundfarbe, Textfarbe und optionale Beschriftung. +6. Die erste passende `columnRule` bestimmt die Hintergrundfarbe der kompletten Zelle und deren Textfarbe. Die Berechnung arbeitet mit Kalenderjahren/-monaten/-tagen, nicht mit pauschalen 365-Tage-Jahren. diff --git a/config/package-solution.json b/config/package-solution.json index 77a63da..70bbbf5 100644 --- a/config/package-solution.json +++ b/config/package-solution.json @@ -3,7 +3,7 @@ "solution": { "name": "expiry-indicator-client-side-solution", "id": "68bb6d2d-9895-45b4-88e8-b98835faa981", - "version": "1.0.4.0", + "version": "1.0.5.0", "includeClientSideAssets": true, "skipFeatureDeployment": false, "features": [ @@ -11,7 +11,7 @@ "title": "ExpiryIndicator command set registration", "description": "Registers ExpiryIndicator commands for modern lists and document libraries. Does not provision ExpiryDate.", "id": "913402af-ab9a-4974-9f86-5c2159ae41db", - "version": "1.0.4.0", + "version": "1.0.5.0", "assets": { "elementManifests": [ "elements.xml" diff --git a/package.json b/package.json index f6940ef..fc87202 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "expiry-indicator", - "version": "1.0.4", + "version": "1.0.5", "private": true, "engines": { "node": ">=6.9.0 <9.0.0" diff --git a/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.manifest.json b/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.manifest.json index 4a05954..588f21b 100644 --- a/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.manifest.json +++ b/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.manifest.json @@ -4,7 +4,7 @@ "alias": "ExpiryIndicatorFieldCustomizer", "componentType": "Extension", "extensionType": "FieldCustomizer", - "version": "1.0.4", + "version": "1.0.5", "manifestVersion": 2, "requiresCustomScript": false } diff --git a/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.ts b/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.ts index 0fe40c9..7d9941f 100644 --- a/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.ts +++ b/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.ts @@ -13,7 +13,6 @@ import { IItemDateValues, resolveBehavior } from '../../common/ExpiryModels'; -import styles from './ExpiryIndicatorFieldCustomizer.module.scss'; import * as strings from 'ExpiryIndicatorStrings'; export interface IExpiryIndicatorFieldCustomizerProperties { @@ -97,27 +96,18 @@ export default class ExpiryIndicatorFieldCustomizer private _renderEvaluation(container: HTMLElement, evaluation: IExpiryEvaluation): void { const wrapper: HTMLSpanElement = document.createElement('span'); - wrapper.className = styles.cell + (evaluation.wasCalculated ? ' ' + styles.calculated : ''); + const cell: HTMLElement = this._findCellElement(container); + this._rememberCellStyle(cell); if (evaluation.matchedRule) { - wrapper.style.backgroundColor = evaluation.matchedRule.backgroundColor; - wrapper.style.color = evaluation.matchedRule.textColor; + cell.style.backgroundColor = evaluation.matchedRule.backgroundColor; + cell.style.color = evaluation.matchedRule.textColor; } - const date: HTMLSpanElement = document.createElement('span'); - date.className = styles.date; - date.textContent = formatDate(evaluation.effectiveExpiryDate); - wrapper.appendChild(date); - - if (evaluation.matchedRule && evaluation.matchedRule.label) { - const label: HTMLSpanElement = document.createElement('span'); - label.className = styles.label; - label.textContent = evaluation.matchedRule.label; - wrapper.appendChild(label); - } + wrapper.textContent = formatDate(evaluation.effectiveExpiryDate); const calculationHint: string = evaluation.wasCalculated ? ' – ' + strings.CalculatedHint : ''; - wrapper.title = strings.DaysUntilExpiry.replace('{0}', String(evaluation.daysUntilExpiry)) + calculationHint; + cell.title = strings.DaysUntilExpiry.replace('{0}', String(evaluation.daysUntilExpiry)) + calculationHint; container.appendChild(wrapper); } @@ -144,14 +134,59 @@ export default class ExpiryIndicatorFieldCustomizer private _renderNeutral(container: HTMLElement, text: string): void { const wrapper: HTMLSpanElement = document.createElement('span'); - wrapper.className = styles.cell + ' ' + styles.neutral; wrapper.textContent = text; container.appendChild(wrapper); } private _clear(container: HTMLElement): void { + this._restoreCellStyle(this._findCellElement(container)); while (container.firstChild) { container.removeChild(container.firstChild); } } + + private _findCellElement(container: HTMLElement): HTMLElement { + let current: HTMLElement | null = container; + let level: number = 0; + while (current && level < 8) { + const className: string = typeof current.className === 'string' ? current.className : ''; + if (current.getAttribute('role') === 'gridcell' || className.indexOf('ms-DetailsRow-cell') >= 0) { + return current; + } + current = current.parentElement; + level++; + } + return container; + } + + private _rememberCellStyle(cell: HTMLElement): void { + if (cell.getAttribute('data-expiry-indicator-styled') === 'true') { + return; + } + cell.setAttribute('data-expiry-indicator-styled', 'true'); + cell.setAttribute('data-expiry-original-background', cell.style.backgroundColor || ''); + cell.setAttribute('data-expiry-original-color', cell.style.color || ''); + cell.setAttribute('data-expiry-original-had-title', cell.hasAttribute('title') ? 'true' : 'false'); + cell.setAttribute('data-expiry-original-title', cell.getAttribute('title') || ''); + } + + private _restoreCellStyle(cell: HTMLElement): void { + if (cell.getAttribute('data-expiry-indicator-styled') !== 'true') { + return; + } + + cell.style.backgroundColor = cell.getAttribute('data-expiry-original-background') || ''; + cell.style.color = cell.getAttribute('data-expiry-original-color') || ''; + if (cell.getAttribute('data-expiry-original-had-title') === 'true') { + cell.setAttribute('title', cell.getAttribute('data-expiry-original-title') || ''); + } else { + cell.removeAttribute('title'); + } + + cell.removeAttribute('data-expiry-indicator-styled'); + cell.removeAttribute('data-expiry-original-background'); + cell.removeAttribute('data-expiry-original-color'); + cell.removeAttribute('data-expiry-original-had-title'); + cell.removeAttribute('data-expiry-original-title'); + } } diff --git a/src/extensions/expiryIndicatorCommandSet/ExpiryIndicatorCommandSet.manifest.json b/src/extensions/expiryIndicatorCommandSet/ExpiryIndicatorCommandSet.manifest.json index 0cef668..6b22c4d 100644 --- a/src/extensions/expiryIndicatorCommandSet/ExpiryIndicatorCommandSet.manifest.json +++ b/src/extensions/expiryIndicatorCommandSet/ExpiryIndicatorCommandSet.manifest.json @@ -4,7 +4,7 @@ "alias": "ExpiryIndicatorCommandSet", "componentType": "Extension", "extensionType": "ListViewCommandSet", - "version": "1.0.4", + "version": "1.0.5", "manifestVersion": 2, "requiresCustomScript": false, "items": {