var params = setParamDefaults(arguments.fieldName, arguments.parameters);
var dtbService = "dateTimeBuilderService";
var dtbController = "dateTimeBuilderController";
var dtbForm = "dateTimeBuilderForms";
var useDebugOutput = false;
// Set defaults for the label and description
var includeLabel = true;
var includeDescription = false;
// Get the DateTime element Name
var dtDataElementName = application.ptCalendar.getEventDateTimeCEName();
// Get the DateTime formid
var dtDataFormID = application.ptCalendar.getEventDateTimeFormID();
// Check the brokenRecurrence status of this DateTime Record
var brokenRecurrence = false;
// Set the newDefaultPickerDate to be prepared if nothing is passed in
var newDefaultPickerDate = "";
var dateTimeArray = ArrayNew(1);
var itm = 0;
// Set the the Ajax Loader Image
var ajaxIMG = '';
var cftDateTimeBuilderCSS = '';
var cftDateTimeBuilderJS = '';
var CSRF_Token = application.ADF.csSecurity.getCSRF_Token();
if ( len(trim(arguments.value)) )
{
dateTimeArray = application.ptCalendar.dateTimeBuilderDAO.getDateTimeData(uuid=arguments.value);
for (itm=1; itm LTE ArrayLen(dateTimeArray); itm=itm+1 ) {
if ( StructKeyExists(dateTimeArray[itm],"values") AND StructKeyExists(dateTimeArray[itm].values,"dtHashID") AND len(trim(dateTimeArray[itm].values.dtHashID)) )
{
brokenRecurrence = true;
break;
}
}
}
else
{
// Pass new date URL variable through to the Calendar Picker
if ( StructKeyExists(request.params,"newSelectedDate") AND application.ptCalendar.date.IsRealDate(request.params.newSelectedDate) )
newDefaultPickerDate = request.params.newSelectedDate;
}
if ( !StructKeyExists(Request, 'cftDateTimeBuilderStylesheet') )
{
application.ADF.scripts.loadUnregisteredResource('/ADF/apps/pt_calendar/style/calendar-datetime-builder.css', "stylesheet", "head", "TERTIARY", 0, 0);
Request.cftDateTimeBuilderStylesheet = 1;
}
application.ptCalendar.scripts.addHeaderCSS(cftDateTimeBuilderCSS, "TERTIARY"); // PRIMARY, SECONDARY, TERTIARY
application.ptCalendar.scripts.addFooterJS(cftDateTimeBuilderJS,"TERTIARY");
#params.btnText#
This event was part of a 'Recurrence Series' but has been modified from the original.
function validate_#arguments.fieldName#(useBind, isRequired)
{
var dtValue = jQuery("input[name=#arguments.fieldName#]").val().trim();
//console.log(useBind, isRequired, dtValue);
if (useBind)
{
var recurValue = jQuery("###arguments.parameters.recurrFieldID#").val().trim();
return (dtValue.length || recurValue.length)
}
else if (isRequired)
return (dtValue !== '');
return true;
}
private any function getValidationJS(required string formName, required string fieldName, required boolean isRequired)
{
var useBind = (arguments.parameters.bindRequired EQ 'one' AND len(arguments.parameters.recurrFieldID)) ? "true" : "false";
var isRequiredStr = arguments.isRequired ? "true" : "false";
return 'validate_#arguments.fieldName#(#useBind#, #isRequiredStr#)';
}
private string function getValidationMsg()
{
if (arguments.parameters.bindRequired EQ 'one' AND len(arguments.parameters.recurrFieldID))
return "Please add a Date/Time entry or set-up Recurrence Properties.";
return "Please add a Date/Time entry.";
}
private struct function setParamDefaults(required string fieldName, required struct parameters)
{
var params = arguments.parameters;
if ( NOT StructKeyExists(params, "fieldID") )
params.fieldID = arguments.fieldName;
else
params.fieldID = trim(params.fieldID);
if ( (NOT StructKeyExists(params, "fieldClass")) OR ( len(trim(params.fieldClass)) LTE 0) )
params.fieldClass = "";
if ( (NOT StructKeyExists(params, "btnText")) OR ( len(trim(params.btnText)) LTE 0) )
params.btnText = "Add New Date/Time";
if ( (NOT StructKeyExists(params, "recurrFieldID")) OR ( len(trim(params.recurrFieldID)) LTE 0) )
params.recurrFieldID = "";
else
params.recurrFieldID = trim(params.recurrFieldID);
// If bound to a Recurrence Build field set the required field properties
if ( (NOT StructKeyExists(params, "bindRequired")) OR ( len(trim(params.bindRequired)) LTE 0) )
params.bindRequired = "none"; // none = standard field required behavior | one = one of the bound fields must have a value
return params;
}
private boolean function isMultiline()
{
return true;
}
public string function getResourceDependencies()
{
return listAppend(super.getResourceDependencies(), "jQuery,jQueryUI,ADFLightbox");
}
public string function loadResourceDependencies()
{
application.ptCalendar.scripts.loadJQuery();
application.ptCalendar.scripts.loadJQueryUI(themeName=application.ptCalendar.getUItheme());
application.ptCalendar.scripts.loadADFLightbox();
}