Skip to content
Snippets Groups Projects
Unverified Commit 2934bc6f authored by Eileen McNaughton's avatar Eileen McNaughton Committed by GitHub
Browse files

Merge pull request #21343 from colemanw/searchKitLinks

SearchKit - Add links to admin table and refresh after popups
parents c71dfd27 9a4c649d
Branches
Tags
No related merge requests found
......@@ -68,6 +68,7 @@ class Admin {
return [
'default' => E::ts('Default'),
'primary' => E::ts('Primary'),
'secondary' => E::ts('Secondary'),
'success' => E::ts('Success'),
'info' => E::ts('Info'),
'warning' => E::ts('Warning'),
......
......@@ -583,19 +583,26 @@
switch (link.action) {
case 'view':
link.title = ts('View %1', {1: entityName});
link.icon = 'fa-external-link';
link.style = 'default';
break;
case 'update':
link.title = ts('Edit %1', {1: entityName});
link.icon = 'fa-pencil';
link.style = 'default';
break;
case 'delete':
link.title = ts('Delete %1', {1: entityName});
link.icon = 'fa-trash';
link.style = 'danger';
break;
}
}
// Links to main entity
// @return {Array}
var mainEntity = searchMeta.getEntity(ctrl.savedSearch.api_entity),
links = _.cloneDeep(mainEntity.paths || []);
_.each(links, function(link) {
......
......@@ -31,18 +31,6 @@
}
};
var defaultIcons = {
view: 'fa-external-link',
update: 'fa-pencil',
delete: 'fa-trash'
};
var defaultStyles = {
view: 'primary',
update: 'warning',
delete: 'danger'
};
$scope.pickIcon = function(index) {
searchMeta.pickIcon().then(function(icon) {
ctrl.group[index].icon = icon;
......@@ -53,9 +41,9 @@
var link = ctrl.getLink(path);
ctrl.group.push({
path: path,
style: link && defaultStyles[link.action] || 'default',
style: link && link.style || 'default',
text: link ? link.title : ts('Link'),
icon: link && defaultIcons[link.action] || 'fa-external-link'
icon: link && link.icon || 'fa-external-link'
});
};
......
......@@ -12,12 +12,13 @@
{{:: ts('Style') }}
</label>
<select id="crm-search-admin-col-style-{{$index}}" class="form-control" ng-model="col.style">
<option ng-repeat="opt in $ctrl.parent.styles" value="{{ opt.key }}">{{ opt.value }}</option>
<option ng-repeat="opt in $ctrl.parent.styles" value="{{:: opt.key }}">{{:: opt.value }}</option>
<option ng-repeat="opt in $ctrl.parent.styles" value="{{:: opt.key + '-outline' }}">{{:: opt.value + ' ' + ts('Outline') }}</option>
</select>
</div>
<div class="form-inline">
<label>
{{:: ts('Menu Text/Icon') }}
{{:: ts('Menu Icon/Text') }}
</label>
<div class="btn-group">
<button type="button" class="btn btn-{{ col.style + ' ' + col.size }}">
......
......@@ -10,7 +10,7 @@
crmSearchAdmin: '^crmSearchAdmin'
},
templateUrl: '~/crmSearchAdmin/resultsTable/crmSearchAdminResultsTable.html',
controller: function($scope, searchMeta, searchDisplayBaseTrait, searchDisplayTasksTrait, searchDisplaySortableTrait) {
controller: function($scope, $element, searchMeta, searchDisplayBaseTrait, searchDisplayTasksTrait, searchDisplaySortableTrait) {
var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
// Mix in traits to this controller
ctrl = angular.extend(this, searchDisplayBaseTrait, searchDisplayTasksTrait, searchDisplaySortableTrait);
......@@ -49,6 +49,25 @@
})
}
};
if (links.length) {
ctrl.display.settings.columns.push({
text: '',
icon: 'fa-bars',
type: 'menu',
size: 'btn-xs',
style: 'secondary-outline',
alignment: 'text-right',
links: _.transform(links, function(links, link) {
links.push({
path: link.path,
text: link.title,
icon: link.icon,
style: link.style,
target: link.action === 'view' ? '_blank' : 'crm-popup'
});
})
});
}
ctrl.debug = {
apiParams: JSON.stringify(ctrl.search.api_params, null, 2)
};
......@@ -57,7 +76,7 @@
this.$onInit = function() {
buildSettings();
this.initializeDisplay($scope, $());
this.initializeDisplay($scope, $element);
$scope.$watch('$ctrl.search.api_entity', buildSettings);
$scope.$watch('$ctrl.search.api_params', buildSettings, true);
};
......
......@@ -90,6 +90,8 @@
});
}
$element.on('crmPopupFormSuccess', this.getResults);
function onChangeFilters() {
ctrl.page = 1;
ctrl.rowCount = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment