Code:
DataMapLayout = function(){
var layout;
var grid;
var gridDataModel;
var datamapPanel;
var addBtn;
var dialog;
return {
init : function(){
layout = new YAHOO.ext.BorderLayout(document.body, {
hideOnLayout: true,
north: {
split:false,
initialSize: 25,
titlebar: false
},
west: {
split:true,
autoScroll:true,
initialSize: 125,
minSize: 125,
maxSize: 400,
titlebar: true,
collapsible: true
},
east: {
split:true,
initialSize: 155,
minSize: 155,
maxSize: 400,
titlebar: true,
collapsible: true
},
south: {
split:true,
initialSize: 100,
minSize: 100,
maxSize: 200,
titlebar: true,
collapsible: true
},
center: {
titlebar: false,
autoScroll:false,
tabPosition: 'top',
closeOnTab: true,
alwaysShowTabs: true
}
});
// tell the layout not to perform layouts until we're done adding everything
layout.beginUpdate();
layout.add('north', new YAHOO.ext.ContentPanel('header'));
// initialize the statusbar
// create the add note toolbar
var notetb = new YAHOO.ext.ContentPanel('add-note',
{fitToFrame:true, adjustments:[-6, 0], resizeEl:'header'})
southPanel = new YAHOO.ext.ContentPanel('datamapnotes', {title: 'Field - Data Mapping Notes', toolbar: notetb});
//southPanel = new YAHOO.ext.ContentPanel('datamapnotes', {title: 'Field - Data Mapping Notes'});
south = layout.getRegion('south');
south.add(southPanel);
layout.add('west', new YAHOO.ext.ContentPanel('datamaps', {title: 'Data Maps', fitToFrame:false}));
layout.add('east', new YAHOO.ext.ContentPanel('scenarios', {title: 'Scenarios Using Field', fitToFrame:true}));
var innerLayout = new YAHOO.ext.BorderLayout('main', {
south: {
split:true,
initialSize: 250,
minSize: 100,
maxSize: 400,
autoScroll:true,
collapsible:true,
titlebar: true,
animate: true,
cmargins: {top:2,bottom:0,right:0,left:0}
},
center: {
autoScroll:false,
titlebar:false
}
});
innerLayout.beginUpdate();
// create the feed grid
this.createGrid('Account');
innerLayout.add('center', new YAHOO.ext.GridPanel(grid, {title: 'DIS to Source System Grid'}));
// restore innerLayout state
innerLayout.restoreState();
innerLayout.endUpdate(true);
// add the nested layout
datamapPanel = new YAHOO.ext.NestedLayoutPanel(innerLayout, 'Account');
layout.add('center', datamapPanel);
layout.restoreState();
layout.endUpdate();
Download.init();
},
createGrid : function(){
function formatMoney(value){
value -= 0;
value = (Math.round(value*100))/100;
value = (value == Math.floor(value)) ? value + '.00' : ( (value*10 == Math.floor(value*10)) ? value + '0' : value);
return "$" + value;
};
function formatBoolean(value){
return value ? 'Yes' : 'No';
};
function formatDate(value){
return value.dateFormat('m/d/Y');
};
function parseDate(value){
return new Date(Date.parse(value));
};
function parseStatusID(value){
return new Date(Date.parse(value));
};
var schema = {
root: 'datamap.datamapfields',
id: 'name',
fields: ['id','datamap','name', 'origin','type', 'dbColumnName', 'requirement', 'maxLength', 'refDataKey',
'derivationType', 'refDataType', 'domain', 'defaultValue', 'position', 'sourceSystemName',
'hasData','SourceTableName','SourceFieldName', 'condition', 'addRefDataKeys', 'timeSource',
'dateSource','derivationParams', 'vendor', 'productVersion']
};
gridDataModel = new YAHOO.ext.grid.JSONDataModel(schema);
//gridDataModel.setDefaultSort(colModel, 0, "DESC");
var yg = YAHOO.ext.grid;
var cols = [{
header: "DataMap",
width: 1,
dataIndex: 1
},{
header: "Position",
width: 50,
dataIndex: 13
},{
header: "Name",
width: 170,
dataIndex: 2
},{
header: "Type",
width: 75,
dataIndex: 4
},{
header: "Max Length",
width: 65,
dataIndex: 7
},{
header: "Default",
width: 40,
dataIndex: 12
},{
header: "Domain Values",
width: 80,
dataIndex: 11
},{
header: "Source System Name",
width: 80,
dataIndex: 14,
editor: new yg.TextEditor({allowBlank: true})
},{
header: "Has Data",
width: 70,
dataIndex: 15,
renderer: formatBoolean,
editor: new yg.CheckboxEditor()
},{
header: "Source Table Name",
width: 80,
dataIndex: 16,
editor: new yg.TextEditor({allowBlank: true})
},{
header: "Source Field Name",
width: 80,
dataIndex: 17,
editor: new yg.TextEditor({allowBlank: true})
}];
var colModel = new YAHOO.ext.grid.DefaultColumnModel(cols);
colModel.defaultSortable = true;
//var sm = new YAHOO.ext.grid.EditorSelectionModel();
grid = new YAHOO.ext.grid.EditorGrid('grid', gridDataModel, colModel);
grid.render();
grid.autoSizeHeaders = true;
gridDataModel.load('getdatamap.php', 'datamapname=Account');
gridDataModel.addListener('cellupdated', onCellUpdated);
var wait = getEl('wait');
gridDataModel.addListener('beforeload', wait.show, wait, true);
gridDataModel.addListener('load', wait.hide, wait, true);
//var sm = grid.getSelectionModel();
grid.addListener('rowclick', onRowClicked);
DataMapListObj.startRequest();
DataMapNoteObj.startRequest();
ScenarioDataMapObj.startRequest('Account', 'AccountIdentifier');
},
updateGrid : function(datamap){
gridDataModel.load('getdatamap.php', 'datamapname=' + datamap, this.updateTabLabel(datamap) );
var el = document.getElementById("datamapfieldlist");
if (el != null) {
el.parentNode.removeChild(el);
}
},
updateTabLabel : function (title) {
datamapPanel.setTitle(title);
}
}
}();