FIRSTCLASS.apps.Integration = {
_repositories: false,
_isInitialized: false,
_onInit: [],
_baseUrl: FIRSTCLASS.session.baseURL + "__Open-Item/UserApplications",
_templatePart: "?Templates=JS&Close=-1&JSON=2",
_commands: {
search: 5000,
getInfo: 5001,
copy: 5002,
link: 5003,
view: 5004,
browse: 5005,
save: 5006,
archive: 5007,
close: 5999,
reserve: 5011,
unreserve: 5012
}
};
FIRSTCLASS.apps.Integration.init = function() {
if (FIRSTCLASS.apps.Integration._isInitialized) {
return;
}
var url = FIRSTCLASS.apps.Integration._baseUrl + FIRSTCLASS.apps.Integration._templatePart + "&Both=1";
//"?Templates=JS&Close=-1";
var callbacks = {
success: FIRSTCLASS.apps.Integration._parseInitResponse,
failure: FIRSTCLASS.apps.Integration._parseInitResponse
};
FIRSTCLASS.util.net.asyncRequest("GET", url, callbacks);
};
FIRSTCLASS.apps.Integration.capabilitiesBits = {
search: 1,
browse: 2,
getinfo: 4,
download: 8,
copy: 16,
link: 32,
view: 64,
saveto: 128,
sendarchive: 256,
deletefrom: 512,
reserve: 1024,
unreserve: 2048,
browsermclassifications: 4096,
getrmfields: 8192,
workflow: 16384
};
FIRSTCLASS.apps.Integration._parseCapabilitiesBitmask = function(capabilities) {
var obj = {};
FIRSTCLASS.lang.deepCopyObjData(obj, FIRSTCLASS.apps.Integration.capabilitiesBits);
for (var i in obj) {
if (FIRSTCLASS.lang.binary.AND(capabilities,obj[i])) {
obj[i] = 1;
} else {
obj[i] = 0;
}
}
return obj;
};
FIRSTCLASS.apps.Integration._parseInitResponse = function (response) {
var obj = false, i, repositories;
if (response.status == 200) {
if (response.responseJSON) {
obj = response.responseJSON;
}
repositories = [];
for (i in obj.records) {
var capabilities = {
browse: 0,
search: 0,
upload: 0,
sendarchive: 0
};
if (obj.records[i].capabilities) {
capabilities = FIRSTCLASS.apps.Integration._parseCapabilitiesBitmask(obj.records[i].capabilities);
}
repositories[i] = {
name: obj.records[i].name,
uri: obj.records[i].uri,
handler: FIRSTCLASS.apps.Integration.ECM,
capabilities: capabilities
};
}
FIRSTCLASS.apps.Integration._repositories = repositories;
}
FIRSTCLASS.apps.Integration._isInitialized = true;
for (i in FIRSTCLASS.apps.Integration._onInit) {
FIRSTCLASS.apps.Integration._onInit[i].func(FIRSTCLASS.apps.Integration._onInit[i].config);
}
FIRSTCLASS.apps.Integration._onInit = [];
};
FIRSTCLASS.apps.Integration.initRepository = function(repositoryname) {
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(repositoryname);
if (repository === 0 || repository == -1) {
// no such repository
return;
} else {
var baseurl = FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.apps.Integration._baseUrl)
+ repository.uri
+ FIRSTCLASS.apps.Integration._templatePart;
var callbacks = {
success: FIRSTCLASS.apps.Integration._parseInitRepositoryResponse,
failure: FIRSTCLASS.apps.Integration._parseInitRepositoryResponse
};
FIRSTCLASS.apps.Integration._initingRepository = repository;
FIRSTCLASS.util.net.asyncRequest('GET', baseurl, callbacks);
}
};
FIRSTCLASS.apps.Integration._parseInitRepositoryResponse = function (response) {
var obj = false;
if (response.status == 200) {
if (response.responseJSON) {
obj = response.responseJSON;
} else {
FIRSTCLASS.apps.Integration._initingRepository.objid = -1;
return;
}
FIRSTCLASS.apps.Integration._initingRepository.objid = obj.objid;
} else {
FIRSTCLASS.apps.Integration._initingRepository.objid = -1;
}
for (var i in FIRSTCLASS.apps.Integration._onInit) {
FIRSTCLASS.apps.Integration._onInit[i].func(FIRSTCLASS.apps.Integration._onInit[i].config);
}
FIRSTCLASS.apps.Integration._onInit = [];
};
FIRSTCLASS.apps.Integration.getRepositories = function() {
if (FIRSTCLASS.apps.Integration._isInitialized) {
return FIRSTCLASS.apps.Integration._repositories;
} else {
FIRSTCLASS.apps.Integration.init();
return false;
}
};
FIRSTCLASS.apps.Integration.getRepositoryByName = function(name) {
if (FIRSTCLASS.apps.Integration._isInitialized) {
for (var i in FIRSTCLASS.apps.Integration._repositories) {
if (FIRSTCLASS.apps.Integration._repositories[i].name == name) {
return FIRSTCLASS.apps.Integration._repositories[i];
}
}
return 0;
} else {
return -1;
}
};
FIRSTCLASS.apps.Integration.getRepositoryByObjid = function(objid) {
if (FIRSTCLASS.apps.Integration._isInitialized) {
for (var i in FIRSTCLASS.apps.Integration._repositories) {
if (FIRSTCLASS.apps.Integration._repositories[i].objid == objid) {
return FIRSTCLASS.apps.Integration._repositories[i];
}
}
return 0;
} else {
return -1;
}
};
FIRSTCLASS.apps.Integration.ECM = {
};
FIRSTCLASS.apps.Integration.ECM.search = function(config) {
// config = {key, domElement, repository}
this._searchconfig = config;
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(config.repository);
if (repository === 0) {
// no such repository
} else if (repository == -1) {
// not init'ed, init then run again
FIRSTCLASS.apps.Integration._onInit.push({func: FIRSTCLASS.apps.Integration.ECM.search, config:config});
FIRSTCLASS.apps.Integration.init();
} else {
// got repository
if (repository.objid) {
FIRSTCLASS.apps.Integration.ECM._searchStep2(repository.objid);
} else {
FIRSTCLASS.apps.Integration._onInit.push({func: FIRSTCLASS.apps.Integration.ECM.search, config:config});
FIRSTCLASS.apps.Integration.initRepository(config.repository);
}
}
};
FIRSTCLASS.apps.Integration.ECM._searchStep2 = function(objid) {
var that = this;
if (objid == -1) {
this._searchconfig.domElement.innerHTML = "
"+FIRSTCLASS.locale.integrations.ecm.search.unavailable+"";
return;
}
if (!this._searchconfig.repository) {
this._searchconfig.repository = FIRSTCLASS.apps.Integration.getRepositories()[0].name;
}
var form = document.createElement("DIV");
var btnlabel = FIRSTCLASS.locale.integrations.ecm.search.submit;
var html = [''];
form.innerHTML = html.join("");
for (var i in form.firstChild.childNodes) {
if (form.firstChild.childNodes[i].name && form.firstChild.childNodes[i].name.indexOf("4000") > 0) {
form.firstChild.childNodes[i].value = this._searchconfig.key;
} else if (form.firstChild.childNodes[i].name && form.firstChild.childNodes[i].name.indexOf("7000") > 0) {
var repositories = FIRSTCLASS.apps.Integration.getRepositories();
for (var j in repositories) {
if (repositories[j].name == this._searchconfig.repository) {
form.firstChild.childNodes[i].value = j;
break;
}
}
}
}
var callbacks = {
success: function(response) {
var url = form.firstChild.action;
var idx = url.indexOf("/"+FIRSTCLASS.opCodes.FormSave);
url = url.substr(0,idx)+"?FormID=10223";
that._ECMsearchurl = url;
that.lldatasource = new FIRSTCLASS.util.DataSource({
containerBaseUrl: url,
autoLoad: false,
requestGranularity: 100,
messagebodies: false,
docbodies: false,
paramStr: "&DoWait=1",
isSameRow: function(row1, row2) {
return row1.uid == row2.uid;
},
isRadForm: true
});
var lllvconfig = {
domElement: that._searchconfig.domElement,
dataSource: that.lldatasource,
fillOnScroll: false,
loadByPage: false,
threading: {
format: "none",
sortfunc: false
},
rowHandler: FIRSTCLASS.apps.Search.handlers.ECM,
padText: ""+ FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.integrations.ecm.search.searching, {repository:that._searchconfig.repository})+"
",
padHeight: true
};
that._ECMListView = new FIRSTCLASS.layout.ListView(lllvconfig);
that._ECMListView.updatePadHeight(FIRSTCLASS.ui.Dom.getViewportHeight());
that.fetchRows();
//FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({success:FIRSTCLASS.apps.Integration.ECM._parseResponse, failure:FIRSTCLASS.apps.Integration.ECM._parseResponse});
},
failure: function(response) {
that._searchconfig.domElement.innerHTML = ""+FIRSTCLASS.locale.integrations.ecm.search.unavailable+"";
}};
/* YAHOO.util.Connect.setForm(form.firstChild);
FIRSTCLASS.util.net.asyncRequest('POST', form.firstChild.action, callbacks);*/
FIRSTCLASS.util.net.doAsyncPost({form: form.firstChild, upload: false, callbacks: callbacks});
};
FIRSTCLASS.apps.Integration.ECM.fetchRows = function() {
if (this.lldatasource) {
this.lldatasource.fetchRows();
var that = this;
var listener = {
foundRows: false,
onRow: function(row) {
that.lldatasource.removeRowListener(listener);
that._ECMListView.clearPadText();
this.foundRows = true;
},
fillFinished: function(isNewDelivery, justadded) {
if (!this.foundRows && !justadded) {
that._ECMListView.updatePadText(FIRSTCLASS.locale.integrations.ecm.search.noresult);
}
},
onFillCompleted: function(dsrc) {
if (!this.foundRows) {
that._ECMListView.updatePadText(FIRSTCLASS.locale.integrations.ecm.search.noresult);
}
}
};
this.lldatasource.addRowListener(listener);
}
};
FIRSTCLASS.apps.Integration.ECM._parseResponse = function (response) {
return response.responseJSON;
};
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete = function(callbacks, objid, params) {
if (objid) {
FIRSTCLASS.apps.Integration.ECM._currentObjID = objid;
} else if (FIRSTCLASS.apps.Integration.ECM._currentObjID) {
objid = FIRSTCLASS.apps.Integration.ECM._currentObjID;
} else {
return;
}
var url = FIRSTCLASS.session.baseURL
+ '__OBJID_' + objid
+ "?Templates=JS&JSON=2&DoWait=1&" + FIRSTCLASS.ui.Dom.getCurrTimestamp();
FIRSTCLASS.util.net.asyncRequest('GET', url, callbacks, false, {responseparameters: params});
};
FIRSTCLASS.apps.Integration.ECM.doCommand = function(config) {
var form = document.createElement("DIV");
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(config.repository);
if (repository === 0 || repository == -1) {
// integration not init'ed or repository doesn't exist -- FIXME
} else {
if (!repository.objid) {
// repository not init'ed, init and try again
FIRSTCLASS.apps.Integration._onInit.push({func: FIRSTCLASS.apps.Integration.ECM.doCommand, config:config});
FIRSTCLASS.apps.Integration.initRepository(config.repository);
} else {
var form = {
action: FIRSTCLASS.session.baseURL
+ '__OBJID_'
+ repository.objid
+ "/"+FIRSTCLASS.opCodes.FormSave
+"?Close=-1&Clear=1&FormID=10223&Templates=JS&JSON=2&"
+ FIRSTCLASS.ui.Dom.getCurrTimestamp(),
method: 'post',
enctype:'multipart/form-data',
elements:[]
};
/*if (config.repository) {
html.push('');
}*/
if (config.xuid) {
form.elements.push({type:'text', name:"FieldID:4001=STRING", value:config.xuid});
}
for (var i in config.fields) {
var type = "STRING";
switch(parseInt(i)) {
case 4006:
case 4007:
type = "LITERALSTRING";
break;
default:
type = "STRING";
}
form.elements.push({type:'text', name:'FieldID:' + i + '=' + type, value: config.fields[i]});
}
form.elements.push({type:'text', name: "FieldID:9000=STRING", value: "0"});
form.elements.push({type:'hidden', name: 'FieldID:' + config.command + '=BUTTON', value:"0"});
/* YAHOO.util.Connect.setForm(form.firstChild);
FIRSTCLASS.util.net.asyncRequest('POST', form.firstChild.action, config.callbacks);*/
FIRSTCLASS.util.net.doAsyncPost({form: form, upload: false, callbacks: config.callbacks, responseparameters: config.responseparameters});
}
}
};
FIRSTCLASS.apps.Integration.ECM.copyTo = function(config) {
this._copyConfig = config;
FIRSTCLASS.apps.Integration.ECM.pickCommunityForCopy(config.repository);
};
FIRSTCLASS.apps.Integration.ECM.linkTo = function(config) {
this._linkConfig = config;
FIRSTCLASS.apps.Integration.ECM.pickCommunityForLink(config.repository);
};
FIRSTCLASS.apps.Integration.ECM.getInfo = function(config) {
var cmdConfig = {
command: 5001,
xuid: config.xuid,
callbacks: config.callbacks,
repository: config.repository
};
FIRSTCLASS.apps.Integration.ECM.doCommand(cmdConfig);
};
FIRSTCLASS.apps.Integration.ECM.doBrowse = function(config) {
FIRSTCLASS.apps.Integration.ECM.Browse.doBrowse(config);
};
FIRSTCLASS.apps.Integration.ECM.doView = function(config) {
this.doCommand({command: 5004, xuid: config.xuid, repository:config.repository});
};
FIRSTCLASS.apps.Integration.ECM.archiveTo = function(config) {
};
FIRSTCLASS.apps.Integration.ECM.pickCommunityForCopy = function(repository) {
FIRSTCLASS.apps.Integration.ECM.pickCommunity({
title:FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.integrations.ecm.copy.title, {repository:repository}),
submittext: FIRSTCLASS.locale.integrations.ecm.copy.submit,
submit:FIRSTCLASS.apps.Integration.ECM.onCommunityPickedForCopy,
custombutton: FIRSTCLASS.locale.integrations.ecm.copy.submitcustom,
repository: repository
});
};
FIRSTCLASS.apps.Integration.ECM.pickCommunityForLink = function(repository) {
FIRSTCLASS.apps.Integration.ECM.pickCommunity({
title:FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.integrations.ecm.link.title, {repository:repository}),
submittext: FIRSTCLASS.locale.integrations.ecm.link.submit,
submit:FIRSTCLASS.apps.Integration.ECM.onCommunityPickedForLink,
custombutton: FIRSTCLASS.locale.integrations.ecm.link.submitcustom
});
};
FIRSTCLASS.apps.Integration.ECM.pickCommunity = function(config) {
var that = this;
var domElement = document.createElement("DIV");
this._domElement = domElement;
var baseurl = FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.session.baseURL)+"__MemForm?FormID=11001&Templates=ECM";
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(config.repository);
if (repository.capabilities.reserve) {
baseurl += "&AllowReserve=1";
}
this._dialog = new FIRSTCLASS.apps.FormDialog({
baseUrl: baseurl,
domElement:domElement,
title: config.title,
buttons: [
{ text:FIRSTCLASS.locale.integrations.ecm.cancel, type: "cancel" },
{ text:config.submittext, isDefault: true, disabled: true, type: "submit" }
],
submit: config.submit,
cancel: FIRSTCLASS.apps.Integration.ECM.onCommunityCancel,
hide: FIRSTCLASS.apps.Integration.ECM.onCommunityCancel,
hideaftersubmit: false,
hideaftercancel: false,
zIndex: 1000,
onDomInserted: function() {
FIRSTCLASS.apps.Integration.ECM.populateCommunityPicker();
}
});
FIRSTCLASS.apps.Integration.ECM.buttontext = config.custombutton;
};
FIRSTCLASS.apps.Integration.ECM.communityPicked = function() {
var domel = $('fcECMDropdown');
var buttons = FIRSTCLASS.apps.Integration.ECM._dialog.getButtons();
buttons[1].set('disabled', false);
buttons[1].removeClass('fcHidden');
buttons[1].set('label', FIRSTCLASS.locale.doSub(FIRSTCLASS.apps.Integration.ECM.buttontext, {community: domel.firstChild.value}));
};
FIRSTCLASS.apps.Integration.ECM.populateCommunityPicker = function() {
var html = ["");
var domel = $('fcECMDropdown');
domel.innerHTML = html.join("");
var config = {
domElement:$('fcECMTagPicker'),
item: false,
personal:FIRSTCLASS.session.desktop.personaltags,
container: false,
editable: true,
showonconfig:true
};
FIRSTCLASS.apps.Workflows.Tags.reconfigure(config);
if (targetname) {
var buttons = FIRSTCLASS.apps.Integration.ECM._dialog.getButtons();
buttons[1].set('disabled', false);
buttons[1].removeClass('fcHidden');
buttons[1].set('label', FIRSTCLASS.locale.doSub(FIRSTCLASS.apps.Integration.ECM.buttontext, {community: targetname}));
}
};
FIRSTCLASS.apps.Integration.ECM.onCommunityPickedForCopy = function() {
var reserve = $('fcECMReserve');
var communityname = $('fcECMDropdown').firstChild.value;
var description = $('fcECMDescription').value;
FIRSTCLASS.apps.Integration.ECM._copyConfig.communityname = communityname;
FIRSTCLASS.apps.Integration.ECM._copyConfig.description = description;
if (reserve && reserve.checked) {
reserve = true;
} else {
reserve = false;
}
// FIRSTCLASS.apps.Integration.ECM.onCommunityPickedForCopyDoReserve();
// } else {
FIRSTCLASS.apps.Integration.ECM.onCommunityPickedForCopyDoCopy(reserve);
// }
};
FIRSTCLASS.apps.Integration.ECM.Unreserve = function(config) {
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(config.repository);
/*var config = {
dialog: FIRSTCLASS.apps.Integration.ECM.Browse._dialog,
xuid: FIRSTCLASS.apps.Integration.ECM.Browse._currenttargetxuid,
repository: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository
};*/
var cmdConfig = {
fields: {
"4001": config.xuid,
"4002": "", //parent xuid
"4009": "" // clear version field
},
command: FIRSTCLASS.apps.Integration._commands.unreserve,
repository: config.repository,
callbacks: {
success: function() {
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success: FIRSTCLASS.apps.Integration.ECM.onCommunityActionSuccess,
failure: FIRSTCLASS.apps.Integration.ECM.onGenericFailure
}, repository.objid);
},
failure: function(response) {
FIRSTCLASS.apps.Integration.ECM.onGenericFailure(response);
}
}
};
config.domElement.innerHTML = "" + FIRSTCLASS.locale.integrations.ecm.unreserve.wait + "
";
FIRSTCLASS.apps.Integration.ECM.doCommand(cmdConfig);
};
FIRSTCLASS.apps.Integration.ECM.onCommunityPickedForCopyDoReserve = function() {
var div = $('fcECMPicker');
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(FIRSTCLASS.apps.Integration.ECM._copyConfig.repository);
var cmdConfig = {
fields: {
"4001": FIRSTCLASS.apps.Integration.ECM._copyConfig.xuid,
"4002": "", //parent xuid
"4003": "", //community name
"4005": FIRSTCLASS.apps.Integration.ECM._copyConfig.fname, //file name
"4009": "" // clear version field
},
command: FIRSTCLASS.apps.Integration._commands.reserve,
repository: FIRSTCLASS.apps.Integration.ECM._copyConfig.repository,
callbacks: {
success: function() {
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success: FIRSTCLASS.apps.Integration.ECM.onCommunityReserveSuccess,
failure: FIRSTCLASS.apps.Integration.ECM.onCommunityReserveFailure
}, repository.objid);
},
failure: function(response) {
FIRSTCLASS.apps.Integration.ECM.onCommunityReserveFailure(response);
}
}
};
div.innerHTML = FIRSTCLASS.locale.integrations.ecm.reserve.wait;
FIRSTCLASS.apps.Integration.ECM.doCommand(cmdConfig);
};
FIRSTCLASS.apps.Integration.ECM.onCommunityReserveSuccess = function(response) {
FIRSTCLASS.apps.Integration.ECM.onCommunityPickedForCopyDoCopy();
};
FIRSTCLASS.apps.Integration.ECM.onGenericFailure = function(response) {
// unable to reserve!
var div = $('fcECMPicker');
var params = {
response: response.responseJSON,
guide: FIRSTCLASS.locale.integrations.ecm.failed,
domElement: div
};
FIRSTCLASS.apps.Integration.ECM._genericOnFailure(params);
};
FIRSTCLASS.apps.Integration.ECM.onCommunityPickedForCopyDoCopy = function(reserve) {
var config = {
command: FIRSTCLASS.apps.Integration._commands.copy,
fname: FIRSTCLASS.apps.Integration.ECM._copyConfig.fname,
xuid: FIRSTCLASS.apps.Integration.ECM._copyConfig.xuid,
progresstext: FIRSTCLASS.locale.integrations.ecm.copy.wait,
repository: FIRSTCLASS.apps.Integration.ECM._copyConfig.repository,
version: FIRSTCLASS.apps.Integration.ECM._copyConfig.version,
targetname: FIRSTCLASS.apps.Integration.ECM._copyConfig.communityname,
description: FIRSTCLASS.apps.Integration.ECM._copyConfig.description,
reserve: reserve
};
FIRSTCLASS.apps.Integration.ECM.onCommunityPicked(config);
};
FIRSTCLASS.apps.Integration.ECM.onCommunityPickedForLink = function() {
var config = {
command: FIRSTCLASS.apps.Integration._commands.link,
fname: FIRSTCLASS.apps.Integration.ECM._linkConfig.fname,
xuid: FIRSTCLASS.apps.Integration.ECM._linkConfig.xuid,
progresstext: FIRSTCLASS.locale.integrations.ecm.link.wait,
repository: FIRSTCLASS.apps.Integration.ECM._linkConfig.repository,
version: FIRSTCLASS.apps.Integration.ECM._linkConfig.version,
targetname: $('fcECMDropdown').firstChild.value,
description: $('fcECMDescription').value
};
FIRSTCLASS.apps.Integration.ECM.onCommunityPicked(config);
};
FIRSTCLASS.apps.Integration.ECM.onCommunityPicked = function(config) {
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(config.repository);
var communityname = config.targetname;
var cmdConfig = {
fields: {
"4003": communityname,
"4005": config.fname,
"4007": FIRSTCLASS.apps.Workflows.Tags.getTags(true),
"4006": config.description,
"4009": config.version
},
command: config.command,
xuid: config.xuid,
repository: config.repository,
callbacks: {
success: function() {
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success:FIRSTCLASS.apps.Integration.ECM.onCommunityActionSuccess,
failure:FIRSTCLASS.apps.Integration.ECM.onCommunityActionFailure
}, repository.objid);
},
failure: function(response) {
FIRSTCLASS.apps.Integration.ECM.onGenericFailure(response);
}
}
};
if (config.reserve) {
cmdConfig.fields['4050'] = 1;
} else {
cmdConfig.fields['4050'] = 0;
}
FIRSTCLASS.apps.Integration.ECM.doCommand(cmdConfig);
/* FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success:FIRSTCLASS.apps.Integration.ECM.onCommunityActionSuccess,
failure:FIRSTCLASS.apps.Integration.ECM.onCommunityActionFailure
}, repository.objid);*/
var div = $('fcECMPicker');
div.innerHTML = "" + config.progresstext + "
";
var buttons = FIRSTCLASS.apps.Integration.ECM._dialog.getButtons();
for (var i in buttons) {
buttons[i].set('disabled', true);
buttons[i].addClass('fcHidden');
}
};
FIRSTCLASS.apps.Integration.ECM.doSaveToRepository = function(config) {
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(config.repository);
var cmdConfig = {
fields: {
"4001": "",
"4002": config.parentxuid, //parent xuid
"4003": config.community, //community name
"4005": config.fname, //file name
"4009": "" // clear version field
},
command: FIRSTCLASS.apps.Integration._commands.save,
repository: config.repository,
callbacks: {
success: function() {
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success: FIRSTCLASS.apps.Integration.ECM.onCommunityActionSuccess,
failure: FIRSTCLASS.apps.Integration.ECM.onCommunityActionFailure
}, repository.objid, config);
},
failure: function() {
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success: FIRSTCLASS.apps.Integration.ECM.onCommunityActionSuccess,
failure: FIRSTCLASS.apps.Integration.ECM.onCommunityActionFailure
}, repository.objid, config);
}
}
};
if (config.unreserve) {
cmdConfig.fields['4050'] = 1;
} else {
cmdConfig.fields['4050'] = 0;
}
if (config.xuid) {
cmdConfig.fields["4001"] = config.xuid;
}
FIRSTCLASS.apps.Integration.ECM.doCommand(cmdConfig);
};
FIRSTCLASS.apps.Integration.ECM.doArchiveToRepository = function(config) {
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(config.repository);
var cmdConfig = {
fields: {
"4001": "",
"4002": config.parentxuid, // parent xuid to archive to
"4003": config.community.name //community name
},
command: FIRSTCLASS.apps.Integration._commands.archive,
repository: config.repository
};
FIRSTCLASS.apps.Integration.ECM.doCommand(cmdConfig);
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success: FIRSTCLASS.apps.Integration.ECM.onCommunityActionSuccess,
failure: FIRSTCLASS.apps.Integration.ECM.onCommunityActionFailure
}, repository.objid);
};
FIRSTCLASS.apps.Integration.ECM.onCommunityActionSuccess = function(response, params) {
var obj = FIRSTCLASS.apps.Integration.ECM._parseResponse(response);
var div = $('fcECMPicker');
if (!div) {
div = FIRSTCLASS.apps.Integration.ECM.Browse._domElement;
}
if (obj && obj.response && obj.response.code == 1) {
// success
if (params.unreserve && false) {
var config = {
dialog: FIRSTCLASS.apps.Integration.ECM.Browse._dialog,
domElement: div,
xuid: FIRSTCLASS.apps.Integration.ECM.Browse._currenttargetxuid,
repository: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository
};
FIRSTCLASS.apps.Integration.ECM.Unreserve(config);
FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.unreserve = false
} else {
div.innerHTML = ""+FIRSTCLASS.locale.integrations.ecm.succeeded+"";
}
} else {
// failure
// if it was a timeout, the responseText will be blank
if (response.responseText.length === 0) {
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository);
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success: FIRSTCLASS.apps.Integration.ECM.onCommunityActionSuccess ,
failure: FIRSTCLASS.apps.Integration.ECM.onCommunityActionFailure
} /* omit objid because we are reissuing same command */);
return;
}
var params = {
response: response.responseJSON,
guide: FIRSTCLASS.locale.integrations.ecm.failed,
domElement: div
};
FIRSTCLASS.apps.Integration.ECM._genericOnFailure(params);
//div.innerHTML = FIRSTCLASS.locale.integrations.ecm.failed+"
" + obj.response.message;
}
if (FIRSTCLASS.apps.Integration.ECM.Browse._dialog) {
var buttons = FIRSTCLASS.apps.Integration.ECM.Browse._dialog.getButtons();
buttons[0].set('disabled', false);
buttons[0].set('label', FIRSTCLASS.locale.integrations.ecm.browse.close);
buttons[0].removeClass('fcHidden');
buttons[1].destroy();
}
};
FIRSTCLASS.apps.Integration.ECM.onCommunityActionFailure = function(response) {
var div = FIRSTCLASS.apps.Integration.ECM.Browse._domElement;
var message = "";
var params = {
response: response.responseJSON,
guide: FIRSTCLASS.locale.integrations.ecm.failed,
domElement: div
};
FIRSTCLASS.apps.Integration.ECM._genericOnFailure(params);
/*
if (obj && obj.response && obj.response.message) {
message = obj.response.message;
} else {
message = response.responseText;
}
div.innerHTML = FIRSTCLASS.locale.integrations.ecm.failed+"
" + message;
var buttons = FIRSTCLASS.apps.Integration.ECM._dialog.getButtons();
buttons[0].set('disabled', false);
buttons[0].set('label', FIRSTCLASS.locale.integrations.ecm.close);
buttons[0].removeClass('fcHidden');
buttons[1].destroy();*/
};
FIRSTCLASS.apps.Integration.ECM.onCommunityCancel = function() {
FIRSTCLASS.apps.Integration.ECM._domElement.innerHTML = "";
FIRSTCLASS.apps.Integration.ECM._dialog.destroy();
};
FIRSTCLASS.apps.Integration.ECM.eventHandlers = {
click: {
ecmview: function(that, fcevent) {
//that.doView({xuid: fcevent.fcattrs});
},
ecmcopy: function(that, fcevent) {
that.copyTo({xuid: fcevent.fcattrs, fname:fcevent.target.getAttribute('fname'), repository: fcevent.target.getAttribute('repository'), version: fcevent.target.getAttribute('version')});
},
ecmlink: function(that, fcevent) {
that.linkTo({xuid: fcevent.fcattrs, fname:fcevent.target.getAttribute('fname'), repository: fcevent.target.getAttribute('repository'), version: fcevent.target.getAttribute('version')});
}
}
};
FIRSTCLASS.apps.Integration.ECM.handleEvent = function(event, fcevent) {
var handlers = this.eventHandlers[event.type], rv;
if (handlers) {
var handler = handlers[fcevent.fcid];
if (handler) {
rv = handler(this, fcevent);
if (typeof rv == "undefined") {
rv = true;
}
}
}
};
FIRSTCLASS.apps.Integration.ECM.Browse = {
selectionModes: {
all: 0,
leaves: 1,
nodes: 2
}
};
FIRSTCLASS.apps.Integration.ECM.Browse.doBrowse = function(config) {
// config = {repository, xuid, title, savecallbacks, defaultfilename}
FIRSTCLASS.apps.Integration.ECM.Browse._currenttargetxuid = false
this._currentconfig = config;
this._currentxuid = config.xuid;
this._treenodes = [];
this._contents = [];
if (config.selMode) {
this._selectionMode = config.selMode;
} else {
this._selectionMode = FIRSTCLASS.apps.Integration.ECM.Browse.selectionModes.all;
}
var domElement = document.createElement("DIV");
FIRSTCLASS.apps.Integration.ECM.Browse._domElement = domElement;
var submit = FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSave;
if (config.mode == "sendto") {
submit = FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSend;
} else if (config.mode =="archive") {
submit = FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseArchive;
}
var baseurl = FIRSTCLASS.lang.ensureSlashUrl(FIRSTCLASS.session.baseURL)+"__MemForm?FormID=12001&Templates=ECM";
if (config.reserved) {
baseurl += "&AllowUnreserve=1";
}
this._dialog = new FIRSTCLASS.apps.FormDialog({
baseUrl: baseurl,
domElement:domElement,
title: config.title,
buttons: [
{ text:FIRSTCLASS.locale.integrations.ecm.cancel, type: "cancel" },
{ text:FIRSTCLASS.locale.integrations.ecm.save, isDefault: true, disabled: true, type: "submit" }
],
submit: submit,
cancel: FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseCancel,
hideaftersubmit: false,
hideaftercancel: false,
onHide: FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseCancel,
onDomInserted: function() {
FIRSTCLASS.apps.Integration.ECM.Browse._handleFormAvailable();
}
});
if (config.xuid == "") {
config.xuid = "2000";
}
var cmdConfig = {
command: FIRSTCLASS.apps.Integration._commands.browse,
xuid: config.xuid,
repository: config.repository,
callbacks: {
success: FIRSTCLASS.apps.Integration.ECM.Browse.doCheckForResponse
}
};
FIRSTCLASS.apps.Integration.ECM.doCommand(cmdConfig);
};
FIRSTCLASS.apps.Integration.ECM.Browse.doCheckForResponse = function(response) {
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository);
FIRSTCLASS.apps.Integration.ECM.Browse.checkForResponse(repository.objid);
};
FIRSTCLASS.apps.Integration.ECM.Browse.checkForResponse = function(objid) {
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success: FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseResponse,
failure: FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseResponse
}, objid);
};
FIRSTCLASS.apps.Integration.ECM.Browse._handleFormAvailable = function() {
FIRSTCLASS.apps.Integration.ECM.Browse._titleDomEl = $('fcECMBrowseTitle');
FIRSTCLASS.apps.Integration.ECM.Browse._treeDomEl = $('fcECMBrowseTree');
FIRSTCLASS.apps.Integration.ECM.Browse._nameDomEl = $('fcECMBrowseNamePicker');
if (FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.fname) {
FIRSTCLASS.apps.Integration.ECM.Browse._nameDomEl.value = FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.fname;
YAHOO.util.Dom.setStyle('fcECMBrowseContainer', 'display', '');
} else {
YAHOO.util.Dom.setStyle('fcECMBrowseContainer', 'display', 'none');
}
if (FIRSTCLASS.apps.Integration.ECM.Browse._contentAvailable) {
FIRSTCLASS.apps.Integration.ECM.Browse._populateContent();
}
};
FIRSTCLASS.apps.Integration.ECM.Browse._setupTreeView = function() {
this._treeView = new YAHOO.widget.TreeView(FIRSTCLASS.apps.Integration.ECM.Browse._treeDomEl/*, {
singleNodeHighlight: true
}*/);
this._treeView.singleNodeHighlight = true;
this._treenodes[this._currentxuid] = this._treeView.getRoot();
this._treeView.setDynamicLoad(FIRSTCLASS.apps.Integration.ECM.Browse._doNavigate);
this._treeView.draw();
this._treeView.subscribe('clickEvent', FIRSTCLASS.apps.Integration.ECM.Browse._handleNodeClick);
};
FIRSTCLASS.apps.Integration.ECM.Browse.getSelectionXUID = function() {
return this._currentxuid;
};
FIRSTCLASS.apps.Integration.ECM.Browse.doesFileNameExistInSelectedFolder = function(fname) {
var obj = this._contents[this._currentxuid];
if (typeof obj == "undefined") {
return -1;
}
for (var i in obj.browserecords) {
var rec = obj.browserecords[i];
var isleaf = (rec.iscontainer == "false");
if (isleaf && rec.name.indexOf(fname) === 0 && fname.indexOf(rec.name) === 0) {
// found file, now you need to do a get info to find out if you can save
return rec.xuid;
}
}
return false;
};
FIRSTCLASS.apps.Integration.ECM.Browse.doCheckForFileNameInSelectedFolder = function(fname, callback) {
FIRSTCLASS.apps.Integration.ECM.Browse._checkFname = fname;
FIRSTCLASS.apps.Integration.ECM.Browse._checkCB = callback;
FIRSTCLASS.apps.Integration.ECM.Browse._doNavigate(false, FIRSTCLASS.apps.Integration.ECM.Browse.doCheckForFileNameInSelectedFolderDone, FIRSTCLASS.apps.Integration.ECM.Browse._currentxuid);
};
FIRSTCLASS.apps.Integration.ECM.Browse.doCheckForFileNameInSelectedFolderDone = function() {
var exists = FIRSTCLASS.apps.Integration.ECM.Browse.doesFileNameExistInSelectedFolder(FIRSTCLASS.apps.Integration.ECM.Browse._checkFname);
FIRSTCLASS.apps.Integration.ECM.Browse._checkCB({fnamechecked:exists});
};
FIRSTCLASS.apps.Integration.ECM.Browse._doNavigate = function(node, fnLoadComplete, xuid) {
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository);
if (repository === 0 || repository == -1) {
// error
} else {
if (node) {
xuid = node.data.xuid;
}
var cmdConfig = {
command: FIRSTCLASS.apps.Integration._commands.browse,
xuid: xuid,
repository: repository.name,
callbacks: {
success: FIRSTCLASS.apps.Integration.ECM.Browse.doCheckForResponse
}
};
FIRSTCLASS.apps.Integration.ECM.doCommand(cmdConfig);
FIRSTCLASS.apps.Integration.ECM.Browse._onLoadComplete = fnLoadComplete;
FIRSTCLASS.apps.Integration.ECM.Browse._currentxuid = xuid;
}
};
FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseResponse = function(response) {
var obj = response.responseJSON;
if (obj) {
FIRSTCLASS.apps.Integration.ECM.Browse._handleBrowseResponse(obj);
}
};
FIRSTCLASS.apps.Integration.ECM.Browse._handleBrowseResponse = function(obj) {
//this._currentxuid = obj.inputs.xuid;
this._contents[this._currentxuid] = obj;
if (FIRSTCLASS.apps.Integration.ECM.Browse._titleDomEl) {
FIRSTCLASS.apps.Integration.ECM.Browse._populateContent();
}
};
FIRSTCLASS.apps.Integration.ECM.Browse._handleNodeClick = function(event) {
var rc = false;
var doHighlight = false;
if (FIRSTCLASS.apps.Integration.ECM.Browse._selectionMode == FIRSTCLASS.apps.Integration.ECM.Browse.selectionModes.all) {
doHighlight = true;
} else if (FIRSTCLASS.apps.Integration.ECM.Browse._selectionMode == FIRSTCLASS.apps.Integration.ECM.Browse.selectionModes.leaves) {
if (event.node.isLeaf) {
doHighlight = true;
} else {
rc = true;
}
} else //{ FIRSTCLASS.apps.Integration.ECM.Browse.selectionModes.nodes:
if (!event.node.isLeaf) {
doHighlight = true;
}
if (doHighlight) {
FIRSTCLASS.apps.Integration.ECM.Browse._currentxuid = event.node.data.xuid;
event.node.highlight();
event.node.focus();
//event.node.refresh();
}
this.render();
return rc;
};
FIRSTCLASS.apps.Integration.ECM.Browse._populateContent = function() {
var obj = this._contents[this._currentxuid];
if (obj.response.code != 1) {
var params = {
response: obj,
guide: FIRSTCLASS.locale.integrations.ecm.failed,
domElement: FIRSTCLASS.apps.Integration.ECM.Browse._domElement
};
FIRSTCLASS.apps.Integration.ECM._genericOnFailure(params);
var buttons = FIRSTCLASS.apps.Integration.ECM.Browse._dialog.getButtons();
buttons[1].set('disabled', true);
buttons[1].addClass('fcHidden');
} else if (!obj.getinfo.iscontainer) {
YAHOO.util.Dom.setStyle(FIRSTCLASS.apps.Integration.ECM.Browse._treeDomEl, 'height', '50px');
// we're trying to add a version to an existing document
FIRSTCLASS.apps.Integration.ECM.Browse._treeDomEl.innerHTML = FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.integrations.ecm.versionconfirm, {fname:obj.getinfo.filename, repository:FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository});
FIRSTCLASS.apps.Integration.ECM.Browse._currenttargetxuid = obj.getinfo.xuid;
FIRSTCLASS.apps.Integration.ECM.Browse._currentxuid = obj.getinfo.parentxuid;
} else {
if (!this._treeView) {
this._setupTreeView();
}
//var html = [""];
var record = false;
var parent = false;
for (var i in obj.browserecords) {
record = obj.browserecords[i];
if (!this._treenodes[record.xuid]) {
parent = this._treenodes[record.parentxuid];
if (!parent) {
parent = this._treeView.getRoot();
}
var isleaf = (record.iscontainer == "false");
if (!isleaf || isleaf && this._currentconfig.showleaves) {
var node = new YAHOO.widget.TextNode({
// html:record.name,
label:record.name,// + " " +record.xuid,
expanded:false,
xuid:record.xuid,
version: record.version,
isLeaf: isleaf,
enableHighlight: true
// href: "#"+top.location.hash
}, parent);
this._treenodes[record.xuid] = node;
}
}
}
this._treeView.render();
}
if (this._onLoadComplete) {
this._onLoadComplete();
this._onLoadComplete = false;
}
};
/*
// FIXME: Implement me
FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseArchive = function() {
var config = {
parentxuid: FIRSTCLASS.apps.Integration.ECM.Browse._currentxuid,
community: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.community.name,
repository: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository
};
FIRSTCLASS.apps.Integration.ECM.doArchiveToRepository(config);
};*/
FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSend = function(config) {
var fname = FIRSTCLASS.apps.Integration.ECM.Browse._nameDomEl.value;// = $('fcECMBrowseNamePicker');
var xuid = false;
var verify = false;
if (config && config.fnamechecked) {
verify = true;
xuid = config.fnamechecked;
} else if (FIRSTCLASS.apps.Integration.ECM.Browse._currenttargetxuid) {
verify = false;
xuid = FIRSTCLASS.apps.Integration.ECM.Browse._currenttargetxuid;
} else {
var exists = FIRSTCLASS.apps.Integration.ECM.Browse.doesFileNameExistInSelectedFolder(fname);
if (exists == -1) {
// dispatch check
FIRSTCLASS.apps.Integration.ECM.Browse.doCheckForFileNameInSelectedFolder(fname, FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSend);
return;
} else if (exists) {
xuid = exists;
verify = true;
} else {
verify = false;
}
}
if (xuid && verify) {
var rc = confirm(FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.integrations.ecm.versionconfirm, {fname:fname, repository:FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository}));
if (!rc) {
return;
}
// confirm new version
//return;
} //else {
// continue
//}
var myconfig = {
parentxuid: FIRSTCLASS.apps.Integration.ECM.Browse._currentxuid,
community: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.community.name,
fname: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.fname,
repository: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository
};
var unreserve = $('fcECMUnReserve');
if (unreserve && unreserve.checked) {
myconfig.unreserve = true;
}
if (xuid) {
myconfig.xuid = xuid;
}
FIRSTCLASS.apps.Integration.ECM.doSaveToRepository(myconfig);
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository);
if (repository === 0 || repository == -1) {
// error
} else {
FIRSTCLASS.apps.Integration.ECM.Browse._domElement.innerHTML = ""+FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.integrations.ecm.send.sending, {repository:repository.name})+"
";
var buttons = FIRSTCLASS.apps.Integration.ECM.Browse._dialog.getButtons();
buttons[0].set('disabled', true);
buttons[0].addClass('fcHidden');
buttons[1].set('disabled', true);
buttons[1].addClass('fcHidden');/*
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success: FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSendSuccess,
failure: FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSendFailure
}, repository.objid);*/
}
};
FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSendSuccess = function(response) {
var rc = 0;
if (response.responseJSON) {
rc = response.responseJSON.response.code;
}
if (rc == 1) {
var buttons = FIRSTCLASS.apps.Integration.ECM.Browse._dialog.getButtons();
buttons[0].set('disabled', false);
buttons[0].set('label', FIRSTCLASS.locale.integrations.ecm.close);
buttons[0].removeClass('fcHidden');
buttons[1].destroy();
FIRSTCLASS.apps.Integration.ECM.Browse._domElement.innerHTML = ""+FIRSTCLASS.locale.integrations.ecm.succeeded+"";
} else {
FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSendFailure(response);
}
FIRSTCLASS.apps.Integration.ECM.Browse._currenttargetxuid = false;
};
FIRSTCLASS.apps.Integration.ECM.errors = {
"-1": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error1,
handleError: function(params) {
params.domElement.innerHTML = "" + params.guide + "
" + params.response.response.message + "";
}
},
"-2": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error2
},
"-3": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error3,
handleError: function(params) {
params.domElement.innerHTML = "" + params.guide + "
" + params.response.response.message + "";
}
},
"-4": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error4
},
"-5": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error4
},
"-10": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error10
},
"-11": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error11
},
"-12": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error12
},
"-13": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error13
},
"-99": {
description: FIRSTCLASS.locale.integrations.ecm.errors.error99
}
};
FIRSTCLASS.apps.Integration.ECM._genericOnFailure = function(params) {
var obj = params.response;
var message = false;
var handler = false;
if (obj && obj.response && obj.response.message) {
handler = FIRSTCLASS.apps.Integration.ECM.errors[obj.response.code];
if (handler) {
message = handler.description;
} else {
message = obj.response.message;
}
} else {
message = response.responseText;
}
if (handler && handler.handleError) {
handler.handleError(params);
} else {
params.domElement.innerHTML = ""+params.guide+"
" + message + "";
}
};
FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSendFailure = function(response) {
var buttons = FIRSTCLASS.apps.Integration.ECM.Browse._dialog.getButtons();
buttons[0].set('disabled', false);
buttons[0].removeClass('fcHidden');
buttons[0].set('label', FIRSTCLASS.locale.integrations.ecm.close);
buttons[1].destroy();
var obj = false;
var message = "";
if (response.responseJSON) {
obj = response.responseJSON;
}
var params = {
response: obj,
guide: FIRSTCLASS.locale.integrations.ecm.failed,
domElement: FIRSTCLASS.apps.Integration.ECM.Browse._domElement
};
FIRSTCLASS.apps.Integration.ECM._genericOnFailure(params);
};
FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSave = function() {
if (FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.callbacks && FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.callbacks.save) {
var node = FIRSTCLASS.apps.Integration.ECM.Browse._treenodes[FIRSTCLASS.apps.Integration.ECM.Browse._currentxuid];
if (node.isLeaf) {
FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.callbacks.save({xuid:node.data.xuid, fname:node.label, version:node.data.version});
}
}
FIRSTCLASS.apps.Integration.ECM.Browse.close();
};
FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseArchive = function() {
if (FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.callbacks && FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.callbacks.archive) {
var node = FIRSTCLASS.apps.Integration.ECM.Browse._treenodes[FIRSTCLASS.apps.Integration.ECM.Browse._currentxuid];
if (!node.isLeaf) {
FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.callbacks.archive({parentxuid:node.data.xuid});
}
}
var repository = FIRSTCLASS.apps.Integration.getRepositoryByName(FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository);
if (repository === 0 || repository == -1) {
// error
} else {
FIRSTCLASS.apps.Integration.ECM.Browse._domElement.innerHTML = ""+FIRSTCLASS.locale.doSub(FIRSTCLASS.locale.integrations.ecm.send.sending, {repository:repository.name})+"
";
var buttons = FIRSTCLASS.apps.Integration.ECM.Browse._dialog.getButtons();
buttons[0].set('disabled', true);
buttons[0].addClass('fcHidden');
buttons[1].set('disabled', true);
buttons[1].addClass('fcHidden');
FIRSTCLASS.apps.Integration.ECM.watchForResponseComplete({
success: FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSendSuccess ,
failure: FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseSendFailure
}, repository.objid);
}
};
FIRSTCLASS.apps.Integration.ECM.Browse._onBrowseCancel = function() {
if (FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.callbacks && FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.callbacks.cancel) {
FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.callbacks.cancel();
}
window.setTimeout(FIRSTCLASS.apps.Integration.ECM.Browse.close, 10);
};
FIRSTCLASS.apps.Integration.ECM.Browse.close = function() {
if (FIRSTCLASS.apps.Integration.ECM.Browse._treeView) {
FIRSTCLASS.apps.Integration.ECM.Browse._treeView.destroy();
FIRSTCLASS.apps.Integration.ECM.Browse._treeView = false;
}
if (FIRSTCLASS.apps.Integration.ECM.Browse._dialog) {
FIRSTCLASS.apps.Integration.ECM.Browse._dialog.destroy();
FIRSTCLASS.apps.Integration.ECM.Browse._dialog = false;
}
FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig = false;
};
FIRSTCLASS.apps.Integration.ECM.Browse.Actions = {
copy: function(config) {
var cf = {
xuid: config.xuid,
fname: config.fname,
repository: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository,
version: config.version,
target: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.target
};
FIRSTCLASS.apps.Integration.ECM.copyTo(cf);
},
put: function(config) {
alert(FIRSTCLASS.locale.integrations.ecm.browse.upload);
},
archive: function(config) {
var cf = {
parentxuid: config.parentxuid,
repository: FIRSTCLASS.apps.Integration.ECM.Browse._currentconfig.repository,
community: this.community
};
FIRSTCLASS.apps.Integration.ECM.doArchiveToRepository(cf);
}
};
FIRSTCLASS.apps.Integration.ECM.Browse.eventHandlers = {
click: {
node: function(that, fcevent) {
FIRSTCLASS.apps.Integration.ECM.Browse._currentxuid = fcevent.fcattrs;
// FIRSTCLASS.apps.Integration.ECM.Browse._handleNodeClick(fcevent.fcattrs);
}
}
};
FIRSTCLASS.apps.Integration.ECM.Browse.handleEvent = function(event, fcevent) {
var handlers = this.eventHandlers[event.type], rv;
if (handlers) {
var handler = handlers[fcevent.fcid];
if (handler) {
rv = handler(this, fcevent);
if (typeof rv == "undefined") {
rv = true;
}
}
}
};
if (FIRSTCLASS.session.loggedon) {
FIRSTCLASS.apps.Integration.init();
}
YAHOO.register("fcIntegration", FIRSTCLASS.apps.Integration, {version: "0.0.1", build: "1"});