NAME
Solstice::SortService - Create the Solstice::Buttons necessary for managing a sortable table.
SYNOPSIS
#takes three arguments - a preference service in which to store the data, and
#the key names for the field and direction preference
my $sort_service = Solstice::SortService->new($pref_service, "sort_field_preference_name", "sort_dir_preference_name");
#flush may be necessary if used in a controller, as many controller functions run twice per click
$sort_service->flush();
#add the fields to sort on.
$sort_service->addSortField({
label => $lang_service->getString('tool_header'),
button_name => 'tool_sort_button',
sort_func => sub {
lc $a->getApplicationName() cmp lc $b->getApplicationName() ||
lc $a->getImplementationName() cmp lc $b->getImplementationName()
},
action => 'sort',
default => 1,
});
$sort_service->addSortField({
label => $lang_service->getString('tool_project'),
button_name => 'project_sort_button',
action => 'sort',
sort_func => sub {
lc $a->getImplementationName() cmp lc $b->getImplementationName()
},
rev_sort_func => sub {
#some optional reverse sort function - otherwise the order
#given by sort_func is just reversed
},
});
#make use of the sort method
my $iterator = $list->iterator();
$iterator->sort($sort_service->getSortMethod());
#in the view, create the service (with the same params!) and put the auto-created buttons into
#the param hash
my $sort_service = Solstice::SortService->new($pref_service, "sort_field_preference_name", "sort_dir_preference_name");
return {
%params,
$self->processChildViews(),
$sort_service->getSortLinks(),
}
DESCRIPTION
Export
None by default.
Methods
- new()
- sortDateTime($datetime_a, $datetime_b)
-
Generic datetime object sorting method. Handles the case where either datetime object is undefined.
AUTHOR
Catalyst Research & Development Group, <catalyst@u.washington.edu>
VERSION
$Revision: 191 $
COPYRIGHT
Copyright 1998-2007 Office of Learning Technologies, University of Washington
Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.