From: Coleman Watts Date: Mon, 30 Dec 2013 01:09:47 +0000 (-0800) Subject: CRM-13863 - Ajaxify event tabs X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4b628e67745625ab3b9820731c125979792a0c4f;p=civicrm-core.git CRM-13863 - Ajaxify event tabs --- diff --git a/CRM/Admin/Page/ScheduleReminders.php b/CRM/Admin/Page/ScheduleReminders.php index 8d117b33d6..b42ee60901 100644 --- a/CRM/Admin/Page/ScheduleReminders.php +++ b/CRM/Admin/Page/ScheduleReminders.php @@ -128,6 +128,7 @@ class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic { * @static */ function browse($action = NULL) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); // Get list of configured reminders $reminderList = CRM_Core_BAO_ActionSchedule::getList(); diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index 32c0651b5d..1b873b1748 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -338,7 +338,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { } CRM_Core_Session::setStatus(ts("'%1' information has been saved.", - array(1 => ($subPage == 'friend') ? 'Friend' : $className) + array(1 => CRM_Utils_Array::value('title', CRM_Utils_Array::value($subPage, $this->get('tabHeader')), $className)) ), ts('Saved'), 'success'); $config = CRM_Core_Config::singleton(); @@ -353,18 +353,14 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { $this->postProcessHook(); if ($this->controller->getButtonName('submit') == "_qf_{$className}_upload_done") { if ($this->_isTemplate) { - CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/eventTemplate', - 'reset=1' - )); + CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1')); } else { - CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/manage', - 'reset=1' - )); + CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/event/manage', 'reset=1')); } } else { - CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/event/manage/{$subPage}", + CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url("civicrm/event/manage/{$subPage}", "action=update&reset=1&id={$this->_id}" )); } diff --git a/CRM/Event/Form/ManageEvent/ScheduleReminders.php b/CRM/Event/Form/ManageEvent/ScheduleReminders.php index de285bf3bc..58c400b9e8 100755 --- a/CRM/Event/Form/ManageEvent/ScheduleReminders.php +++ b/CRM/Event/Form/ManageEvent/ScheduleReminders.php @@ -58,7 +58,7 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage $field = 'event_template'; } $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $field, $this->_id ); - if (is_array($reminderList)) { + if ($reminderList && is_array($reminderList)) { // Add action links to each of the reminders foreach ($reminderList as & $format) { $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE; @@ -82,8 +82,11 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage $this->_id ); } - $this->assign('rows', $reminderList); } + else { + $reminderList = TRUE; + } + $this->assign('rows', $reminderList); } } diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 92756352fe..d591fc35a9 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -58,55 +58,23 @@ class CRM_Event_Form_ManageEvent_TabHeader { return NULL; } + $default = array( + 'link' => NULL, + 'valid' => TRUE, + 'active' => TRUE, + 'current' => FALSE, + 'class' => 'ajaxForm', + ); + $tabs = array( - 'settings' => array('title' => ts('Info and Settings'), - 'link' => NULL, - 'valid' => TRUE, - 'active' => TRUE, - 'current' => FALSE, - ), - 'location' => array('title' => ts('Event Location'), - 'link' => NULL, - 'valid' => TRUE, - 'active' => TRUE, - 'current' => FALSE, - ), - 'fee' => array('title' => ts('Fees'), - 'link' => NULL, - 'valid' => TRUE, - 'active' => TRUE, - 'current' => FALSE, - ), - 'registration' => array('title' => ts('Online Registration'), - 'link' => NULL, - 'valid' => TRUE, - 'active' => TRUE, - 'current' => FALSE, - ), - 'reminder' => array('title' => ts('Schedule Reminders'), - 'link' => NULL, - 'valid' => TRUE, - 'active' => TRUE, - 'current' => FALSE, - ), - 'conference' => array('title' => ts('Conference Slots'), - 'link' => NULL, - 'valid' => TRUE, - 'active' => TRUE, - 'current' => FALSE, - ), - 'friend' => array('title' => ts('Tell a Friend'), - 'link' => NULL, - 'valid' => TRUE, - 'active' => TRUE, - 'current' => FALSE, - ), - 'pcp' => array('title' => ts('Personal Campaigns'), - 'link' => NULL, - 'valid' => TRUE, - 'active' => TRUE, - 'current' => FALSE, - ) + 'settings' => array('title' => ts('Info and Settings')) + $default, + 'location' => array('title' => ts('Event Location')) + $default, + 'fee' => array('title' => ts('Fees')) + $default, + 'registration' => array('title' => ts('Online Registration')) + $default, + 'reminder' => array('title' => ts('Schedule Reminders'), 'class' => 'livePage') + $default, + 'conference' => array('title' => ts('Conference Slots')) + $default, + 'friend' => array('title' => ts('Tell a Friend')) + $default, + 'pcp' => array('title' => ts('Personal Campaigns')) + $default, ); // check if we're in shopping cart mode for events diff --git a/js/Common.js b/js/Common.js index a8674d6600..f9ba78ac9b 100644 --- a/js/Common.js +++ b/js/Common.js @@ -896,6 +896,9 @@ CRM.validate = CRM.validate || { }).fail(function() { that._onFailure(); }); + }, + _destroy: function() { + this.element.removeClass('crm-ajax-container'); } }); diff --git a/js/crm.livePage.js b/js/crm.livePage.js index b7f8f15f4d..2d01bef689 100644 --- a/js/crm.livePage.js +++ b/js/crm.livePage.js @@ -5,7 +5,8 @@ cj(function($) { // Widgetize the content area .crmSnippet() // Open action links in a popup - .on('click', 'a.button, a.action-item', function() { + .off('click.crmLivePage') + .on('click.crmLivePage', 'a.button, a.action-item', function() { // only follow real links not javascript buttons if ($(this).attr('href') === '#' || $(this).attr('onclick')) { return; diff --git a/templates/CRM/Admin/Form/ScheduleReminders.tpl b/templates/CRM/Admin/Form/ScheduleReminders.tpl index a19fb449b0..1bd573ad75 100644 --- a/templates/CRM/Admin/Form/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Form/ScheduleReminders.tpl @@ -142,11 +142,6 @@ {include file="CRM/Contact/Form/Task/EmailCommon.tpl" upload=1 noAttach=1} -{/if} - -
{include file="CRM/common/formButtons.tpl" location="bottom"}
- - {include file="CRM/common/showHideByFieldValue.tpl" trigger_field_id = "is_repeat" trigger_value = "true" @@ -289,3 +284,8 @@ {/literal} + +{/if} + +
{include file="CRM/common/formButtons.tpl" location="bottom"}
+ diff --git a/templates/CRM/Admin/Page/Reminders.tpl b/templates/CRM/Admin/Page/Reminders.tpl index 7f97a331e1..379393a57e 100755 --- a/templates/CRM/Admin/Page/Reminders.tpl +++ b/templates/CRM/Admin/Page/Reminders.tpl @@ -26,9 +26,11 @@ *} {* this template is for configuring Scheduled Reminders Table*} {strip} - {include file="CRM/common/enableDisableApi.tpl"} - {include file="CRM/common/crmeditable.tpl"} - {include file="CRM/common/jsortable.tpl"} + {if $rows and is_array($rows)} + {include file="CRM/common/enableDisableApi.tpl"} + {include file="CRM/common/crmeditable.tpl"} + {include file="CRM/common/jsortable.tpl"} + {/if} @@ -42,18 +44,22 @@ - {foreach from=$rows item=row} - - - - - - - - - - - {/foreach} + {if $rows and is_array($rows)} + {foreach from=$rows item=row} + + + + + + + + + + + {/foreach} + {else} + + {/if}
{$row.title}{$row.entity} - {$row.value}{if $row.absolute_date}{$row.absolute_date|crmDate}{else}{$row.start_action_offset} {$row.start_action_unit}{if $row.start_action_offset > 1}{ts}(s){/ts}{/if} {$row.start_action_condition} {$row.entityDate}{/if}{$row.status}{if $row.is_repeat eq 1}{ts}Yes{/ts}{else}{ts}No{/ts}{/if} {if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}{$row.action|replace:'xx':$row.id}
{$row.title}{$row.entity} - {$row.value}{if $row.absolute_date}{$row.absolute_date|crmDate}{else}{$row.start_action_offset} {$row.start_action_unit}{if $row.start_action_offset > 1}{ts}(s){/ts}{/if} {$row.start_action_condition} {$row.entityDate}{/if}{$row.status}{if $row.is_repeat eq 1}{ts}Yes{/ts}{else}{ts}No{/ts}{/if} {if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}{$row.action|replace:'xx':$row.id}
{ts}No Scheduled Reminders have been created.{/ts}
{/strip} diff --git a/templates/CRM/Admin/Page/ScheduleReminders.tpl b/templates/CRM/Admin/Page/ScheduleReminders.tpl index dfb08bee8a..a8f519bb9d 100644 --- a/templates/CRM/Admin/Page/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Page/ScheduleReminders.tpl @@ -29,6 +29,8 @@ {if $action eq 1 or $action eq 2 or $action eq 8 or $action eq 16384} {include file="CRM/Admin/Form/ScheduleReminders.tpl"} {else} +{* include wysiwyg related files*} +{include file="CRM/common/wysiwyg.tpl" includeWysiwygEditor=true} {capture assign=schedRemindersDocLink}{docURL page="user/current/email/scheduled-reminders/"}{/capture}
{ts}Scheduled reminders allow you to automatically send messages to contacts regarding their memberships, participation in events, or other activities.{/ts} {$schedRemindersDocLink} @@ -45,8 +47,8 @@ {else}
- {capture assign=crmURL}{crmURL p='civicrm/admin/scheduleReminders' q="action=add&reset=1"}{/capture} - {ts 1=$crmURL}There are no Scheduled Reminders configured. You can add one.{/ts} + {capture assign=crmURL}href="{crmURL p='civicrm/admin/scheduleReminders' q="action=add&reset=1"}" class="action-item"{/capture} + {ts 1=$crmURL}There are no Scheduled Reminders configured. You can add one.{/ts}
{/if} {/if} diff --git a/templates/CRM/Contact/Page/View/Summary.js b/templates/CRM/Contact/Page/View/Summary.js index edf04537ae..0259a90680 100644 --- a/templates/CRM/Contact/Page/View/Summary.js +++ b/templates/CRM/Contact/Page/View/Summary.js @@ -98,8 +98,8 @@ CRM.reloadChangeLogTab(); } // Refresh tab contents - Simple logging - else if ($('#Change_Log div').length) { - $('#Change_Log').load($("#tab_log a").attr('href')); + else if ($('#changeLog').closest('.ui-tabs-panel').data('civicrmCrmSnippet')) { + $('#changeLog').closest('.ui-tabs-panel').crmSnippet('destroy'); } } else { diff --git a/templates/CRM/Contact/Page/View/Summary.tpl b/templates/CRM/Contact/Page/View/Summary.tpl index 6146484d31..27eef2bc6d 100644 --- a/templates/CRM/Contact/Page/View/Summary.tpl +++ b/templates/CRM/Contact/Page/View/Summary.tpl @@ -140,7 +140,7 @@ {foreach from=$allTabs key=tabName item=tabValue} -
  • +
  • {$tabValue.title} {$tabValue.count} diff --git a/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl b/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl index 96c1076d24..4224711518 100755 --- a/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl +++ b/templates/CRM/Event/Form/ManageEvent/ScheduleReminders.tpl @@ -154,80 +154,79 @@ {include file="CRM/Contact/Form/Task/EmailCommon.tpl" upload=1 noAttach=1} - {/if} -
    - {include file="CRM/common/formButtons.tpl" location="bottom"}
    -
  • -{/if} -{include file="CRM/common/showHideByFieldValue.tpl" -trigger_field_id = "is_repeat" -trigger_value = "true" -target_element_id = "repeatFields" -target_element_type = "table-row" -field_type = "radio" -invert = "false" -} - -{include file="CRM/common/showHideByFieldValue.tpl" -trigger_field_id ="recipient" -trigger_value = 'manual' -target_element_id ="recipientManual" -target_element_type ="table-row" -field_type ="select" -invert = 0 -} - -{include file="CRM/common/showHideByFieldValue.tpl" -trigger_field_id ="recipient" -trigger_value = 'group' -target_element_id ="recipientGroup" -target_element_type ="table-row" -field_type ="select" -invert = 0 -} - -{literal} - -{/literal} + {literal} + + {/literal} + {/if} +
    + {include file="CRM/common/formButtons.tpl" location="bottom"}
    + +{/if} diff --git a/templates/CRM/common/TabHeader.js b/templates/CRM/common/TabHeader.js index 56cdcab228..7e2543a3ca 100644 --- a/templates/CRM/common/TabHeader.js +++ b/templates/CRM/common/TabHeader.js @@ -1,4 +1,9 @@ // https://civicrm.org/licensing +/** + * By default this simply loads tabs via ajax CRM.loadPage method + * Tabs with class 'ajaxForm' will use CRM.loadForm instead, suitable for most forms + * Tabs with class 'livePage' will get popup action links, suitable for crud tables + */ cj(function($) { var tabSettings = CRM.tabSettings || {}; tabSettings.active = tabSettings.active ? $('#tab_' + tabSettings.active).prevAll().length : 0; @@ -24,6 +29,23 @@ cj(function($) { }) }); } + if (ui.tab.hasClass('livePage')) { + ui.panel + .off('click.crmLivePage') + .on('click.crmLivePage', 'a.button, a.action-item', function() { + // only follow real links not javascript buttons + if ($(this).attr('href') === '#' || $(this).attr('onclick')) { + return; + } + CRM.loadForm($(this).attr('href'), { + openInline: 'a:not([href="#"])' + }).on('crmFormSuccess', function(e, data) { + // Refresh when form completes + ui.panel.crmSnippet('refresh'); + }); + return false; + }); + } CRM[method]($('a', ui.tab).attr('href'), params); } e.preventDefault();