group_by view is not hardcoded anymore. fixed javaScripts - still wont work properly in ie

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1364 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
p.tessenow 15 years ago
parent 81348ddb88
commit 9b16e58783
  1. 46
      app/views/cost_reports/_group_by.rhtml
  2. 33
      assets/javascripts/select_list_move_optgroup.js

@ -4,50 +4,46 @@
query A CostQuery object
%>
<%#TODO: replace me with a drag&drop group_by selector %>
<table style="border-collapse: collapse; border: 0pt none;" id="group_by_table">
<tbody><tr>
<td colspan="2">
<select style="width: 150px;" size="9" multiple="multiple" id="group_by_container">
<optgroup label="Entries">
<option value="tracker_id">Tracker</option>
<option value="activity_id">Activity</option>
<option value="cost_object_id">Cost object</option>
<option value="cost_type_id">Cost type</option>
<option value="issue_id">Issue</option>
</optgroup>
<optgroup label="Issues">
<option value="spent_on">Spent on</option>
<option value="tmonth">Month</option>
<% CostQuery::GroupBy.all_grouped.each do |label, group_by_ary| %>
<optgroup label="<%= l(label) %>" data-category="<%= label.to_s %>">
<% group_by_ary.each do |group_by| %>
<option value="<%= group_by.underscore_name %>" data-category="<%= label.to_s %>"><%= l(group_by.label) %></option>
<% end %>
</optgroup>
<% end %>
</select>
</td>
<td align="center" valign="middle">
<input type="button" onclick="moveOptions(this.form.group_by_container, this.form.group_by_columns);" value=""><br>
<input type="button" onclick="moveOptions(this.form.group_by_columns, this.form.group_by_container);" value="">
<input type="button" onclick="moveOptions(this.form.group_by_container, this.form.group_by_columns);" value="&#8594;"><br>
<input type="button" onclick="moveOptions(this.form.group_by_columns, this.form.group_by_container);" value="&#8592;">
</td>
<td style="padding-left: 0pt;" valign="middle">
<h3>Columns</h3>
<select style="width: 150px;" size="4" name="groups[columns][]" multiple="multiple" id="group_by_columns">
<option value="tyear">Year</option>
<option value="tweek">Week</option>
</select>
</td>
<td align="center" valign="middle">
<input type="button" onclick="moveOptionUp(this.form.group_by_columns);" value=""><br>
<input type="button" onclick="moveOptionDown(this.form.group_by_columns);" value="">
<input type="button" onclick="moveOptionUp(this.form.group_by_columns);" value="&#8593;"><br>
<input type="button" onclick="moveOptionDown(this.form.group_by_columns);" value="&#8595;">
</td>
</tr>
<tr>
<td align="center" valign="middle" colspan="2">
<input type="button" onclick="moveOptions(this.form.group_by_container, this.form.group_by_rows);" value="">
<input type="button" onclick="moveOptions(this.form.group_by_rows, this.form.group_by_container);" value="">
<input type="button" onclick="moveOptions(this.form.group_by_container, this.form.group_by_rows);" value="&#8595;">
<input type="button" onclick="moveOptions(this.form.group_by_rows, this.form.group_by_container);" value="&#8593;">
</td>
<td colspan="3" rowspan="2" align="center" valign="middle">
<table border="1" style="border-collapse: collapse">
<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>
<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>
<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>
<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>
<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>
<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>
<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>
<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>
</table>
</td>
</tr>
@ -55,13 +51,11 @@
<td style="padding-left: 0pt;" valign="middle">
<h3>Rows</h3>
<select style="width: 150px;" size="4" name="groups[rows][]" multiple="multiple" id="group_by_rows">
<option value="project_id">Project</option>
<option value="user_id">User</option>
</select>
</td>
<td align="center" valign="middle">
<input type="button" onclick="moveOptionUp(this.form.group_by_rows);" value=""><br>
<input type="button" onclick="moveOptionDown(this.form.group_by_rows);" value="">
<input type="button" onclick="moveOptionUp(this.form.group_by_rows);" value="&#8593;"><br>
<input type="button" onclick="moveOptionDown(this.form.group_by_rows);" value="&#8595;">
</td>
</tr></tbody>
</table>

@ -1,25 +1,42 @@
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
function addOption(theSel, theText, theValue)
function addOption(theSel, theText, theValue, theCategory)
{
theSel = $(theSel.id);
var newOpt = new Option(theText, theValue);
var selLength = theSel.length;
theSel.options[selLength] = newOpt;
newOpt.setAttribute("data-category", theCategory);
if (theCategory && (theSel.childElements().length > 0) && theSel.down(0).tagName == "OPTGROUP") { // add the opt to the given category
opt_groups = theSel.childElements();
for (i in opt_groups)
if (opt_groups[i].getAttribute("data-category") == theCategory) {
opt_groups[i].appendChild(newOpt);
break;
}
}
else { // no category given, just add the opt to the end of the select list
var selLength = theSel.length;
theSel.options[selLength] = newOpt;
}
}
function swapOptions(theSel, index1, index2)
function swapOptions(theSel, index1, index2) //FIXME: add category support
{
theSel = $(theSel.id);
var text, value;
text = theSel.options[index1].text;
value = theSel.options[index1].value;
category = theSel.options[index1].getAttribute("data-category");
theSel.options[index1].text = theSel.options[index2].text;
theSel.options[index1].value = theSel.options[index2].value;
theSel.options[index1].setAttribute("data-category", theSel.options[index2].getAttribute("data-category"));
theSel.options[index2].text = text;
theSel.options[index2].value = value;
theSel.options[index2].setAttribute("data-category", category);
}
function deleteOption(theSel, theIndex)
{
theSel = $(theSel.id);
var selLength = theSel.length;
if(selLength>0)
{
@ -29,9 +46,12 @@ function deleteOption(theSel, theIndex)
function moveOptions(theSelFrom, theSelTo)
{
theSelFrom = $(theSelFrom.id);
theSelTo = $(theSelTo.id);
var selLength = theSelFrom.length;
var selectedText = new Array();
var selectedValues = new Array();
var selectedCategories = new Array();
var selectedCount = 0;
var i;
@ -42,6 +62,7 @@ function moveOptions(theSelFrom, theSelTo)
{
selectedText[selectedCount] = theSelFrom.options[i].text;
selectedValues[selectedCount] = theSelFrom.options[i].value;
selectedCategories[selectedCount] = theSelFrom.options[i].getAttribute("data-category");
deleteOption(theSelFrom, i);
selectedCount++;
}
@ -49,13 +70,14 @@ function moveOptions(theSelFrom, theSelTo)
for(i=selectedCount-1; i>=0; i--)
{
addOption(theSelTo, selectedText[i], selectedValues[i]);
addOption(theSelTo, selectedText[i], selectedValues[i], selectedCategories[i]);
}
if(NS4) history.go(0);
}
function moveOptionUp(theSel) {
theSel = $(theSel.id);
var index = theSel.selectedIndex;
if (index > 0) {
swapOptions(theSel, index-1, index);
@ -64,6 +86,7 @@ function moveOptionUp(theSel) {
}
function moveOptionDown(theSel) {
theSel = $(theSel.id);
var index = theSel.selectedIndex;
if (index < theSel.length - 1) {
swapOptions(theSel, index, index+1);

Loading…
Cancel
Save