/** * Class Description * @namespace FIRSTCLASS.apps * @module Community * @requires * @optional * @title Community base Application */ /** * Constructor definition * @class Community * @constructor * @param {Object} config (required) the configuration object * @param {string|HTMLElement} config.div (required) the div to load into * @param {string} config.baseUrl (required) the container base url */ FIRSTCLASS.apps.WorkflowIntegration = function(config) { /** * Private member variables * * Private variables are identified by the convention of naming them with a leading underscore. * i.e. this._privateVariable */ if (config.logTime) { config.logTime("Workflow Integration App Init"); } var that = this; this._domElement = document.createElement("div"); this._config = config; var dsconfig = { containerBaseUrl: this.uri, autoLoad: false, watchForNew: true, messagebodies: false, nosymbiomainfetch: true, sortFirstFetch: false, serversort: "&Table=-3_9", fetchThreads: true, initialRequestGranularity: 5, requestGranularity: 10, pollInterval: 100, objtypefilter: FIRSTCLASS.objTypes.odocument }; if (this._config.logTime) { dsconfig.logTime = this._config.logTime; } this._dataSource = new FIRSTCLASS.util.DataSource(dsconfig); this._lvDomElement = document.createElement("div"); YAHOO.util.Dom.addClass(this._lvDomElement, "fcAppScrollingContent"); YAHOO.util.Dom.addClass(this._lvDomElement, "fcWorkflowMailbox"); this._contentPane = FIRSTCLASS.ui.widgets.buildContentBox(this._lvDomElement, 'fcWhiteContentBox'); this._domElement.appendChild(this._contentPane); var lvConfig = { domElement: this._lvDomElement, dataSource: this._dataSource, fillOnScroll:true, threading: { format: "bythread", sortfunc: this._rowSort, threadsortfunc: this._threadSort, originRowIsHeader: true, collapseRead: true, displayThreadContributors: true }, listenForNavKeys: false, selectionFollowsScroll: true, padHeight: true, padText: FIRSTCLASS.locale.community.loading, drawOffScreen: false, rowFilter: this.rowFilter, feedConfig: { allowReplies: false }, scrollDetectorInterval: 500 }; this._listView = new FIRSTCLASS.layout.ListView(lvConfig); this._listView.updatePadText({top:"Show All | Assignments | Initiated
", align:"right"}); this._dataSource.addRowListener(this); FIRSTCLASS.session.addHistoryEntry(this); this.activate(); FIRSTCLASS.apps.Integration.init(); this._doFilter({type:"assignments"}); LyteBox.callbacks = { beforeStart: function() { FIRSTCLASS.events.disable(); that._listView.deactivate(); that._dataSource.deactivate(); }, afterEnd: function() { FIRSTCLASS.events.enable(); that._listView.activate(); that._dataSource.activate(); } }; }; /** HISTORY MANAGEMENT VARIABLES **/ FIRSTCLASS.apps.WorkflowIntegration.prototype.uri = FIRSTCLASS.session.baseURL + "__Open-Item/Workflows"; FIRSTCLASS.apps.WorkflowIntegration.prototype.cacheable = false; /** HISTORY MANAGEMENT VARIABLES END **/ FIRSTCLASS.apps.WorkflowIntegration.prototype.onRow = function(row, dataSource, atEnd, hasMore, isNewDelivery) { if (isNewDelivery) { this._listView.selectRow(row); } }; FIRSTCLASS.apps.WorkflowIntegration.prototype.rowFilter = function(row) { return row.status.sent && row.status.outgoing || !row.status.outgoing; }; FIRSTCLASS.apps.WorkflowIntegration.prototype.activate = function () { this.activateSideBars(); FIRSTCLASS.util.revealContents(); FIRSTCLASS.ui.Dom.replaceContentsWithElement(this._config.parentDiv, this._domElement); this.resizeEvent(); FIRSTCLASS.session.setActiveApplication(this, "WorkflowIntegration"); YAHOO.util.Dom.setStyle(document.body, "height", "100%"); YAHOO.util.Dom.setStyle(document.body, "overflow", "hidden"); FIRSTCLASS.ui.setDocumentTitle("Workflows"); FIRSTCLASS.ui.navBar.setTitle("Workflows"); FIRSTCLASS.ui.navBar.setBottomText(""); var that = this; FIRSTCLASS.util.quickFilter({domEl: $('quickfilter'), casesensitive: true, callback: { filter: function(str) { that._doFilter({type:'quickfilter', pattern:str}); }, reset: function() { that._clearFilter(); } }}); }; FIRSTCLASS.apps.WorkflowIntegration.prototype.__fcAppName = "FIRSTCLASS.apps.WorkflowIntegration"; FIRSTCLASS.apps.WorkflowIntegration.prototype.deactivate = function() { FIRSTCLASS.ui.MiniProfile.hideBoxNow(); YAHOO.util.Dom.setStyle(document.body, "height", ""); YAHOO.util.Dom.setStyle(document.body, "overflow", ""); // this._dataSource.deactivate(); }; FIRSTCLASS.apps.WorkflowIntegration.prototype.dispose = function() { if (this._config.logTime) { this._config.logTime("WorkflowIntegration app dispose called"); } // this._dataSource.dispose(); }; FIRSTCLASS.apps.WorkflowIntegration.prototype.activateSideBars = function() { FIRSTCLASS.ui.leftSideBar.hide(); FIRSTCLASS.ui.rightSideBar.hide(); }; FIRSTCLASS.apps.WorkflowIntegration.prototype.resizeEvent = function(event) { var viewport = FIRSTCLASS.ui.Dom.getViewportBounds(); if (!this.sbTop) { this.sbTop = YAHOO.util.Dom.getY($("fcRightSideBar")); } /* these are hard coded values, change them if the ui changes */ var ypos2 = 115; var xpos2 = 20; var ypos = 114; var sbTop = this.sbTop; if (FIRSTCLASS.skin && FIRSTCLASS.skin.community && FIRSTCLASS.skin.community.sidebars && FIRSTCLASS.skin.community.sidebars.right && FIRSTCLASS.skin.community.sidebars.right.bottompad) { sbTop += FIRSTCLASS.skin.community.sidebars.right.bottompad; } FIRSTCLASS.ui.rightSideBar.adjustBoxHeights(viewport.ht-sbTop); var sbwid = viewport.wd*0.02; if (sbwid < 180) { sbwid = 180; } FIRSTCLASS.session.RuntimeCSS.updateRule('.fcListViewRow .fcBody', "max-width: " + (viewport.wd - sbwid - 300) + "px;overflow-x:auto;"); var newheight = viewport.ht-ypos-1; if (ypos) { var appContent = FIRSTCLASS.ui.Dom.getChildByClassName("fcAppScrollingContent", this._domElement); if (appContent) { newheight = viewport.ht - ypos2 - 31; if (newheight <= 0) { return; } var newwidth = viewport.wd - xpos2 - 1; if (YAHOO.env.ua.ie) { YAHOO.util.Dom.setStyle(appContent, "overflow-y", "scroll"); YAHOO.util.Dom.setStyle(appContent, "overflow-x", "hidden"); } else { YAHOO.util.Dom.setStyle(appContent, "overflow", "auto"); } YAHOO.util.Dom.setStyle(appContent, "height", newheight+"px"); } } var fcMain = $("fcMain"); if (fcMain) { YAHOO.util.Dom.setStyle(fcMain, "height", viewport.ht+"px"); } }; FIRSTCLASS.apps.WorkflowIntegration.showForm = function(row, formBox) { FIRSTCLASS.util.FormParser.showForm({baseUri: FIRSTCLASS.apps.WorkflowIntegration.prototype.uri, row: row, box: formBox}); // var builtUri = FIRSTCLASS.apps.WorkflowIntegration.prototype.uri + "/" + row.uri + "?Templates=JS&JSON=2"; // FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks.requests[row.messageid] = {row: row, box:formBox}; // var request = FIRSTCLASS.util.net.doAsyncGet({action:builtUri, callbacks:FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks}); }; /*FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks = { requests: {}, success: function(response) { if (response.responseJSON) { var js = response.responseJSON; this.requests[js.messageid].formJSON = js; var box = this.requests[js.messageid].box; FIRSTCLASS.util.FormParser.setForm(box, js, FIRSTCLASS.session.baseURL + "Livelink Workflow Inbox/"); //delete this.requests[js.messageid]; } }, failure: function(response) { } };*/ FIRSTCLASS.apps.WorkflowIntegration.prototype._clearFilter = function() { this._filterType = false; this._dataSource.reset(); this._listView.reLoadFromDataSource(); $('fcQFP').value = ""; YAHOO.util.Dom.setStyle($('filterall'), 'font-weight', 'bold'); YAHOO.util.Dom.setStyle($('filterassignments'), 'font-weight', ''); YAHOO.util.Dom.setStyle($('filterinitiated'), 'font-weight', ''); }; FIRSTCLASS.apps.WorkflowIntegration.prototype._doFilter = function(cfg) { if (this._filterType != cfg.type) { YAHOO.util.Dom.setStyle($('filterall'), 'font-weight', ''); YAHOO.util.Dom.setStyle($('filterassignments'), 'font-weight', ''); YAHOO.util.Dom.setStyle($('filterinitiated'), 'font-weight', ''); var handled = false; var ft = false; switch(cfg.type) { case "assignments": this._dataSource.reconfigure({tackon:"&ColFilter=8122_(1)", containerBaseUrl: this.uri}); $('fcQFP').value = ""; handled = true; YAHOO.util.Dom.setStyle($('filterassignments'), 'font-weight', 'bold'); break; case "initiated": this._dataSource.reconfigure({tackon:"&ColFilter=8122_(2)", containerBaseUrl: this.uri}); $('fcQFP').value = ""; handled = true; YAHOO.util.Dom.setStyle($('filterinitiated'), 'font-weight', 'bold'); break; case "quickfilter": //var uri = FIRSTCLASS.search({key:cfg.pattern, scope: this._config.baseUrl, doquickfilter:true, justreturnsearchurl: true}); //this._dataSource.reconfigure({tackon:"", containerBaseUrl: uri, useobjid: true}); var fields = [ "12218", "12209", "12203" ]; var tackon = "&ColFilter="; var pattern = ".*" + cfg.pattern + ".*"; /*var pattern = ".*"; var pattern2 = ".*" + cfg.pattern + ".*"; var lcasePattern = cfg.pattern.toLowerCase(); var ucasePattern = cfg.pattern.toUpperCase(); for (var j = 0; j < cfg.pattern.length; j++) { var lower = lcasePattern.charAt(j); var upper = ucasePattern.charAt(j); pattern += "("+ lower + "|" + upper + ")"; } pattern += ".*"; var test = "Approval Template" var test2 = "approval Template" var regex = new RegExp(pattern); var match1 = regex.exec(test); var match2 = regex.exec(test2); debugger;*/ for (var i in fields) { if (i !== 0) { tackon += "|"; } tackon += fields[i] + "_[" + pattern + "]"; } this._dataSource.reconfigure({tackon:tackon, containerBaseUrl: this.uri}); handled = true; ft = cfg.type + cfg.pattern; YAHOO.util.Dom.setStyle($('filterall'), 'font-weight', 'bold'); break; default: } if (!ft) { ft = cfg.type; } if (handled) { this._filterType = ft; this._listView.reLoadFromDataSource(); } } }; FIRSTCLASS.apps.WorkflowIntegration.eventHandlers = { click: { showform: function(that, fcevent) { var messageid = fcevent.fcattrs; var targetRow = that._listView.findRowElementFromElement(fcevent.target); var formBox = FIRSTCLASS.ui.Dom.getChildByClassName("fclvrowformdoc", targetRow.el); YAHOO.util.Dom.removeClass(formBox, 'fcHidden'); FIRSTCLASS.apps.WorkflowIntegration.showForm(targetRow.row, formBox); }, filter: function(that, fcevent, evt) { if (fcevent.fcattrs == "all") { that._clearFilter(); } else if (fcevent.fcattrs == "assignments") { that._doFilter({type:'assignments'}); } else if (fcevent.fcattrs == "initiated") { that._doFilter({type:'initiated'}); } else if (fcevent.fcattrs == "quickfilter") { var quickfilter = $('fcQFP'); if (quickfilter) { that._doFilter({type:"quickfilter", pattern: quickfilter.value}); } } }/*, saveform: function(that, fcevent) { var messageid = fcevent.fcattrs; var request = FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks.requests[messageid]; var box = request.box; var form = box.firstChild.firstChild; if (FIRSTCLASS.util.FormParser.prepareFormToSave(form, request.formJSON)) { FIRSTCLASS.util.FormParser.submitForm(form, request.formJSON, {success: function() { debugger; delete FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks.requests[messageid]; box.innerHTML = ""; }, failure: function() { debugger; }}); return true; } else { return false; } }, clearform: function(that, fcevent) { var messageid = fcevent.fcattrs; var box = FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks.requests[messageid].box; delete FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks.requests[messageid]; box.innerHTML = ""; return true; }, addrepeat: function(that, fcevent) { var field = fcevent.fcattrs; var messageid = fcevent.target.getAttribute('messageid'); var request = FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks.requests[messageid]; var form = request.box.firstChild.firstChild; if (request) { FIRSTCLASS.util.FormParser.addRepeat(request.formJSON, form, field); return true; } return false; }, removerepeat: function(that, fcevent) { var field = fcevent.fcattrs; var messageid = fcevent.target.getAttribute('messageid'); var request = FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks.requests[messageid]; var form = request.box.firstChild.firstChild; if (request) { FIRSTCLASS.util.FormParser.removeRepeat(request.formJSON, form, field); return true; } return false; }, formbutton: function(that, fcevent) { var field = fcevent.fcattrs; var messageid = fcevent.target.getAttribute('messageid'); var request = FIRSTCLASS.apps.WorkflowIntegration.showFormCallbacks.requests[messageid]; var form = request.box.firstChild.firstChild; if (request) { FIRSTCLASS.util.FormParser.handleButtonPress(request.formJSON, form, field); return true; } return false; }*/ } }; FIRSTCLASS.apps.WorkflowIntegration.prototype.handleEvent = function(evt, fcevent) { var rv = false; rv = FIRSTCLASS.util.FormParser.handleEvent(evt, fcevent); if (!rv) { var handlers = FIRSTCLASS.apps.WorkflowIntegration.eventHandlers[evt.type]; if (handlers) { var handler = handlers[fcevent.fcid]; if (handler) { rv = handler(this, fcevent); if (typeof rv == "undefined") { rv = true; } } } } if (!rv) { rv = this._listView.handleEvent(evt, fcevent); } return rv; }; YAHOO.register("fcWorkflowIntegration", FIRSTCLASS.apps.WorkflowIntegration, {version: "0.0.1", build: "1"});