-<a href="{{ $ctrl.settings.addButton.url }}" 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 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>
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) {
- this.settings.addButton.url = CRM.url(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() {
<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.settings.addButton.url"></div>
+ <div class="btn-group pull-right" ng-include="'~/crmSearchDisplay/AddButton.html'" ng-if="$ctrl.addButton"></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.settings.addButton.url"></div>
+ <div class="btn-group pull-right" ng-include="'~/crmSearchDisplay/AddButton.html'" ng-if="$ctrl.addButton"></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.settings.addButton.url"></div>
+ <div class="btn-group pull-right" ng-include="'~/crmSearchDisplay/AddButton.html'" ng-if="$ctrl.addButton"></div>
</div>
<table class="{{:: $ctrl.settings.classes.join(' ') }}">
<thead>