Initial commit
This commit is contained in:
commit
f4bfb0e367
71 changed files with 10399 additions and 0 deletions
127
Dam/Components/Controls/Check.pm
Normal file
127
Dam/Components/Controls/Check.pm
Normal file
|
@ -0,0 +1,127 @@
|
|||
=head1 NAME
|
||||
|
||||
App::api::controls::Control_Check
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $check = Component__Get(CONTROL_CHECK, ['check']);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Control para marcar/desmarcar una opción.
|
||||
|
||||
=head1 ARGUMENTS
|
||||
|
||||
(
|
||||
TYPE => 'Check',
|
||||
ID => 'check' (default),
|
||||
INFO => 1 (show info in header; default) or 0 (don't show),
|
||||
LABEL => 'Check' (default),
|
||||
LABEL_INFO => Same as LABEL (default),
|
||||
DEFAULT => 0 (unchecked; default) or 1 (checked)
|
||||
)
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
|
||||
package Dam::Components::Controls::Check;
|
||||
|
||||
use Exporter qw(import);
|
||||
our @EXPORT = qw(
|
||||
Control__html Control__js Get
|
||||
);
|
||||
|
||||
use Dam::Util;
|
||||
use Dam::DamLogic;
|
||||
|
||||
|
||||
|
||||
my $ID_DEFAULT = 'check';
|
||||
|
||||
|
||||
|
||||
sub __arguments {
|
||||
my $arg_ref = shift;
|
||||
|
||||
$$arg_ref{LABEL} = 'Check' if is_empty($$arg_ref{LABEL});
|
||||
$$arg_ref{LABEL_INFO} = $$arg_ref{LABEL} if is_empty($$arg_ref{LABEL_INFO});
|
||||
|
||||
check_arguments($arg_ref,
|
||||
TYPE => [ ARG_REQUIRED ],
|
||||
ID => [ ARG_DEFAULT, $ID_DEFAULT ],
|
||||
INFO => [ ARG_DEFAULT, 1, 0 ],
|
||||
LABEL => [ ARG_REQUIRED ],
|
||||
LABEL_INFO => [ ARG_REQUIRED ],
|
||||
DEFAULT => [ ARG_DEFAULT, 0, 1 ]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub Control__html {
|
||||
my ($self, $arg_ref, $info_ref) = @_;
|
||||
|
||||
__arguments($arg_ref);
|
||||
|
||||
my $check_value = !is_report() ? $$arg_ref{DEFAULT} : is_empty(cgiapp_param($$arg_ref{ID})) ? 0 : 1;
|
||||
|
||||
push(@{$info_ref}, { DATA => _t('Option'), VALUE => $$arg_ref{LABEL_INFO} }) if $$arg_ref{INFO} && $check_value;
|
||||
|
||||
return strval('
|
||||
<div class="form-group form-group-', $ID_DEFAULT, ' input-lg">
|
||||
<label for="', $$arg_ref{ID}, '"><input type="checkbox" id="', $$arg_ref{ID}, '" name="', $$arg_ref{ID}, '" value="check"', $check_value ? ' checked ' : ' ', '/> ', $$arg_ref{LABEL}, '</label>
|
||||
</div>
|
||||
');
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub Control__js {
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub Get {
|
||||
my ($self, $id) = @_;
|
||||
|
||||
$id = $ID_DEFAULT if is_empty($id);
|
||||
|
||||
return is_empty(cgiapp_param($id)) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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