1 (function(angular
, $, _
) {
4 angular
.module('crmSearchAdmin').component('searchAdminDisplayTable', {
11 parent
: '^crmSearchAdminDisplay'
13 templateUrl
: '~/crmSearchAdmin/displays/searchAdminDisplayTable.html',
14 controller: function($scope
, searchMeta
) {
15 var ts
= $scope
.ts
= CRM
.ts('org.civicrm.search_kit'),
19 {name
: 'table', label
: ts('Row Borders')},
20 {name
: 'table-bordered', label
: ts('Column Borders')},
21 {name
: 'table-striped', label
: ts('Even/Odd Stripes')}
24 // Check if array contains item
25 this.includes
= _
.includes
;
27 // Add or remove an item from an array
28 this.toggle = function(collection
, item
) {
29 if (_
.includes(collection
, item
)) {
30 _
.pull(collection
, item
);
32 collection
.push(item
);
36 this.$onInit = function () {
37 if (!ctrl
.display
.settings
) {
38 ctrl
.display
.settings
= _
.extend({}, _
.cloneDeep(CRM
.crmSearchAdmin
.defaultDisplay
.settings
), {columns
: null});
39 if (searchMeta
.getEntity(ctrl
.apiEntity
).order_by
) {
40 ctrl
.display
.settings
.sort
.push([searchMeta
.getEntity(ctrl
.apiEntity
).order_by
, 'ASC']);
43 // Displays created prior to 5.43 may not have this property
44 ctrl
.display
.settings
.classes
= ctrl
.display
.settings
.classes
|| [];
45 ctrl
.parent
.initColumns({label
: true, sortable
: true});
51 })(angular
, CRM
.$, CRM
._
);