From 0347707003cce3b3b235f55909f1dfcfdadc0491 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 26 Apr 2017 12:01:44 -0400 Subject: [PATCH] Save the current tab feature for edit events. 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 | 9 +- views/admin/events/edit.html | 192 ++++++++++++++--------- views/admin/events/editAdminContact.html | 2 +- views/admin/events/editFiles.html | 2 +- views/admin/events/editLocation.html | 2 +- views/admin/events/editSchedule.html | 12 +- views/admin/events/editStatus.html | 2 +- 7 files changed, 136 insertions(+), 85 deletions(-) diff --git a/models/admin/events/list.php b/models/admin/events/list.php index ffccd52..a7bc0d2 100644 --- a/models/admin/events/list.php +++ b/models/admin/events/list.php @@ -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, ); diff --git a/views/admin/events/edit.html b/views/admin/events/edit.html index 87cc492..5e6087a 100644 --- a/views/admin/events/edit.html +++ b/views/admin/events/edit.html @@ -56,14 +56,15 @@ {else} {/if} + @@ -80,7 +81,7 @@ - +
@@ -144,7 +145,7 @@ */ $('.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'); @@ -155,6 +156,9 @@ 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; @@ -166,7 +170,7 @@ // Make sure there's at least one location {if !$locations} - addNewLocationForm(); + addNewLocationForm(); {/if} initLocations(); @@ -175,90 +179,69 @@ } - // 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)); }); /* @@ -397,6 +380,63 @@ } + /* + * 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 */ @@ -439,9 +479,9 @@ } // 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() { @@ -1280,6 +1320,10 @@ // 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(); + } + }); diff --git a/views/admin/events/editAdminContact.html b/views/admin/events/editAdminContact.html index 7b3e873..0f37afa 100644 --- a/views/admin/events/editAdminContact.html +++ b/views/admin/events/editAdminContact.html @@ -1,7 +1,7 @@ - +
diff --git a/views/admin/events/editFiles.html b/views/admin/events/editFiles.html index 376599b..536c407 100644 --- a/views/admin/events/editFiles.html +++ b/views/admin/events/editFiles.html @@ -1,7 +1,7 @@ -
+
@@ -359,7 +359,7 @@ - @@ -369,7 +369,7 @@
Custom Dates
File #1: diff --git a/views/admin/events/editLocation.html b/views/admin/events/editLocation.html index b44d76c..d3b02fd 100644 --- a/views/admin/events/editLocation.html +++ b/views/admin/events/editLocation.html @@ -25,7 +25,7 @@ {if !$settings.use_venue_locations} {/if} - +
@@ -317,7 +317,7 @@ {foreach $newRecurrence.fieldData.week_of_month.bitmap as $v} - {/foreach} + {/foreach}
diff --git a/views/admin/events/editSchedule.html b/views/admin/events/editSchedule.html index 6e4768c..3c82b79 100644 --- a/views/admin/events/editSchedule.html +++ b/views/admin/events/editSchedule.html @@ -1,7 +1,7 @@ - +
- @@ -296,7 +296,7 @@ {/if} - {/foreach} + {/foreach}

Event Occurrences: {$timesCount}

@@ -155,7 +155,7 @@
 

Add Specific Dates that Don't Fit Schedule Above

Use this section to enter specific additional dates that don't fit into a regular monthly, weekly or daily schedule above. +
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.
 
{$v.name}  
{$v.name}  
 

Add Specific Dates that Don't Fit Schedule Above

Use this section to enter specific additional dates that don't fit into a regular monthly, weekly or daily schedule above. +
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".
 
- +

Click on Dates to select/remove those dates for this schedule.

diff --git a/views/admin/events/editStatus.html b/views/admin/events/editStatus.html index 9e4b5fe..0cd158d 100644 --- a/views/admin/events/editStatus.html +++ b/views/admin/events/editStatus.html @@ -8,7 +8,7 @@ {/if} {/if} - +
-- 2.17.1
Event Name: