nextmatch sortheader can specify a default sort now: default is ASC and can now be set to DESC

This commit is contained in:
Ralf Becker 2005-07-17 21:42:11 +00:00
parent 4b97e9463c
commit b68fb24b25
2 changed files with 20 additions and 13 deletions

View File

@ -786,10 +786,6 @@ function get_rows($query,&$rows,&$readonlys)
{
$rows = array( );
}
else
{
array_unshift($rows,0); each($rows); <span>// first entry is not used !!!</span>
}
$readonlys = array( ); <span>// set readonlys to enable/disable our edit/delete-buttons</span>
while (list($n,$note) = each($rows))
{
@ -846,9 +842,9 @@ function index($content = 0)
</td>
</tr>
<tr>
<td><b>Nextmatch-<br />SortHeader</b><p><b>Nextmatch-<br />FilterHeader</b></td>
<td><b>Nextmatch-<br />SortHeader</b><p><b>Nextmatch-<br />FilterHeader</b><p><b>Nextmatch-<br />AccountFilter</b></td>
<td>
&lt;nextmatch type="nextmatch-sortheader" id="col-name" label="ColLabel"/><p>
&lt;nextmatch type="nextmatch-sortheader" id="col-name" options="DESC" label="ColLabel"/><p>
&lt;nextmatch type="nextmatch-filterheader" id="col-name"/><p>
&lt;nextmatch type="nextmatch-accountfilter" id="col-name"/>
</td>
@ -859,7 +855,8 @@ function index($content = 0)
<b>nextmatch-sortheader</b><br />
Widget to be placed as a colum-header in the headerline of a nextmatch-template. It allows, by clicking on it,
to order the lines of the nextmatch after a certain column. The column-name is given as <b>name</b> (xml:id) the
<b>label</b> is show as a link of button (no javascript). Consecutive click on the header change the sorting
<b>label</b> is show as a link of button (no javascript). One can specify a default sorting: <b>options</b>={DESC|ASC} (default=ASC),
to be used when the header is clicked for the first time. Consecutive click on the header change the sorting
direction, indicated by a little up- or down-arrow.<p>
<b>nextmatch-filterheader</b><br />
Widget to allow to show only certain row, which match a selected filter-value. The column-name is given as <b>name</b>

View File

@ -113,7 +113,8 @@
);
switch ($cell['type'])
{
case 'nextmatch-sortheader':
case 'nextmatch-sortheader': // Option: default sort: ASC(default) or DESC
$extension_data['default_sort'] = preg_match('/^(ASC|DESC)$/i',$cell['size']) ? strtoupper($cell['size']) : 'ASC';
$cell['type'] = 'button';
$cell['onchange'] = True;
if (!$cell['help'])
@ -135,7 +136,7 @@
}
return True;
case 'nextmatch-filterheader':
case 'nextmatch-filterheader': // Option: as for selectbox: [extra-label(default ALL)[,#lines(default 1)]]
$cell['type'] = 'select';
if (!$cell['size'])
{
@ -149,7 +150,7 @@
$extension_data['old_value'] = $value = $nm_global['col_filter'][$this->last_part($name)];
return True;
case 'nextmatch-accountfilter':
case 'nextmatch-accountfilter': // Option: as for selectbox: [extra-label(default ALL)[,#lines(default 1)]]
$cell['type'] = 'select-account';
$cell['name'] .= '[account]';
if (!$cell['size'])
@ -305,14 +306,15 @@
if ($value_in)
{
$nm_global['order'] = $this->last_part($name);
$nm_global['default_sort'] = $extension_data['default_sort'];
}
return False; // dont report value back, as it's in the wrong location (rows)
case 'select-account': // used by nextmatch-accountfilter
case 'nextmatch-filterheader':
if ($value_in != $extension_data['old_value'])
if ($value_in != $extension_data['old_value'] && !(!$value_in && !$extension_data['old_value']))
{
//echo "<p>setting nm_global[filter][".$this->last_part($name)."]=$value_in</p>\n";
//echo "<p>setting nm_global[filter][".$this->last_part($name)."]='$value_in' (was '$extension_data[old_value]')</p>\n";
$nm_global['filter'][$this->last_part($name)] = $value_in;
}
return False; // dont report value back, as it's in the wrong location (rows)
@ -381,7 +383,15 @@
elseif ($nm_global['order'])
{
$value['order'] = $nm_global['order'];
$value['sort'] = $old_value['order'] == $nm_global['order'] && $old_value['sort']!='DESC'?'DESC':'ASC';
if ($old_value['order'] != $value['order'])
{
$value['sort'] = $nm_global['default_sort'];
}
else
{
$value['sort'] = $old_value['sort'] != 'DESC' ? 'DESC' : 'ASC';
}
//echo "<p>old_value=$old_value[order]/$old_value[sort] ==> $value[order]/$value[sort]</p>\n";
$loop = True;
}
elseif ($nm_global['filter'])