Afform - Fix endless spinner on "New Search Display" dropdown when there are none
authorColeman Watts <coleman@civicrm.org>
Thu, 8 Apr 2021 02:11:03 +0000 (22:11 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 8 Apr 2021 02:11:03 +0000 (22:11 -0400)
ext/afform/admin/ang/afAdmin/afAdminList.controller.js
ext/afform/admin/ang/afAdmin/afAdminList.html

index e16398426044508f73c41f1d0a53158771d1d8ea..f966af174689cfd2d8891751c41c154e061da544 100644 (file)
     $scope.types = _.indexBy(ctrl.tabs, 'name');
     _.each(['form', 'block', 'search'], function(type) {
       if ($scope.types[type]) {
-        $scope.types[type].options = [];
         if (type === 'form') {
           $scope.types.form.default = '#create/form/Individual';
         }
       }
     });
+    $scope.types.system.options = false;
 
     this.afforms = _.transform(afforms, function(afforms, afform) {
       afform.type = afform.type || 'system';
@@ -35,7 +35,7 @@
 
     this.createLinks = function() {
       ctrl.searchCreateLinks = '';
-      if ($scope.types[ctrl.tab].options.length) {
+      if ($scope.types[ctrl.tab].options) {
         return;
       }
       var links = [];
@@ -66,6 +66,7 @@
         $scope.types.block.options = _.sortBy(links, function(item) {
           return item.url === '#create/block/*' ? '0' : item.label;
         });
+        // Add divider after the * entity (content block)
         $scope.types.block.options.splice(1, 0, {'class': 'divider', label: ''});
       }
 
index c6ff0b7f860aa92da661bc1509d9a3c706aa6e1d..276e4d0538ba315ee5ea00e18deff2accba4f3f2 100644 (file)
@@ -10,7 +10,7 @@
   <div class="form-inline">
     <label for="afform-list-filter">{{:: ts('Filter:') }}</label>
     <input class="form-control" type="search" id="afform-list-filter" ng-model="$ctrl.searchAfformList" placeholder="&#xf002">
-    <div class="btn-group pull-right" ng-if="types[$ctrl.tab].options">
+    <div class="btn-group pull-right" ng-if="types[$ctrl.tab].options !== false">
       <a ng-if="types[$ctrl.tab].default" href="{{ types[$ctrl.tab].default }}" class="btn btn-primary">
         {{ ts('New %1', {1: types[$ctrl.tab].label }) }}
       </a>
         <span class="caret"></span>
       </button>
       <ul class="dropdown-menu">
-        <li>
-          <input ng-if="types[$ctrl.tab].options.length" type="search" class="form-control" placeholder="&#xf002" ng-model="searchCreateLinks.label">
-          <a href ng-if="!types[$ctrl.tab].options.length"><i class="crm-i fa-spinner fa-spin"></i></a>
+        <li ng-class="{disabled: !types[$ctrl.tab].options || !types[$ctrl.tab].options.length}">
+          <input ng-if="types[$ctrl.tab].options && types[$ctrl.tab].options.length" type="search" class="form-control" placeholder="&#xf002" ng-model="searchCreateLinks.label">
+          <a href ng-if="!types[$ctrl.tab].options"><i class="crm-i fa-spinner fa-spin"></i></a>
+          <a href ng-if="types[$ctrl.tab].options && !types[$ctrl.tab].options.length">{{:: ts('None Found') }}</a>
         </li>
         <li ng-repeat="link in types[$ctrl.tab].options | filter:searchCreateLinks" class="{{:: link.class }}">
           <a ng-if=":: link.url" href="{{:: link.url }}">