Skip to content

Commit

Permalink
Angular - Switch to settingsFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Oct 12, 2023
1 parent 17b11cc commit c6f2793
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
13 changes: 13 additions & 0 deletions CRM/Mosaico/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,17 @@ public static function sendImage(string $file) {
flush();
}

public static function getAngularSettings(): array {
return [
'canDelete' => Civi::service('civi_api_kernel')->runAuthorize('MosaicoTemplate', 'delete', ['version' => 3, 'check_permissions' => 1]),
// If there are any navbars that we should try to avoid, include them
// in these jQuery selectors.
'topNav' => '#civicrm-menu',
'drupalNav' => '#toolbar',
'joomlaNav' => '.com_civicrm > .navbar',
'leftNav' => '.wp-admin #adminmenu',
'variantsPct' => CRM_Mosaico_AbDemux::DEFAULT_AB_PERCENTAGE,
];
}

}
33 changes: 7 additions & 26 deletions ang/crmMosaico.ang.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
<?php
// This file declares an Angular module which can be autoloaded
// in CiviCRM. See also:
// http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
// Main Angular module for Mosaico

$canRead = Civi::service('civi_api_kernel')->runAuthorize('MosaicoTemplate', 'get', ['version' => 3, 'check_permissions' => 1]);
if (!$canRead) {
return [];
}

$result = [
return [
'requires' => ['crmUi', 'crmUtil', 'ngRoute', 'crmMailing', 'crmDialog'],
'js' =>
[
0 => 'ang/crmMosaico.js',
1 => 'ang/crmMosaico/*.js',
2 => 'ang/crmMosaico/*/*.js',
'js' => [
'ang/crmMosaico.js',
'ang/crmMosaico/*.js',
'ang/crmMosaico/*/*.js',
],
'css' => ['css/mosaico-bootstrap.css'],
'bundles' => ['bootstrap3'],
'partials' => [
'ang/crmMosaico',
],
'settings' =>
[
'canDelete' => Civi::service('civi_api_kernel')->runAuthorize('MosaicoTemplate', 'delete', ['version' => 3, 'check_permissions' => 1]),
// If there are any navbars that we should try to avoid, include them
// in these jQuery selectors.
'topNav' => '#civicrm-menu',
'drupalNav' => '#toolbar',
'joomlaNav' => '.com_civicrm > .navbar',
'leftNav' => '.wp-admin #adminmenu',
'variantsPct' => CRM_Mosaico_AbDemux::DEFAULT_AB_PERCENTAGE,
],
'settingsFactory' => ['CRM_Mosaico_Utils', 'getAngularSettings'],
];
return $result;

0 comments on commit c6f2793

Please sign in to comment.