From: Kurund Jalmi Date: Thu, 28 Mar 2013 11:52:18 +0000 (+0530) Subject: worked on CRM-12202, reuse existing CRM.confirm(), more code cleanup X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e290f251db096f0077cfea5b321efa6d8cfb49cd;p=civicrm-core.git worked on CRM-12202, reuse existing CRM.confirm(), more code cleanup --- diff --git a/templates/CRM/Case/Form/ActivityChangeStatus.js b/templates/CRM/Case/Form/ActivityChangeStatus.js index 7421776de1..77e077fadf 100644 --- a/templates/CRM/Case/Form/ActivityChangeStatus.js +++ b/templates/CRM/Case/Form/ActivityChangeStatus.js @@ -10,63 +10,49 @@ cj(function($) { }); function changeActivityStatus(activityId, current_status_id, caseId) { - var buttons = {}; - buttons[ts('Ok')] = function() { - // update the status - var status_id = $("#activity_change_status").val( ); - if (status_id === current_status_id) { - $(this).dialog('close').remove(); - return false; - } - - var dataUrl = CRM.url('civicrm/ajax/rest'); - var data = 'json=1&version=3&entity=Activity&action=update&id=' + activityId + '&status_id=' + status_id - + '&case_id=' + caseId; - $.ajax({ - type : 'POST', - dataType : 'json', - url : dataUrl, - data : data, - success : function(values) { - if (values.is_error) { - CRM.alert(values.error_message, ts('Unable to change status'), 'error'); - return false; - } - else { - // just reload the page on success - window.location.reload(); - } - }, - error : function(jqXHR, textStatus) { - CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error'); - return false; - } - }); - - $(this).dialog('close').remove(); - }; - - buttons[ts('Cancel')] = function() { - $(this).dialog('close').remove(); - }; - - var data = 'snippet=1&reset=1'; - var o = $('
'); addCiviOverlay(o); + var data = 'snippet=1&reset=1'; o.load(CRM.url('civicrm/case/changeactivitystatus'), data, function() { removeCiviOverlay(o); cj("#activity_change_status").val(current_status_id); - }) - .dialog({ - modal: true, - title: ts('Change Activity Status'), - resizable: false, - buttons: buttons, - beforeClose: function() { - $(this).dialog("destroy"); + }); + + CRM.confirm(function() { + // update the status + var status_id = $("#activity_change_status").val( ); + if (status_id === current_status_id) { + return false; } + + var dataUrl = CRM.url('civicrm/ajax/rest'); + var data = 'json=1&version=3&entity=Activity&action=update&id=' + activityId + '&status_id=' + status_id + + '&case_id=' + caseId; + $.ajax({ + type : 'POST', + dataType : 'json', + url : dataUrl, + data : data, + success : function(values) { + if (values.is_error) { + CRM.alert(values.error_message, ts('Unable to change status'), 'error'); + return false; + } + else { + // just reload the page on success + window.location.reload(); + } + }, + error : function(jqXHR) { + CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error'); + return false; + } + }); + } + ,{ + title: ts('Change Activity Status'), + message: o } ); }