I just noticed that the make names aren't being sorted in ascending order in the make select field of the make/model selector block. The code in the _vehicle_ymm_build_make_menu function looks correct:

  $return = $query->extend('TableSort')
      ->orderBy('make_name', 'ASC')
      ->execute();

but the options produced on my form aren't sorted in ascending order (see attached image). What might be wrong? The list of models is sorted correctly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ignigena’s picture

Can you do me a favor and paste the source code of the select menu that is generated for the Make dropdown?

Also, navigate to /ymm/0/1970/make on your site and paste the JSON output here.

Both will help me figure out what may be causing the sorting issue on your end.

Thanks!

sah62’s picture

Can do. One thing I just noted: I'm seeing the problem in Chrome 26.0.1410.64 m and IE 9.0.8112.16421. It works with Firefox 20.0.1, all on Windows 7.

Navigating to "http://mysite.com/ymm/0/1970/make" produces a 404. Here's the HTML source:

<div class="region region-sidebar-first sidebar"><div class="region-inner clearfix"><section id="block-vehicle-ymm-selector" class="block block-vehicle-ymm odd first block-count-7 block-region-sidebar-first block-selector" ><div class="block-inner clearfix">  
      <h2 class="block-title">Search for Parts!</h2>
  
  <div class="block-content content"><form action="/" method="post" id="vehicle-ymm-selector-form" accept-charset="UTF-8"><div><fieldset class="form-wrapper" id="edit-ymm"><div class="fieldset-wrapper"><select class="vehicle-ymm-year form-select" id="edit-year" name="year"><option value="0">Year</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1955">1955</option><option value="1956">1956</option><option value="1957">1957</option></select><select class="vehicle-ymm-make form-select" id="edit-make-id" name="make_id"><option value="0" selected="selected">Make</option><option value="8">AMC</option><option value="4">Buick</option><option value="2">Chevrolet</option><option value="3">de Tomaso</option><option value="9">Dodge</option><option value="1">Ford</option><option value="7">Ford Truck</option><option value="13">Lincoln</option><option value="6">Mercury</option><option value="5">Oldsmobile</option><option value="10">Plymouth</option><option value="11">Pontiac</option><option value="14">Shelby</option></select><select class="vehicle-ymm-model form-select" id="edit-model" name="model"><option value="0">Model</option></select><select class="vehicle-ymm-trim form-select" id="edit-model-id" name="model_id"><option value="0" selected="selected">Trim</option></select><input class="vehicle-ymm-limit-selector" type="hidden" name="limit_selector" value="1" />
</div></fieldset>
<input type="submit" id="edit-submit" name="op" value="Go" class="form-submit" /><input type="hidden" name="form_build_id" value="form-_NOH898H2EgbNStiuRS10q2wgv0dnroyeIr6HSowhpQ" />
<input type="hidden" name="form_token" value="fVpigYSFBo2uHj4vXG8uuahNHNry8mnVT8wltrbYWxo" />
<input type="hidden" name="form_id" value="vehicle_ymm_selector_form" />
</div></form></div>
Ignigena’s picture

Category: support » bug

Seems like a jQuery issue. I am able to replicate this on my end. While the Make menu will sort alphabetically on first load, once you select a year and the list is refreshed it seems to go in order of the Make ID (which is also the option value)

Reclassifying as a bug report and looking into a resolution.

Ignigena’s picture

The issue seems to be that the jQuery each() function returns it's data asynchronously which results in unpredictable sorting of the drop down menu. I've added a very simple sorting function to each menu to ensure that the menus get sorted alphabetically after they are populated.

I've attached a patch below, apply it and see if it solves the problem on your installation. I was able to update my installation and noticed it seemed to fix the problem.

Ignigena’s picture

Status: Active » Needs review
sah62’s picture

FileSize
18.5 KB

The patch looks good. It identified an interesting issue, though: case sensitivity. See the attached image. Is it possible to do case-insensitive sort? It might be possible by normalizing the values to either all upper or all lower case prior to making the comparisons.

Ignigena’s picture

Ahh yes. Try the attached patch as it adds a conversion to lowercase before it compares the values to be sorted.

sah62’s picture

Status: Needs review » Reviewed & tested by the community

Looks great!

Ignigena’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Committed!

sah62’s picture

Status: Closed (fixed) » Needs work
FileSize
41.86 KB

Sorry, I need to reopen this. While the select fields in the block form work fine, I just found an issue when trying to tag a node with a year, make, and model value. After selecting a year I try to select a make. I see multiple values for several of the makes as shown in the attached picture. Here's the HTML source:

<tbody>
 <tr class="draggable odd"><td class="field-multiple-drag"></td><td><select class="vehicle-ymm-year form-select" id="edit-field-applications-und-0-year" name="field_applications[und][0][year]"><option value="0">Year</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1955">1955</option><option value="1956">1956</option><option value="1957">1957</option></select><select class="vehicle-ymm-make form-select" id="edit-field-applications-und-0-make-id" name="field_applications[und][0][make_id]"><option value="0">Make</option><option value="8">AMC</option><option value="4">Buick</option><option value="2">Chevrolet</option><option value="12">Chrysler</option><option value="3">de Tomaso</option><option value="9">Dodge</option><option value="1">Ford</option><option value="7">Ford Truck</option><option value="13">Lincoln</option><option value="6">Mercury</option><option value="5">Oldsmobile</option><option value="10">Plymouth</option><option value="11">Pontiac</option><option value="14">Shelby</option></select><select class="vehicle-ymm-model form-select" id="edit-field-applications-und-0-model" name="field_applications[und][0][model]"><option value="0">Model</option></select><select class="vehicle-ymm-trim form-select" id="edit-field-applications-und-0-model-id" name="field_applications[und][0][model_id]"><option value="0">Trim</option></select><input class="vehicle-ymm-limit-selector" type="hidden" name="field_applications[und][0][limit_selector]" value="0" />
<a class="vehicle_ymm_remove_button button">Remove</a></td><td class="delta-order"><div class="form-item form-type-select form-item-field-applications-und-0--weight">
  <label class="element-invisible" for="edit-field-applications-und-0-weight">Weight for row 1 </label>
 <select class="field_applications-delta-order form-select" id="edit-field-applications-und-0-weight" name="field_applications[und][0][_weight]"><option value="0" selected="selected">0</option></select>
</div>
</td> </tr>
</tbody>

The issue disappears if I revert to the unpatched versions of the javascript files.

Ignigena’s picture

I am unable to duplicate this on my installation or on a fresh Drupal installation. I'm sure you've already tried clearing your caches. What theme are you using for your admin pages? Anything else I can get to try and replicate on my end would be very helpful!

sah62’s picture

I'm using the Sky theme. I did clear all caches after patching the files, but I'll do it again and try to do some more debugging later tonight.

sah62’s picture

More info, but no breakthroughs: I just removed and re-installed the module and cleared all caches. The select block works fine. I'm seeing this problem when I try to add values to a field associated with one of my Ubercart products. Every time I select a new model year it adds the make values associated with that year to the available make select options without clearing out the old values first. I'm getting duplicates because this process is cumulative.

Ignigena’s picture

Good information to help me replicate. Is this a multi-value field? Or, do you have more than one field on the form?

sah62’s picture

FileSize
75.45 KB

This is a "Vehicle reference" field using the "Year/Make/Model dropdown" widget (see attached image). There are other Ubercart-specific fields on the form. I've seen the problem when the node has only one of these vehicle reference fields and when it has multiple vehicle reference fields.

Ignigena’s picture

Got it. Let me try and debug this more this evening. I am using Drupal Commerce rather than Ubercart so my environment is different. I'm going to try and match your environment as close as possible and see if I can get it to replicate.

Thanks for all the info!

sah62’s picture

Another potential consideration: I have both the year/make/model selector block and the product field visible on the same page when editing the product. If I configure the block so that it's displayed only on the front page the problem appears to go away.

sah62’s picture

Have you been able to reproduce this behavior? It might be doable as described in #17.

Ignigena’s picture

I have been able to reproduce this behaviour. Sorry for the delay in getting a patch out. I'll try to get some work done on this and get it committed. It's been a bit crazy around these parts lately!

jppuffnstuff’s picture

Status: Needs work » Needs review
FileSize
6.62 KB

Try this patch.

I noticed that the jQuery sort function you were using was appending the sorted Make results to the HTML select element after each AJAX request, rather than sorting and replacing it. So I just sorted the string before it was turned into HTML.

sah62’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, the patch seems to do the trick. Everything looks fine.

Ignigena’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
6.71 KB

Rerolled the patch due to a few minor coding standards issues specifically indentation and trailing white space. Please review https://drupal.org/coding-standards#indenting

The attached patch should apply cleanly and maintain Drupal coding standards.

sah62’s picture

Seems to work fine for me.

tonkatuph’s picture

FileSize
5.8 KB

Hi,
First, thank you for the great module.
Second, my years in the make/model selector are not arranged in order descending.

I've tried applying the patches with no luck.

Any idea? I'm using the latest dev version on Drupal 7

Ignigena’s picture

Status: Needs review » Fixed

Committed to Dev.

tonkatuph’s picture

I just downloaded the recent dev and it's still not showing in order. Under the issues it says the problem was fixed...any ideas?

Regards

Ignigena’s picture

tonkatuph: are you seeing the sorting order incorrect in only the Years drop down or in multiple drop downs? Can you reproduce in all browsers or does it appear to be specific to Firefox (only asking because I see the issue you filed about Firefox and I haven't had a chance to dig into it)

Let me know!

tonkatuph’s picture

I'm seeing the sort order incorrectly in the "Years" dropdown only in the YMM selector for chrome, firefox, ie8 and safari. For some reason it's just not in descending order. It's out of order :D

The issue with firefox seems to be when you select a year in YMM, the make jumps to the last option and doesn't set the focus to remain on make. You have re-select make, then select the actual make name before you select a model to work properly.

And The illegal choice error still seems to pop up in the latest dev when using the MMY selector, but it's and easy fix.

Thanks!

sah62’s picture

FileSize
24.2 KB

Here's what I see in Chrome, Firefox and IE 9 with the latest dev release. Only the last few year values on the list (the earliest years) are out of order.

tonkatuph’s picture

That's funny, I have the same thing. I cleared my database and re-added a bunch of info and it seems to work but the last couple of values are off too.

Regards

Ignigena’s picture

Very strange. I'll look into the sorting thing.

tonkatuph: sounds like Javascript is potentially throwing an error that is causing those other JS elements to break. Take a look at your Console window and see if these errors relate to the Vehicle module. If so, please start a new issue since this is new.

Thanks!

Ignigena’s picture

Status: Fixed » Needs work
tonkatuph’s picture

Okay, that was a good idea. Found out that the chosen module was screwing things up with the YMM selector and other drop downs.

tonkatuph’s picture

Seems like it's reordering the years based on the models. Changing the reorder to ASC seems to make the order work, but of course we need DESC.

tonkatuph’s picture

There seems to be a conflict with the chosen module. Any idea how to fix this?

I can't select the model in the YMM selector. I'm able to select year and make but not model.

Thanks.

Kwaailappies’s picture

Hi

We are building a car parts and modification site, how do I get the search block to check for drupal commerce products, it is not a content type so our products doesn't appear in the search,

Also is it possivble to have the manufacturers "brands" link from images, we have all the images we want to load but want to link the images to the brand name.

Thanks in advance! hope we can use this module!

T

Ignigena’s picture

Hi kwaailappies, I'd love to help with your questions but can you please post this in a separate issue under the "Support Request" category? This will help ensure this thread stays on topic.

Thanks!

tonkatuph’s picture

Issue summary: View changes

Any progress on getting the order corrected?

asaifan’s picture

Long time and it didn't fix till now !!! i hope someone fixxed this issue