'name' => 'icon',
],
[
- 'number' => 'icon',
+ 'name' => 'number',
],
[
'name' => 'apiBatch',
this.getLinks = function(columnKey) {
if (!ctrl.links) {
ctrl.links = {'*': ctrl.crmSearchAdmin.buildLinks(), '0': []};
+ ctrl.links[''] = _.filter(ctrl.links['*'], {join: ''});
+ searchMeta.getSearchTasks(ctrl.savedSearch.api_entity).then(function(tasks) {
+ _.each(tasks, function (task) {
+ if (task.number === '> 0' || task.number === '=== 1') {
+ var link = {
+ text: task.title,
+ icon: task.icon,
+ task: task.name,
+ entity: ctrl.savedSearch.api_entity,
+ target: 'crm-popup',
+ join: '',
+ style: task.name === 'delete' ? 'danger' : 'default'
+ };
+ ctrl.links['*'].push(link);
+ ctrl.links[''].push(link);
+ }
+ });
+ });
}
if (!columnKey) {
return ctrl.links['*'];
controller: function ($scope, $element, $timeout, searchMeta) {
var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
ctrl = this,
- linkProps = ['path', 'entity', 'action', 'join', 'target', 'icon', 'text', 'style', 'condition'];
+ linkProps = ['path', 'task', 'entity', 'action', 'join', 'target', 'icon', 'text', 'style', 'condition'];
ctrl.permissionOperators = [
{key: '=', value: ts('Has')},
path: 'civicrm/'
});
var defaultLinks = _.filter(ctrl.links, function(link) {
- return !link.join;
+ return link.action && !link.join;
});
_.each(ctrl.group, function(item) {
setDefaults(item, item);
};
this.getLink = function() {
- return _.findWhere(ctrl.links, {action: ctrl.link.action, join: ctrl.link.join, entity: ctrl.link.entity});
+ return _.find(ctrl.links, function(link) {
+ if (ctrl.link.task && link.task === ctrl.link.task && link.entity === ctrl.link.entity) {
+ return true;
+ } else if (ctrl.link.action && link.action === ctrl.link.action && link.entity === ctrl.link.entity && link.join == ctrl.link.join) {
+ return true;
+ }
+ return false;
+ });
};
}
<div class="crm-flex-1 input-group" >
- <input type="text" class="form-control" ng-if="!$ctrl.link.action" ng-model="$ctrl.link.path" ng-model-options="{updateOn: 'blur'}" ng-change="$ctrl.onChange({newLink: $ctrl.link})">
- <div class="input-group-btn" style="{{ $ctrl.link.action ? '' : 'width:27px' }}">
- <button type="button" ng-click="$ctrl.menuOpen = true;" class="btn btn-sm btn-secondary-outline dropdown-toggle crm-search-admin-combo-button" ng-if="$ctrl.link.action" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ <input type="text" class="form-control" ng-if="!$ctrl.link.action && !$ctrl.link.task" ng-model="$ctrl.link.path" ng-model-options="{updateOn: 'blur'}" ng-change="$ctrl.onChange({newLink: $ctrl.link})">
+ <div class="input-group-btn" style="{{ $ctrl.link.action || $ctrl.link.task ? '' : 'width:27px' }}">
+ <button type="button" ng-click="$ctrl.menuOpen = true;" class="btn btn-sm btn-secondary-outline dropdown-toggle crm-search-admin-combo-button" ng-if="$ctrl.link.action || $ctrl.link.task" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ $ctrl.getLink().text }}
</button>
<button type="button" ng-click="$ctrl.menuOpen = true;" class="btn btn-sm btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
</button>
- <ul class="dropdown-menu {{ $ctrl.link.action ? '' : 'dropdown-menu-right' }}" style="min-width: 223px;">
+ <ul class="dropdown-menu {{ $ctrl.link.action || $ctrl.link.task ? '' : 'dropdown-menu-right' }}" style="min-width: 223px;">
<li ng-repeat="link in $ctrl.links" ng-class="{disabled: link === $ctrl.getLink()}">
- <a href ng-click="$ctrl.setValue(link)">{{:: link.text }}</a>
+ <a href ng-click="$ctrl.setValue(link)">
+ <i class="crm-i {{:: link.icon }}"></i>
+ {{:: link.text }}
+ </a>
</li>
- <li ng-class="{disabled: !$ctrl.link.action}">
+ <li ng-class="{disabled: !$ctrl.link.action && !$ctrl.link.task}">
<a href ng-click="$ctrl.setValue({path: 'civicrm/'})">
+ <i class="crm-i fa-terminal"></i>
{{:: ts('Other...') }}
</a>
</li>
</ul>
</div>
</div>
-<crm-search-admin-token-select ng-if="!$ctrl.link.action" model="$ctrl.link" field="path"></crm-search-admin-token-select>
+<crm-search-admin-token-select ng-if="!$ctrl.link.action && !$ctrl.link.task" model="$ctrl.link" field="path"></crm-search-admin-token-select>
<option value="_blank">{{:: ts('New tab') }}</option>
<option value="crm-popup">{{:: ts('Popup dialog') }}</option>
</select>
- <crm-search-admin-link-select ng-if="col.link" link="col.link" on-change="$ctrl.parent.onChangeLink(col, newLink)" api-entity="$ctrl.apiEntity" api-params="$ctrl.apiParams" links=":: $ctrl.parent.getLinks(col.key)">
+ <crm-search-admin-link-select ng-if="col.link" link="col.link" on-change="$ctrl.parent.onChangeLink(col, newLink)" api-entity="$ctrl.apiEntity" api-params="$ctrl.apiParams" links="$ctrl.parent.getLinks(col.key)">
</crm-search-admin-link-select>
</div>
<div class="form-inline crm-search-admin-flex-row">