added conditional to show message if no lists are found
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 26 May 2016 12:54:08 +0000 (08:54 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 26 May 2016 12:54:08 +0000 (08:54 -0400)
class-streamsendfeedaddon.php

index 75adfc6..464726c 100644 (file)
@@ -115,6 +115,34 @@ class GFStreamSendAddOn extends GFFeedAddOn
         }
         array_unshift($lists,array('label'=>'Select a List', 'value'=>''));
         
+        if(!empty($lists)){
+            $listArray = array(
+                'label'   => 'Lists',
+                'type'    => 'select',
+                'name'    => 'lists',
+                'tooltip' => 'Select a list to add the contact',
+                'choices' => $lists
+            );
+        } else {
+          $listArray = array(
+                'label'   => 'Lists',
+                'type'    => 'text',
+                'name'    => 'noLists',
+                'value'   => 'No lists detected'
+            );
+        }
+        ?>  
+        <script type="text/javascript">
+            document.addEventListener("DOMContentLoaded", function(event) { 
+                var list = document.getElementById('noLists');
+                list.style.background = "none";
+                list.readOnly = true;   
+                list.style.border = "none";
+                list.style.color = "red";
+                list.style.boxShadow = "none";
+        });
+        </script>
+        <?php
         return array(
             array(
                 'title'  => 'StreamSend Form Settings',
@@ -127,14 +155,7 @@ class GFStreamSendAddOn extends GFFeedAddOn
                         'tooltip' => esc_html__( 'Just a name', 'StreamSend' ),
                         'class'   => 'small',
                     ),
-                    array(
-                         'label'   => 'Lists',
-                         'type'    => 'select',
-                         'name'    => 'lists',
-                         'tooltip' => 'Select a list to add the contact',
-                         'choices' => $lists
-                               
-                        ),
+                    $listArray,
                     array(
                          'label'   => 'Enable Opt-In',
                          'type'    => 'checkbox',