From 4e070acf473ae9992a3561594cce55123be0a7ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 22 Mar 2016 15:18:51 +0100 Subject: [PATCH] TopQuickSearch: Konfiguration in client_config --- SL/Controller/ClientConfig.pm | 7 ++++- SL/Controller/TopQuickSearch.pm | 29 +++++++++---------- SL/Controller/TopQuickSearch/Base.pm | 2 +- SL/Controller/TopQuickSearch/GLTransaction.pm | 2 +- SL/DB/MetaSetup/Default.pm | 1 + locale/de/all | 4 +++ .../defaults_add_quick_search_modules.sql | 8 +++++ .../webpages/client_config/_features.html | 11 +++++++ templates/webpages/menu/header.html | 2 +- 9 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 sql/Pg-upgrade2/defaults_add_quick_search_modules.sql diff --git a/SL/Controller/ClientConfig.pm b/SL/Controller/ClientConfig.pm index d002f427a..4ce4faa0a 100644 --- a/SL/Controller/ClientConfig.pm +++ b/SL/Controller/ClientConfig.pm @@ -16,11 +16,12 @@ use SL::Helper::Flash; use SL::Locale::String qw(t8); use SL::PriceSource::ALL; use SL::Template; +use SL::Controller::TopQuickSearch; __PACKAGE__->run_before('check_auth'); use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(defaults all_warehouses all_weightunits all_languages all_currencies all_templates all_price_sources h_unit_name + 'scalar --get_set_init' => [ qw(defaults all_warehouses all_weightunits all_languages all_currencies all_templates all_price_sources h_unit_name available_quick_search_modules all_project_statuses all_project_types posting_options payment_options accounting_options inventory_options profit_options balance_startdate_method_options) ], ); @@ -191,6 +192,10 @@ sub init_all_price_sources { [ map { [ $_->name, $_->description ] } @classes ]; } +sub init_available_quick_search_modules { + [ SL::Controller::TopQuickSearch->new->available_modules ]; +} + # # filters # diff --git a/SL/Controller/TopQuickSearch.pm b/SL/Controller/TopQuickSearch.pm index 8c6661e83..b72174928 100644 --- a/SL/Controller/TopQuickSearch.pm +++ b/SL/Controller/TopQuickSearch.pm @@ -57,10 +57,20 @@ sub available_modules { map { $_->new } @available_modules; } +sub enabled_modules { + my %enabled_names = map { + $_ => 1 + } @{ $::instance_conf->get_quick_search_modules }; + + grep { + $enabled_names{$_->name} + } $_[0]->available_modules +} + sub active_modules { grep { $::auth->assert($_->auth, 1) - } $_[0]->available_modules + } $_[0]->enabled_modules } sub init_module { @@ -118,8 +128,8 @@ my $search = SL::Controller::TopQuickSearch->new; This controller provides abstraction for different search plugins, and ensures that all follow a common useability scheme. -Modules should be configurable, but currently are not. Diabling modules can be -done by removing them from available_modules. +Modules should be configurable per user, but currently are not. Disabling +modules can be done by removing them from available_modules or in client_config. =head1 BEHAVIOUR REQUIREMENTS @@ -161,21 +171,10 @@ the user should not see. =head1 INTERFACE -Plugins need to provide: - - - name - - localized description for config - - localized description for textfield - - autocomplete callback - - redirect callback - -the frontend will only generate urls of the forms: - action=TopQuickSearch/autocomplete&module=&term= - action=TopQuickSearch/search&module=&term= +The full interface is described in L =head1 TODO - - filter available searches with auth - toggling with cofiguration doesn't work yet =head1 BUGS diff --git a/SL/Controller/TopQuickSearch/Base.pm b/SL/Controller/TopQuickSearch/Base.pm index 18c3b88e8..6c6061848 100644 --- a/SL/Controller/TopQuickSearch/Base.pm +++ b/SL/Controller/TopQuickSearch/Base.pm @@ -48,7 +48,7 @@ Internal name, must be plain ASCII. =item C -Localized name used in the configuration (NYI) +Localized name used in the configuration. =item C diff --git a/SL/Controller/TopQuickSearch/GLTransaction.pm b/SL/Controller/TopQuickSearch/GLTransaction.pm index 2b4facdec..77854ff4c 100644 --- a/SL/Controller/TopQuickSearch/GLTransaction.pm +++ b/SL/Controller/TopQuickSearch/GLTransaction.pm @@ -12,7 +12,7 @@ use List::Util qw(sum); sub auth { 'general_ledger' } -sub name { 'gl_transction' } +sub name { 'gl_transaction' } sub description_config { t8('GL search') } diff --git a/SL/DB/MetaSetup/Default.pm b/SL/DB/MetaSetup/Default.pm index 619a429ea..96c4b0f1f 100644 --- a/SL/DB/MetaSetup/Default.pm +++ b/SL/DB/MetaSetup/Default.pm @@ -84,6 +84,7 @@ __PACKAGE__->meta->columns( project_type_id => { type => 'integer' }, purchase_delivery_order_show_delete => { type => 'boolean', default => 'true' }, purchase_order_show_delete => { type => 'boolean', default => 'true' }, + quick_search_modules => { type => 'array' }, reqdate_interval => { type => 'integer', default => '0' }, require_transaction_description_ps => { type => 'boolean', default => 'false', not_null => 1 }, requirement_spec_section_order_part_id => { type => 'integer' }, diff --git a/locale/de/all b/locale/de/all index bad475fb7..de2c7f2e3 100755 --- a/locale/de/all +++ b/locale/de/all @@ -221,6 +221,7 @@ $self->{texts} = { 'All clients' => 'Alle Mandanten', 'All general ledger entries' => 'Alle Hauptbucheinträge', 'All groups' => 'Alle Gruppen', + 'All modules' => 'Alle Module', 'All of the exports you have selected were already closed.' => 'Alle von Ihnen ausgewählten Exporte sind bereits abgeschlossen.', 'All partsgroups' => 'Alle Warengruppen', 'All price sources' => 'Alle Preisquellen', @@ -1114,6 +1115,8 @@ $self->{texts} = { 'Employees' => 'Benutzer', 'Empty selection for warehouse will not be added, even if the old bin is still visible (use back and forth to edit again).' => 'Leere Lager-Auswahl wird ignoriert, selbst wenn noch ein Lagerplatz ausgewählt ist. Alle Daten können durch zurück und vorwärts korrigiert werden.', 'Empty transaction!' => 'Buchung ist leer!', + 'Enabled Quick Searched' => 'Aktivierte Schnellsuchen', + 'Enabled modules' => 'Aktivierte Module', 'End date' => 'Enddatum', 'Enter a description for this new draft.' => 'Geben Sie eine Beschreibung für diesen Entwurf ein.', 'Enter longdescription' => 'Langtext eingeben', @@ -2184,6 +2187,7 @@ $self->{texts} = { 'Quarterly' => 'quartalsweise', 'Query Type' => 'Art der Abfrage', 'Queue' => 'Warteschlange', + 'Quick Searches that will be shown in the header in this client' => 'Schnellsuchen, die in der Kopfzeile in diesem Mandanten gezeigt werden sollen', 'Quotation' => 'Angebot', 'Quotation Date' => 'Angebotsdatum', 'Quotation Date missing!' => 'Angebotsdatum fehlt!', diff --git a/sql/Pg-upgrade2/defaults_add_quick_search_modules.sql b/sql/Pg-upgrade2/defaults_add_quick_search_modules.sql new file mode 100644 index 000000000..737792567 --- /dev/null +++ b/sql/Pg-upgrade2/defaults_add_quick_search_modules.sql @@ -0,0 +1,8 @@ +-- @tag: defaults_add_quick_search_modules +-- @description: Mandantenkonfiguration für Schnellsuche +-- @depends: release_3_4_0 +-- @encoding: utf-8 + +ALTER TABLE defaults ADD COLUMN quick_search_modules TEXT[]; + +UPDATE defaults SET quick_search_modules = '{"contact","gl_transaction"}'; diff --git a/templates/webpages/client_config/_features.html b/templates/webpages/client_config/_features.html index 0a2eb02e1..0a06d43e0 100644 --- a/templates/webpages/client_config/_features.html +++ b/templates/webpages/client_config/_features.html @@ -174,5 +174,16 @@ [% L.yes_no_tag('defaults.show_longdescription_select_item', SELF.defaults.show_longdescription_select_item) %] + [% LxERP.t8("Enabled Quick Searched") %] + + [% 'Quick Searches that will be shown in the header in this client' | $T8 %] + +
+ [% L.select_tag("defaults.quick_search_modules[]", SELF.available_quick_search_modules, value_key="name", title_key="description_config", id="defaults_quick_searches", multiple=1, default=SELF.defaults.quick_search_modules) %] + [% L.multiselect2side("defaults_quick_searches", labelsx=LxERP.t8("All modules"), labeldx=LxERP.t8("Enabled modules")) %] +
+ + + diff --git a/templates/webpages/menu/header.html b/templates/webpages/menu/header.html index 8e7367182..f566af72b 100644 --- a/templates/webpages/menu/header.html +++ b/templates/webpages/menu/header.html @@ -6,7 +6,7 @@ [[% 'New window/tab' | $T8 %]] [[% 'Print' | $T8 %]] -[%- FOREACH search = quick_search.active_modules %] +[%- FOREACH search = quick_search.enabled_modules %] [] [%- END %] -- 2.20.1