mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-25 12:58:05 +02:00
Create Category search display
This commit is contained in:
parent
016ca2a735
commit
b9de61f9f7
7 changed files with 185 additions and 0 deletions
|
@ -20,4 +20,8 @@ return [
|
|||
'api4',
|
||||
],
|
||||
'settings' => [],
|
||||
'basePages' => ['civicrm/search', 'civicrm/admin/search'],
|
||||
'exports' => [
|
||||
'contactcats_category_display' => 'E',
|
||||
],
|
||||
];
|
||||
|
|
22
ang/crmSearchDisplayContactCat.ang.php
Normal file
22
ang/crmSearchDisplayContactCat.ang.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
// Angular module crmSearchDisplayContactCat.
|
||||
// @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
|
||||
|
||||
return [
|
||||
'js' => [
|
||||
'ang/crmSearchDisplayContactCat.js',
|
||||
'ang/crmSearchDisplayContactCat/*.js',
|
||||
// 'ang/crmSearchDisplayContactCat/*/*.js',
|
||||
],
|
||||
'css' => [
|
||||
'ang/crmSearchDisplayContactCat.css',
|
||||
],
|
||||
'partials' => [
|
||||
'ang/crmSearchDisplayContactCat',
|
||||
],
|
||||
'requires' => ['crmUi', 'crmUtil', 'ngRoute'],
|
||||
'settings' => [],
|
||||
'basePages' => ['civicrm/search', 'civicrm/admin/search'],
|
||||
'exports' => ['crmSearchAdminDisplayContactCat', 'crmSearchDisplayContactCat'],
|
||||
];
|
1
ang/crmSearchDisplayContactCat.css
Normal file
1
ang/crmSearchDisplayContactCat.css
Normal file
|
@ -0,0 +1 @@
|
|||
/* Add any CSS rules for Angular module "crmContactcats" */
|
73
ang/crmSearchDisplayContactCat.js
Normal file
73
ang/crmSearchDisplayContactCat.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
console.log(123);
|
||||
// see https://docs.civicrm.org/dev/en/latest/searchkit/displays/
|
||||
(function(angular, $, _) {
|
||||
// Declare a list of dependencies.
|
||||
angular.module('crmSearchDisplayContactCat', CRM.angRequires('crmSearchDisplayContactCat'));
|
||||
// angular.module('crmContactcats').component();
|
||||
|
||||
// This is to be the display
|
||||
// NOTE: the component name is {CamelCaseNameFromOptionValue}
|
||||
// Standard seems to be to name crmSearchDisplay{YourName}
|
||||
angular.module("crmSearchDisplayContactCat").component("crmSearchDisplayContactCat", {
|
||||
templateUrl: "~/crmSearchDisplayContactCat/crmSearchDisplayContactCat.html",
|
||||
bindings: {
|
||||
apiEntity: '@',
|
||||
search: '<',
|
||||
display: '<',
|
||||
apiParams: '<',
|
||||
settings: '<',
|
||||
filters: '<',
|
||||
totalCount: '=?'
|
||||
},
|
||||
// controller: function($scope, $timeout, crmApi4, crmStatus, $document) {
|
||||
controller: function($scope, $element, searchDisplayBaseTrait, searchDisplayTasksTrait) {
|
||||
// Mix in required traits
|
||||
ctrl = angular.extend(this, _.cloneDeep(searchDisplayBaseTrait), _.cloneDeep(searchDisplayTasksTrait));
|
||||
console.log("hello display");
|
||||
var ts = ($scope.ts = CRM.ts(null)),
|
||||
ctrl = this;
|
||||
|
||||
// this.$onInit gets run after the this controller is called, and after the bindings have been applied.
|
||||
this.$onInit = function() {
|
||||
console.log("calling initializeDisplay");
|
||||
this.initializeDisplay($scope, $element);
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// This is to be the admin settings for the display
|
||||
// NOTE: the component name is 'searchAdminDisplay'{CamelCaseValueFromOptionValue}
|
||||
angular.module("crmSearchDisplayContactCat").component("searchAdminDisplayContactCat", {
|
||||
templateUrl: "~/crmSearchDisplayContactCat/searchAdminDisplayContactCat.html",
|
||||
bindings: {
|
||||
display: '<',
|
||||
apiEntity: '<',
|
||||
apiParams: '<'
|
||||
},
|
||||
require: {
|
||||
parent: '^crmSearchAdminDisplay'
|
||||
},
|
||||
controller: function($scope, searchMeta, crmUiHelp) {
|
||||
console.log("hello admin");
|
||||
let ctrl = this;
|
||||
// var ts = ($scope.ts = CRM.ts(null)),
|
||||
// ctrl = this;
|
||||
this.getColTypes = function() {
|
||||
return ctrl.parent.colTypes;
|
||||
};
|
||||
// this.$onInit gets run after the this controller is called, and after the bindings have been applied.
|
||||
this.$onInit = async function() {
|
||||
if (!ctrl.display.settings) {
|
||||
console.log("applying display.settings as was nonwl");
|
||||
ctrl.display.settings = {
|
||||
something: 'nothing',
|
||||
limit: ctrl.parent.getDefaultLimit(),
|
||||
sort: ctrl.parent.getDefaultSort(),
|
||||
pager: {}
|
||||
};
|
||||
}
|
||||
ctrl.parent.initColumns({});
|
||||
};
|
||||
}});
|
||||
|
||||
})(angular, CRM.$, CRM._);
|
|
@ -0,0 +1,18 @@
|
|||
<div class="crm-search-display crm-search-display-contact-cat">
|
||||
<p>This is the crmSearchDisplayContactCat thing</p>
|
||||
<div class="form-inline">
|
||||
<div class="btn-group" ng-include="'~/crmSearchDisplay/SearchButton.html'" ></div>
|
||||
<div class="form-group pull-right" ng-include="'~/crmSearchDisplay/toolbar.html'" ng-if="$ctrl.toolbar"></div>
|
||||
</div>
|
||||
<ol style="list-style: disc;">
|
||||
<li ng-repeat="(rowIndex, row) in $ctrl.results" class="{{:: row.cssClass }}">
|
||||
<span style="color:{{row.data['ContactCategory_ContactCategoryDefinition_category_definition_id_01.color']}};" >
|
||||
<i class="crm-i {{row.data['ContactCategory_ContactCategoryDefinition_category_definition_id_01.icon']}}" ></i>
|
||||
{{row.data['category_definition_id:label']}}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
</ol>
|
||||
<div ng-include="'~/crmSearchDisplay/Pager.html'"></div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1 @@
|
|||
hello
|
66
managed/OptionValue_crm_search_display_contact_cat.mgd.php
Normal file
66
managed/OptionValue_crm_search_display_contact_cat.mgd.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
use CRM_Contactcats_ExtensionUtil as E;
|
||||
|
||||
return [
|
||||
[
|
||||
'name' => 'OptionValue_crm_search_display_contact_cat',
|
||||
'entity' => 'OptionValue',
|
||||
'cleanup' => 'unused',
|
||||
'update' => 'unmodified',
|
||||
'params' => [
|
||||
'version' => 4,
|
||||
'values' => [
|
||||
'option_group_id.name' => 'search_display_type',
|
||||
'label' => E::ts('Category'),
|
||||
'value' => 'contact-cat',
|
||||
'name' => 'crm-search-display-contact-cat',
|
||||
'weight' => 6,
|
||||
'description' => E::ts('Shows the current and previous categories for this contact'),
|
||||
'icon' => 'fa-tag',
|
||||
],
|
||||
'match' => [
|
||||
'option_group_id',
|
||||
'name',
|
||||
],
|
||||
],
|
||||
],
|
||||
// Weird, so this bit belongs elsewhere
|
||||
[
|
||||
'name' => 'OptionValue_crm_search_display_contact_cat_SearchDisplay_Category_per_contact_Category_1',
|
||||
'entity' => 'SearchDisplay',
|
||||
'cleanup' => 'unused',
|
||||
'update' => 'unmodified',
|
||||
'params' => [
|
||||
'version' => 4,
|
||||
'values' => [
|
||||
'name' => 'Category_per_contact_Category_1',
|
||||
'label' => E::ts('Category Category'),
|
||||
'saved_search_id.name' => 'Category_per_contact',
|
||||
'type' => 'contact-cat',
|
||||
'settings' => [
|
||||
'something' => 'nothing',
|
||||
'limit' => 50,
|
||||
'sort' => [],
|
||||
'pager' => [],
|
||||
// not sure about the columns bit.
|
||||
'columns' => [
|
||||
[
|
||||
'type' => 'field',
|
||||
'key' => 'id',
|
||||
'dataType' => 'Integer',
|
||||
],
|
||||
[
|
||||
'type' => 'field',
|
||||
'key' => 'category_definition_id:label',
|
||||
'dataType' => 'Integer',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'match' => [
|
||||
'saved_search_id',
|
||||
'name',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue