})
// Controller for tabbed view of SavedSearches
- .controller('searchList', function($scope, $timeout, searchMeta, formatForSelect2, dialogService) {
+ .controller('searchList', function($scope, $timeout, searchMeta, formatForSelect2) {
var ts = $scope.ts = CRM.ts('org.civicrm.search_kit'),
ctrl = $scope.$ctrl = this;
searchEntity = 'SavedSearch';
return {results: formatForSelect2(CRM.crmSearchAdmin.tags, 'id', 'name', ['color', 'description'])};
};
+ this.getPrimaryEntities = function() {
+ this.primaryEntities = _.filter(CRM.crmSearchAdmin.schema, {searchable: 'primary'});
+ };
+
// Tabs include a rowCount which will be updated by the search controller
this.tabs = [
{name: 'custom', title: ts('Custom Searches'), icon: 'fa-search-plus', rowCount: null, filters: {has_base: false}},
</a>
</li>
</ul>
- <a class="btn btn-primary" href="#/create/Contact/" ng-if="$ctrl.tab !== 'segment'">
- <i class="crm-i fa-plus"></i>
- {{:: ts('New Search') }}
- </a>
- <a class="btn btn-primary" href ng-if="$ctrl.tab === 'segment'" title="{{:: ts('New Data Segment') }}" crm-dialog-popup="searchSegmentDialog" popup-tpl="~/crmSearchAdmin/searchSegment/editDialog.html">
- <i class="crm-i fa-plus"></i>
- {{:: ts('New Segment') }}
- </a>
+ <div class="btn-group" ng-if="$ctrl.tab !== 'segment'">
+ <a class="btn btn-primary" href="#/create/Contact" >
+ <i class="crm-i fa-plus"></i>
+ {{:: ts('New Search') }}
+ </a>
+ <button type="button" ng-click="$ctrl.getPrimaryEntities()" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu dropdown-menu-right">
+ <li ng-repeat="entity in $ctrl.primaryEntities">
+ <a ng-href="#/create/{{ entity.name }}">
+ <i class="crm-i {{:: entity.icon }}"></i>
+ {{:: entity.title_plural }}
+ </a>
+ </li>
+ <li title="{{:: ts('Choose other entities on the search screen') }}">
+ <a href="#/create/Contact">{{:: ts('More...') }}</a>
+ </li>
+ </ul>
+ </div>
+ <div class="btn-group" ng-if="$ctrl.tab === 'segment'">
+ <a class="btn btn-primary" href title="{{:: ts('New Data Segment') }}" crm-dialog-popup="searchSegmentDialog" popup-tpl="~/crmSearchAdmin/searchSegment/editDialog.html">
+ <i class="crm-i fa-plus"></i>
+ {{:: ts('New Data Segment') }}
+ </a>
+ <button type="button" ng-click="$ctrl.getPrimaryEntities()" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu dropdown-menu-right">
+ <li ng-repeat="entity in $ctrl.primaryEntities">
+ <a href title="{{:: ts('New Data Segment') }}" crm-dialog-popup="searchSegmentDialog" popup-tpl="~/crmSearchAdmin/searchSegment/editDialog.html" popup-data="{entity_name: entity.name}">
+ <i class="crm-i {{:: entity.icon }}"></i>
+ {{:: entity.title_plural }}
+ </a>
+ </li>
+ <li title="{{:: ts('Choose other entities on the search screen') }}">
+ <a href title="{{:: ts('New Data Segment') }}" crm-dialog-popup="searchSegmentDialog" popup-tpl="~/crmSearchAdmin/searchSegment/editDialog.html">{{:: ts('More...') }}</a>
+ </li>
+ </ul>
+ </div>
</div>
<div ng-repeat="tab in $ctrl.tabs" ng-show="$ctrl.tab === tab.name">
angular.module('crmSearchAdmin').component('crmSearchAdminSegment', {
bindings: {
- segmentId: '<',
+ segment: '<',
},
templateUrl: '~/crmSearchAdmin/searchSegment/crmSearchAdminSegment.html',
controller: function ($scope, searchMeta, dialogService, crmApi4, crmStatus) {
this.entitySelect = searchMeta.getPrimaryAndSecondaryEntitySelect();
ctrl.saving = false;
- ctrl.segment = {items: []};
// Drag-n-drop settings for reordering items
this.sortableOptions = {
};
this.$onInit = function() {
- if (ctrl.segmentId) {
+ if (ctrl.segment.id) {
$('.ui-dialog:visible').block();
crmApi4('SearchSegment', 'get', {
- where: [['id', '=', ctrl.segmentId]]
+ where: [['id', '=', ctrl.segment.id]]
}, 0).then(function(segment) {
ctrl.segment = segment;
originalEntity = segment.entity_name;
searchMeta.loadFieldOptions([segment.entity_name]);
$('.ui-dialog:visible').unblock();
});
+ } else {
+ ctrl.segment.items = [];
+ ctrl.onChangeEntity();
}
};
<br>
<div class="form-inline">
<label for="search-segment-entity_name">{{:: ts('For') }} <span class="crm-marker">*</span></label>
- <input id="search-segment-entity_name" class="form-control collapsible-optgroups" required ng-model="$ctrl.segment.entity_name" ng-change="$ctrl.onChangeEntity()" crm-ui-select="{allowClear: false, data: $ctrl.entitySelect, placeholder: ts('Entity')}">
+ <input id="search-segment-entity_name" class="form-control huge collapsible-optgroups" required ng-model="$ctrl.segment.entity_name" ng-change="$ctrl.onChangeEntity()" crm-ui-select="{allowClear: false, data: $ctrl.entitySelect, placeholder: ts('Entity')}">
</div>
<br>
<fieldset>
<div crm-dialog="searchSegmentDialog">
- <crm-search-admin-segment segment-id="model.data.id"></crm-search-admin-segment>
+ <crm-search-admin-segment segment="model"></crm-search-admin-segment>
</div>
<div class="text-right">
<div class="btn-group btn-group-xs">
- <a class="btn btn-primary" href crm-dialog-popup="searchSegmentDialog" popup-tpl="~/crmSearchAdmin/searchSegment/editDialog.html" popup-data="row" title="{{:: ts('Edit Data Segment') }}">
+ <a class="btn btn-primary" href crm-dialog-popup="searchSegmentDialog" popup-tpl="~/crmSearchAdmin/searchSegment/editDialog.html" popup-data="row.data" title="{{:: ts('Edit Data Segment') }}">
<i class="crm-i fa-pencil"></i>
{{:: ts('Edit') }}
</a>
#bootstrap-theme .crm-search-nav-tabs {
position: relative;
}
-#bootstrap-theme .crm-search-nav-tabs > a.btn {
+#bootstrap-theme .crm-search-nav-tabs > div.btn-group {
position: absolute;
right: 0;
top: 0;