projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Letter: "alle" E-Mail-Adressen per Anhaken als Empfänger
[kivitendo-erp.git]
/
scripts
/
generate_client_js_actions.pl
diff --git
a/scripts/generate_client_js_actions.pl
b/scripts/generate_client_js_actions.pl
index
d2219a1
..
f7f9a16
100755
(executable)
--- a/
scripts/generate_client_js_actions.pl
+++ b/
scripts/generate_client_js_actions.pl
@@
-4,10
+4,11
@@
use strict;
use warnings;
use File::Slurp;
use warnings;
use File::Slurp;
+use FindBin;
use List::Util qw(first max);
use Template;
use List::Util qw(first max);
use Template;
-my $rel_dir =
(first { -f "${_}/SL/ClientJS.pm" } qw(. ..)) || die "ClientJS.pm not found"
;
+my $rel_dir =
$FindBin::Bin . '/..'
;
my @actions;
foreach (read_file("${rel_dir}/SL/ClientJS.pm")) {
my @actions;
foreach (read_file("${rel_dir}/SL/ClientJS.pm")) {
@@
-15,7
+16,7
@@
foreach (read_file("${rel_dir}/SL/ClientJS.pm")) {
next unless (m/^my \%supported_methods/ .. m/^\);/);
next unless (m/^my \%supported_methods/ .. m/^\);/);
- push @actions, [ 'action', $1, $2, $3 ] if m/^ \s+ '? ([a-zA-Z_:]+) '? \s*=>\s* (\d+) , (?: \s* \# \s+ (.+))? $/x;
+ push @actions, [ 'action', $1, $2, $3 ] if m/^ \s+ '? ([a-zA-Z_:]+) '? \s*=>\s* (
-?
\d+) , (?: \s* \# \s+ (.+))? $/x;
push @actions, [ 'comment', $1, $2 ] if m/^ \s+\# \s+ (.+?) (?: \s* pattern: \s+ (.+))? $/x;
}
push @actions, [ 'comment', $1, $2 ] if m/^ \s+\# \s+ (.+?) (?: \s* pattern: \s+ (.+))? $/x;
}
@@
-33,7
+34,9
@@
foreach my $action (@actions) {
$pattern = $action->[2] eq '<DEFAULT>' ? $default_pattern : $action->[2] if $action->[2];
} else {
$pattern = $action->[2] eq '<DEFAULT>' ? $default_pattern : $action->[2] if $action->[2];
} else {
- my $args = $action->[2] == 1 ? '' : join(', ', map { "action[$_]" } (2..$action->[2]));
+ my $args = $action->[2] == 1 ? ''
+ : $action->[2] < 0 ? 'action.slice(2, action.length)'
+ : join(', ', map { "action[$_]" } (2..$action->[2]));
$output .= sprintf(' %s if (action[0] == \'%s\')%s ',
$first ? ' ' : 'else',
$output .= sprintf(' %s if (action[0] == \'%s\')%s ',
$first ? ' ' : 'else',
@@
-47,6
+50,7
@@
foreach my $action (@actions) {
$call =~ s/<TARGET>/'action[1]'/eg;
$call =~ s/<FUNCTION>/$function/eg;
$call =~ s/<ARGS>/$args/eg;
$call =~ s/<TARGET>/'action[1]'/eg;
$call =~ s/<FUNCTION>/$function/eg;
$call =~ s/<ARGS>/$args/eg;
+ $call =~ s/<ARG(\d+)>/'action[' . ($1 + 1) . ']'/eg;
$output .= $call . ";\n";
$first = 0;
$output .= $call . ";\n";
$first = 0;
@@
-55,6
+59,6
@@
foreach my $action (@actions) {
$output .= sprintf "\n else\%sconsole.log('Unknown action: ' + action[0]);\n", ' ' x (4 + 2 + 6 + 3 + 4 + 2 + $longest + 1);
$output .= sprintf "\n else\%sconsole.log('Unknown action: ' + action[0]);\n", ' ' x (4 + 2 + 6 + 3 + 4 + 2 + $longest + 1);
-my $template = Template->new({
RELATIV
E => 1 });
+my $template = Template->new({
ABSOLUT
E => 1 });
$template->process($rel_dir . '/scripts/generate_client_js_actions.tpl', { actions => $output }, $rel_dir . '/js/client_js.js') || die $template->error(), "\n";
print "js/client_js.js generated automatically.\n";
$template->process($rel_dir . '/scripts/generate_client_js_actions.tpl', { actions => $output }, $rel_dir . '/js/client_js.js') || die $template->error(), "\n";
print "js/client_js.js generated automatically.\n";