Save the current tab feature for edit events.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 26 Apr 2017 16:01:44 +0000 (12:01 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 26 Apr 2017 16:01:44 +0000 (12:01 -0400)
Before when you saved an event it always ending back at the first tab.
Now we're saving the tab that was last on so when the edit page reloads
it will be on the correct tab.

models/admin/events/list.php
views/admin/events/edit.html
views/admin/events/editAdminContact.html
views/admin/events/editFiles.html
views/admin/events/editLocation.html
views/admin/events/editSchedule.html
views/admin/events/editStatus.html

index ffccd52..a7bc0d2 100644 (file)
@@ -96,6 +96,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
     public function modelAction($actionData = false)
     {
 
+        $currentTab       = 'glm-table-descr';
         $lockedToMember   = false;
         $isModerated      = false;
         $numbEvents       = 0;
@@ -223,6 +224,11 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
             $option = $_REQUEST['option'];
         }
 
+        // See if there's a currentTab in $_REQUEST array
+        if ( isset( $_REQUEST['currentTab'] ) && $_REQUEST['currentTab'] ) {
+            $currentTab = filter_var( $_REQUEST['currentTab'], FILTER_SANITIZE_STRING );
+        }
+
         // Get event ID if supplied
         if (isset($_REQUEST['event'])) {
 
@@ -844,10 +850,11 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
             'paging'            => $paging,
             'prevStart'         => $prevStart,
             'nextStart'         => $nextStart,
-            'start'             => $start                                           = 1,
+            'start'             => $start = 1,
             'limit'             => $limit,
             'namesList'         => $namesList,
             'eventDefaultState' => $this->config['settings']['event_default_state'],
+            'currentTab'        => $currentTab,
 
         );
 
index 87cc492..5e6087a 100644 (file)
     {else}
         <input type="hidden" name="option" value="insert">
     {/if}
+    <input type="hidden" name="currentTab" value="{$currentTab}">
 
        <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
-            <a id="glm-event-descr" data-show-table="glm-table-descr" class="glm-event-tab nav-tab nav-tab-active">Event Description</a>
-            <a id="glm-event-location" data-show-table="glm-table-location" class="glm-event-tab nav-tab">Location</a>
-            <a id="glm-event-recurrence" data-show-table="glm-table-recurrence" class="glm-event-tab nav-tab">Dates</a>
-            <a id="glm-event-calendar" data-show-table="glm-table-calendar" class="glm-event-tab nav-tab">Summary Calendar</a>
-            <a id="glm-event-admin" data-show-table="glm-table-settings" class="glm-event-tab nav-tab">Administrative Contact</a>
-            <a id="glm-event-files" data-show-table="glm-table-files" class="glm-event-tab nav-tab">Attach Files</a>
+            <a id="glm-event-descr" data-show-table="glm-table-descr" class="glm-event-tab nav-tab nav-tab{if $currentTab == 'glm-table-descr'} nav-tab-active{/if}">Event Description</a>
+            <a id="glm-event-location" data-show-table="glm-table-location" class="glm-event-tab nav-tab{if $currentTab == 'glm-table-location'} nav-tab-active{/if}">Location</a>
+            <a id="glm-event-recurrence" data-show-table="glm-table-recurrence" class="glm-event-tab nav-tab{if $currentTab == 'glm-table-recurrence'} nav-tab-active{/if}">Dates</a>
+            <a id="glm-event-calendar" data-show-table="glm-table-calendar" class="glm-event-tab nav-tab{if $currentTab == 'glm-table-calendar'} nav-tab-active{/if}">Summary Calendar</a>
+            <a id="glm-event-admin" data-show-table="glm-table-settings" class="glm-event-tab nav-tab{if $currentTab == 'glm-table-settings'} nav-tab-active{/if}">Administrative Contact</a>
+            <a id="glm-event-files" data-show-table="glm-table-files" class="glm-event-tab nav-tab{if $currentTab == 'glm-table-files'} nav-tab-active{/if}">Attach Files</a>
         </h2>
 
         <!-- Status and Description -->
@@ -80,7 +81,7 @@
 
         <!-- Calendar -->
 
-        <table id="glm-table-calendar" class="glm-admin-table glm-hidden glm-event-table">
+        <table id="glm-table-calendar" class="glm-admin-table glm-event-table{if $currentTab != 'glm-table-calendar'} glm-hidden{/if}">
             <tr>
                 <td>
                     <div id="eventCalendar"></div>
              */
             $('.glm-event-tab').click( function() {
 
-                // Clear tabl highlights and hide all tables
+                // Clear table highlights and hide all tables
                 $('.glm-event-tab').removeClass('nav-tab-active');
                 $('.glm-event-table').addClass('glm-hidden');
 
                 var table = $(this).attr('data-show-table');
                 $('#' + table).removeClass('glm-hidden');
 
+                // Set the hidden input field with current tab value
+                $('input[name=currentTab]').val(table);
+
                 if (table == 'glm-table-recurrence' && !recurrencesInited) {
                     initRecurrence();
                     recurrencesInited = true;
 
                         // Make sure there's at least one location
                         {if !$locations}
-                                addNewLocationForm();
+                            addNewLocationForm();
                         {/if}
 
                         initLocations();
 
                     }
 
-                    // Check Use Member Location checkbox
-                    memberID = $('#memberSelect').val();
-                    otherMemberID = $('#useOtherRefDest').val();
-                    if (memberID == '') {
+                    initMemberLocationCheckbox();
+                }
 
-                        // No member selected - Clear checkbox, Dissable checkbox, Show location
-                        $('#useMemberLocationCheckbox').prop('checked', false);
-                        $('#useMemberLocationCheckbox').prop('disabled', true);
-                        $('#useMemberMessage').addClass('glm-hidden');
-                        $('#notUseMemberMessage').removeClass('glm-hidden');
-                        if ( otherMemberID == '' ) {
-                            $('#locationContainer').removeClass('glm-hidden');
-                        }
+                if (table == 'glm-table-calendar' && !fullCalendarLoaded) {
 
-                    } else {
+                    initFullCalendar();
 
-                        // Member set - Enable checkbox
-                        $('#useMemberLocationCheckbox').prop('disabled', false);
-                        $('#useMemberMessage').removeClass('glm-hidden');
-                        $('#notUseMemberMessage').addClass('glm-hidden');
+                    fullCalendarLoaded = true;
 
-                    }
                 }
 
-                if (table == 'glm-table-calendar' && !fullCalendarLoaded) {
+            });
 
-                    // **** Should probably move all this to a function and check if it's been initialized already
-                    $('#eventCalendar').fullCalendar({
-        {if $haveTimes}
-                        events: [
-            {$sep = ''}
-            {foreach $times as $t}
-                            {$sep}{
-                                title : '{$t.recur_name|replace:"'":"\'"}',
-                                start : '{$t.start_time.datetime}',
-                                end   : '{$t.end_time.datetime}',
-                                allday : {$t.all_day.value}
-                            }
-                {$sep = ','}
-            {/foreach}
-                        ],
-                        defaultDate : '{$firstTime.start_time.datetime}',
-                        timeFormat  : 'h:mma',
-                        fixedWeekCount : false,
-                        eventClick: function(calEvent, jsEvent, view) {
-                            $("#occurrences").dialog();
-                            $(this).css('border-color', 'red');
-                        }
-/*                        ,
-                        dayClick: function(date, allDay, jsEvent, view) {
+            function initCurrentTab(){
+                // Clear table highlights and hide all tables
+                //$('.glm-event-tab').removeClass('nav-tab-active');
+                //$('.glm-event-table').addClass('glm-hidden');
 
-                            if (allDay) {
-                                alert('Clicked on the entire day: ' + date);
-                            }else{
-                                alert('Clicked on the slot: ' + date);
-                            }
+                // Get the table name for the currentTab
+                var table = $('input[name=currentTab]').val();
+                // Show the currentTab
+                //$('#' + table).removeClass('glm-hidden');
 
+                // Highlight selected tab
+                $('a[data-show-table="' + table + '"]').addClass('nav-tab-active');
 
-                            alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
 
-                            alert('Current view: ' + view.name);
+                if (table == 'glm-table-recurrence' && !recurrencesInited) {
+                    initRecurrence();
+                    recurrencesInited = true;
+                }
 
-                            // change the day's background color just for fun
-                            $(this).css('background-color', 'red');
+                if (table == 'glm-table-location') {
 
-                        alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
-                        alert('Current view: ' + view.name);
+                    if (!locationsInited) {
 
+                        // Make sure there's at least one location
+                        {if !$locations}
+                            addNewLocationForm();
+                        {/if}
+
+                        initLocations();
+                        initNewCity();
+                        locationsInited = true;
 
+                    }
 
-                        }
-*/
-        {/if}
-                    });
+                    initMemberLocationCheckbox();
+                }
+
+                if (table == 'glm-table-calendar' && !fullCalendarLoaded) {
+
+                    initFullCalendar();
 
                     fullCalendarLoaded = true;
 
                 }
+            }
 
-                // Count remaining characters in field
-                $('.glm-char-count').keyup( function() {
-                    glmCharsRemaining($(this));
-                });
 
+            // Count remaining characters in field
+            $('.glm-char-count').keyup( function() {
+                glmCharsRemaining($(this));
             });
 
             /*
 
             }
 
+            /*
+             * Initialize the Member Location Checkbox
+             */
+            function initMemberLocationCheckbox() {
+                // Check Use Member Location checkbox
+                    memberID = $('#memberSelect').val();
+                    otherMemberID = $('#useOtherRefDest').val();
+                    if (memberID == '') {
+
+                        // No member selected - Clear checkbox, Disable checkbox, Show location
+                        $('#useMemberLocationCheckbox').prop('checked', false);
+                        $('#useMemberLocationCheckbox').prop('disabled', true);
+                        $('#useMemberMessage').addClass('glm-hidden');
+                        $('#notUseMemberMessage').removeClass('glm-hidden');
+                        if ( otherMemberID == '' ) {
+                            $('#locationContainer').removeClass('glm-hidden');
+                        }
+
+                    } else {
+
+                        // Member set - Enable checkbox
+                        $('#useMemberLocationCheckbox').prop('disabled', false);
+                        $('#useMemberMessage').removeClass('glm-hidden');
+                        $('#notUseMemberMessage').addClass('glm-hidden');
+
+                    }
+            }
+
+            /*
+             * Initialize the Full Calendar
+             */
+            function initFullCalendar(){
+                $('#eventCalendar').fullCalendar({
+                    {if $haveTimes}
+                        events: [
+                        {$sep = ''}
+                        {foreach $times as $t}
+                            {$sep}{
+                                title : '{$t.recur_name|replace:"'":"\'"}',
+                                start : '{$t.start_time.datetime}',
+                                end   : '{$t.end_time.datetime}',
+                                allday : {$t.all_day.value}
+                            }
+                            {$sep = ','}
+                        {/foreach}
+                        ],
+                        defaultDate : '{$firstTime.start_time.datetime}',
+                        timeFormat  : 'h:mma',
+                        fixedWeekCount : false,
+                        eventClick: function(calEvent, jsEvent, view) {
+                            $("#occurrences").dialog();
+                            $(this).css('border-color', 'red');
+                        }
+                    {/if}
+                });
+            }
+
             /*
              * Recurrences
              */
             }
 
             // Make sure there's at least one recurrence
-    {if !$recurrences}
-            addNewRecurrenceForm();
-    {/if}
+            {if !$recurrences}
+                addNewRecurrenceForm();
+            {/if}
 
             // When adding a new recurrence is requested
             $("#addRecurrence").click( function() {
             // Flash certain elements for a short time after display
             $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
 
+            if ( $('input[name=currentTab]').val() != 'glm-table-descr' ) {
+                initCurrentTab();
+            }
+
         });
     </script>
 
index 7b3e873..0f37afa 100644 (file)
@@ -1,7 +1,7 @@
 
 <!-- Options and Settings -->
 
-    <table id="glm-table-settings" class="glm-admin-table glm-event-table glm-hidden">
+    <table id="glm-table-settings" class="glm-admin-table glm-event-table{if $currentTab != 'glm-table-settings'} glm-hidden{/if}">
         <tr>
             <td>
                 <table>
index 376599b..536c407 100644 (file)
@@ -1,7 +1,7 @@
 
 <!-- File Upload -->
 
-    <table id="glm-table-files" class="glm-admin-table glm-event-table glm-hidden">
+    <table id="glm-table-files" class="glm-admin-table glm-event-table{if $currentTab != 'glm-table-files'} glm-hidden{/if}">
         <tr>
             <th {if $event.fieldRequired.file1}class="glm-required"{/if}>File #1:</th>
             <td {if $event.fieldFail.file1}class="glm-form-bad-input"{/if}>
index b44d76c..d3b02fd 100644 (file)
@@ -25,7 +25,7 @@
 {if !$settings.use_venue_locations}
     <input type="hidden" name="other_ref_dest" value="0">
 {/if}
-<table id="glm-table-location" class="glm-admin-table glm-hidden glm-event-table">
+<table id="glm-table-location" class="glm-admin-table glm-event-table{if $currentTab != 'glm-table-location'} glm-hidden{/if}">
     <tr>
         <td id="placeLocationDeletesHere" colspan="2">
 
index 6e4768c..3c82b79 100644 (file)
@@ -1,7 +1,7 @@
 
 <!-- Recurrences - Event Schedule -->
 
-<table id="glm-table-recurrence" class="glm-admin-table glm-hidden glm-event-table">
+<table id="glm-table-recurrence" class="glm-admin-table glm-event-table{if $currentTab != 'glm-table-recurrence'} glm-hidden{/if}">
     <tr>
         <td id="placeRecurDeletesHere" colspan="2">
             <h2 {if !$haveTimes}class="glm-error"{/if}><b>Event Occurrences:</b> {$timesCount}</h2>
                                 <tr><td colspan="3">&nbsp;</td></tr>
                                 <tr><td colspan="3"><hr width="50%"></td></tr>
                                 <tr><td colspan="3"><h2 style="text-align: center;">Add Specific Dates that Don't Fit Schedule Above</h2></td></tr>
-                                <tr><td colspan="3">Use this section to enter specific additional dates that don't fit into a regular monthly, weekly or daily schedule above. 
+                                <tr><td colspan="3">Use this section to enter specific additional dates that don't fit into a regular monthly, weekly or daily schedule above.
                                     If all your dates don't fit a recurring schedule above, you may click "None" for all of the options above and select all specific dates for your event here.</td></tr>
                                 <tr><td colspan="3">&nbsp;</td></tr>
                                 <tr>
                                 </tr><tr>
                 {/if}
                                     <td style="white-space: nowrap;"><input type="checkbox" name="{ newRecurID }_month_of_year[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
-            {/foreach}              
+            {/foreach}
                                 </tr>
                             </table>
                         </td>
                                 <tr>
             {foreach $newRecurrence.fieldData.week_of_month.bitmap as $v}
                                     <td style="white-space: nowrap;"><input type="checkbox" name="{ newRecurID }_week_of_month[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
-            {/foreach}              
+            {/foreach}
                                 </tr>
                             </table>
                         </td>
                     <tr><td colspan="3">&nbsp;</td></tr>
                     <tr><td colspan="3"><hr width="50%"></td></tr>
                     <tr><td colspan="3"><h2 style="text-align: center;">Add Specific Dates that Don't Fit Schedule Above</h2></td></tr>
-                    <tr><td colspan="3">Use this section to enter specific additional dates that don't fit into a regular monthly, weekly or daily schedule above. 
+                    <tr><td colspan="3">Use this section to enter specific additional dates that don't fit into a regular monthly, weekly or daily schedule above.
                         If all your dates don't fit a recurring schedule above, you may click "None" for all of the options above and select all specific dates for your event here.
                         You may set dates here that are not from "First date" to "Last Date".</td></tr>
                     <tr><td colspan="2">&nbsp;</td></tr>
                             <div data-id="{ newRecurID }" class="button glm-button-small glm-set-none recur-calendar">Custom Dates</div>
                         </td>
                         <td>
-                            
+
                             <div id="recurCalendarDialog_{ newRecurID }" class="glm-dialog-box" title="">
                                 <p>Click on Dates to select/remove those dates for this schedule.</p>
                                 <div id="recurCalendar_{ newRecurID }"></div>
index 9e4b5fe..0cd158d 100644 (file)
@@ -8,7 +8,7 @@
         {/if}
     {/if}
 
-    <table id="glm-table-descr" class="glm-admin-table glm-event-table">
+    <table id="glm-table-descr" class="glm-admin-table glm-event-table{if $currentTab != 'glm-table-descr'} glm-hidden{/if}">
 
         <tr>
             <th {if $event.fieldRequired.name}class="glm-required"{/if}>Event Name:</th>