diff --git a/ang/crmSearchDisplayContactCat.js b/ang/crmSearchDisplayContactCat.js index 802fff4..606df89 100644 --- a/ang/crmSearchDisplayContactCat.js +++ b/ang/crmSearchDisplayContactCat.js @@ -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,17 +48,25 @@ 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', { - weekday: 'short', - day: 'numeric', - month: 'short', - year: 'numeric', - }); + const d = (new Date(row.data.activity_date_time.replace(' ', 'T'))), + when = d.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, + when, + data: row.data, }; }); ctrl.ourData = {rows, count:rows.length}; diff --git a/ang/crmSearchDisplayContactCat/crmSearchDisplayContactCat.html b/ang/crmSearchDisplayContactCat/crmSearchDisplayContactCat.html index 58bd3bb..fa039f4 100644 --- a/ang/crmSearchDisplayContactCat/crmSearchDisplayContactCat.html +++ b/ang/crmSearchDisplayContactCat/crmSearchDisplayContactCat.html @@ -8,10 +8,10 @@
- {{ts('Category')}}: + {{ts('Category')}}:   {{ts('Loading')}} - +   {{$ctrl.ourData.rows[0].new.label}} diff --git a/managed-hold/OptionValue_crm_search_display_contact_cat.mgdx.php b/managed-hold/OptionValue_crm_search_display_contact_cat.mgdx.php deleted file mode 100644 index 9953dd5..0000000 --- a/managed-hold/OptionValue_crm_search_display_contact_cat.mgdx.php +++ /dev/null @@ -1,66 +0,0 @@ - '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', - ], - ], - ], -]; diff --git a/managed/OptionValue_crm_search_display_contact_cat.mgd.php b/managed/OptionValue_crm_search_display_contact_cat.mgd.php new file mode 100644 index 0000000..a60bb94 --- /dev/null +++ b/managed/OptionValue_crm_search_display_contact_cat.mgd.php @@ -0,0 +1,27 @@ + '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', + ], + ], + ], +];