sub action_ajax_autocomplete {
my ($self, %params) = @_;
- my $value = $::form->{column} || 'description';
-
# if someone types something, and hits enter, assume he entered the full name.
# if something matches, treat that as sole match
# unfortunately get_models can't do more than one per package atm, so we d it
my @hashes = map {
+{
- value => $_->$value,
- label => $_->long_description,
+ value => $_->displayable_name,
+ label => $_->displayable_name,
id => $_->id,
partnumber => $_->partnumber,
description => $_->description,
controller => $self,
sorted => {
_default => {
- by => 'description',
+ by => 'partnumber',
dir => 1,
},
partnumber => t8('Partnumber'),
my $ret =
$self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) .
- join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(column type unit convertible_unit)) .
- $self->input_tag("", (ref $value && $value->can('description')) ? $value->description : '', id => "${id}_name", %params);
+ join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(type unit convertible_unit)) .
+ $self->input_tag("", ref $value ? $value->displayable_name : '', id => "${id}_name", %params);
$::request->layout->add_javascripts('autocomplete_part.js');
$::request->presenter->need_reinit_widgets($id);
var $type = $('#' + real_id + '_type');
var $unit = $('#' + real_id + '_unit');
var $convertible_unit = $('#' + real_id + '_convertible_unit');
- var $column = $('#' + real_id + '_column');
var state = STATES.PICKED;
var last_real = $real.val();
var last_dummy = $dummy.val();
'filter.obsolete': 0,
'filter.unit_obj.convertible_to': $convertible_unit && $convertible_unit.val() ? $convertible_unit.val() : '',
no_paginate: $('#no_paginate').prop('checked') ? 1 : 0,
- column: $column && $column.val() ? $column.val() : '',
current: $real.val(),
};
function set_item (item) {
if (item.id) {
$real.val(item.id);
- // autocomplete ui has name, ajax items have description
- $dummy.val(item.name ? item.name : item.description);
+ // autocomplete ui has name, use the value for ajax items, which contains displayable_name
+ $dummy.val(item.name ? item.name : item.value);
} else {
$real.val('');
$dummy.val('');
type: function() { return $type },
unit: function() { return $unit },
convertible_unit: function() { return $convertible_unit },
- column: function() { return $column },
update_results: update_results,
result_timer: result_timer,
set_item: set_item,