adding member index view file to the flyout, adding editMember action and ajax model
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 27 Dec 2018 18:55:40 +0000 (13:55 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 27 Dec 2018 18:55:40 +0000 (13:55 -0500)
models/admin/ajax/adminSearch.php
models/admin/ajax/memberEdit.php [new file with mode: 0644]
models/admin/manageDashboard/members.php
models/admin/member/memberEdit.php
setup/validActions.php
views/admin/manageDashboard/index.html
views/admin/manageDashboard/list.html
views/admin/members/index.html

index 53b0339..48adaa6 100644 (file)
@@ -89,7 +89,7 @@ class GlmMembersAdmin_ajax_adminSearch
 
         $status = $this->config['status_numb']['Active'];
         $list   = apply_filters('glm-member-db-admin-search', '');
-        $this->write_log("LIST: ". $list);
+     
         
         $return = array(
             'searchData'    => $list     // Where our events list will go
diff --git a/models/admin/ajax/memberEdit.php b/models/admin/ajax/memberEdit.php
new file mode 100644 (file)
index 0000000..0a0260c
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Members List Export by AJAX
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @entity  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+require_once GLM_MEMBERS_PLUGIN_PATH . '/controllers/admin.php';
+/**
+ *
+ * This class exports the currently selected members list
+ * to a printable HTML file, to a CSV file, or otherwise.
+ */
+class GlmMembersAdmin_ajax_memberEdit extends glmMembersAdmin
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /**
+     * Constructor
+     *
+     * This constructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        //parent::__construct(false, false);
+
+    }
+
+    /**
+     * Perform Model Action
+     *
+     * This modelAction takes an AJAX image upload and stores the image in the
+     * media/images directory of the plugin.
+     *
+     * This model action does not return, it simply does it's work then calls die();
+     *
+     * @param $actionData
+     *
+     * Echos JSON string as response and does not return
+     */
+    public function modelAction ($actionData = false)
+    {
+        global $wpdb;
+        $memberID = $_REQUEST['memberID'];
+        $editData = $this->controller( 'member', 'index', array("memberID" => $memberID), true, true);
+
+        $return = array(
+            "test"          => $sql,
+            'searchData'    => $editData       // Where our events list will go
+        );
+
+        header('Content-type:application/json;charset=utf-8', true);
+        echo json_encode($return);
+        wp_die();
+    }
+}
index f603da0..a4d378d 100644 (file)
@@ -111,7 +111,7 @@ class GlmMembersAdmin_manageDashboard_members extends GlmDataMembers
      */
     public function modelAction ($actionData = false)
     {
-        $this->writes_log($_REQUEST);
+        // $this->writes_log($_REQUEST);
         $view = "index";
         if($_REQUEST['view'] == "list") $view = 'list';
         
index b92b8ea..bb1049c 100644 (file)
@@ -117,6 +117,7 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers
         $haveMember        = false;
         $memberName        = false;
         $addingMember      = false;
+       
 
         // Check for action option - Should be one of the values in the "switch" statement below
         $option = false;
index 134af7a..8b12d5b 100644 (file)
@@ -50,6 +50,7 @@ $glmMembersValidActions = array(
             'countiesMapData'     => 'glm-member-db',
             'glmTextSearch'         => 'glm-member-db',
             'adminSearch'           => 'glm-member-db',
+            'memberEdit'           => 'glm-member-db',
         ),
         'manageDashboard' => array(
             'members' => 'glm-member-db',
index acb2c10..52f483f 100644 (file)
     <div id="edit-screen" class="edit-screen sidenav"></div>
 </div>
 
-<script type="module">
+<script>
     
     jQuery(function($){
-        window.Glma = {  
-            adminSearch: function(data){
+        var Glma = (function() {  
+            var xhr = function(data, complete, success, type,error){
                 $.ajax({
                     dataType: "json",
-                    type : 'POST',
+                    type : type,
                     url: '{$ajaxUrl}',
                     data: data,
-                    complete: $("#glm-admin-search-overlay").fadeOut('slow'),
-                    success: function(data) {
-                        console.log(data);
-                        $("#glm-admin-member-list").append(data.searchData);
-                    }
+                    complete: complete,
+                    success: success,
+                    error: error
                 });
             }
-        };
+            return {
+                adminSearch: function(data){
+                    xhr(
+                        data,
+                        $("#glm-admin-search-overlay").fadeOut('slow'), 
+                        function(data) {
+                            $("#glm-admin-member-list").append(data.searchData);
+                        },
+                        "POST",
+                        function(error) {
+                            console.log(error);
+                        },
+                    );
+                },
+                memberEdit: function(data){
+                    xhr(
+                        data,
+                        function(complete) {
+                            
+                        },
+                        function(success) {
+                            console.log(success);
+                            $(".edit-screen").html(success.searchData);
+                        },
+                        "POST",
+                        function(error) {
+                            console.log(error);
+                        },
+                    );
+                }
+            }
+        })();
 
 
         /*
-            *  Init Materialize collapsible
-            */
-        jQuery(function($){
-            $('.collapsible').collapsible();
-            $('select').formSelect();
-            $('.modal').modal();
-            $(".side-nav").sidenav({
-                inDuration     : 500,
-                outDuration    : 500
-            });
-        })
+        *  Init Materialize collapsible
+        */
+        $('.collapsible').collapsible();
+        $('select').formSelect();
+        $('.modal').modal();
+        $(".side-nav").sidenav({
+            inDuration : 500,
+            outDuration        : 500
+        });
+        
 
         /*
             *  Text Search Autocomplete
@@ -57,7 +86,7 @@
             jQuery(function($){
                 let searchResults   = {};
                 let imageUrl        = `{$glmPluginMediaUrl}/images`
-                let data = {
+                let listData = {
                     action      : 'glm_members_admin_ajax',
                     glm_action  : 'glmTextSearch',
                     table       : textSearchData.table,
                 $('input#'+textSearchData.slug+'-text').autoComplete({
                     minChars: 1,
                     source: function( request, response ) {
-                        data.query = request;
+                        listData.query = request;
                         $.ajax({
                             dataType: "json",
                             type : 'POST',
                             url: '{$ajaxUrl}',
-                            data: data,
+                            data: listData,
                             success: function(data) {
                                 console.log(data.searchData);
                                 if(data.searchData){
         }
 
         /*
-            *  Date Search Widget
-            */
+        *  Date Search Widget
+        */
         function dateSearch(dateSearchData){
             jQuery(function($){
 
             });
         }
                 
-        let data = {
+        let listData = {
             action      : 'glm_members_admin_ajax',
             glm_action  : 'adminSearch',
             form_action : 'list',
             // fields      : textSearchData.fields,
             // where       : textSearchData.where
         }
-        window.Glma.adminSearch(data);
-
+        Glma.adminSearch(listData);
+   
         $(".glm-admin-search-field").on("change", function(){
-            console.log( $(this) );
-            window.Glma.adminSearch(data);
+            Glma.adminSearch(listData);
         });
         $('.edit-screen').sidenav({
-            inDuration : 600,
-            outDuration        : 600
+            inDuration : 400,
+            outDuration        : 400
         });
         $(document).on("click",".member-record", function(){
-            console.log( $(this).data("id") );
+            var editData = {
+                action      : 'glm_members_admin_ajax',
+                glm_action  : 'memberEdit',
+                form_action : 'index',
+                view        : "index",
+                option      : 'index',
+                memberID    : $(this).data('id')
+            }
+
             
+            Glma.memberEdit(editData);
+           
             M.Sidenav.getInstance($('.edit-screen')[0]).open();   
         })
     });
index 27b37d0..2418376 100644 (file)
@@ -13,3 +13,4 @@
         <div id="no-results">No Members</div>
     {/if}
 </div>
+
index a1bf681..009929f 100644 (file)
     </script>
 {/if}
 
-{include file='admin/footer.html'}
-
+{include file='admin/footer.html'}
\ No newline at end of file