Initial commit
This commit is contained in:
commit
f4bfb0e367
71 changed files with 10399 additions and 0 deletions
124
Dam/Components/Actions/Download.pm
Normal file
124
Dam/Components/Actions/Download.pm
Normal file
|
@ -0,0 +1,124 @@
|
|||
=head1 NAME
|
||||
|
||||
Dam::Components::Actions::Download
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $download_mode = Component__Get(ACTION_DOWNLOAD, ['csv']);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Action to execute a download.
|
||||
|
||||
=head1 ARGUMENTS
|
||||
|
||||
(
|
||||
TYPE => 'Download',
|
||||
ID => 'csv' (default),
|
||||
LABEL => 'CSV' (default),
|
||||
TOOLTIP => 'Download the current report in CSV format' (default),
|
||||
ICON => 'download-alt' (default),
|
||||
MODE_EXT => 'CSV' (default),
|
||||
FILE_EXT => 'csv' (default)
|
||||
)
|
||||
|
||||
=cut
|
||||
|
||||
package Dam::Components::Actions::Download;
|
||||
|
||||
use Exporter qw(import);
|
||||
our @EXPORT = qw(
|
||||
Action__html Action__js
|
||||
);
|
||||
|
||||
use Dam::Util;
|
||||
use Dam::DamLogic;
|
||||
|
||||
|
||||
|
||||
my $ID_DEFAULT = 'csv';
|
||||
|
||||
|
||||
|
||||
sub __arguments {
|
||||
my $arg_ref = shift;
|
||||
|
||||
check_arguments($arg_ref,
|
||||
TYPE => [ ARG_REQUIRED ],
|
||||
ID => [ ARG_DEFAULT, $ID_DEFAULT ],
|
||||
LABEL => [ ARG_DEFAULT, 'CSV' ],
|
||||
TOOLTIP => [ ARG_DEFAULT, _t('Download current report in CSV format') ],
|
||||
ICON => [ ARG_DEFAULT, 'download-alt' ],
|
||||
MODE_EXT => [ ARG_DEFAULT, 'CSV' ],
|
||||
FILE_EXT => [ ARG_DEFAULT, 'csv' ]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub Action__html {
|
||||
my ($self, $arg_ref, $info_ref) = @_;
|
||||
|
||||
__arguments($arg_ref);
|
||||
|
||||
return is_report() ? strval('
|
||||
<button type="button" class="btn btn-info input-lg" id="', $$arg_ref{ID}, '" data-toggle="tooltip" title="', $$arg_ref{TOOLTIP}, '"><span class="glyphicon glyphicon-', $$arg_ref{ICON}, '"></span> ', $$arg_ref{LABEL}, '</button>
|
||||
') : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub Action__js {
|
||||
my ($self, $arg_ref) = @_;
|
||||
|
||||
__arguments($arg_ref);
|
||||
|
||||
return is_report() ? strval('
|
||||
$("#', $$arg_ref{ID}, '").click(function(){
|
||||
$("#xt").val(3);
|
||||
$("#dm").val("', $$arg_ref{MODE_EXT}, ',', $$arg_ref{FILE_EXT}, '");
|
||||
$("#submit").click();
|
||||
});
|
||||
') : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub Get {
|
||||
my ($download_mode, $filename_extension) = split(',', cgiapp_param('dm'));
|
||||
return is_download() ? $download_mode : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Manuel Cillero C<< <manuel@cillero.es> >>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2004-2020 Manuel Cillero. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
=cut
|
Reference in a new issue