Allows an "Add new" button on drilldown searches.
<div af-fieldset="">
- <div class="af-markup">
- <div class="form-inline">
- <a class="btn btn-primary" target="crm-popup" ng-href="{{ crmUrl('civicrm/admin/custom/group/field/add', {gid: routeParams.gid, reset: 1}) }}">
- <i class="crm-i fa-plus-circle"></i>
- {{:: ts('Add Field') }}
- </a>
- <a class="btn btn-secondary" ng-href="{{ crmUrl('civicrm/admin/custom/group') }}">
- <i class="crm-i fa-times"></i>
- {{:: ts('Done') }}
- </a>
- </div>
- </div>
<crm-search-display-table search-name="Administer_Custom_Fields" display-name="Table" filters="{custom_group_id: routeParams.gid}"></crm-search-display-table>
</div>
FALSE,
],
],
+ 'addButton' => [
+ 'path' => 'civicrm/admin/custom/group/field/add?reset=1&action=add&gid=[custom_group_id]',
+ 'text' => E::ts('Add Custom Field'),
+ 'icon' => 'fa-plus',
+ ],
],
'acl_bypass' => FALSE,
],
-<a ng-href="{{ $ctrl.addButton.url }}" class="btn btn-primary" target="crm-popup">
- <i ng-if="$ctrl.addButton.icon" class="crm-i {{:: $ctrl.addButton.icon }}"></i>
- {{:: $ctrl.addButton.text }}
+<a ng-href="{{ $ctrl.getButtonUrl() }}" class="btn btn-primary" target="crm-popup">
+ <i ng-if="$ctrl.settings.addButton.icon" class="crm-i {{:: $ctrl.settings.addButton.icon }}"></i>
+ {{:: $ctrl.settings.addButton.text }}
</a>
for (var p=0; p < placeholderCount; ++p) {
this.placeholders.push({});
}
- // Calculate URL of addButton and copy addButton to controller property
- // It has to be copied rather than simply adding this.settings.addButton.url,
- // because settings cannot be changed when they are supplied from the markup
- if (this.settings.addButton && this.settings.addButton.path) {
- // Clone the variable to prevent polluting it during Preview mode in the Admin UI
- this.addButton = _.cloneDeep(this.settings.addButton);
- // TODO: Evaluate variables in the path
- this.addButton.url = CRM.url(this.addButton.path);
- }
this.getResults = _.debounce(function() {
$scope.$apply(function() {
return this.settings.actions || this.settings.draggable || (this.settings.tally && this.settings.tally.label);
},
+ getFilters: function() {
+ return _.assign({}, this.getAfformFilters(), this.filters);
+ },
+
getAfformFilters: function() {
return _.pick(this.afFieldset ? this.afFieldset.getFieldData() : {}, function(val) {
return val !== null && (_.includes(['boolean', 'number', 'object'], typeof val) || val.length);
sort: this.sort,
limit: this.limit,
seed: this.seed,
- filters: _.assign({}, this.getAfformFilters(), this.filters),
+ filters: this.getFilters(),
afform: this.afFieldset ? this.afFieldset.getFormName() : null
};
},
+ // Get path for the addButton
+ getButtonUrl: function() {
+ var path = this.settings.addButton.path,
+ filters = this.getFilters();
+ _.each(filters, function(value, key) {
+ path = path.replace('[' + key + ']', value);
+ });
+ return CRM.url(path);
+ },
+
onClickSearchButton: function() {
this.rowCount = null;
this.page = 1;
<div class="crm-search-display crm-search-display-grid">
<div class="form-inline">
<div class="btn-group" ng-include="'~/crmSearchDisplay/SearchButton.html'" ng-if="$ctrl.settings.button"></div>
- <div class="btn-group pull-right" ng-include="'~/crmSearchDisplay/AddButton.html'" ng-if="$ctrl.addButton"></div>
+ <div class="btn-group pull-right" ng-include="'~/crmSearchDisplay/AddButton.html'" ng-if="$ctrl.settings.addButton.path"></div>
</div>
<div
class="crm-search-display-grid-container crm-search-display-grid-layout-{{$ctrl.settings.colno}}"
<div class="crm-search-display crm-search-display-list">
<div class="form-inline">
<div class="btn-group" ng-include="'~/crmSearchDisplay/SearchButton.html'" ng-if="$ctrl.settings.button"></div>
- <div class="btn-group pull-right" ng-include="'~/crmSearchDisplay/AddButton.html'" ng-if="$ctrl.addButton"></div>
+ <div class="btn-group pull-right" ng-include="'~/crmSearchDisplay/AddButton.html'" ng-if="$ctrl.settings.addButton.path"></div>
</div>
<ol ng-if=":: $ctrl.settings.style === 'ol'" ng-include="'~/crmSearchDisplayList/crmSearchDisplayList' + ($ctrl.loading ? 'Loading' : 'Items') + '.html'" ng-style="{'list-style': $ctrl.settings.symbol}"></ol>
<ul ng-if=":: $ctrl.settings.style !== 'ol'" ng-include="'~/crmSearchDisplayList/crmSearchDisplayList' + ($ctrl.loading ? 'Loading' : 'Items') + '.html'" ng-style="{'list-style': $ctrl.settings.symbol}"></ul>
<div class="form-inline">
<div class="btn-group" ng-include="'~/crmSearchDisplay/SearchButton.html'" ng-if="$ctrl.settings.button"></div>
<crm-search-tasks ng-if="$ctrl.settings.actions" entity="$ctrl.apiEntity" ids="$ctrl.selectedRows" search="$ctrl.search" display="$ctrl.display" display-controller="$ctrl" refresh="$ctrl.refreshAfterTask()"></crm-search-tasks>
- <div class="btn-group pull-right" ng-include="'~/crmSearchDisplay/AddButton.html'" ng-if="$ctrl.addButton"></div>
+ <div class="btn-group pull-right" ng-include="'~/crmSearchDisplay/AddButton.html'" ng-if="$ctrl.settings.addButton.path"></div>
</div>
<table class="{{:: $ctrl.settings.classes.join(' ') }}">
<thead>