mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-25 21:28:06 +02:00
Add Category history saved search and searchkit display and afform for contact sum
This commit is contained in:
parent
93be452053
commit
142479d861
7 changed files with 228 additions and 20 deletions
|
@ -1,10 +1,11 @@
|
|||
console.log(123);
|
||||
console.log('crmSearchDisplayContactCat.js loaded');
|
||||
// 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();
|
||||
|
||||
console.log('crmSearchDisplayContactCat module registered');
|
||||
// This is to be the display
|
||||
// NOTE: the component name is {CamelCaseNameFromOptionValue}
|
||||
// Standard seems to be to name crmSearchDisplay{YourName}
|
||||
|
@ -20,21 +21,60 @@ console.log(123);
|
|||
totalCount: '=?'
|
||||
},
|
||||
// controller: function($scope, $timeout, crmApi4, crmStatus, $document) {
|
||||
controller: function($scope, $element, searchDisplayBaseTrait, searchDisplayTasksTrait) {
|
||||
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;
|
||||
|
||||
ctrl.catDefs = null;
|
||||
ctrl.resultsVM = {};
|
||||
ctrl.n = 1;
|
||||
// this.$onInit gets run after the this controller is called, and after the bindings have been applied.
|
||||
this.$onInit = function() {
|
||||
console.log("calling initializeDisplay");
|
||||
// Grab all the category definitions
|
||||
crmApi4('ContactCategoryDefinition', 'get', {
|
||||
orderBy: {presentation_order: 'ASC'}
|
||||
}, 'id').then(r => { ctrl.catDefs = r; console.log('catDefs', ctrl.catDefs); ctrl.n++; });
|
||||
this.initializeDisplay($scope, $element);
|
||||
};
|
||||
|
||||
$scope.$watch('$ctrl.results', () => { ctrl.n++; }, true);
|
||||
$scope.$watch('$ctrl.n', () => {
|
||||
console.log("watch n running");
|
||||
if (!ctrl.catDefs || !ctrl.results?.count) {
|
||||
console.log("...waiting for all the data we need");
|
||||
ctrl.ourData = {
|
||||
rows: [],
|
||||
count: 0,
|
||||
};
|
||||
return ctrl.n;
|
||||
}
|
||||
|
||||
const rows = ctrl.results.map((row) => {
|
||||
const d = (new Date(row.data.activity_date_time.replace(' ', 'T'))).toLocaleString('UTC', {
|
||||
weekday: 'short',
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
});
|
||||
return {
|
||||
contact_id: row.data['Activity_ActivityContact_Contact_01.id'],
|
||||
new: ctrl.catDefs[row.data['Category_changes.new_category_id']],
|
||||
when: d,
|
||||
};
|
||||
});
|
||||
ctrl.ourData = {rows, count:rows.length};
|
||||
console.log("new ourData", ctrl.ourData);
|
||||
return ctrl.n;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
console.log('crmSearchDisplayContactCat registering admin bit');
|
||||
// This is to be the admin settings for the display
|
||||
// NOTE: the component name is 'searchAdminDisplay'{CamelCaseValueFromOptionValue}
|
||||
angular.module("crmSearchDisplayContactCat").component("searchAdminDisplayContactCat", {
|
||||
|
@ -48,7 +88,7 @@ console.log(123);
|
|||
parent: '^crmSearchAdminDisplay'
|
||||
},
|
||||
controller: function($scope, searchMeta, crmUiHelp) {
|
||||
console.log("hello admin");
|
||||
console.log("hello admin controller");
|
||||
let ctrl = this;
|
||||
// var ts = ($scope.ts = CRM.ts(null)),
|
||||
// ctrl = this;
|
||||
|
@ -69,5 +109,6 @@ console.log(123);
|
|||
ctrl.parent.initColumns({});
|
||||
};
|
||||
}});
|
||||
console.log('crmSearchDisplayContactCat ends');
|
||||
|
||||
})(angular, CRM.$, CRM._);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue