From 687d7713f25ece823a0d5f07741df228cec09e61 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 27 Aug 2021 09:39:50 -0400 Subject: [PATCH] Afform - Fix button appearance and block form during submission --- ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php | 2 +- ext/afform/core/ang/af/afForm.component.js | 5 ++++- ext/afform/core/ang/afCore.css | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php b/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php index fa8554171b..2c273ab9ac 100644 --- a/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php +++ b/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php @@ -213,7 +213,7 @@ class AfformAdminMeta { 'title' => E::ts('Submit Button'), 'element' => [ '#tag' => 'button', - 'class' => 'af-button btn-primary', + 'class' => 'af-button btn btn-primary', 'crm-icon' => 'fa-check', 'ng-click' => 'afform.submit()', '#children' => [ diff --git a/ext/afform/core/ang/af/afForm.component.js b/ext/afform/core/ang/af/afForm.component.js index 0b3c2d4453..888953f499 100644 --- a/ext/afform/core/ang/af/afForm.component.js +++ b/ext/afform/core/ang/af/afForm.component.js @@ -4,7 +4,7 @@ bindings: { ctrl: '@' }, - controller: function($scope, $timeout, crmApi4, crmStatus, $window, $location, FileUploader) { + controller: function($scope, $element, $timeout, crmApi4, crmStatus, $window, $location, FileUploader) { var schema = {}, data = {}, status, @@ -79,10 +79,13 @@ $window.location.href = url; } status.resolve(); + $element.unblock(); } this.submit = function() { status = CRM.status({}); + $element.block(); + crmApi4('Afform', 'submit', { name: ctrl.getFormMeta().name, args: $scope.$parent.routeParams || {}, diff --git a/ext/afform/core/ang/afCore.css b/ext/afform/core/ang/afCore.css index 124ead36ff..d1c8f0874d 100644 --- a/ext/afform/core/ang/afCore.css +++ b/ext/afform/core/ang/afCore.css @@ -17,6 +17,9 @@ a.af-api4-action-idle { margin-right: .5em; vertical-align: top; } +af-form { + display: block; +} [af-repeat-item] { position: relative; -- 2.25.1