Skip to content

Commit

Permalink
Add civicrm_admin_ui extension
Browse files Browse the repository at this point in the history
So far this extension replaces 2 screns with SearchDisplay Afforms:
- Custom field groups
- Custom fields
  • Loading branch information
colemanw committed Jan 26, 2022
1 parent 6f97370 commit 9f45c30
Show file tree
Hide file tree
Showing 12 changed files with 1,275 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
!/ext/afform
!/ext/authx
!/ext/civigrant
!/ext/civicrm_admin_ui
!/ext/sequentialcreditnotes
!/ext/flexmailer
!/ext/eventcart
Expand Down
667 changes: 667 additions & 0 deletions ext/civicrm_admin_ui/LICENSE.txt

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions ext/civicrm_admin_ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# civicrm_admin_ui

Enable this extension for some screens under "Administer CiviCRM" to be configurable SearchKit displays.
15 changes: 15 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchAdminCustomFields.aff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div af-fieldset="">
<div class="af-markup">
<div class="form-inline">
<a class="btn btn-primary" target="crm-popup" ng-href="{{ crmUrl('civicrm/admin/custom/group/field/add', {gid: routeParams.gid, reset: 1}) }}">
<i class="crm-i fa-plus-circle"></i>
{{:: ts('Add Field') }}
</a>
<a class="btn btn-secondary" ng-href="{{ crmUrl('civicrm/admin/custom/group') }}">
<i class="crm-i fa-times"></i>
{{:: ts('Done') }}
</a>
</div>
</div>
<crm-search-display-table search-name="Administer_Custom_Fields" display-name="Table" filters="{custom_group_id: routeParams.gid}"></crm-search-display-table>
</div>
8 changes: 8 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchAdminCustomFields.aff.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "search",
"requires": [],
"title": "Fields",
"description": "Administer custom fields list",
"server_route": "civicrm/admin/custom/group/fields",
"permission": "administer CiviCRM data"
}
15 changes: 15 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchAdminCustomGroups.aff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div af-fieldset="">
<div class="af-markup">
<div class="help">
{{:: ts('Custom data is stored in custom fields. Custom fields are organized into logically related custom data sets (e.g. Volunteer Info). Use custom fields to collect and store custom data which are not included in the standard CiviCRM forms. You can create one or many sets of custom fields.') }}
<a href="https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields" target="_blank" class="crm-doc-link no-popup">{{:: ts('Learn more...') }}</a>
</div>
<div>
<a class="btn btn-primary" ng-href="{{:: crmUrl('civicrm/admin/custom/group/edit', {reset: 1}) }}">
<i class="crm-i fa-plus-circle"></i>
{{:: ts('Add Set of Custom Fields') }}
</a>
</div>
</div>
<crm-search-display-table search-name="Administer_Custom_Groups" display-name="Table"></crm-search-display-table>
</div>
8 changes: 8 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchAdminCustomGroups.aff.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "search",
"requires": [],
"title": "Custom Field Groups",
"description": "Administer custom field groups list",
"server_route": "civicrm/admin/custom/group",
"permission": "administer CiviCRM data"
}
119 changes: 119 additions & 0 deletions ext/civicrm_admin_ui/civicrm_admin_ui.civix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php

// AUTO-GENERATED FILE -- Civix may overwrite any changes made to this file

/**
* The ExtensionUtil class provides small stubs for accessing resources of this
* extension.
*/
class CRM_CivicrmAdminUi_ExtensionUtil {
const SHORT_NAME = 'civicrm_admin_ui';
const LONG_NAME = 'civicrm_admin_ui';
const CLASS_PREFIX = 'CRM_CivicrmAdminUi';

/**
* Translate a string using the extension's domain.
*
* If the extension doesn't have a specific translation
* for the string, fallback to the default translations.
*
* @param string $text
* Canonical message text (generally en_US).
* @param array $params
* @return string
* Translated text.
* @see ts
*/
public static function ts($text, $params = []) {
if (!array_key_exists('domain', $params)) {
$params['domain'] = [self::LONG_NAME, NULL];
}
return ts($text, $params);
}

/**
* Get the URL of a resource file (in this extension).
*
* @param string|NULL $file
* Ex: NULL.
* Ex: 'css/foo.css'.
* @return string
* Ex: 'http://example.org/sites/default/ext/org.example.foo'.
* Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'.
*/
public static function url($file = NULL) {
if ($file === NULL) {
return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/');
}
return CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME, $file);
}

/**
* Get the path of a resource file (in this extension).
*
* @param string|NULL $file
* Ex: NULL.
* Ex: 'css/foo.css'.
* @return string
* Ex: '/var/www/example.org/sites/default/ext/org.example.foo'.
* Ex: '/var/www/example.org/sites/default/ext/org.example.foo/css/foo.css'.
*/
public static function path($file = NULL) {
// return CRM_Core_Resources::singleton()->getPath(self::LONG_NAME, $file);
return __DIR__ . ($file === NULL ? '' : (DIRECTORY_SEPARATOR . $file));
}

/**
* Get the name of a class within this extension.
*
* @param string $suffix
* Ex: 'Page_HelloWorld' or 'Page\\HelloWorld'.
* @return string
* Ex: 'CRM_Foo_Page_HelloWorld'.
*/
public static function findClass($suffix) {
return self::CLASS_PREFIX . '_' . str_replace('\\', '_', $suffix);
}

}

use CRM_CivicrmAdminUi_ExtensionUtil as E;

/**
* (Delegated) Implements hook_civicrm_config().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config
*/
function _civicrm_admin_ui_civix_civicrm_config(&$config = NULL) {
static $configured = FALSE;
if ($configured) {
return;
}
$configured = TRUE;

$template =& CRM_Core_Smarty::singleton();

$extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$extDir = $extRoot . 'templates';

if (is_array($template->template_dir)) {
array_unshift($template->template_dir, $extDir);
}
else {
$template->template_dir = [$extDir, $template->template_dir];
}

$include_path = $extRoot . PATH_SEPARATOR . get_include_path();
set_include_path($include_path);
}

/**
* (Delegated) Implements hook_civicrm_entityTypes().
*
* Find any *.entityType.php files, merge their content, and return.
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
*/
function _civicrm_admin_ui_civix_civicrm_entityTypes(&$entityTypes) {
$entityTypes = array_merge($entityTypes, []);
}
26 changes: 26 additions & 0 deletions ext/civicrm_admin_ui/civicrm_admin_ui.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

require_once 'civicrm_admin_ui.civix.php';
// phpcs:disable
use CRM_CivicrmAdminUi_ExtensionUtil as E;
// phpcs:enable

/**
* Implements hook_civicrm_config().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
*/
function civicrm_admin_ui_civicrm_config(&$config) {
_civicrm_admin_ui_civix_civicrm_config($config);
}

/**
* Implements hook_civicrm_entityTypes().
*
* Declare entity types provided by this module.
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
*/
function civicrm_admin_ui_civicrm_entityTypes(&$entityTypes) {
_civicrm_admin_ui_civix_civicrm_entityTypes($entityTypes);
}
38 changes: 38 additions & 0 deletions ext/civicrm_admin_ui/info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<extension key="civicrm_admin_ui" type="module">
<file>civicrm_admin_ui</file>
<name>CiviCRM Administration UI</name>
<description>Administration screens for managing CiviCRM settings, options, custom data, etc.</description>
<license>AGPL-3.0</license>
<maintainer>
<author>Coleman Watts</author>
<email>[email protected]</email>
</maintainer>
<urls>
<url desc="Main Extension Page">http://FIXME</url>
<url desc="Documentation">http://FIXME</url>
<url desc="Support">http://FIXME</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2022-01-02</releaseDate>
<version>1.0</version>
<develStage>alpha</develStage>
<compatibility>
<ver>5.47</ver>
</compatibility>
<requires>
<ext>org.civicrm.search_kit</ext>
<ext>org.civicrm.afform</ext>
</requires>
<comments>Replaces legacy pages with configurable Search Display Forms.</comments>
<classloader>
<psr4 prefix="Civi\" path="Civi"/>
</classloader>
<civix>
<namespace>CRM/CivicrmAdminUi</namespace>
<angularModule>crmCivicrmAdminUi</angularModule>
</civix>
<mixins>
<mixin>[email protected]</mixin>
</mixins>
</extension>
Loading

0 comments on commit 9f45c30

Please sign in to comment.