add manual processing option
authorKurund Jalmi <kurundjalmi@thirdsectordesign.org>
Mon, 21 Aug 2023 13:51:25 +0000 (14:51 +0100)
committerKurund Jalmi <kurundjalmi@thirdsectordesign.org>
Wed, 6 Dec 2023 00:23:33 +0000 (00:23 +0000)
ext/afform/admin/ang/afGuiEditor/afGuiEditor.component.js
ext/afform/admin/ang/afGuiEditor/config-form.html
ext/afform/core/Civi/Api4/Action/Afform/Submit.php
ext/afform/core/Civi/Api4/Afform.php

index f593defc15d1a03a08d290bea16cdc4a94756914..6a80ebbd307a66599a77759d70ac217ed08a9b41 100644 (file)
         }
       };
 
+      this.toggleManualProcessing = function() {
+        if (editor.afform.manual_processing) {
+          editor.afform.manual_processing = null;
+        } else {
+          editor.afform.create_submission = true;
+        }
+      }
+
       this.toggleEmailVerification = function() {
-        if (editor.afform.require_email_confirmation) {
-          editor.afform.require_email_confirmation = null;
+        if (editor.afform.allow_verification_by_email) {
+          editor.afform.allow_verification_by_email = null;
         } else {
           editor.afform.create_submission = true;
+          editor.afform.manual_processing = true;
         }
       }
 
         // This might be set to undefined by validation
         afform.server_route = afform.server_route || '';
         // create submission is required if email confirmation is selected.
-        if (afform.require_email_confirmation) {
+        if (afform.manual_processing || afform.allow_verification_by_email) {
           afform.create_submission = true;
         }
         $scope.saving = true;
index 0d2701e0c595bd62876289afbf35589aa4957b8b..126841257b5dc5ce0b264f0bf5bb4affaed60af0 100644 (file)
       {{:: ts('Submissions') }}
     </legend>
 
+<<<<<<< HEAD
     <p class="form-inline">
       <label class="radio">
         <input class="crm-form-radio" type="radio" name="submit_enabled" ng-model="editor.afform.submit_enabled" ng-value="true">
         {{:: ts('Open') }}
+=======
+    <div class="form-group" >
+      <label>
+        <input type="checkbox" ng-model="editor.afform.create_submission" ng-class="{'disabled': !!editor.afform.manual_processing}">
+        {{:: ts('Log Submissions') }}
+>>>>>>> c04192a7f4 (add manual processing option)
       </label>
       <label class="radio">
         <input class="crm-form-radio" type="radio" name="submit_enabled" ng-model="editor.afform.submit_enabled" ng-value="false">
 
       <div class="form-group" >
         <label>
-          <input type="checkbox" ng-model="editor.afform.require_email_confirmation" ng-click="editor.toggleEmailVerification()">
-          {{:: ts('Verify email before processing') }}
+          <input type="checkbox" ng-model="editor.afform.manual_processing" ng-click="editor.toggleManualProcessing()" ng-class="{'disabled': !!editor.afform.allow_verification_by_email}">
+          {{:: ts('Verify submission before processing') }}
+        </label>
+        <p class="help-block">{{:: ts('The data will be processed manually using Form Sumbission action.') }}</p>
+      </div>
+
+      <div class="form-group" ng-if="!!editor.afform.manual_processing">
+        <label>
+          <input type="checkbox" ng-model="editor.afform.allow_verification_by_email" ng-click="editor.toggleEmailVerification()">
+          {{:: ts('Allow verification by email') }}
         </label>
-        <p class="help-block">{{:: ts('The data will be processed and stored in CiviCRM only after email verfication. Email field is required if you enable this setting.') }}</p>
+        <p class="help-block">{{:: ts('The data will be processed and stored in CiviCRM after email verfication. Email field is required if you enable this setting.') }}</p>
       </div>
 
       <div class="form-group" ng-class="{'has-error': !!config_form.redirect.$error.pattern}">
index 90ba0f08665c389d042d0e74301cb34a37e54552..ffea5c188fd6671254e508a8abfa46170a5a06bd 100644 (file)
@@ -44,7 +44,7 @@ class Submit extends AbstractProcessor {
     // Save submission record
     if (!empty($this->_afform['create_submission'])) {
       $status = 'Processed';
-      if (!empty($this->_afform['require_email_confirmation'])) {
+      if (!empty($this->_afform['manual_processing'])) {
         $status = 'Pending';
       }
 
@@ -57,7 +57,7 @@ class Submit extends AbstractProcessor {
     }
 
     // let's not save the data in other CiviCRM table if email verification is needed.
-    if (!empty($this->_afform['require_email_confirmation'])) {
+    if (!empty($this->_afform['manual_processing'])) {
       return [];
     }
 
index c19a81aa52b5560526feffb50414aaa6efabe385..0484f05330ac005d16cf61738e651a1916d2b2e8 100644 (file)
@@ -241,9 +241,17 @@ class Afform extends Generic\AbstractEntity {
           'data_type' => 'Boolean',
         ],
         [
-          'name' => 'require_email_confirmation',
+          'name' => 'manual_processing',
           'data_type' => 'Boolean',
         ],
+        [
+          'name' => 'allow_verification_by_email',
+          'data_type' => 'Boolean',
+        ],
+        [
+          'name' => 'email_confirmation_template_id',
+          'data_type' => 'Integer',
+        ],
         [
           'name' => 'navigation',
           'title' => E::ts('Navigation Menu'),