From: Coleman Watts Date: Mon, 19 Sep 2022 15:18:00 +0000 (-0400) Subject: SearchKit - Fix 'Add New' button X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=06e0b279b7232a994fc460277b855b190a87941d;p=civicrm-core.git SearchKit - Fix 'Add New' button --- diff --git a/ext/search_kit/ang/crmSearchDisplay/AddButton.html b/ext/search_kit/ang/crmSearchDisplay/AddButton.html index 29c6b72536..93135230da 100644 --- a/ext/search_kit/ang/crmSearchDisplay/AddButton.html +++ b/ext/search_kit/ang/crmSearchDisplay/AddButton.html @@ -1,4 +1,4 @@ - - - {{:: $ctrl.settings.addButton.text }} + + + {{:: $ctrl.addButton.text }} diff --git a/ext/search_kit/ang/crmSearchDisplay/traits/searchDisplayBaseTrait.service.js b/ext/search_kit/ang/crmSearchDisplay/traits/searchDisplayBaseTrait.service.js index 5bfdafcecb..e9b5bf051e 100644 --- a/ext/search_kit/ang/crmSearchDisplay/traits/searchDisplayBaseTrait.service.js +++ b/ext/search_kit/ang/crmSearchDisplay/traits/searchDisplayBaseTrait.service.js @@ -26,9 +26,14 @@ 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() { diff --git a/ext/search_kit/ang/crmSearchDisplayGrid/crmSearchDisplayGrid.html b/ext/search_kit/ang/crmSearchDisplayGrid/crmSearchDisplayGrid.html index 710f0dfa69..7722006a24 100644 --- a/ext/search_kit/ang/crmSearchDisplayGrid/crmSearchDisplayGrid.html +++ b/ext/search_kit/ang/crmSearchDisplayGrid/crmSearchDisplayGrid.html @@ -1,7 +1,7 @@
-
+
-
+
      diff --git a/ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.html b/ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.html index 3d57aedf18..285c3f1b45 100644 --- a/ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.html +++ b/ext/search_kit/ang/crmSearchDisplayTable/crmSearchDisplayTable.html @@ -2,7 +2,7 @@
      -
      +