Sei sulla pagina 1di 6

<apex:component controller="WhiteSpaceComponentController" id="WSComponent" layo

ut="block">
<apex:attribute name="accountId" description="Account Id" type="String" requ
ired="true"
assignTo="{! rootAccountId}"/>
<apex:attribute name="targetCurrencyIsoCode" description="Currency in which
the values are to be displayed" type="String" required="false" assignTo="{!targe
tCurrency}"/>
<apex:attribute name="width" description="Width of commponent" type="String"
required="false"
default="100%"/>
<apex:attribute name="height" description="Height of Component" type="String
" required="false"
default="100%"/>
<apex:attribute name="divId" description="Div Where Matrix Created" type="St
ring" required="false" default="whitespace"/>
<apex:attribute name="isPrintMode" description="For PDF" type="Boolean" requ
ired="false" default="false"/>
<apex:attribute name="isReadOnly" description="For GrandStand" type="Boolean
" required="false" default="false"/>
<apex:attribute name="dropUnusedOfferings" description="For PDF" type="Boole
an" required="false" default="false"/>
<apex:attribute name="isAccountDossier" description="For Account Dossier" ty
pe="Boolean" required="false" default="false"/>
<head>
<script src="{!URLFOR($Resource.thirdPartyScript)}/thirdParty/d3/d3.min.
js"></script>
<script src="{!URLFOR($Resource.thirdPartyScript)}/thirdParty/c3/c3.js">
</script>
<apex:includeScript value="{!URLFOR($Resource.jsScript,'js/Whitespace.js
')}"/>
<script type="text/javascript" src="{!URLFOR($Resource.thirdPartyScript,
'thirdParty/highcharts/highcharts.js')}"/>
<script type="text/javascript" src="{!URLFOR($Resource.thirdPartyScript,
'thirdParty/qTip/jquery.qtip.min.js')}"/>
<link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.cssScrip
t,'css/Whitespace.css')}"/>
<link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.cssScrip
t,'css/c3.css')}"/>
<link href="{!URLFOR($Resource.thirdPartyScript)}/thirdParty/jqueryUi/cs
s/custom-theme/jquery-ui-1.10.3.custom.css" rel="stylesheet" media="screen"/>
<link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.thirdPar
tyScript,'thirdParty/orgChart/primitives.latest.css')}" />
<link rel="stylesheet" type="text/css" href="{!URLFOR($Resource.thirdPar
tyScript,'thirdParty/qTip/jquery.qtip.min.css')}"/>
<link href="{!URLFOR($Resource.choosen)}/choosen/df_chosen.css" rel="sty
lesheet" media="screen" />
<script type="text/javascript">
j$ = jQuery.noConflict();
var accId;
var offId;
var inputTextFromOffering = '';
var toolTipApiRef = null;
var node;
function initWhitespace(divId){
j$('#loader').show();
var data = JSON.parse('{!JSENCODE(wsMainData)}');
var comments = JSON.parse('{!JSENCODE(wsCommentsData)}');
var isWhitespaceCreatable = {!$ObjectType.LobOffering__c.Createa

ble};
var isWhitespaceDeletable = {!$ObjectType.LobOffering__c.Deletab
le};
var hasAccess = false;
if(isWhitespaceCreatable && isWhitespaceDeletable) hasAccess = t
rue;
if(data != undefined && data.Offerings != undefined && data.Acco
unts != undefined && data.Offerings.length > 0 && data.Accounts.length > 0 ){
var colors = {
// S
et health colors
whitespace : "white",
background : "#DCDEE0"
};
var config = {
healthRange : {
"title" : "{!$Label.Whitespace_CSAT_Label}",
"Low" : {
"text" : "{!$Label.Whitespace_Low_Label}
",
"minValue" : -6,
"maxValue" : -0.67,
"color" : "#C82506"
},
"Med" : {
"text" : "{!$Label.Whitespace_Med_Label}
",
"minValue" : -0.67,
"maxValue" : 4.22,
"color" : "#F5D328"
},
"High": {
"text" : "{!$Label.Whitespace_High_Label
}",
"minValue" : 4.22,
"maxValue" : 10,
"color" : "#70BF41"
},
"Dark": {
"text" : "{!$Label.Whitespace_Discontinu
ed_Engagement_Label}",
"color" : "#a5abb0"
},
"Opportunity" : {
"text" : "{!$ObjectType.Opportunity.Labe
l}",
"color" : colors.background
}
},
selectionDivText : {
"Opportunity" : "{!$ObjectType.Opportunity.Label}",
"Engagement" : "{!$Label.Whitespace_Engagement_Heal
th_Label}",
"Whitespace" : "{!$Label.LBL_WHITESPACE}"
},
detailGraphTitle : "{!$Label.Whitespace_RevenueOverTime}
"
}
createComponent(divId,data,callbackFn,createWhitespace,{!isP
rintMode},{!dropUnusedOfferings},hasAccess,{!isReadOnly},{!isAccountDossier},com
ments,config);

}
else {
var noData = d3.select("#"+divId)
.append("h1")
.style("font-size","x-large")
.text('{!$Label.Whitespace_No_LOB_Offerings_
Msg}');
}
j$('#loader').hide();
}
function callbackFn(accId,offId,graphDataInput,isEng,isOpp) {
j$('svg *').qtip('destroy');
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.WhiteSpaceComponentController.initMonthlyDa
ta}',
accId,offId,'{!rootAccountId}',isEng,isOpp,
function(result, event){
if (event.status) {
j$('#loader').show();
graphDataInput(result);
j$('#loader').hide();
}
},
{escape: true}
);
}
function editWhitespaceComment() {
data = '<div class="createWS">' +
'<textarea class="wsComment" style="width:220px;height:1
00px;">'+inputTextFromOffering+'</textarea><br><br><br>' +
'<button onclick="toggleWhiteSpace(true,this);" >Save</b
utton>'+
'<button onclick="cancelWhiteSpaceComment();" >Cancel</b
utton>'+
'</div>';
toolTipApiRef.set({
'content.text' : data,
});
toolTipApiRef.reposition();
}
function cancelWhiteSpaceComment (argument) {
data = '<div class="removeWs">' +
'<div><b>'+ inputTextFromOffering +'</b></div><br><br><b
r>' +
' <button onclick="editWhitespaceComment();" >Edit</butt
on>'+
' <button onclick="toggleWhiteSpace(false, this);" >{!$La
bel.Unmark_Whitespace_Label}</button>'+
'</div>';
toolTipApiRef.set({
'content.text' : data,
});
toolTipApiRef.reposition();
}

function createWhitespace(accIdInput,offIdInput,cellId,action) {
j$('svg *').qtip('destroy');
if(toolTipApiRef != null) toolTipApiRef.destroy();
accId = accIdInput;
offId = offIdInput;
node = j$("#"+cellId);
var toolTipContent = "";
if(action) {
toolTipContent = j$("#confirmWs").html();
bindToolTip(node,toolTipContent);
}
else {
if(toolTipApiRef != null) toolTipApiRef.destroy();
toolTipContent = "<div><b>Loading ...</b></div><br><br><br>"
;
bindToolTip(node,toolTipContent);
var data = "";
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.WhiteSpaceComponentController.getWhites
paceData}',
accId,offId,
function(result, event){
if (event.status) {
var textField = '{!JSENCODE(TextFieldWithNamespa
ce)}';
inputTextFromOffering = result[textField];
if(inputTextFromOffering == "" || inputTextFromO
ffering == undefined) {
inputTextFromOffering = "No Comments Availab
le";
}
data = '<div class="removeWs">' +
'<div><b>'+ inputTextFromOffering +'</b>
</div><br><br><br>' +
' <button onclick="editWhitespaceComment
();" >Edit</button>'+
' <button onclick="toggleWhiteSpace(false
, this);" >{!$Label.Unmark_Whitespace_Label}</button>'+
'</div>';
toolTipApiRef.set({
'content.text' : data,
});
toolTipApiRef.reposition();
}
},
{escape: true}
);
}
};
function bindToolTip(node,toolTipContent) {
j$('svg *').qtip({
overwrite : true,
content : {
text : function(event, api) {

toolTipApiRef = api;
return toolTipContent;
},
button : 'close'
},
style : {
width : 250,
height : 150,
classes: 'dfToolTip QTIP_CONTENT_STYLE'
},
position : {
my : 'center left',
at : 'center right',
target : node
},
show : {
solo : true,
event : 'click'
},
hide : {
event : 'unfocus'
},
events : {
hide : function(event, api) {
api.destroy();
}
}
});
}
function toggleWhiteSpace(isCreate, btnRef) {
if(toolTipApiRef != null) toolTipApiRef.destroy();
var inputText = j$(btnRef).siblings('.wsComment').val();
if (isCreate) createWS(inputText);
else removeWS();
}
function createWS(inputText) {
toolTipApiRef.set({
'content.text' : 'Creating Whitespace...',
});
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.WhiteSpaceComponentController.createWhitesp
aceCell}',
accId,offId,inputText,
function(result, event){
if (event.status) {
j$('#loader').show();
location.reload();
j$('#loader').hide();
}
},
{escape: true}
);
}
function removeWS() {
toolTipApiRef.set({
'content.text' : 'Removing Whitespace...',

});
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.WhiteSpaceComponentController.deleteWhitesp
ace}',
accId,offId,
function(result, event){
if (event.status) {
j$('#loader').show();
location.reload();
j$('#loader').hide();
}
},
{escape: true}
);
}
</script>
</head>
<apex:outputPanel layout="block" id="WSComponent">
<div id="loader" style="display:hidden;">
<c:Loading />
</div>
<div id="confirmWs" style="display:none;">
<textarea class="wsComment" style="width:220px;height:100px;"></text
area>
<button onclick="toggleWhiteSpace(true, this);" style="margin-top:10
px;">{!$Label.Mark_Whitespace}</button>
</div>
<div id="{!divId}" style="width:{! width};height:{! height};"></div>
<script type="text/javascript">
initWhitespace("{!divId}");
</script>
</apex:outputPanel>
</apex:component>

Potrebbero piacerti anche