From: G. Richardson Date: Wed, 21 Jan 2015 10:37:14 +0000 (+0100) Subject: Partpicker - displayable_name eingeführt und column entfernt X-Git-Tag: release-3.2.0beta~58 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=dc824520b4024bb73b4522a8dad9aae179b29540;p=kivitendo-erp.git 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. --- diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index e1bbcd9a7..bd5fe6a30 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -20,8 +20,6 @@ __PACKAGE__->run_before(sub { $::auth->assert('part_service_assembly_edit') }, 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 @@ -45,8 +43,8 @@ sub action_ajax_autocomplete { my @hashes = map { +{ - value => $_->$value, - label => $_->long_description, + value => $_->displayable_name, + label => $_->displayable_name, id => $_->id, partnumber => $_->partnumber, description => $_->description, @@ -106,7 +104,7 @@ sub init_models { controller => $self, sorted => { _default => { - by => 'description', + by => 'partnumber', dir => 1, }, partnumber => t8('Partnumber'), diff --git a/SL/Presenter/Part.pm b/SL/Presenter/Part.pm index 57eb1cf98..3088eaa31 100644 --- a/SL/Presenter/Part.pm +++ b/SL/Presenter/Part.pm @@ -37,8 +37,8 @@ sub part_picker { 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); diff --git a/js/autocomplete_part.js b/js/autocomplete_part.js index de8f6e535..9d3c0ae0a 100644 --- a/js/autocomplete_part.js +++ b/js/autocomplete_part.js @@ -32,7 +32,6 @@ namespace('kivi', function(k){ 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(); @@ -61,7 +60,6 @@ namespace('kivi', function(k){ '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(), }; @@ -77,8 +75,8 @@ namespace('kivi', function(k){ 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(''); @@ -233,7 +231,6 @@ namespace('kivi', function(k){ 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,