Revision dc824520
Von Kivitendo Admin vor fast 10 Jahren hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
20 | 20 |
sub action_ajax_autocomplete { |
21 | 21 |
my ($self, %params) = @_; |
22 | 22 |
|
23 |
my $value = $::form->{column} || 'description'; |
|
24 |
|
|
25 | 23 |
# if someone types something, and hits enter, assume he entered the full name. |
26 | 24 |
# if something matches, treat that as sole match |
27 | 25 |
# unfortunately get_models can't do more than one per package atm, so we d it |
... | ... | |
45 | 43 |
|
46 | 44 |
my @hashes = map { |
47 | 45 |
+{ |
48 |
value => $_->$value,
|
|
49 |
label => $_->long_description,
|
|
46 |
value => $_->displayable_name,
|
|
47 |
label => $_->displayable_name,
|
|
50 | 48 |
id => $_->id, |
51 | 49 |
partnumber => $_->partnumber, |
52 | 50 |
description => $_->description, |
... | ... | |
106 | 104 |
controller => $self, |
107 | 105 |
sorted => { |
108 | 106 |
_default => { |
109 |
by => 'description',
|
|
107 |
by => 'partnumber',
|
|
110 | 108 |
dir => 1, |
111 | 109 |
}, |
112 | 110 |
partnumber => t8('Partnumber'), |
SL/Presenter/Part.pm | ||
---|---|---|
37 | 37 |
|
38 | 38 |
my $ret = |
39 | 39 |
$self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) . |
40 |
join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(column type unit convertible_unit)) .
|
|
41 |
$self->input_tag("", (ref $value && $value->can('description')) ? $value->description : '', id => "${id}_name", %params);
|
|
40 |
join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(type unit convertible_unit)) . |
|
41 |
$self->input_tag("", ref $value ? $value->displayable_name : '', id => "${id}_name", %params);
|
|
42 | 42 |
|
43 | 43 |
$::request->layout->add_javascripts('autocomplete_part.js'); |
44 | 44 |
$::request->presenter->need_reinit_widgets($id); |
js/autocomplete_part.js | ||
---|---|---|
32 | 32 |
var $type = $('#' + real_id + '_type'); |
33 | 33 |
var $unit = $('#' + real_id + '_unit'); |
34 | 34 |
var $convertible_unit = $('#' + real_id + '_convertible_unit'); |
35 |
var $column = $('#' + real_id + '_column'); |
|
36 | 35 |
var state = STATES.PICKED; |
37 | 36 |
var last_real = $real.val(); |
38 | 37 |
var last_dummy = $dummy.val(); |
... | ... | |
61 | 60 |
'filter.obsolete': 0, |
62 | 61 |
'filter.unit_obj.convertible_to': $convertible_unit && $convertible_unit.val() ? $convertible_unit.val() : '', |
63 | 62 |
no_paginate: $('#no_paginate').prop('checked') ? 1 : 0, |
64 |
column: $column && $column.val() ? $column.val() : '', |
|
65 | 63 |
current: $real.val(), |
66 | 64 |
}; |
67 | 65 |
|
... | ... | |
77 | 75 |
function set_item (item) { |
78 | 76 |
if (item.id) { |
79 | 77 |
$real.val(item.id); |
80 |
// autocomplete ui has name, ajax items have description
|
|
81 |
$dummy.val(item.name ? item.name : item.description);
|
|
78 |
// autocomplete ui has name, use the value for ajax items, which contains displayable_name
|
|
79 |
$dummy.val(item.name ? item.name : item.value);
|
|
82 | 80 |
} else { |
83 | 81 |
$real.val(''); |
84 | 82 |
$dummy.val(''); |
... | ... | |
233 | 231 |
type: function() { return $type }, |
234 | 232 |
unit: function() { return $unit }, |
235 | 233 |
convertible_unit: function() { return $convertible_unit }, |
236 |
column: function() { return $column }, |
|
237 | 234 |
update_results: update_results, |
238 | 235 |
result_timer: result_timer, |
239 | 236 |
set_item: set_item, |
Auch abrufbar als: Unified diff
Partpicker - displayable_name eingeführt und column entfernt
Der Partpicker zeigt jetzt im Autocomplete und bei ausgewählten Artikeln
die Artikelnummer und die Artikelbeschreibung an.
Das Feature column im Partpicker wurde entfernt. Ursprünglich war die
Idee, unterschiedliche Datenbankfelder (als Alternative zu description)
anzeigen zu können, jetzt wird aber einfach durchgängig displayable_name
verwendet.