GUI: Add new block to the top
authorColeman Watts <coleman@civicrm.org>
Mon, 25 Nov 2019 14:56:25 +0000 (09:56 -0500)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:20 +0000 (19:13 -0700)
Creates new items at top of block, underneath the fieldset legend if present

ext/afform/gui/ang/afGuiEditor.js

index 2db100106cc93415f7a061438852baebd2afd78e..7ad8e075ede3ce9895863311503ebe04a0a1c6a9 100644 (file)
           } else if (classes[0] === 'af-text' || classes[0] === 'af-button') {
             newBlock['#children'] = [{'#text': ts('Enter text')}];
           }
-          $scope.node['#children'].push(newBlock);
+          // Add new block to the top, underneath the fieldset legend if present
+          var pos = $scope.node['#children'].length && $scope.node['#children'][0]['#tag'] === 'legend' ? 1 : 0;
+          $scope.node['#children'].splice(pos, 0, newBlock);
         };
 
         this.removeBlock = function(node) {