reworking the ajax methods for list and edit to make them more flexible
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 28 Dec 2018 21:15:54 +0000 (16:15 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 28 Dec 2018 21:15:54 +0000 (16:15 -0500)
views/admin/manageDashboard/edit.html
views/admin/manageDashboard/index.html

index ce146a6..9d780a8 100644 (file)
                 <a href="{$thisUrl}?page={$thisPage}&glm_action=memberInfo&member={$memberID}" class="button button-primary glm-button glm-right">Add New {$terms.term_member_cap} Profile Version</a>
             </span>
 
-            <div class="glm-admin-show-archived-container">
-                <input type="checkbox" id="showArchived"{if $showArchived} checked="checked"{/if}> Show archived information&nbsp;&nbsp;
-            </div>
+            <label class="glm-admin-show-archived-container">
+                <input type="checkbox" id="showArchived"{if $showArchived} checked="checked"{/if}>
+                <span>Show archived information</span>
+            </label>
         </div>
         <br clear="all">
         <table class="wp-list-table striped glm-admin-table">
             <tr class="alternate{if $m.status.name == 'Active'} glm-admin-table-active{/if}">
           {/if}
                 <td>
-                    <a href="{$thisUrl}?page={$thisPage}&glm_action=memberInfo&member={$memberID}&memberInfo={$m.id}"{if $m.status.value == $statusPending} class="glm-notice edit-member-profile"{/if} data-memberInfo={$m.id}>
+                    <a id="edit-member-profile" href="{$thisUrl}?page={$thisPage}&glm_action=memberInfo&member={$memberID}&memberInfo={$m.id}"{if $m.status.value == $statusPending} class="glm-notice"{/if} data-memberInfo={$m.id}>
                         Edit {if $m.status.name == 'Active'}Current{else}{$m.status.name}{/if} Profile
                     </a>
                 </td>
index 9f428bd..30f0554 100644 (file)
@@ -20,7 +20,7 @@
     
     jQuery(function($){
         var Glma = (function() {  
-            var xhr = function(data, complete, success, type,error){
+            var xhr = function(data, complete, success, error, type){
                 $.ajax({
                     dataType: "json",
                     type : type,
                 });
             }
             return {
-                adminSearch: function(data){
+                adminSearch: function(data, complete, success, error, type){
                     xhr(
                         data,
-                        $("#glm-admin-search-overlay").fadeOut('slow'), 
-                        function(data) {
-                            $("#glm-admin-member-list").html(data.searchData);
-                        },
-                        "POST",
-                        function(error) {
-                            console.log(error);
-                        },
+                        complete, 
+                        success,
+                        error,
+                        type,
                     );
                 },
-                memberEdit: function(data){
+                memberEdit: function(data, complete, success, error, type){
                     xhr(
                         data,
-                        function(complete) {
-                            
-                        },
-                        function(success) {
-                            console.log(success);
-                            $(".edit-screen").html(success.searchData);
-                        },
-                        "POST",
-                        function(error) {
-                            console.log(error);
-                        },
+                        complete, 
+                        success,
+                        error,
+                        type,
                     );
                 }
             }
                             url: '{$ajaxUrl}',
                             data: listData,
                             success: function(data) {
-                                console.log(data.searchData);
+           
                                 if(data.searchData){
                                     let searchDropdown = [];
                                     for(let i = 0;i < data.searchData.length;i++){
                     },
                     onSelect: function(e, term, item){
                         let search = $(item).text();
-                        console.log(search)
+
                         if(search !== "No Results Found"){
                             window.location.replace(textSearchData.resultUrl+searchResults[search].entityID);
                         }
                         toDate = '&' + dateSearchData.toDate + '=' + $(this)[0].el.value;
                     }
                 });
-                console.log( dateSearchData.resultUrl + fromDate + toDate)
+
                 $('#' + dateSearchData.searchBtn).on("click", function(){
                     window.location = dateSearchData.resultUrl + fromDate + toDate;
                 })
         }
 
         
-        Glma.adminSearch(listData);
+        Glma.adminSearch(
+            listData,
+            $("#glm-admin-search-overlay").fadeOut('slow'), 
+            function(data) {
+                $("#glm-admin-member-list").html(data.searchData);
+            },
+            function(error) {
+                console.log(error);
+            },
+            "POST"
+        );
    
         $(".glm-admin-search-field").on("change", function(){
             listData.filterArchived = $("input[name='archivedSearch']:checked").length > 0 ? true : undefined;
             listData.filterFeatured = $("input[name='featuredSearch']:checked").length > 0 ? true : undefined;
             listData.filterPending = $("input[name='pendingSearch']:checked").length > 0 ? true : undefined;
 
-            Glma.adminSearch(listData);
+            Glma.adminSearch(
+                listData,
+                $("#glm-admin-search-overlay").fadeOut('slow'), 
+                function(data) {
+                    $("#glm-admin-member-list").html(data.searchData);
+                },
+                function(error) {
+                    console.log(error);
+                },
+                "POST"
+            );
         });
         $('.edit-screen').sidenav({
             inDuration : 400,
                 memberID    : $(this).parent().data('id')
             }
 
-            
-            Glma.memberEdit(editData);
-           
+            Glma.memberEdit(
+                editData,
+                function(complete) {},
+                function(success) {
+                    $(".edit-screen").html(success.searchData);
+                },
+                function(error) {
+                    console.log(error);
+                },
+                "POST",
+            );           
             M.Sidenav.getInstance($('.edit-screen')[0]).open();   
-        })
+        });
+        $(document).on("click","#edit-member-profile",function(e){
+            e.preventDefault();
+            
+        });
     });
 </script>