Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #51 from kivitendo/2022-redesign-merge-3
2022 redesign merge 3
  • Loading branch information
jbueren committed Nov 3, 2022
2 parents 2f2de4f + c245a50 commit 06f142f
Show file tree
Hide file tree
Showing 547 changed files with 65,205 additions and 70 deletions.
2 changes: 1 addition & 1 deletion SL/Controller/Admin.pm
Expand Up @@ -526,7 +526,7 @@ sub init_all_groups { SL::DB::Manager::AuthGroup ->get_all_sorted
sub init_all_printers { SL::DB::Manager::Printer ->get_all_sorted }
sub init_all_dateformats { [ qw(mm/dd/yy dd/mm/yy dd.mm.yy yyyy-mm-dd) ] }
sub init_all_numberformats { [ '1,000.00', '1000.00', '1.000,00', '1000,00', "1'000.00" ] }
sub init_all_stylesheets { [ qw(lx-office-erp.css Mobile.css kivitendo.css) ] }
sub init_all_stylesheets { [ qw(lx-office-erp.css Mobile.css kivitendo.css design40.css) ] }
sub init_all_dbsources { [ sort User->dbsources($::form) ] }
sub init_all_used_dbsources { { map { (join(':', $_->dbhost || 'localhost', $_->dbport || 5432, $_->dbname) => $_->name) } @{ $_[0]->all_clients } } }
sub init_all_accounting_methods { [ { id => 'accrual', name => t8('Accrual accounting') }, { id => 'cash', name => t8('Cash accounting') } ] }
Expand Down
7 changes: 1 addition & 6 deletions SL/Controller/ClientConfig.pm
Expand Up @@ -19,14 +19,13 @@ use SL::PriceSource::ALL;
use SL::Template;
use SL::Controller::TopQuickSearch;
use SL::DB::Helper::AccountingPeriod qw(get_balance_startdate_method_options);
use SL::Helper::ShippedQty;
use SL::VATIDNr;
use SL::ZUGFeRD;

__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 available_quick_search_modules available_shipped_qty_item_identity_fields
'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 zugferd_settings
posting_options payment_options accounting_options inventory_options profit_options balance_startdate_method_options
displayable_name_specs_by_module) ],
Expand Down Expand Up @@ -210,10 +209,6 @@ sub init_available_quick_search_modules {
[ SL::Controller::TopQuickSearch->new->available_modules ];
}

sub init_available_shipped_qty_item_identity_fields {
[ SL::Helper::ShippedQty->new->available_item_identity_fields ];
}

sub init_displayable_name_specs_by_module {
+{
'SL::DB::Customer' => {
Expand Down
7 changes: 6 additions & 1 deletion SL/Controller/Order.pm
Expand Up @@ -1766,7 +1766,12 @@ sub build_tax_rows {

my $rows_as_html;
foreach my $tax (sort { $a->{tax}->rate cmp $b->{tax}->rate } @{ $self->{taxes} }) {
$rows_as_html .= $self->p->render('order/tabs/_tax_row', TAX => $tax, TAXINCLUDED => $self->order->taxincluded);
$rows_as_html .= $self->p->render(
'order/tabs/_tax_row',
TAX => $tax,
TAXINCLUDED => $self->order->taxincluded,
QUOTATION => $self->order->quotation
);
}
return $rows_as_html;
}
Expand Down
10 changes: 6 additions & 4 deletions SL/Form.pm
Expand Up @@ -468,7 +468,7 @@ sub header {

# output
print $self->create_http_response(content_type => 'text/html', charset => 'UTF-8');
print $doctypes{$params{doctype} || 'transitional'}, $/;
print $doctypes{$params{doctype} || $::request->layout->html_dialect}, $/;
print <<EOT;
<html>
<head>
Expand Down Expand Up @@ -555,11 +555,13 @@ sub _prepare_html_template {
}
$language = "de" unless ($language);

my $webpages_path = $::request->layout->webpages_path;
my $webpages_path = $::request->layout->webpages_path;
my $webpages_fallback = $::request->layout->webpages_fallback_path;

if (-f "${webpages_path}/${file}.html") {
$file = "${webpages_path}/${file}.html";
my @templates = first { -f } map { "${_}/${file}.html" } grep { defined } $webpages_path, $webpages_fallback;

if (@templates) {
$file = $templates[0];
} elsif (ref $file eq 'SCALAR') {
# file is a scalarref, use inline mode
} else {
Expand Down
2 changes: 1 addition & 1 deletion SL/Layout/Admin.pm
@@ -1,7 +1,7 @@
package SL::Layout::Admin;

use strict;
use parent qw(SL::Layout::None);
use parent qw(SL::Layout::Design40Switch);

use SL::Menu;
use SL::Layout::None;
Expand Down
2 changes: 1 addition & 1 deletion SL/Layout/AdminLogin.pm
@@ -1,7 +1,7 @@
package SL::Layout::AdminLogin;

use strict;
use parent qw(SL::Layout::None);
use parent qw(SL::Layout::Design40Switch);

sub start_content {
"<div id='admin' class='admin'>\n";
Expand Down
65 changes: 64 additions & 1 deletion SL/Layout/Base.pm
Expand Up @@ -44,6 +44,17 @@ sub webpages_path {
"templates/webpages";
}

sub webpages_fallback_path {
}

sub html_dialect {
'transitional'
}

sub allow_stylesheet_fallback {
1
}

sub get {
$_[0]->sub_layouts;
return grep { $_ } ($_[0]->sub_layouts_by_name->{$_[1]});
Expand Down Expand Up @@ -139,7 +150,7 @@ sub _find_stylesheet {
my ($self, $stylesheet, $css_path) = @_;

return "$css_path/$stylesheet" if -f "$css_path/$stylesheet";
return "css/$stylesheet" if -f "css/$stylesheet";
return "css/$stylesheet" if -f "css/$stylesheet" && $self->allow_stylesheet_fallback;
return $stylesheet if -f $stylesheet;
return $stylesheet if $stylesheet =~ /^http/; # external
}
Expand Down Expand Up @@ -330,6 +341,58 @@ stylesheets. Javascripts are resolved relative to the C<js/> basedir.
Setting directly with C<stylesheets> and C<javascripts> is eprecated.
=head1 BEHAVIOUR SWITCHES FOR SUB LAYOUTS
Certain methods have been added to adjust behaviour in sub layouts. Most of these are single case uses.
=over 4
=item * sublayouts_by_name
Contains a map that holds named sublayouts. If a sublayout needs to targeted
directly, the compositing layout needs to add it here. Initially introduced for
the ActionPlan.
=item * webpages_path
Overrides the default webpages path "templates/webpages". Used for mobile and design40 styles.
Note that this does not have fallback behaviour by default. It is intended for
stylesheets where the templates are so incompatible that a complete fork of the
templates dir is sensible.
=item * webpages_fallback_path
Allows partial template sets to fallback to other paths in case a template
wasn't found. Intended to be used in conjunction with L</webpages_path>.
Note: in case a template can't be found at all, generic/error.html will be
rendered, and the fallback doesn't work in this case.
=item * allow_stylesheet_fallback
Defaults to true. The default behaviour is that stylesheets not found in the
stylesheet path of the user will fallback to files found in css/. This is
usually desirable for shared stuff like common.css, which contains behaviour
styling. If a stylesheet comes from a separate generator, this can be used to
turn falllback off. Files can still be included with the complete path though.
A request for "common.css" would not find "css/common.css", but a request for
"css/common.css" would be found.
Also see the next section L</GORY DETAILS ABOUT JAVASCRIPT AND STYLESHEET OVERLOADING>
=item * html_dialect
Default 'transitional'. Controls the html dialect that the header will
generate. Used in combination with template overriding for html5.
See also L<SL::Form/header>
=back
=head1 GORY DETAILS ABOUT JAVASCRIPT AND STYLESHEET OVERLOADING
The original code used to store one stylesheet in C<< $form->{stylesheet} >> and
Expand Down
2 changes: 1 addition & 1 deletion SL/Layout/Classic.pm
@@ -1,7 +1,7 @@
package SL::Layout::Classic;

use strict;
use parent qw(SL::Layout::Base);
use parent qw(SL::Layout::Design40Switch);

use SL::Layout::Top;
use SL::Layout::MenuLeft;
Expand Down
55 changes: 55 additions & 0 deletions SL/Layout/Design40Switch.pm
@@ -0,0 +1,55 @@
package SL::Layout::Design40Switch;

use strict;
use parent qw(SL::Layout::Base);

sub is_design40 {
$::myconfig{stylesheet} =~ /design40/i;
}

sub webpages_path {
is_design40() ? "templates/design40_webpages" : $_[0]->SUPER::webpages_path
}

sub webpages_fallback_path {
is_design40() ? "templates/webpages" : $_[0]->SUPER::webpages_fallback_path
}

sub allow_stylesheet_fallback {
!is_design40();
}

sub html_dialect {
is_design40() ? 'html5' : $_[0]->SUPER::html_dialect
}

1;

__END__
=encoding utf-8
=head1 NAME
SL::Layout::Design40Switch - Layout switch for Design 4.0
=head1 SYNOPSIS
Detects whether the user selected the Design4.0 stylesheet, and if so,
overrides some implementation details.
=head1 DESCRIPTION
Once activated, it will set the templates to use C<templates/design40_webpages> instead.
It will also disable css fallback, so that common.css etc won't interfere.
=head1 BUGS
None yet. :)
=head1 AUTHOR
Sven Schöling $<lt>s.schoeling@googlemail.comE<gt>
=cut
2 changes: 1 addition & 1 deletion SL/Layout/Javascript.pm
@@ -1,7 +1,7 @@
package SL::Layout::Javascript;

use strict;
use parent qw(SL::Layout::Base);
use parent qw(SL::Layout::Design40Switch);

use SL::Layout::None;
use SL::Layout::DHTMLMenu;
Expand Down
2 changes: 1 addition & 1 deletion SL/Layout/Login.pm
@@ -1,7 +1,7 @@
package SL::Layout::Login;

use strict;
use parent qw(SL::Layout::None);
use parent qw(SL::Layout::Design40Switch);

sub start_content {
"<div id='login' class='login'>\n";
Expand Down
2 changes: 1 addition & 1 deletion SL/Layout/V3.pm
@@ -1,7 +1,7 @@
package SL::Layout::V3;

use strict;
use parent qw(SL::Layout::Base);
use parent qw(SL::Layout::Design40Switch);

use SL::Layout::None;
use SL::Layout::Top;
Expand Down
17 changes: 12 additions & 5 deletions SL/Presenter.pm
Expand Up @@ -6,6 +6,7 @@ use parent qw(Rose::Object);

use Carp;
use Template;
use List::Util qw(first);

use SL::Presenter::EscapedText qw(is_escaped);

Expand Down Expand Up @@ -45,11 +46,14 @@ sub render {
# Look for the file given by $template if $template is not a reference.
my $source;
if (!ref $template) {
my $webpages_path = $::request->layout->webpages_path;
my $webpages_path = $::request->layout->webpages_path;
my $webpages_fallback = $::request->layout->webpages_fallback_path;

my $ext = $options->{type} eq 'text' ? 'txt' : $options->{type};
$source = "${webpages_path}/${template}.${ext}";
croak "Template file ${source} not found" unless -f $source;

$source = first { -f } map { "${_}/${template}.${ext}" } grep { defined } $webpages_path, $webpages_fallback;

croak "Template file ${template} not found" unless $source;

} elsif (ref($template) eq 'SCALAR') {
# Normal scalar reference: hand over to Template
Expand Down Expand Up @@ -98,7 +102,10 @@ sub render {
sub get_template {
my ($self) = @_;

my $webpages_path = $::request->layout->webpages_path;
my $webpages_path = $::request->layout->webpages_path;
my $webpages_fallback = $::request->layout->webpages_fallback_path;

my $include_path = join ':', grep defined, $webpages_path, $webpages_fallback;

# Make locales.pl parse generic/exception.html, too:
# $::form->parse_html_template("generic/exception")
Expand All @@ -108,7 +115,7 @@ sub get_template {
ABSOLUTE => 1,
CACHE_SIZE => 0,
PLUGIN_BASE => 'SL::Template::Plugin',
INCLUDE_PATH => ".:$webpages_path",
INCLUDE_PATH => ".:$include_path",
COMPILE_EXT => '.tcc',
COMPILE_DIR => $::lx_office_conf{paths}->{userspath} . '/templates-cache',
ERROR => "${webpages_path}/generic/exception.html",
Expand Down
9 changes: 4 additions & 5 deletions SL/Presenter/ItemsList.pm
Expand Up @@ -13,11 +13,10 @@ sub items_list {
my ($items, %params) = @_;

my $text_mode = !!delete $params{as_text};
my $output = SL::Presenter->get->render('presenter/items_list/items_list',
{type => $text_mode ? 'text' : 'html'},
%params,
items => $items);
$output =~ s{\n$}{}x if $text_mode;

my $output = SL::Presenter->get->render('presenter/items_list/items_list', { type => $text_mode ? 'text' : 'html' }, %params, items => $items);

$output =~ s{\n$}{}x if $text_mode;

return $output;
}
8 changes: 7 additions & 1 deletion SL/Presenter/Tag.pm
Expand Up @@ -302,10 +302,16 @@ sub button_tag {

_set_id_attribute(\%attributes, $attributes{name}) if $attributes{name};
$attributes{type} ||= 'button';
$attributes{tag} ||= 'input';

$onclick = 'if (!confirm("'. _J(delete($attributes{confirm})) .'")) return false; ' . $onclick if $attributes{confirm};

html_tag('input', undef, %attributes, value => $value, (onclick => $onclick)x!!$onclick);
if ( $attributes{tag} == 'input' ) {
html_tag('input', undef, %attributes, value => $value, (onclick => $onclick)x!!$onclick)
}
elsif ( $attributes{tag} == 'button' ) {
html_tag('button', undef, %attributes, value => $value, (onclick => $onclick)x!!$onclick);
}
}

sub submit_tag {
Expand Down
4 changes: 2 additions & 2 deletions SL/Template/Plugin/L.pm
Expand Up @@ -228,9 +228,9 @@ sub areainput_tag {

return $self->textarea_tag($name, $value, %attributes, rows => $rows, cols => $cols) if $rows > 1;

return '<span>'
return '<span class="area-input">'
. $self->input_tag($name, $value, %attributes, size => $cols)
. "<img src=\"image/edit-entry.png\" onclick=\"kivi.switch_areainput_to_textarea('${id}')\" style=\"margin-left: 2px;\">"
. "<span class=\"switch-to-textarea\" onclick=\"kivi.switch_areainput_to_textarea('${id}')\"></span>"
. '</span>';
}

Expand Down
2 changes: 1 addition & 1 deletion SL/User.pm
Expand Up @@ -541,7 +541,7 @@ sub get_default_myconfig {
css_path => 'css', # Needed for menunew, see SL::Layout::Base::get_stylesheet_for_user
dateformat => $defaults->dateformat('dd.mm.yy'),
numberformat => $defaults->numberformat('1.000,00'),
stylesheet => $defaults->stylesheet('kivitendo.css'),
stylesheet => $defaults->stylesheet($::lx_office_conf{system}{stylesheet}),
timeformat => $defaults->timeformat('hh:mm'),
%user_config,
);
Expand Down
2 changes: 1 addition & 1 deletion bin/mozilla/am.pl
Expand Up @@ -636,7 +636,7 @@ sub config {
}

$form->{STYLESHEETS} = [];
foreach my $item (qw(lx-office-erp.css kivitendo.css)) {
foreach my $item (qw(lx-office-erp.css kivitendo.css design40.css)) {
push @{ $form->{STYLESHEETS} }, {
'name' => $item,
'value' => $item,
Expand Down
2 changes: 1 addition & 1 deletion bin/mozilla/do.pl
Expand Up @@ -494,6 +494,7 @@ sub form_header {
]);

$::form->{ALL_PROJECTS} = SL::DB::Manager::Project->get_all_sorted(query => \@conditions);
$::form->{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();
$::form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{employee_id}, deleted => 0 ] ]);
$::form->{ALL_SALESMEN} = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{salesman_id}, deleted => 0 ] ]);
$::form->{ALL_SHIPTO} = SL::DB::Manager::Shipto->get_all_sorted(query => [
Expand Down Expand Up @@ -553,7 +554,6 @@ sub form_footer {
my $form = $main::form;

$form->{PRINT_OPTIONS} = setup_sales_purchase_print_options();
$form->{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();

my $shipto_cvars = SL::DB::Shipto->new->cvars_by_config;
foreach my $var (@{ $shipto_cvars }) {
Expand Down

0 comments on commit 06f142f

Please sign in to comment.