Skip to content

Commit

Permalink
Merge branch 'feature-DASH-24_admin-dashboard-widgets-missing-feature…
Browse files Browse the repository at this point in the history
…-checking' of https://github.com/pixl8-brayden/preside-ext-admin-dashboards into feature-DASH-24-feature-checks-for-dash-widgets
  • Loading branch information
DominicWatson committed Jul 4, 2023
2 parents d0df038 + 406bc13 commit 4ca0f7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion handlers/admin/AdminDashboards.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ component extends="preside.system.base.AdminHandler" {
var widget = Duplicate( unsortedOrTranslated[ id ] );

if ( widget.siteTemplates == "*" || ListFindNoCase( widget.siteTemplates, activeSiteTemplate ) ) {
if ( ! widgetService.isUserDashboardWidget( widget.id ) ) {
if ( !widgetService.isEnabled( widget.id ) || !widgetService.isUserDashboardWidget( widget.id ) ) {
continue;
}

Expand Down
16 changes: 16 additions & 0 deletions services/AdminDashboardWidgetService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,22 @@ component {
return $helpers.isTrue( result ?: "" );
}

public boolean function isEnabled( required string widgetId ) {
var coldbox = $getColdbox();
var isEnabledEvent = "admin.admindashboards.widget.#widgetId#.isEnabled";
var result = true;

if ( coldbox.handlerExists( isEnabledEvent ) ) {
result = coldbox.runEvent(
event = isEnabledEvent
, private = true
, prePostExempt = true
);
}

return $helpers.isTrue( result ?: "" );
}

public numeric function nextWidgetSlot( required string dashboardId, required numeric column ) {
var currentMax = $getPresideObject( "admin_dashboard_widget" ).selectData(
filter = { dashboard=arguments.dashboardId, column=arguments.column }
Expand Down

0 comments on commit 4ca0f7e

Please sign in to comment.