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

BIN
pmd/images/and_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
pmd/images/or_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -1,7 +1,10 @@
var history_array = []; var history_array = [];
var tab_array = []; var tab_array = [];
function panel() { var g_index;
function panel(index) {
if (!index) {
$(".toggle_container").hide(); $(".toggle_container").hide();
}
$("h2.tiger").click(function(){ $("h2.tiger").click(function(){
$(this).toggleClass("active").next().slideToggle("slow"); $(this).toggleClass("active").next().slideToggle("slow");
}); });
@@ -26,11 +29,23 @@ function display(init,final) {
for ( var i=0; i < history_array.length; i++){ for ( var i=0; i < history_array.length; i++){
var temp = history_array[i].get_tab() + '.' + history_array[i].get_obj_no(); var temp = history_array[i].get_tab() + '.' + history_array[i].get_obj_no();
str += '<h2 class="tiger"><a href="#">' + temp + '</a></h2>'; 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) { while((history_array[i].get_tab() + '.' + history_array[i].get_obj_no()) == temp) {
str +='<div class="block"> <table>'; str +='<div class="block"> <table width ="250">';
str += '<thead><tr><td>' + history_array[i].get_column_name() + '<td></tr></thead><tr><td>'; str += '<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>'; 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++; i++;
if(i >= history_array.length) { if(i >= history_array.length) {
break; break;
@@ -43,7 +58,97 @@ function display(init,final) {
return str; 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 and_or;
var obj; var obj;
var tab; var tab;
@@ -59,6 +164,9 @@ function display(init,final) {
this.set_and_or = function(nand_or) { this.set_and_or = function(nand_or) {
and_or = nand_or; and_or = nand_or;
}; };
this.get_and_or = function() {
return and_or;
}
this.get_relation = function() { this.get_relation = function() {
return and_or; return and_or;
}; };
@@ -107,7 +215,7 @@ var where = function (nrelation_operator,nquery) {
return query; return query;
}; };
this.getrelation_operator = function() { this.getrelation_operator = function() {
return relation_opearator; return relation_operator;
}; };
this.setquery(nquery); this.setquery(nquery);
this.setrelation_operator(nrelation_operator); this.setrelation_operator(nrelation_operator);

View File

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

View File

@@ -411,7 +411,7 @@ right: 0;
display: none; display: none;
background: #FFF; background: #FFF;
border:1px solid #F5F5F5; border:1px solid #F5F5F5;
width: auto; width: 350 px;
height: auto; height: auto;
padding: 30px 170px 30px 30px; padding: 30px 170px 30px 30px;
color:#FFF; color:#FFF;
@@ -457,20 +457,20 @@ z-index:999;
} }
h2.tiger{ h2.tiger{
background-image: url(images/Header.png);
background-repeat: repeat-x; background-repeat: repeat-x;
padding: 1px; padding: 1px;
font-weight: bold; font-weight: bold;
font-size:14px; font-size:14px;
padding: 50 20 50 20px; padding: 50 20 50 20px;
margin: 0 0 5px 0; margin: 0 0 5px 0;
width: 300px; width: 250px;
float: left; float: left;
color : #333; color : #333;
text-align: center; text-align: center;
} }
h2.tiger a { h2.tiger a {
background-image: url(images/Header.png);
text-align: center; text-align: center;
text-decoration: none; text-decoration: none;
color : #333; color : #333;
@@ -487,22 +487,32 @@ h2.active {
background-repeat: repeat-x; background-repeat: repeat-x;
padding: 1px; padding: 1px;
background-position: left bottom; background-position: left bottom;
} /*--When toggle is tigered, it will shift the image to the bottom to show its "opened" state--*/ }
.toggle_container { .toggle_container {
margin: 0 0 5px; margin: 0 0 5px;
padding: 0; padding: 0;
border-top: 1px solid #d6d6d6; border-top: 1px solid #d6d6d6;
background: #FFF ; background: #FFF ;
width: 300px; width: 250px;
overflow: hidden; overflow: hidden;
font-size: 1.2em; font-size: 1.2em;
clear: both; clear: both;
} }
.toggle_container .block { .toggle_container .block {
background-color: #E7E7E7; background-color: #DBE4E8;
padding:40 15 40 15px; /*--Padding of Container--*/ padding:40 15 40 15px; /*--Padding of Container--*/
border:1px solid #999; border:1px solid #999;
color:#000; color:#000;
} }
.history_table {
text-align: center;
background-color: #9999CC;
}
.history_table2 {
text-align: center;
background-color: #DBE4E8;
}

View File

@@ -468,7 +468,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
</tr> </tr>
<tr> <tr>
<td nowrap="nowrap">Value/<br />Subquery</td> <td nowrap="nowrap">Value/<br />Subquery</td>
<td><textarea name="Query" value="" cols="15"></textarea> <td><textarea id="Query" value="" cols="18"></textarea>
</td> </td>
</tr> </tr>
<tr><td align="center" nowrap="nowrap"><b>Rename To</b></td></tr> <tr><td align="center" nowrap="nowrap"><b>Rename To</b></td></tr>
@@ -519,6 +519,172 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table id="query_rename_to" style="visibility:<?php echo $hidden ?>;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="frams1" width="10px"></td>
<td class="frams5" width="99%" ></td>
<td class="frams2" width="10px"><div class="bor"></div></td>
</tr>
<tr>
<td class="frams8"></td>
<td class="input_tab">
<table width="168" border="0" align="center" cellpadding="2" cellspacing="0">
<thead>
<tr>
<td colspan="2" align="center" nowrap="nowrap"><strong>Rename To</strong></td>
</tr>
</thead>
<tbody id="rename_to">
<tr>
<td width="58" nowrap="nowrap">New Name</td>
<td width="102">
<input type="text" value="" id="e_rename"/>
</td>
</tr>
</tbody>
<tbody>
<tr>
<td colspan="2" align="center" nowrap="nowrap">
<input type="button" class="butt" name="Button"
value="<?php echo __('OK'); ?>" onclick="edit('Rename')" />
<input type="button" class="butt" name="Button"
value="<?php echo __('Cancel'); ?>"
onclick="document.getElementById('query_rename_to').style.visibility = 'hidden';" />
</td>
</tr>
</tbody>
</table>
</td>
<td class="frams6"></td>
</tr>
<tr>
<td class="frams4"><div class="bor"></div></td>
<td class="frams7"></td>
<td class="frams3"></td>
</tr>
</tbody>
</table>
<table id="query_Aggregate" style="visibility:<?php echo $hidden ?>;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="frams1" width="10px"></td>
<td class="frams5" width="99%" ></td>
<td class="frams2" width="10px"><div class="bor"></div></td>
</tr>
<tr>
<td class="frams8"></td>
<td class="input_tab">
<table width="168" border="0" align="center" cellpadding="2" cellspacing="0">
<thead>
<tr>
<td colspan="2" align="center" nowrap="nowrap"><strong>Aggregate</strong></td>
</tr>
</thead>
<tbody>
<tr>
<td width="58" nowrap="nowrap">Operator</td>
<td width="102">
<select name="operator" id="e_operator">
<option value="---" selected="selected">---</option>
<option value="sum" > Sum </option>
<option value="min"> Min </option>
<option value="max"> Max </option>
<option value="avg"> Avg </option>
<option value="avg"> Count </option>
</select>
</td></tr>
</tbody>
<tbody>
<tr>
<td colspan="2" align="center" nowrap="nowrap">
<input type="button" class="butt" name="Button"
value="<?php echo __('OK'); ?>" onclick="edit('Aggregate')" />
<input type="button" class="butt" name="Button"
value="<?php echo __('Cancel'); ?>"
onclick="document.getElementById('query_Aggregate').style.visibility = 'hidden';" />
</td>
</tr>
</tbody>
</table>
</td>
<td class="frams6"></td>
</tr>
<tr>
<td class="frams4"><div class="bor"></div></td>
<td class="frams7"></td>
<td class="frams3"></td>
</tr>
</tbody>
</table>
<table id="query_where" style="visibility:<?php echo $hidden ?>;"
width="5%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="frams1" width="10px"></td>
<td class="frams5" width="99%" ></td>
<td class="frams2" width="10px"><div class="bor"></div></td>
</tr>
<tr>
<td class="frams8"></td>
<td class="input_tab">
<table width="168" border="0" align="center" cellpadding="2" cellspacing="0">
<thead>
<tr>
<td colspan="2" align="center" nowrap="nowrap"><strong>Where</strong></td>
</tr>
</thead>
<tbody id="rename_to">
<tr>
<td width="58" nowrap="nowrap">Opeartor</td>
<td width="102"><select name="erel_opt" id="erel_opt">
<option value="--" selected="selected"> -- </option>
<option value="=" > = </option>
<option value=">"> > </option>
<option value="<"> < </option>
<option value=">="> >= </option>
<option value="<="> <= </option>
<option value="NOT"> NOT </option>
<option value="IN"> IN </option>
<option value="EXCEPT"> Except </option>
<option value="NOT IN"> Not In </option>
</select>
</td>
</tr>
<tr>
<td nowrap="nowrap">Value/<br />Subquery</td>
<td><textarea id="eQuery" value="" cols="18"></textarea>
</td>
</tr>
</tbody>
<tbody>
<tr>
<td colspan="2" align="center" nowrap="nowrap">
<input type="button" class="butt" name="Button"
value="<?php echo __('OK'); ?>" onclick="edit('Where')" />
<input type="button" class="butt" name="Button"
value="<?php echo __('Cancel'); ?>"
onclick="document.getElementById('query_where').style.visibility = 'hidden';" />
</td>
</tr>
</tbody>
</table>
</td>
<td class="frams6"></td>
</tr>
<tr>
<td class="frams4"><div class="bor"></div></td>
<td class="frams7"></td>
<td class="frams3"></td>
</tr>
</tbody>
</table>
<?php <?php
if($_REQUEST['query']) { if($_REQUEST['query']) {
echo '<div class="panel">'; echo '<div class="panel">';