-
-
Notifications
You must be signed in to change notification settings - Fork 826
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Afform - Switch to user-oriented breadcrumbs, move admin link to hove…
…r button Before: In full-page mode, breadcrumbs were orieted toward form-building, with links to edit the form and browse FormBuilder. After: In full-page mode, breadcrumbs are oriented toward general users, with links to parent-pages. Parent pages are, by default calculated based off the route. This adds a 'title' key in function `afform_civicrm_alterMenu` for the benefit of`CRM_Core_Menu::buildBreadcrumb`. Alternately, if the Afform has been placed in the navigation menu, then the breadcrumb is calculated based on the parent menu item.
- Loading branch information
Showing
7 changed files
with
93 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Civi\AfformAdmin; | ||
|
||
use Civi\Core\Service\AutoSubscriber; | ||
use CRM_Afform_ExtensionUtil as E; | ||
|
||
/** | ||
* @package Civi\AfformAdmin | ||
*/ | ||
class AfformAdminInjector extends AutoSubscriber { | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function getSubscribedEvents(): array { | ||
return [ | ||
'hook_civicrm_alterAngular' => 'preprocess', | ||
]; | ||
} | ||
|
||
/** | ||
* @param \Civi\Core\Event\GenericHookEvent $e | ||
* @see CRM_Utils_Hook::alterAngular() | ||
*/ | ||
public static function preprocess($e) { | ||
$changeSet = \Civi\Angular\ChangeSet::create('afformAdmin') | ||
->alterHtml(';\\.aff\\.html$;', function($doc, $path) { | ||
try { | ||
$moduleName = basename($path, '.aff.html'); | ||
// If the user has "administer CiviCRM", inject edit link | ||
if (\CRM_Core_Permission::check('administer CiviCRM')) { | ||
$url = \CRM_Utils_System::url('civicrm/admin/afform', NULL, FALSE, '/edit/' . $moduleName, TRUE); | ||
// Append link to afform directive element (using loop but there should be only one) | ||
foreach (pq('af-form[ctrl]', $doc) as $afForm) { | ||
pq($afForm)->append('<a href="' . $url . '" target="_blank" class="af-admin-edit-form-link"><i class="crm-i fa-gear"></i> ' . E::ts('Edit Form') . '</a>'); | ||
} | ||
} | ||
} | ||
catch (\Exception $e) { | ||
} | ||
}); | ||
$e->angular->add($changeSet); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters