From 9a7ef94f0b79bb9f9c55f8a60b2bb32433ffd551 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 12 Mar 2014 20:13:13 -0400 Subject: [PATCH] CRM-13817 - mini notification default messages based on api action --- js/Common.js | 4 ++-- js/rest.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/js/Common.js b/js/Common.js index 2d04520c30..52cf53d006 100644 --- a/js/Common.js +++ b/js/Common.js @@ -552,13 +552,13 @@ CRM.validate = CRM.validate || { * @return jQuery deferred object - if not supplied a new one will be created */ CRM.status = function(options, deferred) { - // For simple usage without async operations you can pass in a string. 2nd param can be 'success' or 'error' + // For simple usage without async operations you can pass in a string. 2nd param is optional string 'error' if this is not a success msg. if (typeof options === 'string') { return CRM.status({start: options, success: options, error: options})[deferred === 'error' ? 'reject' : 'resolve'](); } var opts = $.extend({ start: ts('Saving...'), - success: ts('Saved.'), + success: ts('Saved'), error: function() { CRM.alert(ts('Sorry an error occurred and your information was not saved'), ts('Error')); } diff --git a/js/rest.js b/js/rest.js index 3b4ffe21a1..380bfcf5c2 100644 --- a/js/rest.js +++ b/js/rest.js @@ -105,7 +105,16 @@ var CRM = CRM || {}; type: params.action.indexOf('get') < 0 ? 'POST' : 'GET' }); if (status) { - CRM.status(status === true ? {} : status, ajax); + // Default status messages + if (status === true) { + status = {success: params.action === 'delete' ? ts('Removed') : ts('Saved')}; + if (params.action.indexOf('get') === 0) { + status.start = ts('Loading...'); + status.success = null; + } + } + var messages = status === true ? {} : status; + CRM.status(status, ajax); } return ajax; }; -- 2.25.1