Add custom field to profile edit
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 3 Jul 2018 16:40:23 +0000 (12:40 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 3 Jul 2018 16:40:23 +0000 (12:40 -0400)
Now contact profile edit has the custom fields.

models/admin/profile/index.php
views/admin/contacts/edit.html
views/admin/profile/index.html

index 6357d39..bce842e 100644 (file)
@@ -121,8 +121,8 @@ class GlmMembersAdmin_profile_index extends GlmDataContacts
         $contactUpdated     = false;
         $contactMembers     = false;
         $membersList        = false;
-        $newEmail       = false;
-        $newEmailError  = false;
+        $newEmail           = false;
+        $newEmailError      = false;
         $customFieldResults = false;
         $view               = 'admin/profile/index.html';
 
@@ -168,6 +168,9 @@ class GlmMembersAdmin_profile_index extends GlmDataContacts
 
                         // If the submission was a success
                         if ($this->contactInfo['status']) {
+                            $this->contactInfo = $this->editEntry(($_REQUEST['id']-0));
+
+                            $customFieldResults = apply_filters( 'glm-member-db-save-custom-fields', $_REQUEST['id']-0 );
 
                             $contactUpdated = true;
 
@@ -240,6 +243,9 @@ class GlmMembersAdmin_profile_index extends GlmDataContacts
 
                         $this->contactInfo = $this->editEntry($this->contactID);
 
+                        $contactInfoID = $this->contactInfo['fieldData']['id'];
+                        $customFieldResults = apply_filters( 'glm-member-db-save-custom-fields', $contactInfoID );
+
                         // If the contact wasn't found, then set ID to false
                         if (!$this->contactInfo['status']) {
                             $this->contactID = false;
@@ -261,15 +267,17 @@ class GlmMembersAdmin_profile_index extends GlmDataContacts
 
         // Compile template data
         $templateData = array(
-            'option'            => $option,
-            'contactID'         => $this->contactID,
-            'contactInfo'       => $this->contactInfo,
-            'contactUpdated'    => $contactUpdated,
-            'contactMembers'    => $contactMembers,
-            'membersList'       => $membersList,
-            'EntityManagerRole' => $this->config['contact_role_numb']['EntityManager'],
-            'new_email'         => $newEmail,
-            'newEmailError'     => $newEmailError
+            'option'             => $option,
+            'contactID'          => $this->contactID,
+            'contactInfo'        => $this->contactInfo,
+            'contactUpdated'     => $contactUpdated,
+            'contactMembers'     => $contactMembers,
+            'membersList'        => $membersList,
+            'EntityManagerRole'  => $this->config['contact_role_numb']['EntityManager'],
+            'new_email'          => $newEmail,
+            'newEmailError'      => $newEmailError,
+            'customFieldResults' => $customFieldResults,
+            'slug'               => GLM_MEMBERS_CONTACTS_PLUGIN_SLUG,
         );
 
         // Return status, any suggested view, and any data to controller
index 3b6ba83..4d0fcc1 100644 (file)
         <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
         <a id="glm-contact-info-profile" data-show-table="glm-table-profile" class="glm-contact-info-tab nav-tab nav-tab-active">Profile Data</a>
         {apply_filters('glm-member-db-custom-fields-nav', '', 'contact-info')}
-        
+
         <!--{if $contactUpdateError}<span class="glm-error glm-flash-updated glm-right">{$terms.term_contact_cap} Profile Update Error</span>{/if}-->
         <!--{if $errorMessage}<span class="glm-error glm-flash-updated glm-right">{$errorMessage}</span>{/if}-->
         </h2>
 
         <div id="glm-table-custom-fields" class="glm-hidden glm-admin-table glm-table glm-contact-info-table">
-            
-        
         {if $option == 'create'}
           {apply_filters('glm-members-custom-fields-form', '', $slug,'','')}
         {else}
index 58f3d9a..79201e0 100644 (file)
             <input type="hidden" name="id" value="{$contactInfo.fieldData.id}">
             <input type="hidden" name="modify_time" value="now">
 
-            <table class="glm-admin-table glm-shrink">
+        <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
+        <a id="glm-contact-info-profile" data-show-table="glm-table-profile" class="glm-contact-info-tab nav-tab nav-tab-active">Profile Data</a>
+        {apply_filters('glm-member-db-custom-fields-nav', '', 'contact-info')}
+        </h2>
+
+        <div id="glm-table-custom-fields" class="glm-hidden glm-admin-table glm-table glm-contact-info-table">
+          {$prefix = $slug|cat:'_'}
+          {$uid = $prefix|cat:$contactInfo.fieldData.id}
+          {apply_filters('glm-members-custom-fields-form', '', $slug,$contactInfo.fieldData.id,'')}
+          {apply_filters('glm-members-custom-fields-form', '', $uid,$contactInfo.fieldData.id,'')}
+        </div>
+            <table id="glm-table-profile" class="glm-admin-table glm-shrink glm-hidden glm-contact-info-table">
                 <tr>
                     <th>Contact For:</th>
                     <td>{$contactInfo.fieldData.ref_type.name} - {$contactInfo.fieldData.ref_dest_name}</td>
 
             jQuery(document).ready(function($) {
 
+            /*
+             * Edit area tabs
+             */
+            $('.glm-contact-info-tab').click( function() {
+                glmSetupAreaTab($(this));
+            });
+
+            // Do inital setup on load for first tab
+            glmSetupAreaTab($('#glm-contact-info-profile'));
+
+            // Setup edit area selected
+            function glmSetupAreaTab(t) {
+
+                // Clear table highlights and hide all tables
+                $('.glm-contact-info-tab').removeClass('nav-tab-active');
+                $('.glm-contact-info-table').addClass('glm-hidden');
+
+                // Highlight selected tab
+                t.addClass('nav-tab-active');
+
+                // Show selected table
+                var table = t.attr('data-show-table');
+                $('#' + table).removeClass('glm-hidden');
+
+                // Count remaining characters in field
+                $('.glm-char-count').keyup( function() {
+                    glmCharsRemaining($(this));
+                });
+
+                $('.glm-char-count').each( function() {
+                    glmCharsRemaining($(this));
+                });
+
+            }
+
                 /*
                  * New City Dialog
                  */