Last modified: 2013-10-08 12:30:43 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T33332, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 31332 - Provide a way to set the initial sort for sortable tables
Provide a way to set the initial sort for sortable tables
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
1.20.x
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-03 19:29 UTC by Niklas Laxström
Modified: 2013-10-08 12:30 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Niklas Laxström 2011-10-03 19:29:12 UTC
Currently there is no way to do this. It would be nice to make it possible to do a link to http://translatewiki.net/w/i.php?title=Special%3ALanguageStats&x=D&code=qqq where it is sorted by translation coverage by default.
Comment 1 Krinkle 2011-10-12 02:31:22 UTC
When permalinks are wanted we usually let the table be built with the TablePager class, which provides server-side sortability for (single or multi-page) tables. It uses query parameters in the URL to trigger which column to sort and in which direction to sort it.

In JavaScript in general, and especially in jquery.tablesorter this would be kinda akward to implement. The problem starts at identifying which table is meant (since there can be multiple table.sortable elements on an article). Then how to identify which column ? Refer by number ?

Currently for the on-page state an incrementing number is used to differentiate between different tables etc. however these are only to be used within a state, not in URLs to new instances/loads of the article as the numbers are likely not the same (there could be an additional table, or tables re-ordered, merged, moved etc. there is no reliable ID.


Taking that the given example is a table outputted by a MediaWiki (PHP) extension, and not wikitext. Using TablePager (or a variation on it that allows GET parameters to handle the sorting) should be do-able.

Alternatively you could implement a few lines of JavaScript as part of the Translate-extension listening to a value in location.hash when the page is loaded and trigger a sort. Again, I suggest to do this inside the special page or extension instead of in jquery.tablesorter as jquery.tablesorter is primarily meant for articles and needs to support multiple tables per-page.

Something with $(document).ready, window.location.hash and $(find table) using $.fn.tablesorter or $.fn.click or $.fn.attr to somehow force an initial sort.

--
Moving from component ResourceLoader to JavaScript (related to the jquery.tablesorter module)
Comment 2 Niklas Laxström 2011-10-12 10:57:26 UTC
TablePager would be a significant detour how I generate the table currently, and I don't need most of the stuff it does, like paging.

Can't we just refer to the table with id/class?
Comment 3 skomorokh 2013-02-26 13:33:30 UTC
It would be really nice to have a better way to do this. Conscientiously entering each row in alphabetical order is a bit more of an editing task. And the process to sort things afterwards seems to be rather more work than would be ideal: 

http://meta.wikimedia.org/wiki/Help:Sorting#Default_order

Seems like this could save a lot of editors a lot of time they could instead devote to content.
Comment 4 Niklas Laxström 2013-06-16 21:05:13 UTC
FYI I implemented a custom solution for my special pages: http://translatewiki.net/w/i.php?title=Special:LanguageStats&suppresscomplete=1#sortable:2=desc

I'm withdrawing this request since there doesn't seem to be interest for generic solution.
Comment 5 Jason Skomorowski 2013-06-21 19:57:19 UTC
I asked Niklas about the implementation out of curiosity and got a reply:

"The code is at:

https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FTranslate.git/6881f09ee2e0e9ad22a404c9c07088e7afaddd4d/resources%2Fjs%2Fext.translate.special.languagestats.js#L122

Feel free to add that to the bug."

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links