(function(){"use strict";u8.Crm.Widgets.ViewWatchlistItemWatchersPopup=function(t,e){this.Widget(t,e)};u8.Crm.Widgets.ViewWatchlistItemWatchersPopup.makeClass({name:"ViewWatchlistItemWatchersPopup",deriveFrom:u8.Base.Widgets.Widget,events:["Close"]});u8.Crm.Widgets.ViewWatchlistItemWatchersPopup.defaults={uid:null,gridOptions:null,headerOptions:null,gridModel:null};$.extend(u8.Crm.Widgets.ViewWatchlistItemWatchersPopup.prototype,{open:function(t){this.uid=t;u8.using({texts:["ViewWatchlistItemWatchersPopup_text"],templates:[{name:"viewWatchlistItemWatchersPopup_template",url:"~/crm/ViewWatchlistItemWatchersPopup.utml.htm"}]},this._create.bind(this))},_create:function(){var s=[{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_2"),dataKey:"watchlistSubscriptionId",width:60,align:"center"},{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_3"),dataKey:"createdByFullName"},{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_4"),dataKey:"createdDate",cellFormatter:t},{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_5"),dataKey:"isActive",align:"center",type:"HTML",cellFormatter:i},{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_6"),dataKey:"notifyOnOption",cellFormatter:e},{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_7"),dataKey:"isDashboardNotification",align:"center",type:"HTML",cellFormatter:i},{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_8"),dataKey:"isPopupNotification",align:"center",type:"HTML",cellFormatter:i},{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_9"),dataKey:"isEmailNotification",align:"center",type:"HTML",cellFormatter:i},{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_10"),dataKey:"isRecordOnlyNotification",align:"center",type:"HTML",cellFormatter:i},{label:$t("TXT_ViewWatchlistItemWatchersPopup_text_11"),dataKey:"notifyOnSpecificFields",cellFormatter:a}];this.gridModel=u8.create("GridModel",{rowActionCount:1,columns:s,selectionMode:"single",pageSize:7,onSelectionChange:this._onGridSelectionChange.bind(this),showPaging:true});var r=this,o=$.extend({parent:this,position:"center",alignTo:"window",allowResize:true,allowMaximize:true,autoShow:false,modal:true,disposeOnClose:true,sizing:"fit",title:$t("TXT_ViewWatchlistItemWatchersPopup_text_1"),onCreate:function(t){r._popup=t;r._createView(r._popup.getContent());r._retrieveWatchers();u8.request("WatchListChannel.GetBusinessObjectName",{id:r.uid.uid},function(t,e){if(e.error){}else{r._popup.setTitle($t("TXT_ViewWatchlistItemWatchersPopup_text_1")+" - "+e.response+"("+r.uid.uid.recordId+")")}})}},this.popup);this._popup=new u8.Base.Widgets.Popup("<div/>",o);this._popup.open()},_createView:function(t){this.gridOptions={emptyGridText:$t("TXT_ViewWatchlistItemWatchersPopup_text_0"),model:this.gridModel,allowColumnReordering:true,allowColumnResizing:true,collapseInvisibleRows:false,header:{fixedText:$t("TXT_ViewWatchlistItemWatchersPopup_text_14")},showPaging:"top"};this.headerOptions={headerName:"Watchers",headerGroupName:"Watchers"};var e=this,i={id:this.id,uid:this.uid,gridOtions:this.gridOptions,headerOptions:this.headerOptions};t.addClass("u8-viewwatchlistitemwatcherspopup").utml({name:"viewWatchlistItemWatchersPopup_template",data:{gridOptions:this.gridOptions,headerOptions:this.headerOptions,id:this.id},itemOptions:{parent:this._popup}},function(){e._popup.autoSizeAndPosition().show()})},_onGridSelectionChange:function(t,e){},_retrieveWatchers:function(){var t=this.gridModel;u8.request("WatchListChannel.ViewAllWatchers",{request:{itemToWatchIdentifier:this.uid.uid.recordId,watchItemType:this.uid.uid.infoAreaId}},function(e,i){if(i.error){}else{t.setData(i.response.watchlistSubscriptions,{createRows:true});t.update({from:0,to:t.getRowCount()-1})}})}});function t(t){var e=u8.services.typeConverter.dateToString(t,"Date Time");return e}function e(t){if(t=="EveryChange"){return $t("TXT_ViewWatchlistItemWatchersPopup_text_12")}if(t=="ChangeOnSpecificField"){return $t("TXT_ViewWatchlistItemWatchersPopup_text_13")}return""}function i(t){return t?'<span class="img u8-img-checkbox-checked-s"></span>':'<span class="img u8-img-checkbox-unchecked-s"></span>'}function a(t){if(t==null||t.length==0){return""}var e="";for(var i=0;i<t.length;i++){e+=t[i].fieldDefinitionName;if(i+1<t.length){e+=","}}return e}})();