mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-26 01:28:05 +02:00
Fix contact summary search display
This commit is contained in:
parent
e65d0dcf6c
commit
ac8d415729
4 changed files with 45 additions and 78 deletions
|
@ -18,10 +18,8 @@
|
|||
totalCount: '=?'
|
||||
},
|
||||
controller: function($scope, $element, crmApi4, searchDisplayBaseTrait, searchDisplayTasksTrait) {
|
||||
console.log('crmSearchDisplayContactCat controller called');
|
||||
// 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;
|
||||
|
||||
|
@ -40,7 +38,7 @@
|
|||
|
||||
$scope.$watch('$ctrl.results', () => { ctrl.n++; }, true);
|
||||
$scope.$watch('$ctrl.n', () => {
|
||||
console.log("watch n running");
|
||||
console.log("watch n running 2025-04-02 ");
|
||||
if (!ctrl.catDefs || !ctrl.results?.count) {
|
||||
console.log("...waiting for all the data we need");
|
||||
ctrl.ourData = {
|
||||
|
@ -50,8 +48,15 @@
|
|||
return ctrl.n;
|
||||
}
|
||||
|
||||
// Should do this at the php end but I don't know how.
|
||||
ctrl.results.sort((a, b) => {
|
||||
if (a.data.activity_date_time < b.data.activity_date_time) return 1;
|
||||
if (a.data.activity_date_time > b.data.activity_date_time) return -1;
|
||||
return a.data.id - b.data.id;
|
||||
});
|
||||
const rows = ctrl.results.map((row) => {
|
||||
const d = (new Date(row.data.activity_date_time.replace(' ', 'T'))).toLocaleString('UTC', {
|
||||
const d = (new Date(row.data.activity_date_time.replace(' ', 'T'))),
|
||||
when = d.toLocaleString('UTC', {
|
||||
weekday: 'short',
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
|
@ -60,7 +65,8 @@
|
|||
return {
|
||||
contact_id: row.data['Activity_ActivityContact_Contact_01.id'],
|
||||
new: ctrl.catDefs[row.data['Category_changes.new_category_id']],
|
||||
when: d,
|
||||
when,
|
||||
data: row.data,
|
||||
};
|
||||
});
|
||||
ctrl.ourData = {rows, count:rows.length};
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
<!-- output the current category -->
|
||||
<details class="">
|
||||
<summary>
|
||||
{{ts('Category')}}:
|
||||
{{ts('Category')}}:
|
||||
<span ng-if="!$ctrl.ourData.count" >{{ts('Loading')}}</span>
|
||||
<span ng-if="$ctrl.ourData.count" style="color:{{$ctrl.ourData.rows[0].new.color}};">
|
||||
<i class="crm-i {{$ctrl.ourData.rows[0].new.icon}}" ></i>
|
||||
<i class="crm-i {{$ctrl.ourData.rows[0].new.icon}}" ></i>
|
||||
{{$ctrl.ourData.rows[0].new.label}}
|
||||
</span>
|
||||
</summary>
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
use CRM_Contactcats_ExtensionUtil as E;
|
||||
|
||||
// This defines a search display type... I think.
|
||||
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_by_contact_Category_1',
|
||||
'entity' => 'SearchDisplay',
|
||||
'cleanup' => 'unused',
|
||||
'update' => 'unmodified',
|
||||
'params' => [
|
||||
'version' => 4,
|
||||
'values' => [
|
||||
'name' => 'Category_by_contact_Category_1',
|
||||
'label' => E::ts('Category Category'),
|
||||
'saved_search_id.name' => 'Category_by_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' => [
|
||||
'name',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
27
managed/OptionValue_crm_search_display_contact_cat.mgd.php
Normal file
27
managed/OptionValue_crm_search_display_contact_cat.mgd.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
use CRM_Contactcats_ExtensionUtil as E;
|
||||
|
||||
// This defines a search display type... I think.
|
||||
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',
|
||||
'description' => E::ts('Shows the current and previous categories for this contact'),
|
||||
'icon' => 'fa-tag',
|
||||
],
|
||||
'match' => [
|
||||
'option_group_id',
|
||||
'name',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue