Update MegaMenu Application Customizer: Version bump to 1.1.0, localization support added, and unnecessary files removed

- Deleted obsolete localization file for English (en-us).
- Updated version number from 1.0.4 to 1.1.0 in manifests.js and manifests.json.
- Added localization support for German (de-de) in a new localization file.
- Removed unnecessary dependencies from manifests.
- Added .gitignore to exclude build artifacts and temporary files.
This commit is contained in:
Torsten Brendgen
2026-07-16 22:43:31 +02:00
parent a2b8165262
commit 97d2b6b5d2
53 changed files with 1071 additions and 1065 deletions

View File

@@ -39,7 +39,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
};
import { SPHttpClient } from '@microsoft/sp-http';
import { findIndex } from '@microsoft/sp-lodash-subset';
import { debugError } from './MegaMenuDebug';
var EmptyGuid = '00000000-0000-0000-0000-000000000000';
var TermCachePrefix = 'MegaMenu:TermSet:';
var PickerCachePrefix = 'MegaMenu:PickerTerms:';
/**
* Service implementation to manage term stores in SharePoint
*/
@@ -47,9 +50,11 @@ var SPTermStorePickerService = (function () {
/**
* Service constructor
*/
function SPTermStorePickerService(props, context) {
function SPTermStorePickerService(props, context, debug) {
if (debug === void 0) { debug = false; }
this.props = props;
this.context = context;
this.debug = debug;
this.clientServiceUrl = this.context.pageContext.web.absoluteUrl + '/_vti_bin/client.svc/ProcessQuery';
this.suggestionServiceUrl = this.context.pageContext.web.absoluteUrl + '/_vti_bin/TaxonomyInternalService.json/GetSuggestions';
}
@@ -63,7 +68,7 @@ var SPTermStorePickerService = (function () {
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
data = "<Request AddExpandoFieldTypeSuffix=\"true\" SchemaVersion=\"15.0.0.0\" LibraryVersion=\"16.0.0.0\" ApplicationName=\".NET Library\" xmlns=\"http://schemas.microsoft.com/sharepoint/clientquery/2009\"><Actions><ObjectPath Id=\"8\" ObjectPathId=\"7\" /><ObjectIdentityQuery Id=\"9\" ObjectPathId=\"7\" /><ObjectPath Id=\"11\" ObjectPathId=\"10\" /><ObjectIdentityQuery Id=\"12\" ObjectPathId=\"10\" /><ObjectPath Id=\"14\" ObjectPathId=\"13\" /><ObjectIdentityQuery Id=\"15\" ObjectPathId=\"13\" /><Query Id=\"16\" ObjectPathId=\"13\"><Query SelectAllProperties=\"false\"><Properties><Property Name=\"Labels\" SelectAll=\"true\"><Query SelectAllProperties=\"false\"><Properties /></Query></Property></Properties></Query></Query></Actions><ObjectPaths><StaticMethod Id=\"7\" Name=\"GetTaxonomySession\" TypeId=\"{981cbc68-9edc-4f8d-872f-71146fcbb84f}\" /><Method Id=\"10\" ParentId=\"7\" Name=\"GetDefaultKeywordsTermStore\" /><Method Id=\"13\" ParentId=\"10\" Name=\"GetTerm\"><Parameters><Parameter Type=\"Guid\">" + termId + "</Parameter></Parameters></Method></ObjectPaths></Request>";
data = "<Request AddExpandoFieldTypeSuffix=\"true\" SchemaVersion=\"15.0.0.0\" LibraryVersion=\"16.0.0.0\" ApplicationName=\".NET Library\" xmlns=\"http://schemas.microsoft.com/sharepoint/clientquery/2009\"><Actions><ObjectPath Id=\"8\" ObjectPathId=\"7\" /><ObjectIdentityQuery Id=\"9\" ObjectPathId=\"7\" /><ObjectPath Id=\"11\" ObjectPathId=\"10\" /><ObjectIdentityQuery Id=\"12\" ObjectPathId=\"10\" /><ObjectPath Id=\"14\" ObjectPathId=\"13\" /><ObjectIdentityQuery Id=\"15\" ObjectPathId=\"13\" /><Query Id=\"16\" ObjectPathId=\"13\"><Query SelectAllProperties=\"false\"><Properties><Property Name=\"Labels\" SelectAll=\"true\"><Query SelectAllProperties=\"false\"><Properties /></Query></Property></Properties></Query></Query></Actions><ObjectPaths><StaticMethod Id=\"7\" Name=\"GetTaxonomySession\" TypeId=\"{981cbc68-9edc-4f8d-872f-71146fcbb84f}\" /><Method Id=\"10\" ParentId=\"7\" Name=\"GetDefaultSiteCollectionTermStore\" /><Method Id=\"13\" ParentId=\"10\" Name=\"GetTerm\"><Parameters><Parameter Type=\"Guid\">" + termId + "</Parameter></Parameters></Method></ObjectPaths></Request>";
reqHeaders = new Headers();
reqHeaders.append('accept', 'application/json');
reqHeaders.append('content-type', 'application/xml');
@@ -74,6 +79,7 @@ var SPTermStorePickerService = (function () {
return [4 /*yield*/, this.context.spHttpClient.post(this.clientServiceUrl, SPHttpClient.configurations.v1, httpPostOptions)];
case 2:
callResult = _a.sent();
this.ensureSuccessfulResponse(callResult, 'Term labels');
return [4 /*yield*/, callResult.json()];
case 3:
jsonResult = _a.sent();
@@ -85,7 +91,7 @@ var SPTermStorePickerService = (function () {
case 4:
error_1 = _a.sent();
result = null;
console.log(error_1.message);
debugError(this.debug, 'SPTermStorePickerService', 'Error reading term labels.', error_1);
return [3 /*break*/, 5];
case 5: return [2 /*return*/, result];
}
@@ -107,6 +113,7 @@ var SPTermStorePickerService = (function () {
body: data
};
return this.context.spHttpClient.post(this.clientServiceUrl, SPHttpClient.configurations.v1, httpPostOptions).then(function (serviceResponse) {
_this.ensureSuccessfulResponse(serviceResponse, 'Term stores');
return serviceResponse.json().then(function (serviceJSONResponse) {
// Construct results
var termStoreResult = serviceJSONResponse.filter(function (r) { return r['_ObjectType_'] === 'SP.Taxonomy.TermStore'; });
@@ -160,8 +167,9 @@ var SPTermStorePickerService = (function () {
* Retrieve all terms for the given term set
* @param termset
*/
SPTermStorePickerService.prototype.getAllTerms = function (termset, hideDeprecatedTags, hideTagsNotAvailableForTagging, useSessionStorage) {
SPTermStorePickerService.prototype.getAllTerms = function (termset, hideDeprecatedTags, hideTagsNotAvailableForTagging, useSessionStorage, cacheMinutes) {
if (useSessionStorage === void 0) { useSessionStorage = true; }
if (cacheMinutes === void 0) { cacheMinutes = 15; }
return __awaiter(this, void 0, void 0, function () {
var _this = this;
var termsetId, termStore, crntTermSet, childTerms, data, reqHeaders, httpPostOptions;
@@ -182,11 +190,11 @@ var SPTermStorePickerService = (function () {
}
_a.label = 2;
case 2:
childTerms = this.getTermsById(termsetId, useSessionStorage);
childTerms = this.getCachedTermSet(termsetId, useSessionStorage);
if (childTerms) {
return [2 /*return*/, childTerms];
}
data = "<Request xmlns=\"http://schemas.microsoft.com/sharepoint/clientquery/2009\" SchemaVersion=\"15.0.0.0\" LibraryVersion=\"16.0.0.0\" ApplicationName=\"Javascript Library\"><Actions><ObjectPath Id=\"1\" ObjectPathId=\"0\" /><ObjectIdentityQuery Id=\"2\" ObjectPathId=\"0\" /><ObjectPath Id=\"4\" ObjectPathId=\"3\" /><ObjectIdentityQuery Id=\"5\" ObjectPathId=\"3\" /><ObjectPath Id=\"7\" ObjectPathId=\"6\" /><ObjectIdentityQuery Id=\"8\" ObjectPathId=\"6\" /><ObjectPath Id=\"10\" ObjectPathId=\"9\" /><Query Id=\"11\" ObjectPathId=\"6\"><Query SelectAllProperties=\"true\"><Properties /></Query></Query><Query Id=\"12\" ObjectPathId=\"9\"><Query SelectAllProperties=\"false\"><Properties /></Query><ChildItemQuery SelectAllProperties=\"false\"><Properties><Property Name=\"IsRoot\" SelectAll=\"true\" /><Property Name=\"Labels\" SelectAll=\"true\" /><Property Name=\"TermsCount\" SelectAll=\"true\" /><Property Name=\"CustomSortOrder\" SelectAll=\"true\" /><Property Name=\"Id\" SelectAll=\"true\" /><Property Name=\"Name\" SelectAll=\"true\" /><Property Name=\"PathOfTerm\" SelectAll=\"true\" /><Property Name=\"Parent\" SelectAll=\"true\" /><Property Name=\"LocalCustomProperties\" SelectAll=\"true\" /><Property Name=\"IsDeprecated\" ScalarProperty=\"true\" /><Property Name=\"IsAvailableForTagging\" ScalarProperty=\"true\" /></Properties></ChildItemQuery></Query></Actions><ObjectPaths><StaticMethod Id=\"0\" Name=\"GetTaxonomySession\" TypeId=\"{981cbc68-9edc-4f8d-872f-71146fcbb84f}\" /><Method Id=\"3\" ParentId=\"0\" Name=\"GetDefaultKeywordsTermStore\" /><Method Id=\"6\" ParentId=\"3\" Name=\"GetTermSet\"><Parameters><Parameter Type=\"Guid\">" + termsetId + "</Parameter></Parameters></Method><Method Id=\"9\" ParentId=\"6\" Name=\"GetAllTerms\" /></ObjectPaths></Request>";
data = "<Request xmlns=\"http://schemas.microsoft.com/sharepoint/clientquery/2009\" SchemaVersion=\"15.0.0.0\" LibraryVersion=\"16.0.0.0\" ApplicationName=\"Javascript Library\"><Actions><ObjectPath Id=\"1\" ObjectPathId=\"0\" /><ObjectIdentityQuery Id=\"2\" ObjectPathId=\"0\" /><ObjectPath Id=\"4\" ObjectPathId=\"3\" /><ObjectIdentityQuery Id=\"5\" ObjectPathId=\"3\" /><ObjectPath Id=\"7\" ObjectPathId=\"6\" /><ObjectIdentityQuery Id=\"8\" ObjectPathId=\"6\" /><ObjectPath Id=\"10\" ObjectPathId=\"9\" /><Query Id=\"11\" ObjectPathId=\"6\"><Query SelectAllProperties=\"true\"><Properties /></Query></Query><Query Id=\"12\" ObjectPathId=\"9\"><Query SelectAllProperties=\"false\"><Properties /></Query><ChildItemQuery SelectAllProperties=\"false\"><Properties><Property Name=\"IsRoot\" SelectAll=\"true\" /><Property Name=\"Labels\" SelectAll=\"true\" /><Property Name=\"TermsCount\" SelectAll=\"true\" /><Property Name=\"CustomSortOrder\" SelectAll=\"true\" /><Property Name=\"Id\" SelectAll=\"true\" /><Property Name=\"Name\" SelectAll=\"true\" /><Property Name=\"PathOfTerm\" SelectAll=\"true\" /><Property Name=\"Parent\" SelectAll=\"true\" /><Property Name=\"LocalCustomProperties\" SelectAll=\"true\" /><Property Name=\"IsDeprecated\" ScalarProperty=\"true\" /><Property Name=\"IsAvailableForTagging\" ScalarProperty=\"true\" /></Properties></ChildItemQuery></Query></Actions><ObjectPaths><StaticMethod Id=\"0\" Name=\"GetTaxonomySession\" TypeId=\"{981cbc68-9edc-4f8d-872f-71146fcbb84f}\" /><Method Id=\"3\" ParentId=\"0\" Name=\"GetDefaultSiteCollectionTermStore\" /><Method Id=\"6\" ParentId=\"3\" Name=\"GetTermSet\"><Parameters><Parameter Type=\"Guid\">" + termsetId + "</Parameter></Parameters></Method><Method Id=\"9\" ParentId=\"6\" Name=\"GetAllTerms\" /></ObjectPaths></Request>";
reqHeaders = new Headers();
reqHeaders.append('accept', 'application/json');
reqHeaders.append('content-type', 'application/xml');
@@ -195,7 +203,11 @@ var SPTermStorePickerService = (function () {
body: data
};
return [2 /*return*/, this.context.spHttpClient.post(this.clientServiceUrl, SPHttpClient.configurations.v1, httpPostOptions).then(function (serviceResponse) {
_this.ensureSuccessfulResponse(serviceResponse, 'Terms');
return serviceResponse.json().then(function (serviceJSONResponse) {
if (!Array.isArray(serviceJSONResponse)) {
throw new Error('The taxonomy service returned an unexpected response.');
}
var termStoreResultTermSets = serviceJSONResponse.filter(function (r) { return r['_ObjectType_'] === 'SP.Taxonomy.TermSet'; });
if (termStoreResultTermSets.length > 0) {
var termStoreResultTermSet_1 = termStoreResultTermSets[0];
@@ -236,7 +248,12 @@ var SPTermStorePickerService = (function () {
}
try {
if (useSessionStorage && window.sessionStorage) {
window.sessionStorage.setItem(termsetId, JSON.stringify(termStoreResultTermSet_1));
var ttlMinutes = _this.normalizeCacheMinutes(cacheMinutes);
var cacheEntry = {
expiresAt: Date.now() + ttlMinutes * 60 * 1000,
value: termStoreResultTermSet_1
};
window.sessionStorage.setItem(TermCachePrefix + termsetId, JSON.stringify(cacheEntry));
}
}
catch (error) {
@@ -265,7 +282,7 @@ var SPTermStorePickerService = (function () {
switch (_b.label) {
case 0:
useSessionStorage = this.props.useSessionStorage;
childTerms = this.getTermsById(termId, useSessionStorage);
childTerms = this.getCachedPickerTerms(termId, useSessionStorage);
if (!childTerms) return [3 /*break*/, 1];
return [2 /*return*/, this.searchTermsBySearchText(childTerms, searchText)];
case 1:
@@ -289,16 +306,16 @@ var SPTermStorePickerService = (function () {
if (useSessionStorage === void 0) { useSessionStorage = true; }
return __awaiter(this, void 0, void 0, function () {
var _this = this;
var returnTerms, childTerms, termSet, terms, anchorTerm_1, anchorTermPath_1, anchorTerms;
var returnTerms, childTerms, termSet, terms, anchorTerm_1, anchorTermPath_1, anchorTerms, cacheEntry;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
returnTerms = [];
childTerms = this.getTermsById(anchorId, useSessionStorage);
childTerms = this.getCachedPickerTerms(anchorId, useSessionStorage);
if (childTerms) {
return [2 /*return*/, childTerms];
}
return [4 /*yield*/, this.getAllTerms(termsetNameOrID, hideDeprecatedTags, hideTagsNotAvailableForTagging)];
return [4 /*yield*/, this.getAllTerms(termsetNameOrID, hideDeprecatedTags, hideTagsNotAvailableForTagging, useSessionStorage, this.props.cacheMinutes)];
case 1:
termSet = _a.sent();
terms = termSet.Terms;
@@ -312,7 +329,11 @@ var SPTermStorePickerService = (function () {
});
try {
if (useSessionStorage && window.sessionStorage) {
window.sessionStorage.setItem(anchorId, JSON.stringify(returnTerms));
cacheEntry = {
expiresAt: Date.now() + this.normalizeCacheMinutes(this.props.cacheMinutes) * 60 * 1000,
value: returnTerms
};
window.sessionStorage.setItem(PickerCachePrefix + anchorId, JSON.stringify(cacheEntry));
}
}
catch (error) {
@@ -370,17 +391,21 @@ var SPTermStorePickerService = (function () {
}
return null;
};
SPTermStorePickerService.prototype.getTermsById = function (termId, useSessionStorage) {
SPTermStorePickerService.prototype.getCachedTermSet = function (termId, useSessionStorage) {
if (useSessionStorage === void 0) { useSessionStorage = true; }
try {
if (useSessionStorage && window.sessionStorage) {
var terms = window.sessionStorage.getItem(termId);
if (terms) {
return JSON.parse(terms);
}
else {
var key = TermCachePrefix + termId;
var terms = window.sessionStorage.getItem(key);
if (!terms) {
return null;
}
var cacheEntry = JSON.parse(terms);
if (!cacheEntry || !cacheEntry.value || !cacheEntry.expiresAt || cacheEntry.expiresAt <= Date.now()) {
window.sessionStorage.removeItem(key);
return null;
}
return cacheEntry.value;
}
else {
return null;
@@ -390,6 +415,39 @@ var SPTermStorePickerService = (function () {
return null;
}
};
SPTermStorePickerService.prototype.getCachedPickerTerms = function (termId, useSessionStorage) {
if (useSessionStorage === void 0) { useSessionStorage = true; }
try {
if (!useSessionStorage || !window.sessionStorage) {
return null;
}
var key = PickerCachePrefix + termId;
var serialized = window.sessionStorage.getItem(key);
if (!serialized) {
return null;
}
var cacheEntry = JSON.parse(serialized);
if (!cacheEntry || !cacheEntry.value || !cacheEntry.expiresAt || cacheEntry.expiresAt <= Date.now()) {
window.sessionStorage.removeItem(key);
return null;
}
return cacheEntry.value;
}
catch (error) {
return null;
}
};
SPTermStorePickerService.prototype.normalizeCacheMinutes = function (value) {
if (typeof value !== 'number' || !isFinite(value)) {
return 15;
}
return Math.min(Math.max(Math.floor(value), 1), 1440);
};
SPTermStorePickerService.prototype.ensureSuccessfulResponse = function (response, operation) {
if (!response.ok) {
throw new Error(operation + ' request failed (' + response.status + ' ' + response.statusText + ').');
}
};
SPTermStorePickerService.prototype.searchTermsBySearchText = function (terms, searchText) {
if (terms) {
return terms.filter(function (t) { return t.name.toLowerCase().indexOf(searchText.toLowerCase()) > -1; });