Added autocomplete to member search in dashboard widget.
authorChuck Scott <cscott@gaslightmedia.com>
Wed, 25 Mar 2015 23:23:12 +0000 (19:23 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Wed, 25 Mar 2015 23:23:12 +0000 (19:23 -0400)
classes/data/dataMembers.php
controllers/admin.php
css/admin.css
js/admin.js
misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php
views/admin/dashboardWidget/index.html
views/admin/member/index.html

index e9389c0..6929d50 100644 (file)
@@ -195,13 +195,17 @@ class GlmDataMembers extends GlmDataAbstract {
        public function getSimpleMembersList()
        {
 
-           $memberList = $this->wpdb->get_results(
-            "
-            SELECT id, name
-              FROM ".$this->table."
-            ;",
-               ARRAY_A
-        );
+           // Save the current fields array and make a copy
+           $fSave = $this->fields;
+           $f = $fSave;
+
+           // Remove what we don't want form the copy and get the list
+           unset($f['access'], $f['member_type'], $f['created']);
+           $this->fields = $f;
+           $memberList = $this->getList();
+
+           // Restore the fields list
+           $this->fields = $fSave;
 
            return $memberList;
        }
index b9f2aad..ed4c037 100644 (file)
@@ -229,11 +229,15 @@ class glmMembersAdmin extends GlmPluginSupport
     public function glmMembersAdminScripts ()
     {
 
+        // jQuery scripts
         wp_enqueue_script('jquery');
         wp_enqueue_script('jquery-style');
         wp_enqueue_script('jquery-ui-core');
         wp_enqueue_script('jquery-ui-dialog');
-        wp_enqueue_style("wp-jquery-ui-dialog");
+        wp_enqueue_script('jquery-ui-autocomplete');
+
+        // jQuery UI Style
+        wp_enqueue_style('wp-jquery-ui-dialog');
 
         wp_enqueue_media();
         wp_register_script('glm-members-admin-js',
index f2938f4..66cba49 100644 (file)
     font-weight: bold;
 }
 .glm-admin-table-active {
-    background: lightblue;
+    background: #99FFFF;
 }
 .glm-admin-image-edit-table {
     border: 2px #ddd solid;
index 5c614ef..564f1eb 100644 (file)
@@ -1,7 +1,12 @@
 
-// Use media uploaded for all file/image uploads
+// Other needed JS code
+
 jQuery(document).ready(function($){
+
+       /* 
+        * Use media uploaded for all file/image uploads
+        */
+
     var custom_uploader;
  
     $('.glm-protp-upload-button').click(function(e) {
@@ -36,5 +41,4 @@ jQuery(document).ready(function($){
  
     });
  
 });
\ No newline at end of file
index 742809d..dd04776 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-03-19 12:58:55
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-03-25 18:21:40
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/index.html" */ ?>
 <?php /*%%SmartyHeaderCode:94073808254c05abfc4adf1-45287000%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->decodeProperties(array (
@@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array (
     '1be35689c5d30d774f40ebc45e387f5f95c45e90' => 
     array (
       0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/index.html',
-      1 => 1426784332,
+      1 => 1427321829,
       2 => 'file',
     ),
   ),
@@ -158,14 +158,16 @@ $_smarty_tpl->tpl_vars['v']->_loop = true;
         <thead>
             <tr>
                 <th>Access</th>
+                <th>Reference Name</th>
                 <th>Created</th>
                 <th>Last Update</th>
-                <th>Reference Name</th>
                 <th> </th>
             </tr>
         </thead>
         <tbody>
-      <?php $_smarty_tpl->tpl_vars["i"] = new Smarty_variable("0", null, 0);?>
+      <?php if (isset($_smarty_tpl->tpl_vars["i"])) {$_smarty_tpl->tpl_vars["i"] = clone $_smarty_tpl->tpl_vars["i"];
+$_smarty_tpl->tpl_vars["i"]->value = "0"; $_smarty_tpl->tpl_vars["i"]->nocache = null; $_smarty_tpl->tpl_vars["i"]->scope = 0;
+} else $_smarty_tpl->tpl_vars["i"] = new Smarty_variable("0", null, 0);?>
       <?php  $_smarty_tpl->tpl_vars['m'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['m']->_loop = false;
  $_from = $_smarty_tpl->tpl_vars['memberInfoRecords']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
 foreach ($_from as $_smarty_tpl->tpl_vars['m']->key => $_smarty_tpl->tpl_vars['m']->value) {
@@ -182,11 +184,11 @@ $_smarty_tpl->tpl_vars['m']->_loop = true;
 &id=<?php echo $_smarty_tpl->tpl_vars['m']->value['id'];?>
 "<?php if ($_smarty_tpl->tpl_vars['m']->value['status']['value']==$_smarty_tpl->tpl_vars['statusPending']->value) {?> class="glm-notice"<?php }?>><?php echo $_smarty_tpl->tpl_vars['m']->value['status']['name'];?>
 </a></td>
+                <td><?php echo $_smarty_tpl->tpl_vars['m']->value['reference_name'];?>
+</td>
                 <td><?php echo $_smarty_tpl->tpl_vars['m']->value['create_time']['datetime'];?>
 </td>
                 <td><?php echo $_smarty_tpl->tpl_vars['m']->value['modify_time']['datetime'];?>
-</td>
-                <td><?php echo $_smarty_tpl->tpl_vars['m']->value['reference_name'];?>
 </td>
                 <td>
                     <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
index 1342844..2b92759 100644 (file)
@@ -3,13 +3,8 @@
 {if $membersList}
         <tr>
             <td colspan="2">
-                <select id="glmMembersList" class="glm-right">
-                    <option value=""></option>
-    {foreach $membersList as $m}
-                    <option value="{$m.id}">{$m.name}</option>
-    {/foreach}                
-                </select>
-                Members
+                <input  id="glmMembersList" type="text" id="autoTest" class="glm-right">
+                <span class="glm-left">Member Search:</span>
             </td>
         </tr>
 {/if}
 {if $membersList}
     <script type="text/javascript">
         jQuery(document).ready(function($) {
-
-            $('#glmMembersList').change( function() {
-                window.location.replace("{$adminURL}?page=glm-members-admin-menu-member&glm_action=index&member=" + $(this).find('option:selected').val() );
-            });
-               
-               
+            
+               /*
+                * Do autocomplete search for member
+                * label: What will be searched
+                * value: What will be displayed when selected
+                * id: Member id added so we can go to the member while showing what was selected
+                * Also note that autocomplete does not properly render HTML codes, so we 
+                * "unescape" them for HTML in Smarty.
+                */
+               var availableTags = [
+    {foreach $membersList as $m}
+                   { label: "{$m.name|unescape:'html'}", value: "{$m.name|unescape:'html'}", id: '{$m.id}' },
+    {/foreach}
+             ];
+             $( "#glmMembersList" ).autocomplete({
+                 source: availableTags,
+                 html: true,
+                 select: function( event, ui ) {
+                        var memberID = ui.item.id;
+                        window.location.replace("{$adminURL}?page=glm-members-admin-menu-member&glm_action=index&member=" + memberID );
+                 }
+             });
+                             
         });
+            
     </script>
 {/if}
\ No newline at end of file
index d801e61..c957fb7 100644 (file)
@@ -92,9 +92,9 @@
         <thead>
             <tr>
                 <th>Access</th>
+                <th>Reference Name</th>
                 <th>Created</th>
                 <th>Last Update</th>
-                <th>Reference Name</th>
                 <th> </th>
             </tr>
         </thead>
             <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}&id={$m.id}"{if $m.status.value == $statusPending} class="glm-notice"{/if}>{$m.status.name}</a></td>
+                <td>{$m.reference_name}</td>
                 <td>{$m.create_time.datetime}</td>
                 <td>{$m.modify_time.datetime}</td>
-                <td>{$m.reference_name}</td>
                 <td>
                     <a href="{$thisURL}?page={$thisPage}&glm_action=memberInfo&member={$memberID}&id={$m.id}&option=clone" class="button-primary glm-right">Clone</a>&nbsp;
                     {if $m.status.name != 'Active'}<a href="{$thisURL}?page={$thisPage}&glm_action=index&member={$memberID}&activateID={$m.id}" class="button-primary glm-button glm-right">Activate</a>{/if}