From 34f37d59006d6883e2ec22ce371b9a90f85ac5e9 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 1 Feb 2021 17:46:26 -0500 Subject: [PATCH] Afform Gui - Basic validation & defaults for server_route --- ext/afform/admin/CRM/AfformAdmin/Upgrader.php | 22 +++++++++---------- .../ang/afGuiEditor/afGuiEditor.component.js | 5 ++++- .../admin/ang/afGuiEditor/config-form.html | 8 +++---- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/ext/afform/admin/CRM/AfformAdmin/Upgrader.php b/ext/afform/admin/CRM/AfformAdmin/Upgrader.php index 5a402f727a..616e6305cc 100644 --- a/ext/afform/admin/CRM/AfformAdmin/Upgrader.php +++ b/ext/afform/admin/CRM/AfformAdmin/Upgrader.php @@ -29,7 +29,7 @@ class CRM_AfformAdmin_Upgrader extends CRM_AfformAdmin_Upgrader_Base { 'permission' => 'administer CiviCRM', 'url' => 'civicrm/admin/afform', 'is_active' => 1, - 'icon' => 'crm-i fa-list-alt' + 'icon' => 'crm-i fa-list-alt', ]); } } @@ -55,15 +55,15 @@ class CRM_AfformAdmin_Upgrader extends CRM_AfformAdmin_Upgrader_Base { * @return TRUE on success * @throws Exception */ - public function upgrade_0001() { - $this->ctx->log->info('Applying update 0001'); - \Civi\Api4\Navigation::update(FALSE) - ->addValue('icon', 'crm-i fa-list-alt') - ->addValue('label', E::ts('Form Builder')) - ->addValue('name', 'afform_admin') - ->addWhere('name', '=', 'afform_gui') - ->execute(); - return TRUE; - } + public function upgrade_0001() { + $this->ctx->log->info('Applying update 0001'); + \Civi\Api4\Navigation::update(FALSE) + ->addValue('icon', 'crm-i fa-list-alt') + ->addValue('label', E::ts('Form Builder')) + ->addValue('name', 'afform_admin') + ->addWhere('name', '=', 'afform_gui') + ->execute(); + return TRUE; + } } diff --git a/ext/afform/admin/ang/afGuiEditor/afGuiEditor.component.js b/ext/afform/admin/ang/afGuiEditor/afGuiEditor.component.js index 288a4bb503..d617cad649 100644 --- a/ext/afform/admin/ang/afGuiEditor/afGuiEditor.component.js +++ b/ext/afform/admin/ang/afGuiEditor/afGuiEditor.component.js @@ -179,8 +179,11 @@ }; $scope.save = function() { + var afform = JSON.parse(angular.toJson($scope.afform)); + // This might be set to undefined by validation + afform.server_route = afform.server_route || ''; $scope.saving = $scope.changesSaved = true; - crmApi4('Afform', 'save', {formatWhitespace: true, records: [JSON.parse(angular.toJson($scope.afform))]}) + crmApi4('Afform', 'save', {formatWhitespace: true, records: [afform]}) .then(function (data) { $scope.saving = false; $scope.afform.name = data[0].name; diff --git a/ext/afform/admin/ang/afGuiEditor/config-form.html b/ext/afform/admin/ang/afGuiEditor/config-form.html index 58630edfa5..1a3ac253c8 100644 --- a/ext/afform/admin/ang/afGuiEditor/config-form.html +++ b/ext/afform/admin/ang/afGuiEditor/config-form.html @@ -4,7 +4,7 @@ - +
@@ -18,10 +18,10 @@
- -

{{:: ts('Expose the form as a standalone page on the web site. (Example: "civicrm/my-form")') }}

+ +

{{:: ts('Expose the form as a standalone webpage. (Must begin with "civicrm/" e.g. "civicrm/my-form")') }}

-- 2.25.1