From 65e51d8ee11d5f8110ccf9d1d46f6c282464576c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Tue, 26 Jan 2021 12:29:31 +0100 Subject: [PATCH] =?utf8?q?PartPicker:=20Option=20f=C3=BCr=20Mehrfachauswah?= =?utf8?q?l=20als=20default=20merken?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Damit lässt sich die Option via js ändern, um z.B. einen Dialog mit Mehrfachauswahl über einen Knopf zu öffnen, während die Funktion der Lupe bei der Einfachauswahl bleibt (oder andersherum). --- SL/Presenter/Part.pm | 16 ++++++++++++---- js/kivi.Part.js | 2 ++ templates/webpages/part/test_page.html | 14 +++++++++----- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/SL/Presenter/Part.pm b/SL/Presenter/Part.pm index bc5ee8ade..40c172b2f 100644 --- a/SL/Presenter/Part.pm +++ b/SL/Presenter/Part.pm @@ -245,6 +245,17 @@ If C<%params> contains C or C even parts will be used for autocompletion which partnumber is a vendor partnumber (makemodel) or a customer partnumber. +If C<%params> contains C an alternative popup will be opened, +allowing multiple items to be selected. Note however that this requires +an additional callback C to work. +Also note that you can set C to 0 (or not set C) on +creation of the picker, but can open the alternative multi select popup +with js like this: +C<$("#pp_id").data("part_picker").o.multiple=1; $("#pp_id").data("part_picker").open_dialog()'> +where C is the dom id of the part picker. +Or you can even do it the other way round setting C to 1 on creation +and open a single selection popup with js. + Obsolete parts will by default not be displayed for selection. However they are accepted as default values and can persist during updates. As with other selectors though, they are not selectable once overridden. @@ -278,10 +289,7 @@ If more than one element matches the input, the internal state will be set to undefined. After that the action C will be executed, which defaults to -opening a popup dialog for graphical interaction. If C contains -C an alternative popup will be opened, allowing multiple items to be -selected. Note however that this requires an additional callback -C to work. +opening a popup dialog for graphical interaction. =item * C diff --git a/js/kivi.Part.js b/js/kivi.Part.js index ccc775a68..a9c58ba73 100644 --- a/js/kivi.Part.js +++ b/js/kivi.Part.js @@ -323,6 +323,7 @@ namespace('kivi.Part', function(ns) { this.last_dummy = this.$dummy.val(); this.timer = undefined; this.dialog = undefined; + this.multiple_default = this.o.multiple; this.init(); }; @@ -487,6 +488,7 @@ namespace('kivi.Part', function(ns) { }, open_dialog: function() { if (this.o.multiple) { + this.o.multiple = this.multiple_default; this.dialog = new ns.PickerMultiPopup(this); } else { this.dialog = new ns.PickerPopup(this); diff --git a/templates/webpages/part/test_page.html b/templates/webpages/part/test_page.html index 3918ee6d1..e1ef28c11 100644 --- a/templates/webpages/part/test_page.html +++ b/templates/webpages/part/test_page.html @@ -26,7 +26,7 @@ Artikel-Klassifizierung: Eink.,Verk.,Prod.
[% P.part.picker('part_id14', undef, classification_id='1,2,4') %]
Artikel-Status: Aktiv (default)
[% P.part.picker('part_id15') %]
-Artikel-Status: Aktiv< (explizit)
+Artikel-Status: Aktiv (explizit)
[% P.part.picker('part_id16', undef, status="active") %]
Artikel-Status: Ungültig
[% P.part.picker('part_id17', undef, status="obsolete") %]
@@ -41,14 +41,18 @@ Convertible unit 'Std': (only select parts with unit Tag/Std/Min)
With multi select popup
[% P.part.picker('part_id8', undef, multiple=1) %]
With multi select popup (only obsolete)
-[% P.part.picker('part_id8', undef, multiple=1, status='obsolete') %]
+[% P.part.picker('part_id9', undef, multiple=1, status='obsolete') %]

All parts including make models of all vendors:
-[% P.part.picker('part_id', undef, with_makemodel=1) %]
+[% P.part.picker('part_id21', undef, with_makemodel=1) %]
All parts including make models of all vendors with multi select popup:
-[% P.part.picker('part_id', undef, with_makemodel=1, multiple=1) %]
+[% P.part.picker('part_id22', undef, with_makemodel=1, multiple=1) %]
All parts including customer partnumbers of all customers:
-[% P.part.picker('part_id', undef, with_customer_partnumber=1) %]
+[% P.part.picker('part_id23', undef, with_customer_partnumber=1) %]
+
+single select dialog for glass-popup-button; multi select with extra button:
+[% P.part.picker('part_id31', undef, multiple=0) %] +[% L.button_tag('$("#part_id31").data("part_picker").o.multiple=1; $("#part_id31").data("part_picker").open_dialog()', 'Add multiple items') %]

Styling

-- 2.20.1