" ).css( "font-style", "italic").attr( "title", `[revised on ${revisedOnFormattedDate}]`));
}
container.append( content );
}
},
{ name : "type",
visible : false, // removed per scrum 60553 on 08/27/2024
showInColumnChooser : false,
width : 43,
caption : "Type",
alignment : 'center',
cellTemplate(container, options) {
if( instance.allowFiles && options.data.FileName ) {
let icon = "image";
if(options.data.fileExt == 'PDF' || options.data.fileExt == 'XLS' || options.data.fileExt == 'TXT')
icon = "doc";
container.addClass('chart-cell');
$('
').dxButton({
icon : icon,
onClick() {
if( options.data.docPath ) {
window.open(options.data.docPath);
}
}
}).css({ "border": "none", "background" : "transparent"}).appendTo(container);
}
}
},
{ type : "buttons", width : 30, visible : true, showInColumnChooser : false,
buttons : [
{
icon : "overflow",
onClick : function( e ) {
const rowData = e.row.data;
$("
").dxContextMenu( {
target : e.event.target ,
items : [
{ text : "Email Note", action : "email" },
{ text : "Delete", action : "delete"}
],
onItemClick : function( e ) {
if( e.itemData.action == "email" ) {
//Fse.Portal.showEmailDialog( null, rowData.docPath, null, instance.portalDocRootURL+"/utilities/weblog.cfm?view=noteBody&webblogId=weblog&postId="+rowData.postId+"&subjectId="+rowData.subjectId+"&subjectType="+rowData.subjectType+"&postType="+rowData.postType );
let messageDefaultsURL = Fse.Util.updateURL( instance.portalDocRootURL+"/utilities/weblog.cfm", {
view : "noteBody",
webblogId : "weblog",
postId : rowData.postId,
subjectId : rowData.subjectId,
subjectType : rowData.subjectType,
postType : rowData.postType
})
if( true ) {
let es = new EmailSender( {
messageDefaultsURL : messageDefaultsURL,
from : Fse.Portal.appConfiguration.STP.userEmailAddress,
trackingCode : `PN001_${instance.partnerType}${instance.partnerId}`,
allowImportant : true,
allowReadReceipt : true,
allowAttachments : true
})
es.show();
} else {
Fse.Portal.showEmailDialog( null, rowData.docPath, null, messageDefaultsURL );
}
}
if( e.itemData.action == "delete" ) {
instance.deletePartnerNote( rowData );
}
},
onHidden : function( e ) {
e.component.element().remove();
}
}).appendTo( $("body") ).dxContextMenu( "show" );
}
}
]
}
// { type : "buttons", width : 100, visible : true, showInColumnChooser : false,
// buttons : [
// {
// icon : "email",
// hint : "Email Note",
// onClick : function( e ) {
// let data = e.row.data;
// Fse.Portal.showEmailDialog( null, data.docPath, null, instance.portalDocRootURL+"/utilities/weblog.cfm?view=noteBody&webblogId=weblog&postId="+data.postId+"&subjectId="+data.subjectId+"&subjectType="+data.subjectType+"&postType="+data.postType );
// }
// },
// /*{
// icon : "edit",
// hint : "Revise Note",
// onClick : function( e ) {
// console.log(e.row.data);
// instance.editPartnerNote( e.row.data );
// }
// },*/
// {
// icon : "trash",
// hint : "Delete Note",
// onClick : function( e ) {
// instance.deletePartnerNote( e.row.data );
// }
// }
// ]
// }
]
}).dxDataGrid( "instance" );
}
/*PartnerNotes.prototype.columns = function() {
let columns = [];
let instance = this;
columns.push(
{ dataField : "postTitle", caption: 'Title', width: 280, editorOptions: { maxLength : 75} },
{
visible : true,
// width : 40,
cellTemplate: function(container, cellInfo) {
const valueDiv = $('
').dxButton({
icon: 'trash',
onClick : function( ) {
//console.log(e);
instance.deletePost( cellInfo.data ).done( function(){
instance.dataGrid.refresh();
});
}
})
valueDiv.css({ "vertical-align": "middle", "border" : "none", "background" : "transparent"});
return valueDiv;
}
}
)
return columns;
}*/
PartnerNotes.prototype.addPartnerNote = function( ) {
let instance = this;
instance.addNoteForm = null;
instance.addNoteForm = $("
").dxForm( {
formData : instance.data,
readOnly : false,
validationGroup : "addNoteFormValidation",
showValidationSummary : true,
items : [
{
dataField : "postTitle",
label : { text : "Title" }, editorType: 'dxTextBox',
editorOptions :{
width : 200,
placeholder : "Title"
}
},
{
dataField : "restrictedComment", label : { text : "Restricted" },
editorType : 'dxCheckBox',
value : false,
editorOptions : {
onValueChanged: function (e) {
const previousValue = e.previousValue;
const newValue = e.value;
}
}
},
{ label : { text : "Comments"},
dataField : "postComment",
editorType : "dxTextArea",
editorOptions :{
colSpan: 2,
width : 280,
height: 100,
// tse-183 maxLength: 500,
// value : comments,
placeholder : "Comments"
},
validationRules : [
{ type : "required",
message: 'You must choose a reason for making this revision',
}
]
},
{
dataField : "attachmentUpload",
visible : instance.allowFiles ? true : false,
editorType : "dxFileUploader",
editorOptions :{
selectButtonText: 'Select File',
labelText: '',
accept: '*',
uploadMode: 'useForm',
onFilesUploaded: function(e) {
console.log( e.request.responseText );
let sFileId = e.request.responseText;
let currentValue = $( '#fileIds' ).val();
if( currentValue ) {
$( '#fileIds' ).val( currentValue + ',' + sFileId );
} else {
$( '#fileIds' ).val( sFileId );
}
}
}
}
]
}).dxForm( "instance" );
let d = $.Deferred();
let submitButton = $("
").dxButton( {
text : "Submit",
type : "default",
useSubmitBehavior: true,
validationGroup: "addNoteFormValidation",
onClick : function( be ) {
var result = be.validationGroup.validate();
if (result.isValid)
{
let formDataToSend = new FormData();
let formData = instance.addNoteForm.option( "formData" );
if( instance.allowFiles ) {
let files = [];
let attachmentUpload = formData.attachmentUpload;
if( attachmentUpload ) {
let addSeq = 0;
attachmentUpload.forEach( function( fe ) {
// addSeq++;
let addFileField = "attachmentUpload";
files.push( addFileField );
formDataToSend.append( addFileField, fe, fe.name );
})
}
}
formData.partnerType = instance.partnerType;
formData.partnerId = instance.partnerId;
formData.ownerId = Fse.Portal.appConfiguration.STP.ownerId;
formData.ownerType = Fse.Portal.appConfiguration.STP.ownerType;
formData.userId = instance.userId;
formData.revise = false;
/*dataToSend.lastModifiedDate = dataToSend.attachmentUpload[0].lastModifiedDate;
dataToSend.name = dataToSend.attachmentUpload[0].name;
dataToSend.size = dataToSend.attachmentUpload[0].size;
dataToSend.lastModified = dataToSend.attachmentUpload[0].lastModified;*/
/* if( files.length ) {
formData.files = files;
}*/
formDataToSend.append( "add", JSON.stringify( [ formData ] ));
$.ajax( {
url : instance.saveURL,
method : "post",
data : formDataToSend,
processData : false,
contentType : false,
enctype : "multipart/form-data"
}).always( function() {
instance.addPopup.hide();
instance.dataGrid.refresh();
})
}
return d;
}
}).dxButton( "instance" );
let popupToolbarItems = [
{ toolbar : "bottom", location : "after", widget : "dxButton",
options : {
text : "Cancel",
type : "normal",
onClick : function( be ) {
if( confirm( "Are you sure?" )) {
instance.addPopup.hide();
}
}
}
},
{ toolbar : "bottom", location : "after", template : function() {
return submitButton.element();
}
}
];
let addPopup = $("
").dxPopup( {
title : "Add Note",
height : 350,
width: 430,
resizeEnabled: true,
hideOnOutsideClick : true,
toolbarItems : popupToolbarItems,
contentTemplate : function() {
return $("
")
.append( instance.addNoteForm.element() );
},
onShown: function (e) {
// console.log(instance.partnerContactForm.getEditor('operatorContact'));
},
onHidden : function( e ) {
e.component.element().remove();
e.component.dispose();
// console.log(instance);
}
}).dxPopup( "instance" );
instance.addPopup = addPopup;
instance.addPopup.element().appendTo( "body" );
instance.addPopup.show();
}
PartnerNotes.prototype.editPartnerNote = function( partnerNoteData ) {
let instance = this;
instance.reviseNoteForm = null;
let restrictedValue = "";
if ( typeof partnerNoteData.restrictedComment !== 'undefined')
{
// alert(partnerNoteData.restrictedComment);
if (partnerNoteData.restrictedComment == 'Y')
{ restrictedValue = true;}
else if (partnerNoteData.restrictedComment == 'N')
{restrictedValue = false;}
}
partnerNoteData.restrictedValue = restrictedValue;
instance.reviseNoteForm = $("
").dxForm( {
formData : partnerNoteData,
validationGroup : "reviseNoteFormValidation",
showValidationSummary : true,
items : [
{
dataField : "postTitle",
label : { text : "Title" }, editorType: 'dxTextBox',
editorOptions :{
width : 80,
placeholder : "Title"
}
},
{
label : { location : "left", text : "Restricted", visible: true },
template : function( options, itemElement ) {
let restrictedCheckBox = $("
").dxCheckBox( {
//text: "Check here to suppress Marketing Emails",
value: restrictedValue,
name: "restrictedComment",
onValueChanged: function (e) {
//const previousValue = e.previousValue;
let newValue = e.value;
options.component.updateData( "restrictedComment", newValue );
}
}).css( { "display" : "block" } );
itemElement.append( restrictedCheckBox );
}
}
,
{ label : { text : "Comments"},
dataField : "postComment",
editorType : "dxTextArea",
editorOptions :{
colSpan: 2,
width : 300,
height: 90,
//maxLength: 500,
// value : comments,
placeholder : "Comments"
}
},
{
dataField : "revisedReason",
label : { text : "Reason" },
editorType : "dxSelectBox",
editorOptions : {
width : 180,
placeholder : "--Select One-- ",
dataSource: instance.reviseReasons,
displayExpr: "Reason",
valueExpr : "Reason",
showClearButton : true,
},
validationRules : [
{ type : "required",
message: 'You must choose a reason for making this revision',
}
]
}
]
}).dxForm( "instance" );
let d = $.Deferred();
let submitButton = $("
").dxButton( {
text : "Submit",
type : "default",
validationGroup: "reviseNoteFormValidation",
onClick : function( be ) {
var result = be.validationGroup.validate();
if (result.isValid)
{
//alert("coming here");
instance.saveNote(
{
data : instance.reviseNoteForm.option( "formData" ),
onSuccess : function( data ) {
d.resolve( data );
instance.dataGrid.refresh();
}
});
}
return d;
}
}).dxButton( "instance" );
let popupToolbarItems = [
{ toolbar : "bottom", location : "after", widget : "dxButton",
options : {
text : "Cancel",
type : "normal",
onClick : function( be ) {
if( confirm( "Are you sure?" )) {
instance.revisePopup.hide();
}
}
}
},
{ toolbar : "bottom", location : "after", template : function() {
return submitButton.element();
}
}
];
let revisePopup = $("
").dxPopup( {
title : "Revise Note",
height : 400,
width: 400,
resizeEnabled: true,
hideOnOutsideClick : true,
toolbarItems : popupToolbarItems,
contentTemplate : function() {
return $("
")
.append( instance.reviseNoteForm.element() )
.append("
").append( "Revise comments only when absolutely necessary.").css({"font-weight" : "bold"});
},
onShown: function (e) {
// console.log(instance.partnerContactForm.getEditor('operatorContact'));
},
onHidden : function( e ) {
e.component.element().remove();
e.component.dispose();
// console.log(instance);
}
}).dxPopup( "instance" );
instance.revisePopup = revisePopup;
instance.revisePopup.element().appendTo( "body" );
instance.revisePopup.show();
}
PartnerNotes.prototype.saveNote= function(toBeSavedNoteData) {
let instance = this;
console.log("in save");
instance.options = $.extend( true, {}, toBeSavedNoteData );
//let revise = instance.options.revise;
let loadPanelPopUp = null;
loadPanelPopUp = instance.revisePopup.element();
/* else
{
loadPanelPopUp = instance.addPopup.element();
}*/
let dataToSend = $.extend( true, {}, instance.options.data );
// TODO - get this to protect the page until the load operation is complete
let loadPanel = $("
").dxLoadPanel( {
message : "Working...",
deplay : 0,
hideOnOutsideClick : false,
hideOnParentScroll : false,
container : loadPanelPopUp,
onHidden : function( e ) {
e.component.element().remove();
e.component.dispose();
}
}).appendTo( $("body") ).dxLoadPanel( "instance" );
dataToSend.partnerType = instance.partnerType;
dataToSend.partnerId = instance.partnerId;
dataToSend.ownerId = Fse.Portal.appConfiguration.STP.ownerId;
dataToSend.ownerType = Fse.Portal.appConfiguration.STP.ownerType;
dataToSend.userId = instance.userId;
loadPanel.show();
Fse.Ajax.performAction( {
object : "WEBLOG.savePartnerNote",
data : dataToSend
}).done( function( savePartnerResult ) {
//console.log("output = ");
// console.log(dltPartnerResult);
instance.options.onSuccess(savePartnerResult);
}).then( function() {
loadPanel.hide();
instance.revisePopup.hide();
/*else{
instance.addPopup.hide();
}*/
instance.dataGrid.refresh();
});
}
PartnerNotes.prototype.deletePartnerNote = function( partnerNoteData ) {
let instance = this;
instance.deleteNoteForm = null;
instance.deleteNoteForm = $("
").dxForm( {
formData : partnerNoteData,
readOnly : false,
validationGroup : "deleteNoteFormValidation",
showValidationSummary : true,
items : [
{
dataField : "revisedReason",
label : { text : "Reason" },
editorType : "dxSelectBox",
editorOptions : {
placeholder : "--Select One-- ",
dataSource: instance.deleteReasons,
displayExpr: "Reason",
valueExpr : "Reason",
showClearButton : true,
},
validationRules : [
{ type : "required",
message: 'You must choose a reason for deleting this note.',
}
]
}]
}).dxForm( "instance" );
let d = $.Deferred();
let submitButton = $("
").dxButton( {
text : "Submit",
type : "default",
validationGroup: "deleteNoteFormValidation",
onClick : function( be ) {
var result = be.validationGroup.validate();
if (result.isValid)
{
//alert("coming here");
instance.deleteNote({data : partnerNoteData, onSuccess : function( data ) {
d.resolve( data );
instance.dataGrid.refresh();
} });
}
return d;
}
}).dxButton( "instance" );
let popupToolbarItems = [
{ toolbar : "bottom", location : "after", widget : "dxButton",
options : {
text : "Cancel",
type : "normal",
onClick : function( be ) {
if( confirm( "Are you sure?" )) {
instance.deleteConfirmPopup.hide();
}
}
}
},
{ toolbar : "bottom", location : "after", template : function() {
return submitButton.element();
}
}
];
let deleteConfirmPopup = $("
").dxPopup( {
title : "Delete Note",
height : 150,
width: 350,
resizeEnabled: true,
hideOnOutsideClick : true,
toolbarItems : popupToolbarItems,
contentTemplate : function() {
return $("
").append( "Please select a reason for deleting this note.")
.append("
").append( instance.deleteNoteForm.element() );
},
onShown: function (e) {
// console.log(instance.partnerContactForm.getEditor('operatorContact'));
},
onHidden : function( e ) {
e.component.element().remove();
e.component.dispose();
// console.log(instance);
}
}).dxPopup( "instance" );
instance.deleteConfirmPopup = deleteConfirmPopup;
instance.deleteConfirmPopup.element().appendTo( "body" );
instance.deleteConfirmPopup.show();
}
PartnerNotes.prototype.deleteNote= function(toBeDeletedPartnerNoteData) {
let instance = this;
// console.log("in delete");
// console.log(toBeDeletedPartnerNoteData);
instance.options = $.extend( true, {}, toBeDeletedPartnerNoteData );
let dataToSend = $.extend( true, {}, instance.options.data );
// TODO - get this to protect the page until the load operation is complete
let loadPanel = $("
").dxLoadPanel( {
message : "Working...",
deplay : 0,
hideOnOutsideClick : false,
hideOnParentScroll : false,
container : instance.deleteConfirmPopup.element(),
onHidden : function( e ) {
e.component.element().remove();
e.component.dispose();
}
}).appendTo( $("body") ).dxLoadPanel( "instance" );
dataToSend.partnerType = instance.partnerType;
dataToSend.partnerId = instance.partnerId;
dataToSend.ownerId = Fse.Portal.appConfiguration.STP.ownerId;
dataToSend.ownerType = Fse.Portal.appConfiguration.STP.ownerType;
// console.log(dataToSend);
loadPanel.show();
Fse.Ajax.performAction( {
object : "WEBLOG.deletePartnerNote",
data : dataToSend
}).done( function( dltPartnerResult ) {
//console.log("output = ");
// console.log(dltPartnerResult);
instance.options.onSuccess(dltPartnerResult);
}).then( function() {
loadPanel.hide();
instance.deleteConfirmPopup.hide();
});
}