/** * IBM Confidential OCO Source Materials IBM Business Platform: CA Share * (C) Copyright IBM Corp. 2017, 2018 * * The source code for this program is not published or otherwise divested of * its trade secrets, irrespective of what has been deposited with the U.S. * Copyright Office */ define("bi/notifications/app/n10nController",["react","react-dom","ba-react-admin/ba-react-admin.min","bi/content_apps/utils/GlassContextHelper","bacontentnav/utils/ContentStoreObject","q","jquery","bi/sharecommon/utils/translator"],function(e,t,n,i,s,a,o,r){return{MAX_DISPLAY:20,PREVIEW_PANE_WIDTH:"400px",showNotificationContent:function(a){return a.glassContext.getSvc(".Notification").then(function(d){return d.getSpecificNotification(a.messageId).then(function(l){var c=e.createElement(n.PreviewView,{onHide:a.onHideCallback,data:l,glassContext:a.glassContext,GlassContextHelper:i,ContentStoreObject:s,StringResource:r,messageList:a.messageListView});l.unread&&d.markRead(a.messageId),o(".flyoutPane.pane-right.active.shadow").append('
'),t.unmountComponentAtNode(document.getElementsByClassName("notificationNewSlideout")[0]),c&&c.type.prototype.setOpen(),t.render(c,document.getElementsByClassName("notificationNewSlideout")[0])})["catch"](function(){})}.bind(this))},deleteNotification:function(e,t){return t.glassContext.getSvc(".Notification").then(function(t){return t.deleteNotification(e)})},getNotificationState:function(e,t){return t.glassContext.getSvc(".Notification").then(function(t){return t.getNotificationState(e)})},updateNotificationState:function(e,t){return t.glassContext.getSvc(".Notification").then(function(t){return t.updateNotificationState(e)})},getObjectProperties:function(e,t){return t.glassContext.getSvc(".Content").then(function(t){var n=t.getBaseObjectsURL()+"/"+e.reportId+"?fields=type,runInAdvancedViewer";return Promise.resolve(t.get(n,{})).then(function(t){if(t.data[0]){var n=t.data[0];return"runInAdvancedViewer"in n&&(e.runInAdvancedViewer=n.runInAdvancedViewer),"type"in n&&(e.type=n.type),e}return Promise.reject()}.bind(this))}.bind(this))}}}),define("bi/notifications/views/n10nBtnView",["bi/glass/app/NavbarButtonSlideoutController","underscore","bi/notifications/app/n10nController","bi/sharecommon/utils/translator"],function(e,t,n,i){"use strict";var s=e.extend({onRender:function(e){e&&(this.glassContext=e.glassContext,e.target.plugin.$el.attr("aria-live","polite")),this.glassContext.getSvc(".Notification").then(function(e){e.on("notifications:newCount",function(e){this.updateButtonText(e)}.bind(this)),e.getNewNotifications()}.bind(this))},updateButtonText:function(e){var t="",s=$(".n10n_badge button");s.length>0&&(e>0?(t=e>n.MAX_DISPLAY?n.MAX_DISPLAY+"+":e,s.attr("data-badge",t),s.attr("aria-label",i.translate("notification_button_accessible_label",{count:t}))):(s.removeAttr("data-badge"),s.removeAttr("aria-label")))}});return s}),define("bi/notifications/views/legacyAppButtonView",["bi/glass/app/plugins/MenuActionInterface","bi/commons/utils/Utils"],function(e,t){"use strict";var n=e.extend({onSelectItem:function(e){var n=e.target.specItemIndex,i=e.target.plugin.itemSpec.items[n];i.tool&&t.legacyLaunch(e.glassContext,i.tool)},isItemVisible:function(e){var t=e.target.itemId,n=t.split("."),i=n[n.length-1];return"legacy_myInbox"===i||"legacy_myWatchItems"===i?this._getIsLaunchable():!1},onRender:function(e){e.glassContext.services.config.getLegacyLaunchable().done(function(e){this._setIsLaunchable(1===e)}.bind(this))},_setIsLaunchable:function(e){this.isLaunchable=e},_getIsLaunchable:function(){return this.isLaunchable}});return n}),define("bi/sharecommon/utils/simpledoT",["doT"],function(e){var t=e;return t.NOT_REPLACED="__NOT_REPLACED__",t.options={verbose:!1},t.simpleTemplate=function(n){var i=n;return t.options.verbose&&(i=n.replace(/\{\{(=[\s\S]+?(\}?)+)\}\}/g,"{{$1 || '"+t.NOT_REPLACED+"($1)'}}")),e.template(i)},t}),define("text!bi/notifications/templates/notification.html",[],function(){return'\n
\n
\n \n
\n
\n
\n'}),define("text!bi/notifications/templates/emptyMessageList.html",[],function(){return'\n
\n
\n\n
{{=it.text}}
\n
\n'}),define("text!bi/notifications/templates/loadingMessagesPopUp.html",[],function(){return'\n\n
'}),define("text!bi/notifications/templates/messagesList.html",[],function(){return'\n{{~it.msgs :msg:index}}\n
\n
\n
\n \n
\n\n
\n \n {{? msg.read === \'unread\'}}{{?}}\n {{=msg.subject}}\n {{? msg.read === \'unread\'}}{{?}}\n \n
\n {{=msg.sender}}\n
\n
\n {{=msg.date}}\n
\n
\n
\n \n
\n{{~}}\n'}),define("bi/notifications/views/messageListView",["bi/commons/ui/View","underscore","jquery","q","bi/sharecommon/utils/simpledoT","text!bi/notifications/templates/messagesList.html","bi/sharecommon/utils/translator","bi/commons/utils/Utils","bi/notifications/app/n10nController","bi/commons/utils/ContentFormatter","moment-timezone"],function(e,t,n,i,s,a,o,r,d,l,c){var u=500,h="L",f=e.extend({init:function(e){f.inherited("init",this,arguments),n.extend(this,e),this.timezone=this.glassContext.services.userProfile.preferences.timeZoneID,this.defaultLocale=this.glassContext.services.userProfile.preferences.contentLocale||"en-us",this.KEYS={TAB:9,ENTER:13,SPACE:32,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40}},setData:function(e){this.data=e},_setEvents:function(){this.$el.find(".n10n_message").off(".n10n").on("keydown.n10n",this._handleKeyDown.bind(this)),this.$el.find(".n10n_message_inner:not(.clickBound)").addClass("clickBound").on("primaryaction",function(e){var t=e.currentTarget.parentNode.id,n=this.$el.find(e.currentTarget.parentNode);if(!n.hasClass("selected")){var i={messageId:t,messageListView:this,glassContext:this.glassContext,onHideCallback:this.clear.bind(this)};d.showNotificationContent(i,this.slideout),this._displayAsRead(n)}}.bind(this)),this.$el.find(".n10n_delete_icon:not(.clickBound)").addClass("clickBound").on("primaryaction",function(e){var t=e.currentTarget.parentNode.id,i={messageId:t,pending:!0};if(this.glassContext.services.userProfile.preferences.accessibilityFeatures)this.glassContext.appController.showMessage(o.translate("delete_notification_confirm_message"),o.translate("delete_confirm"),"info",["ok","cancel"],void 0,function(e){"ok"===e.btn&&this._completeNotificationDelete(i)}.bind(this));else{var s=n(e.currentTarget.parentNode);s.hide(u),this.glassContext.appController.showToast(o.translate("delete_notification_message"),{type:"info",btnLabel:o.translate("delete_undo"),callback:function(){i.pending=!1,this.$el.find("#"+i.messageId).show(u)}.bind(this),newestOnTop:!0,preventDuplicates:!1,timeOut:6e3,extendedTimeOut:1e3,onHidden:function(){this._completeNotificationDelete(i)}.bind(this)})}}.bind(this))},_handleKeyDown:function(e){var t=e.keyCode||e.charCode||e.which||0;if(t===this.KEYS.UP_ARROW||t===this.KEYS.DOWN_ARROW||t===this.KEYS.LEFT_ARROW||t===this.KEYS.RIGHT_ARROW){var i,s=n(e.currentTarget);switch(t){case this.KEYS.DOWN_ARROW:case this.KEYS.RIGHT_ARROW:i=s.next(),"none"==i.css("display")&&(i=i.next());break;case this.KEYS.UP_ARROW:case this.KEYS.LEFT_ARROW:i=s.prev(),"none"==i.css("display")&&(i=i.prev())}i&&i.length>0&&i.find("div.n10n_message_inner").focus(),e.preventDefault()}n(e.target.parentNode).nextAll().length<=1&&(t===this.KEYS.DOWN_ARROW||t===this.KEYS.RIGHT_ARROW)&&this.loadMessagesCallback&&"function"==typeof this.loadMessagesCallback&&this.loadMessagesCallback(this.$el.parent())},_completeNotificationDelete:function(e){var t=this.$el.find("#"+e.messageId),n={glassContext:this.glassContext};e.pending&&d.deleteNotification(e.messageId,n).done(function(){t.remove()}.bind(this))},clear:function(){this.$el.find(".n10n_message").removeClass("selected")},_displayAsRead:function(e){e.attr("aria-label",o.translate("read_notification")),e.find("strong").contents().unwrap(),e.find(".wft_message_unread_32").addClass("wft_message_read_32").removeClass("wft_message_unread_32")},_formatContent:function(){for(var e=this.$el.find(".n10n_message_subject"),t=this.$el.find(".n10n_message_date"),n=this.$el.find(".n10n_message_sender"),i=0;i0){var n=e.next(".n10n_message");if(1==n.length)n.find(".n10n_message_inner").focus(),e=n;else{var i=e.prev(".n10n_message");1==i.length&&(i.find(".n10n_message_inner").focus(),e=i)}}return e}});return f}),define("bi/notifications/views/notificationView",["underscore","jquery","q","bi/sharecommon/utils/simpledoT","text!bi/notifications/templates/notification.html","text!bi/notifications/templates/emptyMessageList.html","text!bi/notifications/templates/loadingMessagesPopUp.html","bi/sharecommon/utils/translator","bi/glass/app/ContentView","bi/notifications/views/messageListView","bi/commons/utils/Utils","bi/notifications/app/n10nController","../../admin/ba-graphics/dist/illustrations-js/notifications_128"],function(e,t,n,i,s,a,o,r,d,l,c,u,h){var f=!0,g=null,p=d.extend({init:function(e){p.inherited("init",this,arguments),t.extend(this,e),this.offset=0,this.prependLoading=!1,this.currentTopUnreadId="",this.currentTopReadId="",this.isShowingEmptyMessageList=!1,this.loadingAnimation=c.getLoadingAnimation(1),this.$loadingMessagePopUp=t(i.template(o)())},setFocus:function(){this.$el.find(".n10n_message_container .n10n_message:first .n10n_message_inner").focus()},_setEvents:function(){this.offset=0;var e=this.$el.find(".n10n_message_container"),t=0,n=!1;e.on("keypress",function(e){var t=e.keyCode||e.charCode||e.which||0;32==t&&e.preventDefault()}),e.scroll(function(){var i=e.scrollTop();i>t&&!n&&i>=e[0].scrollHeight-e.innerHeight()&&(n=!0,this._checkForMoreMessages(e).then(function(){n=!1})),t=i}.bind(this))},_checkForMoreMessages:function(e){return e.find(".n10n_message:last").after(this.$loadingMessagePopUp.append(this.loadingAnimation)),this.glassContext.getSvc(".Notification").then(function(e){return e.getNotifications(u.MAX_DISPLAY,this.offset)}.bind(this)).then(function(e){return g.appendNewMessages(e),this.$loadingMessagePopUp.remove(),this.offset+=e.length,!0}.bind(this))["catch"](function(){})},_loadNewMessages:function(e){function n(e,i,s){for(var o=0;o0&&(this.$el.find(".emptyTableContent").remove(),this.isShowingEmptyMessageList=!1),this.offset+=n.length,g=new l({$el:this.$el.find(".n10n_message_container"),glassContext:this.glassContext,data:n,slideout:this.slideout,loadMessagesCallback:this._checkForMoreMessages.bind(this)}),g.render(),this._getNewTopMsgIds(),f&&(e.on("notifications:deleted",this._getNewTopMsgIds.bind(this)),e.on("notifications:read",this._getNewTopMsgIds.bind(this)),e.on("notifications:new",function(e){var n=e,i=!this.currentTopUnreadId,s=!i,a=i&&e.length,o=s&&e[0].id!==this.currentTopUnreadId&&e[0].id!==this.currentTopReadId,d=a||o;d&&t("#share_message_list").length&&!this.prependLoading&&this.glassContext.appController.showToast(r.translate("toast_new_notifications"),{type:"info",onclick:function(e){e.preventDefault(),this._loadNewMessages(n)}.bind(this),timeOut:0,extendedTimeOut:0})}.bind(this)),f=!1),this}.bind(this))}.bind(this))},_getNewTopMsgIds:function(e){this.currentTopUnreadId=this.$el.find(".n10n_message:has(.unread)").first().attr("id")||"",this.currentTopReadId=this.$el.find(".n10n_message:has(.read)").first().attr("id")||""},__setNotificationViewFirstRender:function(e){f=e}});return p}),define("js/notifications/notificationsBundle",function(){});