mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-26 03:28:06 +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: '=?'
|
totalCount: '=?'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element, crmApi4, searchDisplayBaseTrait, searchDisplayTasksTrait) {
|
controller: function($scope, $element, crmApi4, searchDisplayBaseTrait, searchDisplayTasksTrait) {
|
||||||
console.log('crmSearchDisplayContactCat controller called');
|
|
||||||
// Mix in required traits
|
// Mix in required traits
|
||||||
ctrl = angular.extend(this, _.cloneDeep(searchDisplayBaseTrait), _.cloneDeep(searchDisplayTasksTrait));
|
ctrl = angular.extend(this, _.cloneDeep(searchDisplayBaseTrait), _.cloneDeep(searchDisplayTasksTrait));
|
||||||
console.log("hello display");
|
|
||||||
var ts = ($scope.ts = CRM.ts(null)),
|
var ts = ($scope.ts = CRM.ts(null)),
|
||||||
ctrl = this;
|
ctrl = this;
|
||||||
|
|
||||||
|
@ -40,7 +38,7 @@
|
||||||
|
|
||||||
$scope.$watch('$ctrl.results', () => { ctrl.n++; }, true);
|
$scope.$watch('$ctrl.results', () => { ctrl.n++; }, true);
|
||||||
$scope.$watch('$ctrl.n', () => {
|
$scope.$watch('$ctrl.n', () => {
|
||||||
console.log("watch n running");
|
console.log("watch n running 2025-04-02 ");
|
||||||
if (!ctrl.catDefs || !ctrl.results?.count) {
|
if (!ctrl.catDefs || !ctrl.results?.count) {
|
||||||
console.log("...waiting for all the data we need");
|
console.log("...waiting for all the data we need");
|
||||||
ctrl.ourData = {
|
ctrl.ourData = {
|
||||||
|
@ -50,17 +48,25 @@
|
||||||
return ctrl.n;
|
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 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'))),
|
||||||
weekday: 'short',
|
when = d.toLocaleString('UTC', {
|
||||||
day: 'numeric',
|
weekday: 'short',
|
||||||
month: 'short',
|
day: 'numeric',
|
||||||
year: 'numeric',
|
month: 'short',
|
||||||
});
|
year: 'numeric',
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
contact_id: row.data['Activity_ActivityContact_Contact_01.id'],
|
contact_id: row.data['Activity_ActivityContact_Contact_01.id'],
|
||||||
new: ctrl.catDefs[row.data['Category_changes.new_category_id']],
|
new: ctrl.catDefs[row.data['Category_changes.new_category_id']],
|
||||||
when: d,
|
when,
|
||||||
|
data: row.data,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
ctrl.ourData = {rows, count:rows.length};
|
ctrl.ourData = {rows, count:rows.length};
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
<!-- output the current category -->
|
<!-- output the current category -->
|
||||||
<details class="">
|
<details class="">
|
||||||
<summary>
|
<summary>
|
||||||
{{ts('Category')}}:
|
{{ts('Category')}}:
|
||||||
<span ng-if="!$ctrl.ourData.count" >{{ts('Loading')}}</span>
|
<span ng-if="!$ctrl.ourData.count" >{{ts('Loading')}}</span>
|
||||||
<span ng-if="$ctrl.ourData.count" style="color:{{$ctrl.ourData.rows[0].new.color}};">
|
<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}}
|
{{$ctrl.ourData.rows[0].new.label}}
|
||||||
</span>
|
</span>
|
||||||
</summary>
|
</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