I'm very frustrated with the system_modules form. Even though everyone tries with sledge hammers to make you use Drush, I like to use the UI way to enable, disable and uninstall my modules.

There are a few things which are not very nice.

  • Even with like 10 fieldsets and a lot of modules, all fieldsets stay open all the time. At least I think, there should be something like: "If more than 5 fieldsets, return them collapsed".
  • There are no buttons, to collapse or expand all fieldsets
  • Strg-F for Browsersearch is useless because the dependencies of modules are all over the place, so if the module you would like to jump to quickly via Browsersearch is in 20 different rows, you win nothing
  • The dependencies have no "jump to anchor" behavior which indeed would help to jump to the module I would like to enable or so

That said, I hacked together something neat - a quicksearch.

You can see what it does here: http://screencast.com/t/jXbKIasn

The patch is around 30 lines of code.

  // system.module line 916ff
  $form['quicksearch'] = array(
    '#type'          => 'textfield',
    '#title'         => t('Module Quicksearch'),
    '#default_value' => '',
    '#size'          => 60,
    '#maxlength'     => 128,
    '#required'      => FALSE,
    '#weight'        => -1000
  );

  drupal_add_js(drupal_get_path('module', 'system') . '/system.quicksearch.js');

  return $form;
}
// system.quicksearch.js
(function($) {
    $(document).ready(function() {
        $('.page-admin-modules #edit-quicksearch').keyup(function() {
            var quicksearch = $(this).val().toLowerCase();

            // Reset of all rows and fieldsets
            $('#system-modules fieldset table tbody tr').show();
            $('#system-modules fieldset').removeClass('collapsed');

            // Hiding all rows that do not match
            if (quicksearch.length >= 1) {
                $('#system-modules fieldset table tbody tr td:nth-child(2)').each(function(index) {
                    var module = $(this).text().toLowerCase();
                    if (module.indexOf(quicksearch) == -1) {
                        $(this).parent().hide();
                    }
                });
            }

            // Closing all fieldsets that do not match
            $('#system-modules fieldset').filter(function() {
                var rows   = $('table tbody tr', this).size();
                var closed = $('table tbody tr:hidden', this).size();
                return rows == closed;
            }).addClass('collapsed');
        });
    });
})(jQuery);

There are a few things to note: It works well, but does not deal with hitting enter in that textfield. I never did, but that might an issue. As an goodie you could recolor the background after sorting so that its still even/odd colored. I did not added that. The use of the external file was just for the purpuse of not messing around in other javascript files.

I'm not sure if it is better to use the javascript Drupal object here. I did it pure jQuery for demonstration.

As far as I can tell, I did not harmed the rest of the form, so everything should still function as expected.

I really would like to see clickable dependencies, like jump to behavior, but that was not my focus here.

Comments

nod_’s picture

I haven't tested the patch/module yet. I'd just like to point out two unrelated points. There is some inefficient jQuery code here and there is a — very long — issue about this #538904: D8UX: Redesign Modules Page :)

amateescu’s picture

Title: Usebility Enhancement of the Modules page. » Usability enhancements for the Modules page
Status: Active » Closed (duplicate)

Yeah, it's probably better to help out in #538904: D8UX: Redesign Modules Page.

ro-no-lo’s picture

The jQuery reacts very fast on my machine. Not sure how slow that is on a mobile device. Were do you see the poor performance anyway? I like techtalk and also leanring new tricks.

There is another thread (I found after you pointed out that there is a huge one, where liek 150 lines of javascript is used).

klonos’s picture

There was this issue before: #396478: Searchable modules page which spawned the Instant filter project. It inserts a search field in various drupal admin UI forms. Did you try that?

klonos’s picture

...oh, and of course there's the more heavy-duty, modules-page-centric Module Filter project too ;)

ro-no-lo’s picture

StatusFileSize
new1.66 KB

I extracted my approach inte an simple modul. I guess I'll go with the instant filter module in the future. The module filter module bloats it to much. I still wonder how that problem is not fixed in like 2,5 years. Well nice that there are solutions in the meantime.

For everyone interested, this is my filter for D7 in like 40 lines of code. Works well imho. No core hacks.

ro-no-lo’s picture

Issue summary: View changes

added note.