Skip to content

Commit

Permalink
Bugfix: Only overwrite localizations with exactly identical key and d…
Browse files Browse the repository at this point in the history
…omain after an update in the UI
  • Loading branch information
vigorouscoding committed Feb 8, 2024
1 parent 9c23c8b commit bc6ffe9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions structr-base/src/main/resources/structr/js/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,16 @@ let _Localization = {
let keyField = _Localization.uiElements.getLocalizationDetailKey();
keyField.value = key;
delete keyField.dataset['oldValue'];
if (key) keyField.dataset['oldValue'] = key;
if (key) {
keyField.dataset['oldValue'] = key;
}

let domainField = _Localization.uiElements.getLocalizationDetailDomain();
domainField.value = domain;
delete domainField.dataset['oldValue'];
if (domain) domainField.dataset['oldValue'] = domain;
if (domain) {
domainField.dataset['oldValue'] = domain;
}

_Localization.clearLocalizationDetailsList();

Expand Down Expand Up @@ -370,9 +374,9 @@ let _Localization = {
let keyField = _Localization.uiElements.getLocalizationDetailKey();
let domainField = _Localization.uiElements.getLocalizationDetailDomain();

let oldKey = keyField.dataset['oldValue'] || null;
let oldKey = keyField.dataset['oldValue'] ?? null;
let curKey = keyField.value.trim();
let oldDomain = domainField.dataset['oldValue'] || null;
let oldDomain = domainField.dataset['oldValue'] ?? null;
let curDomain = domainField.value.trim();
if (curDomain === '') {
curDomain = null;
Expand All @@ -397,7 +401,9 @@ let _Localization = {

for (let loc of result) {

patchData.push(Object.assign({ id: loc.id }, newData));
if (oldKey === loc.name && oldDomain === loc.domain) {
patchData.push(Object.assign({ id: loc.id }, newData));
}
}

let putResponse = await fetch(Structr.rootUrl + 'Localization/', {
Expand Down

0 comments on commit bc6ffe9

Please sign in to comment.