From 46e1177c8b8a14cfef2765e1f7b784116bddfc17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 26 Mar 2014 16:51:18 +0100 Subject: [PATCH] PartPicker: Diverse Verbesserungen MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - Dialog vergrössert - Unterstützung für Listenansicht - Bild hoch Bild runter im paginaten gemappt - Focus nach Klickauswahl wieder auf das ursprüngliche Feld gesetzt - Unterscheidung zwischen minimaler Rückmeldung (nur id und name) und fettem json Objekt verbessert. Im letzten Fall wird immer garantiert das komplette Objekt ausgeliefert. --- css/kivitendo/main.css | 30 +++++++++++-- css/lx-office-erp/main.css | 28 ++++++++++-- js/autocomplete_part.js | 43 +++++++++++++++++-- locale/de/all | 1 + .../webpages/part/_part_picker_result.html | 20 +++++---- .../webpages/part/part_picker_search.html | 6 +++ 6 files changed, 108 insertions(+), 20 deletions(-) diff --git a/css/kivitendo/main.css b/css/kivitendo/main.css index 553135998..3b8599383 100644 --- a/css/kivitendo/main.css +++ b/css/kivitendo/main.css @@ -384,6 +384,9 @@ label { .float-left { float: left; } +.float-right { + float: right; +} .block-context { overflow: hidden; @@ -402,22 +405,41 @@ label { } div.part_picker_part { - float:left; width: 350px; padding: 5px; margin: 5px; - overflow:hidden; border: 1px; border-color: darkgray; border-style: solid; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; - background-color: whitesmoke; + background-color: white; cursor: pointer; } - div.part_picker_part:hover { background-color: #CCCCCC; color: #FE5F14; border-color: gray; } +div.ppp_block { + overflow:hidden; + float:left; + width: 350px; +} +div.ppp_block span.ppp_block_number { + float:left; +} +div.ppp_block span.ppp_block_description { + float:right; + font-weight:bold; +} +div.ppp_line span.ppp_block_description { + margin-left:1em; + font-weight:bold; +} +div.ppp_line span.ppp_block_sellprice { + display:none; +} +span.toggle_selected { + font-weight: bold; +} diff --git a/css/lx-office-erp/main.css b/css/lx-office-erp/main.css index 95cfe0db7..f42c8724f 100644 --- a/css/lx-office-erp/main.css +++ b/css/lx-office-erp/main.css @@ -436,6 +436,9 @@ label { .float-left { float: left; } +.float-right { + float: right; +} .block-context { overflow: hidden; @@ -454,10 +457,8 @@ label { } div.part_picker_part { - float:left; width: 350px; padding: 5px; margin: 5px; - overflow:hidden; border: 1px; border-color: darkgray; border-style: solid; @@ -467,8 +468,29 @@ div.part_picker_part { background-color: whitesmoke; cursor: pointer; } - div.part_picker_part:hover { background-color: lightgray; border-color: gray; } +div.ppp_block { + overflow:hidden; + float:left; + width: 350px; +} +div.ppp_block span.ppp_block_number { + float:left; +} +div.ppp_block span.ppp_block_description { + float:right; + font-weight:bold; +} +div.ppp_line span.ppp_block_description { + margin-left:1em; + font-weight:bold; +} +div.ppp_line span.ppp_block_sellprice { + display:none; +} +span.toggle_selected { + font-weight: bold; +} diff --git a/js/autocomplete_part.js b/js/autocomplete_part.js index 158f8bd37..62c1bf4bf 100644 --- a/js/autocomplete_part.js +++ b/js/autocomplete_part.js @@ -8,10 +8,16 @@ namespace('kivi', function(k){ ESCAPE: 27, ENTER: 13, TAB: 9, + LEFT: 37, + RIGHT: 39, + PAGE_UP: 33, + PAGE_DOWN: 34, }; var o = $.extend({ limit: 20, delay: 50, + fat_set_item: 0, // use this option to get a fat item json with all + // relevant data instead of the guaranteed id + name }, options); var STATES = { UNIQUE: 1, @@ -35,7 +41,11 @@ namespace('kivi', function(k){ real_id: real_id, }, ajax_data($dummy.val())), id: 'part_selection', - dialog: { title: k.t8('Part picker') } + dialog: { + title: k.t8('Part picker'), + width: 800, + height: 800, + } }); window.clearTimeout(timer); return true; @@ -46,6 +56,7 @@ namespace('kivi', function(k){ 'filter.all:substr::ilike': term, '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(), }; @@ -71,7 +82,19 @@ namespace('kivi', function(k){ state = STATES.PICKED; last_real = $real.val(); last_dummy = $dummy.val(); - $real.trigger('change').trigger('set_item:PartPicker', item); + $real.trigger('change'); + + if (o.fat_set_item) { + $.ajax({ + url: 'controller.pl?action=Part/show.json', + data: { id: item.id }, + success: function(rsp) { + $real.trigger('set_item:PartPicker', rsp); + }, + }); + } else { + $real.trigger('set_item:PartPicker', item); + } } function make_defined_state () { @@ -94,6 +117,16 @@ namespace('kivi', function(k){ }; function result_timer (event) { + if (!$('no_paginate').prop('checked')) { + if (event.keyCode == KEY.PAGE_UP) { + $('#part_picker_result a.paginate-prev').click(); + return; + } + if (event.keyCode == KEY.PAGE_DOWN) { + $('#part_picker_result a.paginate-next').click(); + return; + } + } window.clearTimeout(timer); timer = window.setTimeout(update_results, 100); } @@ -175,7 +208,7 @@ namespace('kivi', function(k){ var picker = $('
'); $dummy.after(pcont); pcont.append(picker); - picker.addClass('icon16 CRM--Schnellsuche').click(open_dialog); + picker.addClass('icon16 crm--search').click(open_dialog); var pp = { real: function() { return $real }, @@ -192,10 +225,12 @@ namespace('kivi', function(k){ $('div.part_picker_part').each(function(){ $(this).click(function(){ set_item({ - name: $(this).children('input.part_picker_description').val(), id: $(this).children('input.part_picker_id').val(), + name: $(this).children('input.part_picker_description').val(), + unit: $(this).children('input.part_picker_unit').val(), }); close_popup(); + $dummy.focus(); return true; }); }); diff --git a/locale/de/all b/locale/de/all index e1361b2e9..3629e7f07 100755 --- a/locale/de/all +++ b/locale/de/all @@ -180,6 +180,7 @@ $self->{texts} = { 'Aktion' => 'Aktion', 'All' => 'Alle', 'All Accounts' => 'Alle Konten', + 'All as list' => 'Alle als Liste', 'All changes in that file have been reverted.' => 'Alle Änderungen in dieser Datei wurden rückgängig gemacht.', 'All clients' => 'Alle Mandanten', 'All general ledger entries' => 'Alle Hauptbucheinträge', diff --git a/templates/webpages/part/_part_picker_result.html b/templates/webpages/part/_part_picker_result.html index eba16dcd8..5d9486b82 100644 --- a/templates/webpages/part/_part_picker_result.html +++ b/templates/webpages/part/_part_picker_result.html @@ -5,22 +5,24 @@ [%# L.dump(SELF.parts) %] -[% FOREACH part = SELF.parts %] - [% PROCESS part_block %] -[% END %] - -[%- BLOCK part_block %] -
+[% BLOCK part_block %] +
- [% part.partnumber | html %] - [% part.description | html %] + + [% part.partnumber | html %] + [% part.description | html %]
- [% 'Sellprice' | $T8 %]: [% part.sellprice_as_number | html %] + [% 'Sellprice' | $T8 %]: [% part.sellprice_as_number | html %]
[%- END %] + +[% FOREACH part = SELF.parts %] + [% PROCESS part_block %] +[% END %] +
[% L.paginate_controls(target='#part_picker_result', selector='#part_picker_result', models=SELF.models) %] diff --git a/templates/webpages/part/part_picker_search.html b/templates/webpages/part/part_picker_search.html index bf1090bc1..96ddeb26f 100644 --- a/templates/webpages/part/part_picker_search.html +++ b/templates/webpages/part/part_picker_search.html @@ -8,6 +8,10 @@ [% LxERP.t8("Filter") %]: [% L.input_tag('part_picker_filter', SELF.filter.all_substr__ilike, class='part_picker_filter') %] [% L.hidden_tag('part_picker_real_id', FORM.real_id) %] +
+ [% L.checkbox_tag('no_paginate', checked=FORM.no_paginate, id='no_paginate', for_submit=1, label=LxERP.t8('All as list')) %] +
+
@@ -19,4 +23,6 @@ pp.update_results(); }); $('#part_picker_filter').keypress(pp.result_timer); + $('#no_paginate').change(pp.update_results); + -- 2.20.1