From e3bacb356593856e6d3ad3bb1f33ed0ec7b173c8 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 1 Feb 2017 18:12:18 +0100 Subject: [PATCH] * Mobile template: Fix "info message regarding fullscreen" does not respect the discard checkbox --- api/js/jsapi/egw_message.js | 39 ++++++++++++++++++++++++------------- mail/js/app.js | 2 +- pixelegg/js/fw_mobile.js | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/api/js/jsapi/egw_message.js b/api/js/jsapi/egw_message.js index 9c506b2a7a..00d298743b 100644 --- a/api/js/jsapi/egw_message.js +++ b/api/js/jsapi/egw_message.js @@ -59,9 +59,11 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) * * @param {string} _msg message to show or empty to remove previous message * @param {string} _type 'help', 'info', 'error', 'warning' or 'success' (default) - * @param {boolean} _discard if true, it will show a checkbox in order to discard the message, default is false + * @param {string} _discardID unique string id (appname:id) in order to register + * the message as discardable. If no appname given, the id will be prefixed with + * current app. The discardID will be stored in local storage. */ - message: function(_msg, _type, _discard) + message: function(_msg, _type, _discardID) { var jQuery = _wnd.jQuery; @@ -103,22 +105,22 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) .addClass(_type+'_message') .click(function() { //check if the messeage should be discarded forever - if (_type == 'info' && _discard + if (_type == 'info' && _discardID && msg_chkbox && msg_chkbox.is(':checked')) { - var discarded = egw.getLocalStorageItem(egw.app_name(),'discardedMsgs'); + var discarded = egw.getLocalStorageItem(discardAppName,'discardedMsgs'); - if (!isDiscarded(_msg)) + if (!isDiscarded(_discardID)) { if (!discarded) { - discarded = [_msg]; + discarded = [_discardID]; } else { - if (jQuery.isArray(JSON.parse(discarded))) discarded.push(_msg); + if (jQuery.isArray(discarded = JSON.parse(discarded))) discarded.push(_discardID); } - egw.setLocalStorageItem(egw.app_name(),'discardedMsgs',JSON.stringify(discarded)); + egw.setLocalStorageItem(discardAppName,'discardedMsgs',JSON.stringify(discarded)); } } jQuery(this).remove(); @@ -126,18 +128,27 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) .css('position', 'absolute'); // discard checkbox implementation - if (_discard && _type === 'info') + if (_discardID && _type === 'info') { - // helper function to check if the messaege is discarded - var isDiscarded = function (_msg) + var discardID = _discardID.split(':'); + if (discardID.length<2) { - var discarded = JSON.parse(egw.getLocalStorageItem(egw.app_name(),'discardedMsgs')); + _discardID = egw.app_name() +":"+_discardID; + } + var discardAppName = discardID.length>1? discardID[0]: egw.app_name(); + + + // helper function to check if the messaege is discarded + var isDiscarded = function (_id) + { + + var discarded = JSON.parse(egw.getLocalStorageItem(discardAppName,'discardedMsgs')); if (jQuery.isArray(discarded)) { for(var i=0; i< discarded.length; i++) { - if (discarded[i] === _msg) return true; + if (discarded[i] === _id) return true; } } return false; @@ -158,7 +169,7 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd) .attr({for:'msgChkbox'}) .appendTo(msg_discard); - if (isDiscarded(_msg)) return; + if (isDiscarded(_discardID)) return; msg_div.append(msg_discard); } diff --git a/mail/js/app.js b/mail/js/app.js index c4812b1497..ea6e843a11 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -311,7 +311,7 @@ app.classes.mail = AppJS.extend( } break; case 'mail.folder_management': - this.egw.message(this.egw.lang('If you would like to select multiple folders in one action, you can hold ctrl key then select a folder as start range and another folder within a same level as end range, all folders in between will be selected or unselected based on their current status.'),'info',true); + this.egw.message(this.egw.lang('If you would like to select multiple folders in one action, you can hold ctrl key then select a folder as start range and another folder within a same level as end range, all folders in between will be selected or unselected based on their current status.'),'info','mail:folder_management'); break; case 'mail.view': // we need to set mail_currentlyFocused var otherwise mail diff --git a/pixelegg/js/fw_mobile.js b/pixelegg/js/fw_mobile.js index b3aa6aef09..ebd167c2b0 100644 --- a/pixelegg/js/fw_mobile.js +++ b/pixelegg/js/fw_mobile.js @@ -378,7 +378,7 @@ // then prompt user base on the mode, and if the user // discards the message once then do not show it again var fullScreen = this.isNotFullScreen(); - if (fullScreen && this.getUserAgent() !='iOS') egw.message(fullScreen,'info', true); + if (fullScreen && this.getUserAgent() !='iOS') egw.message(fullScreen,'info', 'etemplate:fw_mobile_fullscreen'); }, /**