Skip to content

Commit

Permalink
Merge branch 'feature-CONTENTLIB-2_add-email-content-library' into re…
Browse files Browse the repository at this point in the history
…lease-1.1.0
  • Loading branch information
DominicWatson committed Sep 19, 2023
2 parents 6f23181 + d0c65b6 commit 9f5d783
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
10 changes: 5 additions & 5 deletions handlers/widgets/emailContentLibraryContent.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ component {
private function index( event, rc, prc, args={} ) {
var item = args.content_item ?: "";

if ( contentLibraryService.contentHasAlternatives( item ) ) {
return renderViewlet( event="widgets.contentLibraryContent._nonCacheable", args=args );
if ( contentLibraryService.emailContentHasAlternatives( item ) ) {
return renderViewlet( event="widgets.emailContentLibraryContent._nonCacheable", args=args );
}

return renderContent( "richeditor", contentLibraryService.getContent( item ) );
return renderContent( "richeditor", contentLibraryService.getEmailContent( item ) );
}

private function placeholder( event, rc, prc, args={} ) {
var item = args.content_item ?: "";
var itemLabel = renderLabel( "content_library_content", item );
var itemLabel = renderLabel( "email_content_library_content", item );

return translateResource( uri="widgets.contentLibraryContent:placeholder", data=[ itemLabel ] );
}
Expand All @@ -26,6 +26,6 @@ component {
private function _nonCacheable( event, rc, prc, args={} ) {
var item = args.content_item ?: "";

return renderContent( "richeditor", contentLibraryService.getContent( item ) );
return renderContent( "richeditor", contentLibraryService.getEmailContent( item ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @feature emailContentLibrary
*/
component {
property name="content_library_content" relationship="many-to-one" relatedto="content_library_content" required=true uniqueindexes="content|1" ondelete="cascade" cloneable=true adminRenderer="none" batcheditable=false;
property name="email_content_library_content" relationship="many-to-one" relatedto="email_content_library_content" required=true uniqueindexes="content|1" ondelete="cascade" cloneable=true adminRenderer="none" batcheditable=false;
property name="condition" relationship="many-to-one" relatedto="rules_engine_condition" required=true uniqueindexes="content|2" cloneable=true adminViewGroup="system" sortorder=0 batcheditable=false;

property name="content" type="string" dbtype="text" required=true adminRenderer="none" batcheditable=false widgetCategories="email" linkPickerCategory="email" toolbar="email";
Expand Down
27 changes: 27 additions & 0 deletions services/ContentLibraryService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,39 @@ component {
return record.content ?: "";
}

public string function getEmailContent( required string itemId ) {
var conditionService = _getRulesEngineConditionService();
var conditionalAlternatives = $getPresideObject( "email_content_library_conditional_alternative" ).selectData(
filter = { email_content_library_content = arguments.itemId }
, selectFields = [ "condition", "content" ]
, orderBy = "sort_order"
);

for( var alternative in conditionalAlternatives ) {
if ( conditionService.evaluateCondition( alternative.condition, "webrequest" ) ) {
return alternative.content;
}
}

var record = $getPresideObject( "email_content_library_content" ).selectData(
id = arguments.itemId
, selectFields = [ "content" ]
);
return record.content ?: "";
}

public boolean function contentHasAlternatives( required string itemId ) {
return $getPresideObject( "content_library_conditional_alternative" ).dataExists(
filter = { content_library_content = arguments.itemId }
);
}

public boolean function emailContentHasAlternatives( required string itemId ) {
return $getPresideObject( "email_content_library_conditional_alternative" ).dataExists(
filter = { email_content_library_content = arguments.itemId }
);
}

public void function validateRichContent(
required string recordId
, required string richContent
Expand Down

0 comments on commit 9f5d783

Please sign in to comment.