new features in history tab

This commit is contained in:
ankitg
2010-07-02 12:10:56 +05:30
parent de28609ff9
commit 2c03eb2986
6 changed files with 306 additions and 22 deletions

View File

@@ -1,7 +1,10 @@
var history_array = [];
var tab_array = [];
function panel() {
$(".toggle_container").hide();
var g_index;
function panel(index) {
if (!index) {
$(".toggle_container").hide();
}
$("h2.tiger").click(function(){
$(this).toggleClass("active").next().slideToggle("slow");
});
@@ -26,11 +29,23 @@ function display(init,final) {
for ( var i=0; i < history_array.length; i++){
var temp = history_array[i].get_tab() + '.' + history_array[i].get_obj_no();
str += '<h2 class="tiger"><a href="#">' + temp + '</a></h2>';
str +='<div class="toggle_container">\n';
str += '<div class="toggle_container">\n';
while((history_array[i].get_tab() + '.' + history_array[i].get_obj_no()) == temp) {
str +='<div class="block"> <table>';
str += '<thead><tr><td>' + history_array[i].get_column_name() + '<td></tr></thead><tr><td>';
str += history_array[i].get_type() + '</td><td><img src=""/></td><td><img src="pmd/style/default/images/minus.png"></td></tr>';
str +='<div class="block"> <table width ="250">';
str += '<thead><tr><td>';
if(history_array[i].get_and_or()){
str +='<img src="pmd/images/or_icon.png" onclick="and_or('+i+')" title="OR"/></td>';
}
else {
str +='<img src="pmd/images/and_icon.png" onclick="and_or('+i+')" title="AND"/></td>';
}
str +='<td style="padding-left: 5px;" align="right"><img src="./themes/original/img/b_sbrowse.png" title="column name"/></td><td width="175" style="padding-left: 5px">' + history_array[i].get_column_name();
if (history_array[i].get_type() == "GroupBy" || history_array[i].get_type() == "OrderBy") {
str += '</td><td align="center"><img src="themes/original/img/b_info.png" title="'+detail(i)+'"/><td title="' + detail(i) +'">' + history_array[i].get_type() + '</td></td><td onmouseover="this.className=\'history_table\';" onmouseout="this.className=\'history_table2\'" onclick=history_delete('+ i +')><img src="themes/original/img/b_drop.png" title="Delete"></td></tr></thead>';
}
else {
str += '</td><td align="center"><img src="themes/original/img/b_info.png" title="'+detail(i)+'"/></td><td title="' + detail(i) +'">' + history_array[i].get_type() + '</td><td <td onmouseover="this.className=\'history_table\';" onmouseout="this.className=\'history_table2\'" onclick=history_edit('+ i +')><img src="themes/original/img/b_edit.png" title="Edit"/></td><td onmouseover="this.className=\'history_table\';" onmouseout="this.className=\'history_table2\'" onclick=history_delete('+ i +')><img src="themes/original/img/b_drop.png" title="Delete"></td></tr></thead>';
}
i++;
if(i >= history_array.length) {
break;
@@ -43,7 +58,97 @@ function display(init,final) {
return str;
}
function history(ncolumn_name,nobj,ntab,nobj_no,ntype) {
function and_or(index) {
if (history_array[index].get_and_or()) {
history_array[index].set_and_or(0);
}
else {
history_array[index].set_and_or(1);
}
var existingDiv = document.getElementById('ab');
existingDiv.innerHTML = display(0,0);
panel(1);
}
function detail (index) {
var type = history_array[index].get_type();
var str;
if (type == "Where") {
str = 'Where ' + history_array[index].get_column_name() + history_array[index].get_obj().getrelation_operator() + history_array[index].get_obj().getquery();
}
if (type == "Rename") {
str = 'Rename ' + history_array[index].get_column_name() + ' To ' + history_array[index].get_obj().getrename_to();
}
if (type == "Aggregate") {
str = 'Select ' + history_array[index].get_obj().get_operator() + '( ' + history_array[index].get_column_name() + ' )';
}
if (type == "GroupBy") {
str = 'GroupBy ' + history_array[index].get_column_name() ;
}
if (type == "OrderBy") {
str = 'OrderBy ' + history_array[index].get_column_name() ;
}
return str;
}
function history_delete(index) {
history_array.splice(index,1);
var existingDiv = document.getElementById('ab');
existingDiv.innerHTML = display(0,0);
panel(1);
}
function history_edit(index) {
g_index = index;
var type = history_array[index].get_type();
if (type == "Where") {
document.getElementById('eQuery').value = history_array[index].get_obj().getquery();
document.getElementById('erel_opt').value = history_array[index].get_obj().getrelation_operator();
document.getElementById('query_where').style.left = '230px';
document.getElementById('query_where').style.top = '330px';
document.getElementById('query_where').style.visibility = 'visible';
}
if (type == "Rename") {
//var left = screen.availWidth/2 ;
document.getElementById('query_rename_to').style.left = '230px';
document.getElementById('query_rename_to').style.top = '330px';
document.getElementById('query_rename_to').style.visibility = 'visible';
}
if (type == "Aggregate") {
var left = Glob_X - (document.getElementById('query_Aggregate').offsetWidth>>1);
document.getElementById('query_Aggregate').style.left = left + 'px';
document.getElementById('query_Aggregate').style.top = (screen.height / 4) + 'px';
document.getElementById('query_Aggregate').style.visibility = 'visible';
}
}
function edit(type) {
if (type == "Rename") {
if (document.getElementById('e_rename').value != "") {
history_array[g_index].get_obj().setrename_to(document.getElementById('e_rename').value);
document.getElementById('e_rename').value = "";
}
document.getElementById('query_rename_to').style.visibility = 'hidden';
}
if (type == "Aggregate") {
if (document.getElementById('e_operator').value != '---') {
history_array[g_index].get_obj().set_operator(document.getElementById('e_operator').value);
document.getElementById('e_operator').value = '---';
}
document.getElementById('query_Aggregate').style.visibility = 'hidden';
}
if (type == "Where") {
if (document.getElementById('erel_opt').value != '--' && document.getElementById('eQuery').value !="") {
history_array[g_index].get_obj().setquery(document.getElementById('eQuery').value);
history_array[g_index].get_obj().setrelation_operator(document.getElementById('erel_opt').value);
document.getElementById('eQuery').value = "";
document.getElementById('erel_opt').value = '--';
}
document.getElementById('query_where').style.visibility = 'hidden';
}
var existingDiv = document.getElementById('ab');
existingDiv.innerHTML = display(0,0);
panel(1);
}
function history(ncolumn_name,nobj,ntab,nobj_no,ntype) {
var and_or;
var obj;
var tab;
@@ -59,6 +164,9 @@ function display(init,final) {
this.set_and_or = function(nand_or) {
and_or = nand_or;
};
this.get_and_or = function() {
return and_or;
}
this.get_relation = function() {
return and_or;
};
@@ -107,7 +215,7 @@ var where = function (nrelation_operator,nquery) {
return query;
};
this.getrelation_operator = function() {
return relation_opearator;
return relation_operator;
};
this.setquery(nquery);
this.setrelation_operator(nrelation_operator);

View File

@@ -1014,12 +1014,12 @@ function add_object() {
var sum = 0;
var init = history_array.length;
if (rel.value != '--') {
if (document.getElementsByName('Query').value == "") {
if (document.getElementById('Query').value == "") {
document.getElementById('hint').innerHTML = "value/subQuery is empty" ;
document.getElementById('hint').style.visibility = "visible";
return;
}
var p = document.getElementsByName('Query');
var p = document.getElementById('Query');
var where_obj = new where(rel.value,p.value);//make where object
history_array.push(new history(col_name,where_obj,tab_name,h_tabs[tab_name],"Where"));
sum = sum + 1;
@@ -1040,13 +1040,13 @@ function add_object() {
//make aggregate operator
}
if (document.getElementById('groupby').checked == true ) {
history_array.push(new history(col_name,'GroupBy',tab_name,h_tabs[tab_name],"Group By"));
history_array.push(new history(col_name,'GroupBy',tab_name,h_tabs[tab_name],"GroupBy"));
sum = sum + 1;
document.getElementById('groupby').checked = false;
//make groupby
}
if (document.getElementById('orderby').checked == true) {
history_array.push(new history(col_name,'OrderBy',tab_name,h_tabs[tab_name],"Order By"));
history_array.push(new history(col_name,'OrderBy',tab_name,h_tabs[tab_name],"OrderBy"));
sum = sum + 1;
document.getElementById('orderby').checked = false;
//make orderby
@@ -1057,6 +1057,6 @@ function add_object() {
var existingDiv = document.getElementById('ab');
existingDiv.innerHTML = display(init,history_array.length);
Close_option();
panel();
panel(0);
}