Skip to content

Commit

Permalink
Add sort UI to admin/reports ushahidi#220
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmackay committed Oct 3, 2012
1 parent 214079a commit f6263db
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
13 changes: 13 additions & 0 deletions application/controllers/admin/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ public function index($page = 1)
{
$keyword_raw = "";
}

$order_field = 'date'; $sort = 'DESC';
if (isset($_GET['order']))
{
$order_field = htmlentities($_GET['order']);
}
if (isset($_GET['sort']))
{
$sort = (strtoupper($_GET['sort']) == 'ASC') ? 'ASC' : 'DESC';
}

// Check, has the form been submitted?
$form_error = FALSE;
Expand Down Expand Up @@ -283,6 +293,9 @@ public function index($page = 1)

// Status Tab
$this->template->content->status = $status;
$this->template->content->order_field = $order_field;
$this->template->content->sort = $sort;


// Javascript Header
$this->template->js = new View('admin/reports/reports_js');
Expand Down
25 changes: 24 additions & 1 deletion application/views/admin/reports/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@
</li>
<?php endif; ?>
</ul>

<div class="sort_by">
<?php print form::open(NULL, array('method' => 'get', 'class' => 'sort-form')); ?>
<?php echo Kohana::lang('ui_main.sort_by'); ?>
<?php echo form::dropdown('order', array(
'date' => Kohana::lang('ui_admin.report_date'),
'id' => Kohana::lang('ui_main.id'),
'datemodify' => Kohana::lang('ui_admin.date_modified'),
'dateadd' => Kohana::lang('ui_admin.date_added'),
'title' => Kohana::lang('ui_admin.report_title'),
), $order_field);
echo form::input(array(
'type' => 'hidden',
'name' => 'sort',
'value' => $sort,
'class' => 'sort-field'
));
echo form::hidden('status', $status);
echo form::close(); ?>
</div>
</div>
</div>
<?php if ($form_error): ?>
Expand Down Expand Up @@ -94,7 +114,10 @@
</th>
<th class="col-2"><?php echo Kohana::lang('ui_main.report_details');?></th>
<th class="col-3"><?php echo Kohana::lang('ui_main.date');?></th>
<th class="col-4"><?php echo Kohana::lang('ui_main.actions');?></th>
<th class="col-4">
<a class="sort sort-<?php echo $sort; ?>" title="<?php echo ($sort == 'ASC') ? Kohana::lang('ui_main.ascending') : Kohana::lang('ui_main.descending'); ?>" href="#"></a>
<?php echo Kohana::lang('ui_main.actions');?>
</th>
</tr>
</thead>
<tfoot>
Expand Down
14 changes: 14 additions & 0 deletions application/views/admin/reports/reports_js.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ function showLog(id)
$('#' + id).toggle(400);
}

$(function () {
$("select#order").change(function() { $('.sort-form').submit(); });
$(".sort-ASC").click(function() {
$('.sort-field').val('DESC');
$('.sort-form').submit();
return false;
});
$(".sort-DESC").click(function() {
$('.sort-field').val('ASC');
$('.sort-form').submit();
return false;
});
});

20 changes: 20 additions & 0 deletions media/css/admin/all.css
Original file line number Diff line number Diff line change
Expand Up @@ -2540,3 +2540,23 @@ div.dp-popup td.disabled {
height: 30px;
display: inline-block;
}

.sort_by {
float: right;
margin: 0;
padding: 9px 10px 0;
}

.sort {
width: 18px;
height: 9px;
display: block;
float: right;
margin: 4px 0 0 6px;
}
.sort-ASC {
background: url(../../img/admin/drag.gif) 0 0 no-repeat;
}
.sort-DESC {
background: url(../../img/admin/drag.gif) 0 -8px no-repeat;
}

0 comments on commit f6263db

Please sign in to comment.