Skip to content

Commit

Permalink
fix: ⚡ fix menu designer "new content" menu preview due to multi-site…
Browse files Browse the repository at this point in the history
… bugs
  • Loading branch information
lmajano committed Oct 18, 2023
1 parent 44f00e3 commit d7ba02a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 73 deletions.
1 change: 1 addition & 0 deletions box.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"dbseed:postgres":"task run contentbox/modules/seeders/SeedPostgreSQL.cfc",
"format":"cfformat run config/**/*.cfc,modules_app/**/*.cfc,modules/contentbox/**/*.cfc,tests/**/*.cfc,Application.cfc --overwrite",
"format:watch":"cfformat watch config/**/*.cfc,modules_app/**/*.cfc,modules/contentbox/**/*.cfc,tests/**/*.cfc,Application.cfc ./.cfformat.json",
"format:watch:core":"cfformat watch config/**/*.cfc,modules/contentbox/models/**/*.cfc,tests/**/*.cfc,Application.cfc ./.cfformat.json",
"format:check":"cfformat check config/**/*.cfc,modules_app/**/*.cfc,modules/contentbox/**/*.cfc,tests/**/*.cfc,Application.cfc",
"start:lucee":"server start serverConfigFile='[email protected]' --force",
"start:2018":"server start serverConfigFile='[email protected]' --force",
Expand Down
49 changes: 25 additions & 24 deletions modules/contentbox/models/menu/providers/ContentProvider.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,22 @@ component
setType( "Content" );
setIconClass( "fa fa-archive" );
setEntityName( "cbContentMenuItem" );
setDescription( "A menu item based on existing pages or blog entries" );
setDescription( "A menu item based on existing content items" );
return this;
}

/**
* Retrieves template for use in admin screens for this type of menu item provider
*
* @menuItem.hint The menu item object
* @options.hint Additional arguments to be used in the method
* @menuItem The menu item object
* @options Additional arguments to be used in the method
*/
public string function getAdminTemplate( required any menuItem, required struct options = {} ){
var prc = requestService.getContext().getCollection( private = true );
string function getAdminTemplate( required any menuItem, required struct options = {} ){
var prc = requestService.getContext().getPrivateCollection();
var title = "";
var slug = "";

prc.xehRelatedContentSelector = "#prc.cbAdminEntryPoint#.content.relatedContentSelector";
var title = "";
var slug = "";
if ( !isNull( arguments.menuItem.getContentSlug() ) ) {
var content = contentService.findBySlug(
slug = arguments.menuItem.getContentSlug(),
Expand All @@ -56,39 +57,39 @@ component
slug = arguments.menuItem.getContentSlug();
}
}
var viewArgs = {
menuItem : arguments.menuItem,
xehContentSelector : "#prc.cbAdminEntryPoint#.content.showRelatedContentSelector",
title : title,
slug : slug
};

return variables.renderer.view(
view = "menus/providers/content/admin",
module = "contentbox-admin",
args = viewArgs
args = {
menuItem : arguments.menuItem,
xehContentSelector : "#prc.cbAdminEntryPoint#.content.showRelatedContentSelector",
title : title,
slug : slug
}
);
}

/**
* Retrieves template for use in rendering menu item on the site
*
* @menuItem.hint The menu item object
* @options.hint Additional arguments to be used in the method
* @menuItem The menu item object
* @options Additional arguments to be used in the method
*/
public string function getDisplayTemplate( required any menuItem, required struct options = {} ){
var content = contentService.findBySlug(
string function getDisplayTemplate( required any menuItem, required struct options = {} ){
var content = variables.contentService.findBySlug(
slug = arguments.menuItem.getContentSlug(),
siteID = arguments.menuItem.getMenu().getSiteID()
);
var viewArgs = {
menuItem : arguments.menuItem,
contentLink : CBHelper.linkContent( content = content ),
data : arguments.menuItem.getMemento()
};

return variables.renderer.externalView(
view = "/contentbox/models/menu/views/content/display",
module = "contentbox",
args = viewArgs
args = {
menuItem : arguments.menuItem,
contentLink : variables.CBHelper.linkContent( content: content ),
data : arguments.menuItem.getMemento()
}
);
}

Expand Down
26 changes: 18 additions & 8 deletions modules/contentbox/modules/contentbox-admin/handlers/menus.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ component extends="baseHandler" {
}

/**
* Create a menu Item
* Create a menu item for a provider
*
* @return text
* @return The rendered menu item
*/
function createMenuItem( event, rc, prc ){
prc.provider = menuItemService.getProvider( arguments.rc.type );
Expand All @@ -133,15 +133,25 @@ component extends="baseHandler" {
menuItem : entityNew( prc.provider.getEntityName() ),
provider : prc.provider
};

// set new or persisted id in args
args.menuItemID = !isNull( args.menuItem.getMenuItemID() ) ? args.menuItem.getMenuItemID() : "new-#createUUID()#";
if( args.menuItem.isLoaded() ){
args.menuItemID = args.menuItem.getMenuItemID();
} else {
args.menuItemID = "new-#createUUID()#";
args.menuItem.setMenu( variables.menuService.new().setSite( prc.oCurrentSite ) );
}

var str = "<li class=""dd-item dd3-item"" data-id=""#args.menuItemID#"" :key=""#args.menuItemID#"">";
savecontent variable="menuString" {
writeOutput( view( view = "menus/provider", args = args ) );
savecontent variable="local.renderedMenuItem" {
writeOutput( "<li
class=""dd-item dd3-item""
data-id=""#encodeForHTMLAttribute( args.menuItemID )#""
:key=""#encodeForHTMLAttribute( args.menuItemID )#"">" )
writeOutput( view( view : "menus/provider", args : args ) );
writeOutput( "</li>" );
};
str &= menuString & "</li>";
event.renderData( data = str, type = "text" );

event.renderData( data = renderedMenuItem, type = "text" );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<div role="button" class="dd-handle dd3-handle btn" title="Drag to reorder">
<i class="fa fa-crosshairs fa-lg"></i>
</div>

<div class="dd3-actions">
<cfset btnCls = !args.menuItem.getActive() ? "btn-danger" : "btn-primary">

Expand All @@ -14,9 +15,11 @@
<div class="dd3-content double" data-toggle="context" data-target="##context-menu">
#args.menuItem.getLabel()#
</div>

<button type="button" class="dd3-expand btn" title="Edit Details" @click="$store.menusStore.toggleEditor( '#menuItemID#' )">
<i class="fas fa-pen fa-lg"></i>
</button>

<button class="dd3-delete btn confirmIt"
data-message="Are you sure you want to remove this menu item and all its descendants? <br> Please note that changes are not final until you save the menu."
data-title="Delete Menu Item"
Expand All @@ -25,7 +28,7 @@
<i class="fa fa-trash fa-lg"></i>
</button>
</div>

<div class="dd3-extracontent" x-show="$store.menusStore.editingMenus.indexOf( '#menuItemID#' ) > -1">
<!--- id --->
<cfset label = "label-#getTickCount()#">
Expand Down Expand Up @@ -68,17 +71,20 @@
</div>
</fieldset>

<!---End default fields--->
<cfif len( args.provider.getAdminTemplate( menuItem=args.menuItem ) )>
<!--- Render Provider Attributes --->
<cfset adminTemplate = args.provider.getAdminTemplate( menuItem=args.menuItem )>
<cfif len( adminTemplate )>
<fieldset>
<legend>#args.provider.getName()# Attributes</legend>
<p>These attributes can be used to customize the item's content</p>

<!---do provider thing--->
#args.provider.getAdminTemplate( menuItem=args.menuItem )#
#adminTemplate#

<div class="row">

<!--- data attribute --->
<span class="col-md-6">
<!--- data attribute --->
#html.textfield(
label="Data Attributes:",
name="data",
Expand All @@ -92,8 +98,9 @@
groupWrapper="div class=form-group"
)#
</span>

<!--- title --->
<span class="col-md-6">
<!--- title --->
#html.textfield(
label="Title:",
name="title",
Expand All @@ -113,4 +120,4 @@
</cfif>
<!---end provider thing--->
</div>
</cfoutput>
</cfoutput>
4 changes: 2 additions & 2 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"app":{
"cfengine":"lucee@5.4",
"cfengine":"lucee@5",
"serverHomeDirectory":".engines/lucee5"
},
"name":"contentbox-lucee5",
Expand All @@ -27,7 +27,7 @@
"image":"modules_app/contentbox-custom/_content/ContentBoxIcon300.png"
}
],
"cfconfig":{
"cfconfig":{
"file":".cfconfig.json"
}
}
32 changes: 0 additions & 32 deletions server.json

This file was deleted.

0 comments on commit d7ba02a

Please sign in to comment.