feat: update version to 2.1.2 and enhance ExpiryIndicator functionality with new binding handling

This commit is contained in:
Torsten Brendgen
2026-07-18 23:48:40 +02:00
parent 69a96b90c5
commit d97dbf45aa
10 changed files with 71 additions and 18 deletions

View File

@@ -4,7 +4,7 @@
var FIELD_CUSTOMIZER_ID = 'a555f4fc-d6a6-4421-8189-457449d9bbde';
var SITE_DEFAULTS_PROPERTY = 'PortalSettings.ExpiryIndicator.Defaults';
var WEB_OVERRIDE_PROPERTY = 'PortalSettings.ExpiryIndicator.Override';
var state = { context: null, field: null, config: null, loading: null };
var state = { context: null, field: null, config: null, loading: null, itemEntityType: null };
function configuredExpiryField() {
var scripts = document.getElementsByTagName('script');
@@ -421,16 +421,33 @@
} catch (ignore) { return []; }
}
function getItemEntityType() {
if (state.itemEntityType) { return Promise.resolve(state.itemEntityType); }
return request('GET', listUrl(state.context) + '?$select=ListItemEntityTypeFullName')
.then(function (data) {
var list = data.d || data;
if (!list.ListItemEntityTypeFullName) {
throw new Error('Der REST-Entitätstyp der Liste konnte nicht ermittelt werden.');
}
state.itemEntityType = list.ListItemEntityTypeFullName;
return state.itemEntityType;
});
}
function extendOne(id, config) {
var fields = [config.baseField, config.expiryField].concat(ruleFields(config));
return request('GET', listUrl(state.context) + '/items(' + id + ')?$select=Id,' + fields.join(','))
.then(function (data) {
return Promise.all([
request('GET', listUrl(state.context) + '/items(' + id + ')?$select=Id,' + fields.join(',')),
getItemEntityType()
]).then(function (results) {
var data = results[0];
var entityType = results[1];
var item = data.d || data;
var created = parseDate(item[config.baseField]);
var expiry = parseDate(item[config.expiryField]);
var base = expiry || addDuration(created, behavior(config, item).lifeTime);
var updated = addDuration(base, { value: 1, unit: 'years' });
var body = { '__metadata': { 'type': item.__metadata.type } };
var body = { '__metadata': { 'type': item.__metadata && item.__metadata.type || entityType } };
body[config.expiryField] = updated.toISOString();
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();