From: Coleman Watts Date: Mon, 6 Jan 2014 04:55:41 +0000 (-0800) Subject: CRM-13863 - Ajax event tabs improvements - update 'disabled' tab class, etc. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5d92a7e732f441fd5ae163c9469f6d2f02325f91;p=civicrm-core.git CRM-13863 - Ajax event tabs improvements - update 'disabled' tab class, etc. --- diff --git a/CRM/Core/QuickForm/Action/Display.php b/CRM/Core/QuickForm/Action/Display.php index 832b617d79..e7e51456df 100644 --- a/CRM/Core/QuickForm/Action/Display.php +++ b/CRM/Core/QuickForm/Action/Display.php @@ -157,9 +157,10 @@ class CRM_Core_QuickForm_Action_Display extends CRM_Core_QuickForm_Action { } if ($controller->_QFResponseType == 'json') { - $response = array( - 'content' => $html, - ); + $response = array('content' => $html); + if (!empty($page->ajaxResponse)) { + $response += $page->ajaxResponse; + } if (!empty($form['errors'])) { $response['status'] = 'form_error'; $response['errors'] = $form['errors']; diff --git a/CRM/Event/Form/ManageEvent/EventInfo.php b/CRM/Event/Form/ManageEvent/EventInfo.php index ec5ecdf6b5..2539671f40 100644 --- a/CRM/Event/Form/ManageEvent/EventInfo.php +++ b/CRM/Event/Form/ManageEvent/EventInfo.php @@ -181,10 +181,7 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { CRM_Core_Session::setStatus(ts('If you find that you are creating multiple events with similar settings, you may want to use the Event Templates feature to streamline your workflow.', array(1 => $url)), ts('Tip'), 'info'); } if (!CRM_Utils_System::isNull($eventTemplates)) { - $this->add('select', 'template_id', ts('From Template'), array( - '' => ts('- select -')) + $eventTemplates, - FALSE, array('onchange' => "reloadWindow(this.value);") - ); + $this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $eventTemplates); } } diff --git a/CRM/Event/Form/ManageEvent/Fee.php b/CRM/Event/Form/ManageEvent/Fee.php index 21ce91016e..1363397398 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -796,6 +796,8 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { CRM_Event_BAO_Event::add($params); + // Update tab "disabled" css class + $this->ajaxResponse['tabValid'] = !empty($params['is_monetary']); parent::endPostProcess(); } diff --git a/CRM/Event/Form/ManageEvent/Location.php b/CRM/Event/Form/ManageEvent/Location.php index eddddf145f..c671ce0459 100644 --- a/CRM/Event/Form/ManageEvent/Location.php +++ b/CRM/Event/Form/ManageEvent/Location.php @@ -108,7 +108,7 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { function setDefaultValues() { $defaults = $this->_values; - if (CRM_Utils_Array::value('loc_block_id', $defaults)) { + if (!empty($defaults['loc_block_id'])) { $defaults['loc_event_id'] = $defaults['loc_block_id']; $countLocUsed = CRM_Event_BAO_Event::countEventsUsingLocBlockId($defaults['loc_block_id']); if ($countLocUsed > 1) { @@ -302,6 +302,8 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { $params['id'] = $this->_id; CRM_Event_BAO_Event::add($params); + // Update tab "disabled" css class + $this->ajaxResponse['tabValid'] = TRUE; parent::endPostProcess(); } //end of function diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index 715544b09c..d1f0189b4f 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -696,7 +696,6 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent * @return void */ public function postProcess() { - $params = array(); $params = $this->exportValues(); $params['id'] = $this->_id; @@ -825,6 +824,9 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } } + // Update tab "disabled" css class + $this->ajaxResponse['tabValid'] = !empty($params['is_online_registration']); + parent::endPostProcess(); } //end of function diff --git a/CRM/Event/Form/ManageEvent/ScheduleReminders.php b/CRM/Event/Form/ManageEvent/ScheduleReminders.php index 58c400b9e8..acbc2dcefa 100755 --- a/CRM/Event/Form/ManageEvent/ScheduleReminders.php +++ b/CRM/Event/Form/ManageEvent/ScheduleReminders.php @@ -87,6 +87,9 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage $reminderList = TRUE; } $this->assign('rows', $reminderList); + + // Update tab "disabled" css class + $this->ajaxResponse['tabValid'] = !empty($reminderList) && is_array($reminderList); } } diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index d591fc35a9..2de811aeca 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -67,7 +67,7 @@ class CRM_Event_Form_ManageEvent_TabHeader { ); $tabs = array( - 'settings' => array('title' => ts('Info and Settings')) + $default, + 'settings' => array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') + $default, 'location' => array('title' => ts('Event Location')) + $default, 'fee' => array('title' => ts('Fees')) + $default, 'registration' => array('title' => ts('Online Registration')) + $default, @@ -89,7 +89,7 @@ class CRM_Event_Form_ManageEvent_TabHeader { if ($eventID) { // disable tabs based on their configuration status $sql = " -SELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.id as is_pcp, sch.id as is_reminder +SELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.is_active as is_pcp, sch.id as is_reminder FROM civicrm_event e LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id ) LEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id ) diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index a52317e577..c2b815497c 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -228,7 +228,6 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { * @return void */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this diff --git a/CRM/Friend/Form/Event.php b/CRM/Friend/Form/Event.php index dec3b68e6f..4a1c03296d 100644 --- a/CRM/Friend/Form/Event.php +++ b/CRM/Friend/Form/Event.php @@ -126,6 +126,9 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent { CRM_Friend_BAO_Friend::addTellAFriend($formValues); + // Update tab "disabled" css class + $this->ajaxResponse['tabValid'] = !empty($formValues['tf_is_active']); + parent::endPostProcess(); } diff --git a/CRM/PCP/Form/Event.php b/CRM/PCP/Form/Event.php index e3c88454b5..23ffdde5d8 100644 --- a/CRM/PCP/Form/Event.php +++ b/CRM/PCP/Form/Event.php @@ -204,6 +204,9 @@ class CRM_PCP_Form_Event extends CRM_Event_Form_ManageEvent { $dao = CRM_PCP_BAO_PCP::add($params); + // Update tab "disabled" css class + $this->ajaxResponse['tabValid'] = !empty($params['is_active']); + parent::endPostProcess(); } diff --git a/js/Common.js b/js/Common.js index 52f9c92faf..9493cdcebb 100644 --- a/js/Common.js +++ b/js/Common.js @@ -848,7 +848,8 @@ CRM.validate = CRM.validate || { this.element.addClass('crm-container'); } this._handleOrderLinks(); - this.options.url ? this.refresh() : this.options.url = document.location.href; + // Set default if not supplied + this.options.url = this.options.url || document.location.href; this._originalUrl = this.options.url; }, _onFailure: function(data) { @@ -889,7 +890,7 @@ CRM.validate = CRM.validate || { return; } data.url = url; - that.element.html(data.content); + that.element.trigger('crmBeforeLoad', data).html(data.content); that._handleOrderLinks(); that.element.trigger('crmLoad', data); that.options.crmForm && that.element.trigger('crmFormLoad', data); @@ -930,7 +931,8 @@ CRM.validate = CRM.validate || { data.title && $(this).dialog('option', 'title', data.title); }); } - return $(settings.target).crmSnippet(settings); + $(settings.target).crmSnippet(settings).crmSnippet('refresh'); + return $(settings.target); }; CRM.loadForm = function(url, options) { @@ -945,7 +947,7 @@ CRM.validate = CRM.validate || { onCancel: function(event) {}, onError: function(data) { var $el = $(this); - $el.html(data.content).trigger('crmLoad', data).trigger('crmFormLoad', data); + $el.html(data.content).trigger('crmLoad', data).trigger('crmFormLoad', data).trigger('crmFormError', data); if (typeof(data.errors) == 'object') { $.each(data.errors, function(formElement, msg) { $('[name="'+formElement+'"]', $el).crmError(msg); diff --git a/templates/CRM/Campaign/Form/addCampaignToComponent.tpl b/templates/CRM/Campaign/Form/addCampaignToComponent.tpl index aaf99214a7..79713ff537 100644 --- a/templates/CRM/Campaign/Form/addCampaignToComponent.tpl +++ b/templates/CRM/Campaign/Form/addCampaignToComponent.tpl @@ -59,7 +59,8 @@
{ts}There are currently no active Campaigns.{/ts} {if $campaignInfo.addCampaignURL} - {ts 1=$campaignInfo.addCampaignURL}If you want to associate this record with a campaign, you can create a campaign here.{/ts} + {capture assign="link"}href="{$campaignInfo.addCampaignURL}" class="action-item action-item-first"{/capture} + {ts 1=$link}If you want to associate this record with a campaign, you can create a campaign here.{/ts} {/if} {help id="id-campaign_id" file="CRM/Campaign/Form/addCampaignToComponent.hlp"}
{/if} diff --git a/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl b/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl index 1e40f861d2..a94b6c9280 100644 --- a/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl +++ b/templates/CRM/Event/Form/ManageEvent/EventInfo.tpl @@ -173,19 +173,13 @@ {literal} {/literal} diff --git a/templates/CRM/Event/Form/ManageEvent/Tab.tpl b/templates/CRM/Event/Form/ManageEvent/Tab.tpl index 4d659c0185..095cbcda05 100644 --- a/templates/CRM/Event/Form/ManageEvent/Tab.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Tab.tpl @@ -75,27 +75,35 @@ {literal} {/literal} diff --git a/templates/CRM/common/TabHeader.js b/templates/CRM/common/TabHeader.js index 0209f4e2f3..37fb70f2f5 100644 --- a/templates/CRM/common/TabHeader.js +++ b/templates/CRM/common/TabHeader.js @@ -47,11 +47,15 @@ cj(function($) { }); } ui.panel - .off('crmLoad.tabCount') - .on('crmLoad.tabCount', function(e, data) { + .off('.tabInfo') + .on('crmLoad.tabInfo crmFormSuccess.tabInfo', function(e, data) { if (typeof(data.tabCount) !== 'undefined') { CRM.tabHeader.updateCount(ui.tab, data.tabCount); } + if (typeof(data.tabValid) !== 'undefined') { + var method = data.tabValid ? 'removeClass' : 'addClass'; + ui.tab[method]('disabled'); + } }); CRM[method]($('a', ui.tab).attr('href'), params); }