Bug 5766 - Add configuration for excluding articles from jQuery table sorter
Summary: Add configuration for excluding articles from jQuery table sorter
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Owen Leonard
QA Contact: Bugs List
URL:
Keywords:
Depends on:
Blocks: 7019 10716
  Show dependency treegraph
 
Reported: 2011-02-16 15:04 UTC by Owen Leonard
Modified: 2014-12-07 20:02 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 5766 - Add configuration for excluding articles from DataTables sorting (4.53 KB, patch)
2013-07-03 16:41 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 5766 - Add configuration for excluding articles from DataTables sorting (4.54 KB, patch)
2013-07-06 09:48 UTC, Chris Cormack
Details | Diff | Splinter Review
[PASSED QA] Bug 5766 - Add configuration for excluding articles from DataTables sorting (4.73 KB, patch)
2013-07-08 05:59 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2011-02-16 15:04:54 UTC
The jQuery table sorter can be configured with a custom parser for excluding articles from sorting. Many pages in Koha already include this, but for English only:

  $.tablesorter.addParser({
    id: 'articles', 
    is: function(s) {return false;  }, 
    format: function(s) { return s.toLowerCase().replace(/^(the|an|a) /,''); }, 
    type: 'text' 
  });

A system preference should be created to contain the pipe-delimited articles (or other text) for exclusion so that speakers of other languages can include their own.
Comment 1 Katrin Fischer 2013-04-13 20:20:15 UTC
Owen, could we do something similar with databales?
Comment 2 Owen Leonard 2013-07-03 16:41:34 UTC Comment hidden (obsolete)
Comment 3 Chris Cormack 2013-07-06 09:48:56 UTC Comment hidden (obsolete)
Comment 4 Katrin Fischer 2013-07-08 05:59:51 UTC
Created attachment 19463 [details] [review]
[PASSED QA] Bug 5766 - Add configuration for excluding articles from DataTables sorting

Client-side table sorting should exclude articles like "a," "an," and
"the" when sorting by title. This patch adds a custom sorting plugin for
use by DataTables and a configuration line to the DataTables string
configuration file which can be translated for any language.

As an example, this patch modifies the patron checkout history template
to use the new sort on the title column.

To test, apply the patch and clear your browser cache to ensure the
revised JavaScript file is loaded. Sort the table by title. Titles
should be sorted regardless of the presences of "a," "an", or "the" at
the beginning of the title.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and is a good improvement.
I have added German articles to the list for testing purposes
and it worked nicely.
Comment 5 Katrin Fischer 2013-07-08 06:00:09 UTC
After giving this some more thought it would be nice if this
could be in the configuration. Being able to translate the string
and influence sorting this way is a good start, but maybe not flexible
enough. For libraries with records in multiple languages they will
want to have a longer list they can adjust and not only a translation
for one language.
Comment 6 Galen Charlton 2013-07-08 15:43:47 UTC
Pushed to master.  Thanks, Owen!

However, I agree with Katrin that the translation subsystem isn't necessarily the best place to configure this, for a couple reasons.  First, the language of the catalog interface does not necessarily reflect all of the languages that may be present in the bib data, and I can see a translator not getting the point of translating a list of articles in Pootle.

I would lean towards either a system preference or even a separate table that contains a list of articles (which would be useful in other contexts, e.g., a bib editor plugin that sets the non-filing indicator automatically).

However, since such configuration hooks can readily be put in later, I've decided to push the patch as is.
Comment 7 Tomás Cohen Arazi 2013-08-12 17:03:26 UTC
This patch has been pushed to 3.12.x, will be in 3.12.4.

Thanks Owen!