Fixes and tidies

This commit is contained in:
Rich Lott / Artful Robot 2025-02-27 18:10:48 +00:00
parent e56be4ce31
commit 69d4c6b2e8
11 changed files with 191 additions and 40 deletions

View file

@ -1,3 +0,0 @@
<div af-fieldset="">
<crm-search-display-list search-name="Category_for_contact" display-name="Category_for_contact_List_1" filters="{'contact_id': options.contact_id}"></crm-search-display-list>
</div>

View file

@ -1,13 +0,0 @@
{
"type": "search",
"title": "Category",
"placement": [
"contact_summary_block"
],
"icon": "fa-list-alt",
"server_route": "",
"permission": [
"access CiviCRM"
],
"permission_operator": "AND"
}

View file

@ -0,0 +1,3 @@
<div af-fieldset="">
<crm-search-display-table search-name="SavedSearch_Contact_Category_Counts" display-name="Category_counts"></crm-search-display-table>
</div>

View file

@ -0,0 +1,33 @@
{
"type": "search",
"title": "Contact Category Counts",
"placement": [
"dashboard_dashlet"
],
"icon": "fa-tags",
"server_route": "civicrm/reports/contact-category-counts",
"permission": [
"access CiviCRM"
],
"permission_operator": "AND",
"navigation": {
"parent": "Reports",
"label": "Contact Category Counts",
"weight": 0
},
"modified_date": "2025-02-27 17:32:42",
"requires": null,
"entity_type": null,
"join_entity": null,
"description": null,
"summary_contact_type": null,
"summary_weight": null,
"is_public": false,
"redirect": null,
"submit_enabled": true,
"submit_limit": null,
"create_submission": null,
"manual_processing": null,
"allow_verification_by_email": null,
"email_confirmation_template_id": null
}

View file

@ -27,6 +27,10 @@
ctrl.categoryToEdit = null;
ctrl.categoryDefinitions = null;
ctrl.categoryDefinitions = await crmApi4("ContactCategoryDefinition", 'get', { orderBy: { execution_order: 'ASC' }, withLabels: true });
if (ctrl.categoryDefinitions.count === 0) {
// First time.
ctrl.categoryDefinitions = [];
}
// Ensure we have the minimum of what we need.
if (!ctrl.categoryDefinitions.find(c => c.search_type === 'default')) {
// There's no default one.
@ -80,7 +84,7 @@
// Create a blank
ctrl.categoryToEdit = {
id: 0,
execution_order: ctrl.categoryDefinitions.length,
execution_order: -1,
label: '',
search_type: 'search',
search_data: { saved_search_id: null },
@ -139,8 +143,14 @@
edited.search_data = {saved_search_id};
}
const idx = edited.execution_order;
ctrl.categoryDefinitions[idx] = edited;
if (edited.execution_order === -1) {
// This is a new category, we need to insert it before the default one.
const newIdx = ctrl.categoryDefinitions.length - 1;
ctrl.categoryDefinitions.splice(newIdx, 0, edited);
}
else {
ctrl.categoryDefinitions[edited.execution_order] = edited;
}
ctrl.categoryToEdit = null;
updateOrders();
ctrl.dirty = 'dirty';