Skip to content

Commit

Permalink
fix(edit-content): Navigation is broken for new Content in Content Se…
Browse files Browse the repository at this point in the history
…arch #26440

* fix (view contentlet jsp): enhance reference of current content type

* clean up
  • Loading branch information
zJaaal authored Nov 7, 2023
1 parent 56d7271 commit ba60e73
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
String structureSelected = null;
final String variableName = (String) request.getParameter("filter");
String velocityVarName = null;
if(UtilMethods.isSet(variableName)){
if (com.dotmarketing.beans.Host.HOST_VELOCITY_VAR_NAME.equals(variableName)){
Expand All @@ -68,7 +67,7 @@
try {
ContentType filterContentType = APILocator.getContentTypeAPI(user).find(variableName);
structureSelected = filterContentType != null ? filterContentType.id() : null;
velocityVarName = filterContentType.variable();
} catch (NotFoundInDbException e) {
structureSelected = null;
}
Expand All @@ -79,7 +78,6 @@
try {
ContentType contentType = APILocator.getContentTypeAPI(user).find(structureSelected);
velocityVarName = contentType.variable();
if (contentType != null && com.dotmarketing.beans.Host.HOST_VELOCITY_VAR_NAME.equals(contentType.variable()) ){
structureSelected = null;
Expand Down Expand Up @@ -572,7 +570,7 @@
label: "<%= UtilMethods.escapeSingleQuotes(LanguageUtil.get(pageContext, "Add-New-Content" )) %>",
iconClass: "plusIcon",
onClick: function() {
addNewContentlet(null, "<%= velocityVarName %>");
addNewContentlet(null);
}
});
menu.addChild(menuItem1);
Expand Down Expand Up @@ -781,7 +779,7 @@
}
</script>
<ul data-dojo-type="dijit/Menu" id="actionPrimaryMenu" style="display: none;">
<li data-dojo-type="dijit/MenuItem" data-dojo-props="onClick:function() {addNewContentlet('', '<%= velocityVarName %>')}"><%= UtilMethods.escapeSingleQuotes(LanguageUtil.get(pageContext, "Add-New-Content" )) %></li>
<li data-dojo-type="dijit/MenuItem" data-dojo-props="onClick:function() {addNewContentlet('')}"><%= UtilMethods.escapeSingleQuotes(LanguageUtil.get(pageContext, "Add-New-Content" )) %></li>
<li data-dojo-type="dijit/MenuItem" data-dojo-props="onClick:importContent">
<%= UtilMethods.escapeSingleQuotes(LanguageUtil.get(pageContext, "Import-Content" )) %>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,13 @@ final String calendarEventInode = null!=calendarEventSt ? calendarEventSt.inode(
function updateSelectedStructAux(){
structureInode = dijit.byId('selectedStructAux').value;
addNewContentlet(structureInode);
}
function dispatchCreateContentletEvent(url, contentType) {
var customEvent = document.createEvent("CustomEvent");
customEvent.initCustomEvent("ng-event", false, false, {
name: "create-contentlet",
data: {
Expand All @@ -849,12 +852,30 @@ final String calendarEventInode = null!=calendarEventSt ? calendarEventSt.inode(
function addNewContentlet(structureInode, contentType){
if(structureInode == undefined || structureInode==""){
// This gets the catchall and opens the dialog to select a contentType, and also retrieves the content type when is a custom portlet
if(!contentType){
// This is the same way they get the current var name on downloadToExcel method
let structureVelraw = dojo.byId("structureVelocityVarNames").value;
let structInoderaw = dojo.byId("structureInodesList").value;
let structureVelArray = structureVelraw.split(";");
let structureInodeArray = structInoderaw.split(";");
let contentTypeInode = dijit.byId('structure_inode').value;
contentType = structureVelArray.find((varName, i) => structureInodeArray[i] === contentTypeInode)
}
if(structureInode == undefined || structureInode==""){
// This gets the catchall and opens the dialog to select a contentType, and also retrieves the content type when is a custom portlet
structureInode = dijit.byId('structure_inode').value;
}
if(structureInode == undefined || structureInode=="" || structureInode == "catchall"){
dijit.byId("selectStructureDiv").show();
dijit.byId("selectStructureDiv").show();
return;
}
else if(structureInode == '<%=calendarEventInode %>'){
Expand Down

0 comments on commit ba60e73

Please sign in to comment.