/** * @fileoverview function used in this file builds history tab and generates query. * * @requires jQuery * @requires move.js */ /* global contr */ // js/designer/init.js /* global fromArray:writable */ // js/designer/move.js /* global themeImagePath */ // templates/javascript/variables.twig var DesignerHistory = {}; var historyArray = []; // Global array to store history objects var selectField = []; // Global array to store information for columns which are used in select clause var gIndex; var vqbEditor = null; /** * To display details of objects(where,rename,Having,aggregate,groupby,orderby,having) * * @param {number} index index of historyArray where change is to be made * @return {string} */ DesignerHistory.detail = function (index) { var type = historyArray[index].getType(); var str; if (type === 'Where') { str = 'Where ' + historyArray[index].getColumnName() + historyArray[index].getObj().getRelationOperator() + historyArray[index].getObj().getQuery(); } else if (type === 'Rename') { str = 'Rename ' + historyArray[index].getColumnName() + ' To ' + historyArray[index].getObj().getRenameTo(); } else if (type === 'Aggregate') { str = 'Select ' + historyArray[index].getObj().getOperator() + '( ' + historyArray[index].getColumnName() + ' )'; } else if (type === 'GroupBy') { str = 'GroupBy ' + historyArray[index].getColumnName(); } else if (type === 'OrderBy') { str = 'OrderBy ' + historyArray[index].getColumnName() + ' ' + historyArray[index].getObj().getOrder(); } else if (type === 'Having') { str = 'Having '; if (historyArray[index].getObj().getOperator() !== 'None') { str += historyArray[index].getObj().getOperator() + '( ' + historyArray[index].getColumnName() + ' )'; str += historyArray[index].getObj().getRelationOperator() + historyArray[index].getObj().getQuery(); } else { str = 'Having ' + historyArray[index].getColumnName() + historyArray[index].getObj().getRelationOperator() + historyArray[index].getObj().getQuery(); } } return str; }; /** * Sorts historyArray[] first,using table name as the key and then generates the HTML code for history tab, * clubbing all objects of same tables together * This function is called whenever changes are made in historyArray[] * * * @param {number} init starting index of unsorted array * @param {number} finit last index of unsorted array * @return {string} */ DesignerHistory.display = function (init, finit) { var str; var i; var j; var k; var sto; var temp; // this part sorts the history array based on table name,this is needed for clubbing all object of same name together. for (i = init; i < finit; i++) { sto = historyArray[i]; temp = historyArray[i].getTab(); // + '.' + historyArray[i].getObjNo(); for Self JOINS for (j = 0; j < i; j++) { if (temp > historyArray[j].getTab()) { // + '.' + historyArray[j].getObjNo())) { //for Self JOINS for (k = i; k > j; k--) { historyArray[k] = historyArray[k - 1]; } historyArray[j] = sto; break; } } } // this part generates HTML code for history tab.adds delete,edit,and/or and detail features with objects. str = ''; // string to store Html code for history tab var historyArrayLength = historyArray.length; for (i = 0; i < historyArrayLength; i++) { temp = historyArray[i].getTab(); // + '.' + historyArray[i].getObjNo(); for Self JOIN str += '
'; if (historyArray[i].getAndOr()) { str += ' | '; } else { str += ''; } str += '' + Functions.getImage('b_sbrowse', Messages.strColumnName) + ' | ' + '' + $('').text(historyArray[i].getColumnName()).html() + ' | '; if (historyArray[i].getType() === 'GroupBy' || historyArray[i].getType() === 'OrderBy') { var detailDescGroupBy = $('').text(DesignerHistory.detail(i)).html(); str += ' | ' + Functions.getImage('s_info', DesignerHistory.detail(i)) + ' | ' + '' + historyArray[i].getType() + ' | ' + '' + Functions.getImage('b_drop', Messages.strDelete) + ' | '; } else { var detailDesc = $('').text(DesignerHistory.detail(i)).html(); str += '' + Functions.getImage('s_info', DesignerHistory.detail(i)) + ' | ' + '' + historyArray[i].getType() + ' | ' + '' + Functions.getImage('b_edit', Messages.strEdit) + ' | ' + '' + Functions.getImage('b_drop', Messages.strDelete) + ' | '; } str += '