Skip to content

Commit

Permalink
#25896 include in 22.03.9
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Aug 29, 2023
1 parent c789f11 commit 15033f0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
3 changes: 2 additions & 1 deletion HOTFIX_TRACKING.md
Expand Up @@ -174,4 +174,5 @@ This maintenance release includes the following code fixes:
145. https://github.com/dotCMS/core/issues/24829 : NavTool method getNav must return only published links #24829
146. https://github.com/dotCMS/core/issues/25371 : PP: pushing new folder with limited user fails #25371
147. https://github.com/dotCMS/core/issues/25797 : When uploading multiple files, the files are always in English #25797
148. https://github.com/dotCMS/core/issues/25229 : PP - Integrity Checker, fixing conflicts is not populating the contentlet_as_json field #25229
148. https://github.com/dotCMS/core/issues/25229 : PP - Integrity Checker, fixing conflicts is not populating the contentlet_as_json field #25229
149. https://github.com/dotCMS/core/issues/25896 : Creating a contentlet in a 2nd language removes related content #25896
Expand Up @@ -402,23 +402,63 @@
dijit.byId("<%= relationJsName %>Dialog")._doSearchPage1();
}
function createNewList(listRelationships){
return newList;
}
function mapToCheckCurrentLangExists(listRelationships){
const idExists = new Map();
for (var indexK = 0; indexK < listRelationships.length; indexK++) {
for (var indexL = 0; indexL < listRelationships.length; indexL++) {
if(listRelationships[indexK]['identifier'] == listRelationships[indexL]['identifier'] &&
listRelationships[indexL]['langId'] == <%= contentlet.getLanguageId() %>) {
idExists.set(listRelationships[indexK]['identifier'], true);
break;
}
}
if(!idExists.has(listRelationships[indexK]['identifier'])) {
idExists.set(listRelationships[indexK]['identifier'], false);
}
}
return idExists;
}
//Invoked when a contentlet is selected to fill the contentlet data in the table
function <%= relationJsName %>_addRelationshipCallback(selectedData){
selectedData = selectedData.filter(sibling => sibling.langId == <%= contentlet.getLanguageId() %>);
//selectedData = selectedData.filter(sibling => sibling.langId == <%= contentlet.getLanguageId() %>);
console.log("selectedData");
console.log(selectedData);
const mapIdCurrentLangExist = mapToCheckCurrentLangExists(selectedData);
const newList = [];
for (var indexL = 0; indexL < selectedData.length; indexL++) {
var currentContent = selectedData[indexL];
var currentContentId = currentContent['identifier'];
var mapValue = mapIdCurrentLangExist.get(currentContentId);
if(mapValue && currentContent['langId'] == <%= contentlet.getLanguageId() %>){
newList.push(currentContent);
}
if(!mapValue){
newList.push(currentContent);
}
}
var data = new Array();
var dataToRelate = new Array();
var entries = numberOfRows<%= relationJsName%>();
// Eliminating existing relations
for (var indexJ = 0; indexJ < selectedData.length; indexJ++) {
for (var indexJ = 0; indexJ < newList.length; indexJ++) {
var relationExists = (<%=thereCanBeOnlyOne%> && (entries > 0 || dataToRelate.length>0)) ? true : false;
for (var indexI = 0; indexI < <%= relationJsName %>_Contents.length; indexI++) {
if(selectedData[indexJ]['id'] == <%= relationJsName %>_Contents[indexI]['id']){
if(newList[indexJ]['id'] == <%= relationJsName %>_Contents[indexI]['id']){
relationExists = true;
}
}
if(!relationExists){
dataToRelate[dataToRelate.length] = selectedData[indexJ];
dataToRelate[dataToRelate.length] = newList[indexJ];
}
}
Expand Down

0 comments on commit 15033f0

Please sign in to comment.