Skip to content

Commit

Permalink
#27297 include in 23.10.24 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Jul 30, 2024
1 parent da2c232 commit f18aa87
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1272,11 +1272,11 @@ describe('DotEditContentComponent', () => {
});

spyOn(dotContentletEditorService, 'getActionUrl').and.returnValue(
of('/url/')
of('/url/test?_content_lang=23&test=random')
);
spyOn(dotContentletEditorService, 'create').and.callFake((param) => {
expect(param.data).toEqual({
url: '/url/'
url: '/url/test?_content_lang=1&test=random'
});

const event: any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ browse from the page internal links
.getActionUrl($event.data.contentType.variable)
.pipe(take(1))
.subscribe((url) => {
url = this.setCurrentContentLang(url);
this.dotContentletEditorService.create({
data: { url },
events: {
Expand Down Expand Up @@ -675,4 +676,18 @@ browse from the page internal links
this.pageLanguageId = params['language_id'];
});
}

/**
* Sets the language parameter in the given URL and returns the concatenated pathname and search.
* the input URL doesn't include the host, origin is used as the base URL.
*
* @param {string} url - The input URL ( include pathname and search parameters).
* @returns {string} - The concatenated pathname and search parameters with the language parameter set.
*/
private setCurrentContentLang(url: string): string {
const newUrl = new URL(url, window.location.origin);
newUrl.searchParams.set('_content_lang', this.pageLanguageId);

return newUrl.pathname + newUrl.search;
}
}
3 changes: 2 additions & 1 deletion dotCMS/hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ This maintenance release includes the following code fixes:
125. https://github.com/dotCMS/core/issues/28509 : Remove three dots at the end of the Bundle ID #28509
126. https://github.com/dotCMS/core/issues/28201 : AI Content Block inserts rich content as a single paragraph #28201
127. https://github.com/dotCMS/core/issues/26987 : Set Response Headers Rule Action does not allow double quotes in the value #26987
128. https://github.com/dotCMS/core/issues/26477 : Search filter can't find/filter images #26477
128. https://github.com/dotCMS/core/issues/26477 : Search filter can't find/filter images #26477
129. https://github.com/dotCMS/core/issues/27297 : Edit Page: Edit Contentlet Dialog Language Support #27297
38 changes: 25 additions & 13 deletions dotCMS/src/main/webapp/html/js/dotcms/dijit/form/ContentSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,26 @@ dojo.declare(
if (dijit.byId('langcombo+' + this.dialogCounter)) {
dijit.byId('langcombo+' + this.dialogCounter).destroy();
}
let selectedLang = null;
let options = ''
this.availableLanguages = data;

for (var i = 0; i < data.length; i++) {
options += "<option value='" + data[i].id + "'";
if (this.contentletLanguageId == data[i].id || this.languageId == data[i].id ) {
options += " selected='true' ";
selectedLang = data[i];
}
options +=
'>' + this._getCountryLabel(data[i]) + '</option>';
}
this.search_languages_table.innerHTML = '';
var htmlstr = "<dl class='vertical'>";
htmlstr +=
"<dt><label for='langcombo+" +
this.dialogCounter +
"'>" +
data[0].title +
selectedLang ? selectedLang.title : data[0].title +
'</label></dt>';
htmlstr += '<dd>';
dojo.require('dijit.form.FilteringSelect');
Expand All @@ -278,23 +290,19 @@ dojo.declare(
this.dialogCounter +
"'>";

for (var i = 0; i < data.length; i++) {
htmlstr += "<option value='" + data[i].id + "'";
if (this.contentletLanguageId == data[i].id) {
htmlstr += " selected='true' ";
}
htmlstr +=
'>' +
data[i].language +
(data[i].country == '' ? '' : ' - ' + data[i].country) +
'</option>';
}

htmlstr += options;
htmlstr += '</select>';
htmlstr += '</dd>';
htmlstr += '</dl>';
dojo.place(htmlstr, this.search_languages_table);
dojo.parser.parse(this.search_languages_table);

let obj = dijit.byId('langcombo+' + this.dialogCounter);

// Set the displayed value
if (selectedLang) {
obj.set('displayedValue', this._getCountryLabel(selectedLang));
}
},

_getSiteFolderFieldDefaultHTML: function (){
Expand Down Expand Up @@ -1556,6 +1564,10 @@ dojo.declare(
return iconCode.substring(startIndex, endIndex);
},

_getCountryLabel: function (data) {
return data.language + (data.country === '' ? '' : ' - ' + data.country)
},

_replaceWithIcon: function (parentElement, iconName) {
parentElement.innerHTML =
'<span class="' +
Expand Down
2 changes: 2 additions & 0 deletions dotCMS/src/main/webapp/html/ng-contentlet-selector.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<%
String containerIdentifier = request.getParameter("container_id");
String language_id = request.getParameter("language_id");
User user = PortalUtil.getUser(request);
Container container = null;
if (FileAssetContainerUtil.getInstance().isFolderAssetContainerId(containerIdentifier)) {
Expand Down Expand Up @@ -227,6 +228,7 @@
<div jsId="contentSelector"
containerStructures='<%=containerStructures%>'
onContentSelected="contentSelected"
languageId="<%=language_id%>"
selectButtonLabel='<%= LanguageUtil.get(pageContext, "content.search.select") %>'
dojoType="dotcms.dijit.form.ContentSelector">

Expand Down

0 comments on commit f18aa87

Please sign in to comment.