From 2dab956b4d9cd32ef8fdb34bbef7f41499f157b4 Mon Sep 17 00:00:00 2001
From: Axel Rutz <axel.rutz@clever-systems.net>
Date: Mon, 8 Jun 2015 16:41:01 +0200
Subject: [PATCH] Issue #2415879: No visual feed back

---
 rules_batch.rules.inc | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/rules_batch.rules.inc b/rules_batch.rules.inc
index 00b224d..46cde51 100755
--- a/rules_batch.rules.inc
+++ b/rules_batch.rules.inc
@@ -32,6 +32,11 @@ class RulesBatchLoop extends RulesLoop {
 
   protected $itemName = 'batch loop';
 
+  public function __construct($settings = array(), $variables = NULL) {
+    parent::__construct($settings, $variables);
+    $this->settings['progressive'] = FALSE;
+  }
+
   public function evaluate(RulesState $state) {
 
     try {
@@ -42,6 +47,7 @@ class RulesBatchLoop extends RulesLoop {
         'init_message' => t('Starting rules batch'),
         'progress_message' => t('Processed @current out of @total.'),
         'error_message' => t('Rules Batch has encountered an error.'),
+        'progressive' => $this->settings['progressive'],
       );
 
       batch_set($batch);
@@ -75,4 +81,29 @@ class RulesBatchLoop extends RulesLoop {
  */
 class RulesBatchLoopUI extends RulesLoopUI {
 
+  public function form(&$form, &$form_state, $options = array()) {
+    parent::form($form, $form_state, $options);
+    $settings = $this->element->settings;
+
+    $form['settings'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Settings'),
+      '#description' => t('Show the progress bar if you want to use this loop in the UI, otherwise if this loop is used in a scheduled rule do not show the progress bar.'),
+      '#tree' => TRUE,
+    );
+
+    $form['settings']['progressive'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Show the progress bar'),
+      '#default_value' => $settings['progressive'],
+    );
+  }
+
+  function form_extract_values($form, &$form_state) {
+    parent::form_extract_values($form, $form_state);
+    $form_values = RulesPluginUI::getFormStateValues($form, $form_state);
+
+    $this->element->settings['progressive'] = $form_values['settings']['progressive'];
+  }
+
 }
-- 
2.1.0

