Skip to content

Instantly share code, notes, and snippets.

@awrowse
Created August 8, 2013 20:35
Show Gist options
  • Save awrowse/6188450 to your computer and use it in GitHub Desktop.
Save awrowse/6188450 to your computer and use it in GitHub Desktop.
ChatServerConnect bug fix for CP3 13.2
version: "1.0"
requires:
jsModule:
- standard
- mobile
extends:
widget: standard/chat/ChatServerConnect
components:
- js
RightNow.namespace('Custom.Widgets.chat.ChatServerConnect');
Custom.Widgets.chat.ChatServerConnect = RightNow.Widgets.ChatServerConnect.extend({
/**
* Place all properties that intend to
* override those of the same name in
* the parent inside `overrides`.
*/
overrides: {
/**
* Overrides RightNow.Widgets.ChatServerConnect#constructor.
*/
constructor: function() {
// Call into parent's constructor
this.parent();
},
/**
* Overridable methods from ChatServerConnect:
*
* Call `this.parent()` inside of function bodies
* (with expected parameters) to call the parent
* method being overridden.
*/
// _validateChatParameters : function()
// _onChatValidateParametersResponse: function(type, args)
// _checkAnonymousRequest : function()
// _onChatCheckAnonymousResponse : function(type, args)
// _displayErrors : function()
// _setChatParameters : function()
// _onChatSetParametersResponse : function(type, args)
// _connect : function(resume)
// _setMiscellaneousData : function()
// _onChatConnectResponse: function(type, args)
// _displayResumeSessionDialog : function()
// _resumeSession : function()
// _startNewSession : function()
// _fetchUpdate : function()
// _onFetchUpdateResponse : function()
// _onChatStateChangeResponse : function(type, args)
/**
* Parses POST and URL parameters and sets the miscellaneous data variables
* such as incident custom fields. URL parameters will override POST parameters.
* Also supports legacy custom field URL names... ie incidents.c$columnName
*/
_setMiscellaneousData : function()
{
if(this._miscellaneousData)
return;
this._miscellaneousData = [];
for(var customFieldID in this.data.js.customFields)
{
var customField = this.data.js.customFields[customFieldID],
columnName = customField.col_name.split("c$")[1],
postedCustomFieldName = "Incident_CustomFields_c_" + columnName,
urlCustomFieldName = "Incident.CustomFields.c." + columnName,
legacyCustomFieldName = "incidents.c$" + columnName,
postedCustomFields = this.data.js.postedCustomFields || {},
Url = RightNow.Url;
//if this is a date/date time, we have to assemble all moving parts.
//that's how CONNECT coupled with native form POST works
if(customField.data_type === this.data.js.dateField || customField.data_type === this.data.js.dateTimeField)
{
var year = postedCustomFields[postedCustomFieldName + "_year"] || Url.getParameter(urlCustomFieldName + "_year"),
month = postedCustomFields[postedCustomFieldName + "_month"] || Url.getParameter(urlCustomFieldName + "_month"),
day = postedCustomFields[postedCustomFieldName + "_day"] || Url.getParameter(urlCustomFieldName + "_day"),
hour = postedCustomFields[postedCustomFieldName + "_hour"] || Url.getParameter(urlCustomFieldName + "_hour"),
minute = postedCustomFields[postedCustomFieldName + "_minute"] || Url.getParameter(urlCustomFieldName + "_minute");
// year is required for both date datatypes. If year is null, then the user didn't add a value.
if(year !== null)
this._miscellaneousData[urlCustomFieldName] = year || month || day ? [[year, month, day].join("-"), hour || minute ? [hour, minute].join(":") : "" ].join(" ") : null;
}
else
{
var value = postedCustomFields[postedCustomFieldName] || Url.getParameter(urlCustomFieldName) || Url.getParameter(legacyCustomFieldName);
if(value !== null)
this._miscellaneousData[urlCustomFieldName] = value;
}
}
}
},
/**
* Sample widget method.
*/
methodName: function() {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment