From cbf8ed0240f2cf87a37ebaff9aa36844f66d0a49 Mon Sep 17 00:00:00 2001 From: "Martin Helmling martin.helmling@octosoft.eu" Date: Wed, 22 Feb 2017 11:33:40 +0100 Subject: [PATCH] Dateimanagement: Robustere Mandantenkonfigurierung MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Es wurde das BAckend "None" eingeführt, falls kein Backend enabled ist. Fehlermeldung nun in deutsch falls kein Backend vorhanden. Die Hochladbare Dateigröße ist nun in der Mandantenkonfig in Megabytes (default 10Mb) --- SL/File.pm | 5 ++-- bin/mozilla/gl.pl | 2 +- locale/de/all | 5 +++- sql/Pg-upgrade2/filemanagement_feature.sql | 4 +-- t/file/filesystem.t | 4 +-- .../webpages/client_config/_features.html | 24 +++++++++------- templates/webpages/client_config/form.html | 28 +++++++++++++++++++ 7 files changed, 54 insertions(+), 18 deletions(-) diff --git a/SL/File.pm b/SL/File.pm index 28604249e..1ecd7d510 100644 --- a/SL/File.pm +++ b/SL/File.pm @@ -319,13 +319,14 @@ sub _get_backend { my ($self, $backend_name) = @_; my $class = 'SL::File::Backend::' . $backend_name; my $obj = undef; + die $::locale->text('no backend enabled') if $backend_name eq 'None'; eval { eval "require $class"; $obj = $class->new; - die 'backend not enabled' unless $obj->enabled; + die $::locale->text('backend "#1" not enabled',$backend_name) unless $obj->enabled; 1; } or do { - die 'backend class not found'; + die $::locale->text('backend "#1" not found',$backend_name); }; return $obj; } diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index f62b74b1f..f44f3cbf1 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -955,7 +955,7 @@ sub form_header { my ($init) = @_; - $::request->layout->add_javascripts("autocomplete_chart.js", "kivi.GL.js", "kivi.RecordTemplate.js"); + $::request->layout->add_javascripts("autocomplete_chart.js", "kivi.File.js", "kivi.GL.js", "kivi.RecordTemplate.js"); my @old_project_ids = grep { $_ } map{ $::form->{"project_id_$_"} } 1..$::form->{rowcount}; diff --git a/locale/de/all b/locale/de/all index 4c990ced5..b7be55279 100755 --- a/locale/de/all +++ b/locale/de/all @@ -3004,7 +3004,7 @@ $self->{texts} = { 'The login is not unique.' => 'Der Loginname ist nicht eindeutig.', 'The long description is missing.' => 'Der Langtext fehlt.', 'The master templates where not found.' => 'Der Vorlagensatz wurde nicht gefunden.', - 'The maximum of uploadable filesize' => 'Die maximale Dateigröße in Bytes die hochladbar ist', + 'The maximum of uploadable filesize in Megabyte' => 'Die maximale Dateigröße in Megabytes, die hochladbar ist', 'The name and description are not unique.' => 'Name und Beschreibung sind nicht einmalig.', 'The name in row %d has already been used before.' => 'Der Name in Zeile %d wurde vorher bereits benutzt.', 'The name is invalid.' => 'Der Name ist ungültigt.', @@ -3591,6 +3591,8 @@ $self->{texts} = { 'averconsumed_br' => 'Ø mtl.', 'back' => 'zurück', 'back_br' => 'Zurk.', + 'backend "#1" not enabled' => 'Dateimanagement-Subsystem "#1" nicht aktiviert', + 'backend "#1" not found' => 'Dateimanagement-Subsystem "#1" unbekannt', 'balance' => 'Betriebsvermögensvergleich/Bilanzierung', 'bank_collection_payment_list_#1' => 'bankeinzugszahlungsliste_#1', 'bank_transfer_payment_list_#1' => 'ueberweisungszahlungsliste_#1', @@ -3713,6 +3715,7 @@ $self->{texts} = { 'next' => 'vor', 'no' => 'nein', 'no article assigned yet' => 'noch kein Artikel zugewiesen', + 'no backend enabled' => 'Kein Dateimanagement-Subsystem aktiviert', 'no bestbefore' => 'keine Mindesthaltbarkeit', 'no chargenumber' => 'keine Chargennummer', 'no execution for this client' => 'keine Ausführung für diesen Mandanten', diff --git a/sql/Pg-upgrade2/filemanagement_feature.sql b/sql/Pg-upgrade2/filemanagement_feature.sql index 4c8f8ca20..04d30820a 100644 --- a/sql/Pg-upgrade2/filemanagement_feature.sql +++ b/sql/Pg-upgrade2/filemanagement_feature.sql @@ -2,12 +2,12 @@ -- @description: "Zusätzliche Config flags für Filemanagement" -- @depends: release_3_4_1 ALTER TABLE defaults ADD COLUMN doc_delete_printfiles boolean DEFAULT false; -ALTER TABLE defaults ADD COLUMN doc_max_filesize integer DEFAULT 1000000; +ALTER TABLE defaults ADD COLUMN doc_max_filesize integer DEFAULT 10000000; ALTER TABLE defaults ADD COLUMN doc_storage boolean DEFAULT false; ALTER TABLE defaults ADD COLUMN doc_storage_for_documents text default 'Filesystem'; ALTER TABLE defaults ADD COLUMN doc_storage_for_attachments text default 'Filesystem'; ALTER TABLE defaults ADD COLUMN doc_storage_for_images text default 'Filesystem'; ALTER TABLE defaults ADD COLUMN doc_files boolean DEFAULT false; -ALTER TABLE defaults ADD COLUMN doc_files_rootpath text default ''; +ALTER TABLE defaults ADD COLUMN doc_files_rootpath text default './documents'; ALTER TABLE defaults ADD COLUMN doc_webdav boolean DEFAULT false; ALTER TABLE defaults ADD COLUMN doc_database boolean DEFAULT false; diff --git a/t/file/filesystem.t b/t/file/filesystem.t index fd648e84e..6c22e3d4c 100644 --- a/t/file/filesystem.t +++ b/t/file/filesystem.t @@ -85,7 +85,7 @@ eval { $result=$@; }; $result = substr($result,0,14); -print $result."\n"; +#print $result."\n"; ok($result eq "No object type","correct error 'No object type'"); $::form->{object_type} ='sales_order'; @@ -99,7 +99,7 @@ eval { $result=$@; }; $result = substr($result,0,12); -print $result."\n"; +#print $result."\n"; ok($result eq "No file type","correct error 'No file type'"); clear_up(); diff --git a/templates/webpages/client_config/_features.html b/templates/webpages/client_config/_features.html index b38b66e90..44c158f3e 100644 --- a/templates/webpages/client_config/_features.html +++ b/templates/webpages/client_config/_features.html @@ -37,22 +37,25 @@ [% LxERP.t8('Storage Type for generated/imported PDF Documents') %] [% L.select_tag('defaults.doc_storage_for_documents', - [ [ 'Filesystem', LxERP.t8('Files') ],[ 'Webdav', LxERP.t8('WebDAV') ],[ 'ExtDMS', LxERP.t8('ext.DMS') ],[ 'DB', LxERP.t8('Database') ] ], - default = SELF.defaults.doc_storage_for_documents) %] + [ [ 'None', LxERP.t8('None') ],[ 'Filesystem', LxERP.t8('Files') ],[ 'Webdav', LxERP.t8('WebDAV') ],[ 'ExtDMS', LxERP.t8('ext.DMS') ],[ 'DB', LxERP.t8('Database') ] ], + default = SELF.defaults.doc_storage_for_documents, + onchange="return checkavailable_filebackend(this);") %] [% LxERP.t8('Use this storage backend for all generated PDF-Files') %] [% LxERP.t8('Storage Type for Attachments') %] [% L.select_tag('defaults.doc_storage_for_attachments', - [ [ 'Filesystem', LxERP.t8('Files') ],[ 'Webdav', LxERP.t8('WebDAV') ],[ 'ExtDMS', LxERP.t8('ext.DMS') ],[ 'DB', LxERP.t8('Database') ] ], - default = SELF.defaults.doc_storage_for_attachments) %] + [ [ 'None', LxERP.t8('None') ], [ 'Filesystem', LxERP.t8('Files') ],[ 'Webdav', LxERP.t8('WebDAV') ],[ 'ExtDMS', LxERP.t8('ext.DMS') ],[ 'DB', LxERP.t8('Database') ] ], + default = SELF.defaults.doc_storage_for_attachments, + onchange="return checkavailable_filebackend(this);") %] [% LxERP.t8('Use this storage backend for all uploaded attachments') %] [% LxERP.t8('Storage Type for images') %] [% L.select_tag('defaults.doc_storage_for_images', - [ [ 'Filesystem', LxERP.t8('Files') ],[ 'Webdav', LxERP.t8('WebDAV') ],[ 'ExtDMS', LxERP.t8('ext.DMS') ],[ 'DB', LxERP.t8('Database') ] ], - default = SELF.defaults.doc_storage_for_images) %] + [ [ 'None', LxERP.t8('None') ], [ 'Filesystem', LxERP.t8('Files') ],[ 'Webdav', LxERP.t8('WebDAV') ],[ 'ExtDMS', LxERP.t8('ext.DMS') ],[ 'DB', LxERP.t8('Database') ] ], + default = SELF.defaults.doc_storage_for_images, + onchange="return checkavailable_filebackend(this);") %] [% LxERP.t8('Use this storage backend for uploaded images') %] @@ -62,8 +65,9 @@ [% LxERP.t8('max filesize') %] - [% L.input_tag('defaults.doc_max_filesize',SELF.defaults.doc_max_filesize, size=>10) %] - [% LxERP.t8('The maximum of uploadable filesize') %] + [% L.input_tag('doc_max_filesize_MB','', size=10, onchange="verifyMBSize(this);") %] + [% L.hidden_tag('defaults.doc_max_filesize',SELF.defaults.doc_max_filesize) %] MB + [% LxERP.t8('The maximum of uploadable filesize in Megabyte') %] [% LxERP.t8("Storage Backends") %] @@ -73,7 +77,7 @@ [% LxERP.t8('Root path for file storage') %] - [% L.input_tag('defaults.doc_files_rootpath',SELF.defaults.doc_files_rootpath, style=style) %] + [% L.input_tag('defaults.doc_files_rootpath',SELF.defaults.doc_files_rootpath, style=style, onchange="verifyRootPath(this);") %] [% LxERP.t8('This is the root directory for the File storage backend, must be writable for webserver') %] @@ -83,7 +87,7 @@ [% LxERP.t8('Database') %] - [% L.yes_no_tag('defaults.doc_database', SELF.defaults.doc_database) %] + [% L.yes_no_tag('defaults.doc_database', SELF.defaults.doc_database, disabled=1) %] [% LxERP.t8('Use Database Storage backend (not implemented yet!)') %] diff --git a/templates/webpages/client_config/form.html b/templates/webpages/client_config/form.html index 20935eeb4..eb6714c09 100644 --- a/templates/webpages/client_config/form.html +++ b/templates/webpages/client_config/form.html @@ -38,11 +38,39 @@ function enable_template_controls() { $('#new_templates,#new_master_templates').prop('disabled', existing); } +function verifyMBSize(elem) { + var fsize = parseInt($('#doc_max_filesize_MB').val()); + $('#defaults_doc_max_filesize').val(fsize*1000000.0); + $('#doc_max_filesize_MB').val(fsize); +} + +function verifyRootPath(elem) { + if ( elem.value == "" ) { + elem.value="./documents"; + } +} + +function checkavailable_filebackend(elem) { + var selval = elem.value; + if ( selval == 'Webdav' && $("#defaults_doc_webdav").val() == 0 ) { + elem.value = 'Filesystem'; + } else if ( selval == 'ExtDMS' ) { + elem.value = 'Filesystem'; + } if ( selval == 'DB' && $("#defaults_doc_database").val() == 0 ) { + elem.value = 'Filesystem'; + } + if ( elem.value == 'Filesystem' && $("#defaults_doc_files").val() == 0 ) { + elem.value = 'None'; + } + return false; +} + $(function() { warehouse_selected([% SELF.defaults.warehouse_id || -1 %], [% SELF.defaults.bin_id || -1 %], 'bin_id'); warehouse_selected([% SELF.defaults.warehouse_id_ignore_onhand || -1 %], [% SELF.defaults.bin_id_ignore_onhand || -1 %], 'bin_id_ignore_onhand'); enable_template_controls(); + $('#doc_max_filesize_MB').val(parseInt($('#defaults_doc_max_filesize').val())/1000000.0); $('#use_templates_existing,#use_templates_new').change(enable_template_controls); }) --> -- 2.20.1