Update for list and ajax
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 15 Jun 2018 20:08:24 +0000 (16:08 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 15 Jun 2018 20:08:24 +0000 (16:08 -0400)
Ajax update to get record by id.
List update to order inactive below the active ones.

models/admin/ajax/relay.php
models/admin/relay/index.php
views/admin/relay/index.html

index 047241e..df95482 100644 (file)
@@ -75,23 +75,36 @@ class GlmMembersAdmin_ajax_relay extends GlmDataMessages
      */
     public function modelAction( $actionData = false )
     {
-        $return  = false;
-        $success =  true;
+        $return   = false;
+        $success  =  true;
+        $messages = array();
 
         $option = isset($_REQUEST['option']) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ) : '';
         trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
 
         switch ( $option ) {
-        case 'list':
-        default:
-            $messages = $this->getList( '', "T.updated desc" );
 
-            $results = $messages;
+        case 'view':
+            $where = 'T.status = 10';
+            if ( isset( $_REQUEST['id'] ) && $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
+                $where .= ' AND T.id = ' . $id;
+            }
+            $messages = $this->getList( $where, 'T.updated DESC' );
+            break;
+
+        case 'full':
+            $messages = $this->getList( 'T.status = 10', 'T.updated DESC' );
             break;
+
+        default:
+            $list = $this->getList( 'T.status = 10', 'T.updated DESC', null, null, 1, 1 );
+            $messages = $list['list'];
+            break;
+
         }
 
         header('Content-type:application/json;charset=utf-8', true);
-        echo json_encode( $results );
+        echo json_encode( $messages );
         exit;
 
     }
index a0700e5..df206a8 100644 (file)
@@ -130,7 +130,7 @@ class GlmMembersAdmin_relay_index extends GlmDataMessages
             }
             $view = 'index.html';
         default:
-            $messages = $this->getList( '', "T.updated desc" );
+            $messages = $this->getList( '', "T.status, T.updated desc" );
             break;
         }
 
index f0f24f5..46c9d69 100644 (file)
@@ -11,6 +11,7 @@
 <table class="wp-list-table striped glm-admin-table" style="width: 800px;">
     <thead>
         <th> Edit </th>
+        <th> Status </th>
         <th> Title </th>
         <th> Updated </th>
         <th> Delete </th>
@@ -24,6 +25,9 @@
                     <td>
                         <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=edit&id={$m.id}">Edit</a>
                     </td>
+                    <td>
+                        {$m.status.name}
+                    </td>
                     <td>
                         {$m.title}
                     </td>