</div>\r
</div>\r
</div>\r
-<div id="preview-dialog" class="hiddenElement">\r
- <div id="generated_dates" class="show-block"></div>\r
-</div>\r
{literal}\r
<script type="text/javascript">\r
CRM.$(function($) {\r
});\r
});\r
\r
- //Detect changes in Repeat configuration field\r
- var unsavedChanges = false;\r
- $('div.crm-core-form-recurringentity-block').on('change', function() {\r
- unsavedChanges = true;\r
- });\r
-\r
//If there are changes in repeat configuration, enable save button\r
//Dialog for preview repeat Configuration dates\r
function previewDialog() {\r
+ $('#allowRepeatConfigToSubmit').val(CRM.utils.initialValueChanged('.crm-core-form-recurringentity-block') ? '1' : '0');\r
var payload = $form.serialize() + '&entity_table={/literal}{$entityTable}{literal}&entity_id={/literal}{$currentEntityId}{literal}',\r
settings = CRM.utils.adjustDialogDefaults({\r
url: CRM.url("civicrm/recurringentity/preview", payload)\r
e.preventDefault();\r
});\r
\r
- $('#_qf_Activity_upload-top, #_qf_Activity_upload-bottom').click( function () {\r
- //Process this only when repeat is configured. We need to do this test here as there is a common save for activity.\r
- var isRepeatConfigured = '{/literal}{$scheduleReminderId}{literal}';\r
- if (isRepeatConfigured) {\r
- if (unsavedChanges) {\r
- $('#allowRepeatConfigToSubmit').val('1');\r
- //Set this variable to decide which dialog box to show\r
- $.data( document.body, "preview-dialog", true );\r
- return previewDialog();\r
- }\r
- else {\r
- $.data( document.body, "preview-dialog", false );\r
- return false;\r
- }\r
- }\r
- else {\r
- if (unsavedChanges) {\r
- $('#allowRepeatConfigToSubmit').val('1');\r
- return previewDialog();\r
- }\r
+ $('#_qf_Activity_upload-top, #_qf_Activity_upload-bottom').click( function (e) {\r
+ if (CRM.utils.initialValueChanged('.crm-core-form-recurringentity-block')) {\r
+ e.preventDefault();\r
+ previewDialog();\r
}\r
});\r
\r
| see the CiviCRM license FAQ at http://civicrm.org/licensing |\r
+--------------------------------------------------------------------+\r
*}\r
+{if $hasParent || $isRepeatingEntity || $scheduleReminderId}\r
+ <script type="text/template" id="recurring-dialog-tpl">\r
+ <div class="crm-form-block recurring-dialog">\r
+ <h4>{ts}How would you like this change to affect other entities in the repetition set?{/ts}</h4>\r
+ <div class="crm-block">\r
+ <input type="radio" id="recur-only-this-entity" name="recur_mode" value="1">\r
+ <label for="recur-only-this-entity">{ts}Only this entity{/ts}</label>\r
+ <div class="description">{ts}All other entities in the series will remain unchanged.{/ts}</div>\r
\r
-<div id="recurring-dialog" class="hiddenElement">\r
- {ts}How would you like this change to affect other entities in the repetition set?{/ts}<br/><br/>\r
- <div class="show-block">\r
- <div class="recurring-dialog-inner-wrapper">\r
- <div class="recurring-dialog-inner-left">\r
- <button class="recurring-dialog-button only-this-event">{ts}Only this entity{/ts}</button>\r
- </div>\r
- <div class="recurring-dialog-inner-right">{ts}All other entities in the series will remain same.{/ts}</div>\r
- </div>\r
- <div class="recurring-dialog-inner-wrapper">\r
- <div class="recurring-dialog-inner-left">\r
- <button class="recurring-dialog-button this-and-all-following-event">{ts}This and Following entities{/ts}</button>\r
- </div>\r
- <div class="recurring-dialog-inner-right">{ts}Change applies to this and all the following entities.{/ts}</div>\r
- </div>\r
- <div class="recurring-dialog-inner-wrapper">\r
- <div class="recurring-dialog-inner-left">\r
- <button class="recurring-dialog-button all-events">{ts}All the entities{/ts}</button>\r
- </div>\r
- <div class="recurring-dialog-inner-right">{ts}Change applies to all the entities in the series.{/ts}</div>\r
- </div>\r
+ <input type="radio" id="recur-this-and-all-following-entity" name="recur_mode" value="2">\r
+ <label for="recur-this-and-all-following-entity">{ts}This and Following entities{/ts}</label>\r
+ <div class="description">{ts}Change applies to this and all the following entities.{/ts}</div>\r
+\r
+ <input type="radio" id="recur-all-entity" name="recur_mode" value="3">\r
+ <label for="recur-all-entity">{ts}All the entities{/ts}</label>\r
+ <div class="description">{ts}Change applies to all the entities in the series.{/ts}</div>\r
+ </div>\r
+ <div class="status help"><div class="icon ui-icon-lightbulb"></div>{ts}Changes to date or time will NOT be applied to other entities in the series.{/ts}</div>\r
</div>\r
- <div class="status"><div class="icon ui-icon-lightbulb"></div> Changes to date or time will NOT be applied to other entities in the series.</div>\r
-</div>\r
-{if $hasParent || $isRepeatingEntity}\r
+ </script>\r
{literal}\r
<script type="text/javascript">\r
CRM.$(function($) {\r
- var $dialog;\r
- /** Add your linked entity mapper here **/\r
- var mapper = {'CRM_Event_Form_ManageEvent_EventInfo': '',\r
- 'CRM_Event_Form_ManageEvent_Location': '',\r
- 'CRM_Event_Form_ManageEvent_Fee': '',\r
- 'CRM_Event_Form_ManageEvent_Registration': '',\r
- 'CRM_Friend_Form_Event': 'civicrm_tell_friend',\r
- 'CRM_PCP_Form_Event': 'civicrm_pcp_block',\r
- 'CRM_Activity_Form_Activity': ''\r
- };\r
+ var $form, formClass,\r
+ /** Add your linked entity mapper here **/\r
+ mapper = {\r
+ 'CRM_Event_Form_ManageEvent_EventInfo': '',\r
+ 'CRM_Event_Form_ManageEvent_Location': '',\r
+ 'CRM_Event_Form_ManageEvent_Fee': '',\r
+ 'CRM_Event_Form_ManageEvent_Registration': '',\r
+ 'CRM_Friend_Form_Event': 'civicrm_tell_friend',\r
+ 'CRM_PCP_Form_Event': 'civicrm_pcp_block',\r
+ 'CRM_Activity_Form_Activity': ''\r
+ };\r
+\r
function cascadeChangesDialog() {\r
- $dialog = $("#recurring-dialog").dialog({\r
- title: 'How does this change affect other repeating entities in the set?',\r
- modal: true,\r
- width: '650',\r
- buttons: {\r
- Cancel: function() { //cancel\r
- $( this ).dialog( "close" );\r
- }\r
- }\r
- }).dialog('open');\r
+ CRM.confirm({\r
+ message: $('#recurring-dialog-tpl').html()\r
+ })\r
+ .on('crmConfirm:yes', updateMode)\r
+ .on('click change', 'input[name=recur_mode]', function() {\r
+ $('button[data-op=yes]').prop('disabled', false);\r
+ })\r
+ .parent().find('button[data-op=yes]').prop('disabled', true)\r
}\r
- var form = '';\r
- $('#crm-main-content-wrapper').on('click', 'div.crm-submit-buttons span.crm-button input[value="Save"], div.crm-submit-buttons span.crm-button input[value="Save and Done"]', function() {\r
- form = $(this).parents('form:first').attr('class');\r
- if( form != "" && mapper.hasOwnProperty(form) ){\r
- cascadeChangesDialog();\r
- return false;\r
- }\r
- });\r
-\r
- $("#_qf_Activity_upload-top, #_qf_Activity_upload-bottom").click(function() {\r
- form = $(this).parents('form:first').attr('class');\r
- if( form != "" && mapper.hasOwnProperty(form) ){\r
- var showPreviewDialog = $.data( document.body, "preview-dialog");\r
- if (showPreviewDialog == false) {\r
- cascadeChangesDialog();\r
- }\r
- return false;\r
- }\r
- });\r
\r
- $(".only-this-event").click(function() {\r
- updateMode(1);\r
- });\r
-\r
- $(".this-and-all-following-event").click(function() {\r
- updateMode(2);\r
- });\r
-\r
- $(".all-events").click(function() {\r
- updateMode(3);\r
+ $('#crm-main-content-wrapper').on('click', '.crm-form-submit.validate', function(e) {\r
+ $form = $(this).closest('form');\r
+ var className = ($form.attr('class') || '').match(/CRM_\S*/);\r
+ formClass = className && className[0];\r
+ if (formClass && mapper.hasOwnProperty(formClass) &&\r
+ // For activities, only show this if the changes were not made to the recurring settings\r
+ (formClass !== 'CRM_Activity_Form_Activity' || !CRM.utils.initialValueChanged('.crm-core-form-recurringentity-block'))\r
+ ) {\r
+ cascadeChangesDialog();\r
+ e.preventDefault();\r
+ }\r
});\r
\r
- function updateMode(mode) {\r
- var entityID = parseInt('{/literal}{$entityID}{literal}');\r
- var entityTable = '{/literal}{$entityTable}{literal}';\r
- if (entityID != "" && mode && mapper.hasOwnProperty(form) && entityTable !="") {\r
- var ajaxurl = CRM.url("civicrm/ajax/recurringentity/update-mode");\r
- var data = {mode: mode, entityId: entityID, entityTable: entityTable, linkedEntityTable: mapper[form]};\r
- $.ajax({\r
- dataType: "json",\r
- data: data,\r
- url: ajaxurl,\r
- success: function (result) {\r
+ function updateMode() {\r
+ var mode = $('input[name=recur_mode]:checked', this).val(),\r
+ entityID = parseInt('{/literal}{$entityID}{literal}'),\r
+ entityTable = '{/literal}{$entityTable}{literal}';\r
+ if (entityID != "" && mode && mapper.hasOwnProperty(formClass) && entityTable !="") {\r
+ $.getJSON(CRM.url("civicrm/ajax/recurringentity/update-mode",\r
+ {mode: mode, entityId: entityID, entityTable: entityTable, linkedEntityTable: mapper[formClass]})\r
+ ).done(function (result) {\r
if (result.status != "" && result.status == 'Done') {\r
- $('#mainTabContainer div:visible Form, form.'+form).submit();\r
- $dialog.dialog('close');\r
+ $form.submit();\r
} else if (result.status != "" && result.status == 'Error') {\r
- var errorBox = confirm(ts("Mode could not be updated, save only this event?"));\r
- if (errorBox == true) {\r
- $('#mainTabContainer div:visible Form, form.'+form).submit();\r
- $dialog.dialog('close');\r
- } else {\r
- $dialog.dialog('close');\r
- return false;\r
+ if (confirm(ts("Mode could not be updated, save only this event?"))) {\r
+ $form.submit();\r
}\r
}\r
- }\r
- });\r
+ });\r
}\r
}\r
});\r