parent
7182796216
commit
080feb9c6f
@ -0,0 +1,50 @@
|
||||
package NGCP::Panel::Field::DataTable;
|
||||
use Moose;
|
||||
use Template;
|
||||
extends 'HTML::FormHandler::Field';
|
||||
|
||||
sub build_options {
|
||||
my ($self) = @_;
|
||||
|
||||
return [
|
||||
{ label => 'Select...', value => '' },
|
||||
{ label => '1', value => 1 },
|
||||
{ label => '2', value => 2 },
|
||||
{ label => '3', value => 3 },
|
||||
{ label => '4', value => 4 },
|
||||
{ label => '5', value => 5 },
|
||||
#{ label => '6', value => 6 },
|
||||
];
|
||||
}
|
||||
|
||||
has 'template' => ( isa => 'Str', is => 'rw' );
|
||||
|
||||
sub render_element {
|
||||
my ($self) = @_;
|
||||
my $output;
|
||||
|
||||
|
||||
|
||||
my $vars = {
|
||||
# url => $c->uri_for(".."), fields => [qw/id name/]
|
||||
};
|
||||
#my $t = new Template({});
|
||||
|
||||
use Data::Dumper;
|
||||
print Dumper $self->template;
|
||||
#$t->process($self->template, $vars, $output);
|
||||
return "foo"; #$output;
|
||||
}
|
||||
|
||||
sub render {
|
||||
my ( $self, $result ) = @_;
|
||||
$result ||= $self->result;
|
||||
die "No result for form field '" . $self->full_name . "'. Field may be inactive." unless $result;
|
||||
my $output = $self->render_element( $result );
|
||||
return $output; #$self->wrap_field( $result, $output );
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
# vim: set tabstop=4 expandtab:
|
@ -0,0 +1,28 @@
|
||||
package NGCP::Panel::Widget::DataTable;
|
||||
use Moose::Role;
|
||||
|
||||
has 'template' => (
|
||||
is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'widgets/data_table.tt'
|
||||
);
|
||||
|
||||
#around handle => sub {
|
||||
# my ($foo, $self, $c) = @_;
|
||||
#
|
||||
# print "++++ AdminBillingOverview::handle\n";
|
||||
# return;
|
||||
#};
|
||||
|
||||
#around filter => sub {
|
||||
# my ($foo, $self, $c) = @_;
|
||||
|
||||
# return $self if(
|
||||
# $c->check_user_roles(qw/administrator/) &&
|
||||
# ref $c->controller eq 'NGCP::Panel::Controller::Dashboard'
|
||||
# );
|
||||
# return;
|
||||
#};
|
||||
|
||||
1;
|
||||
# vim: set tabstop=4 expandtab:
|
@ -0,0 +1,112 @@
|
||||
[% MACRO cf_render BLOCK %]
|
||||
|
||||
[% FOREACH this_field IN cf_form.sorted_fields -%]
|
||||
|
||||
[% IF this_field.id == "contract" -%]
|
||||
|
||||
[% cf_new_table_html( cf_table="cf_table",
|
||||
cf_table_fields=cf_contract_titles ) %]
|
||||
[% cf_new_table_definition( cf_table="cf_table",
|
||||
cf_table_src='/contract/ajax',
|
||||
cf_update_field='contract\\\\.id' ) %]
|
||||
|
||||
[% END %]
|
||||
[% IF this_field.id == "contact" -%]
|
||||
|
||||
[% cf_new_table_html( cf_table="cf_table",
|
||||
cf_table_fields=cf_contact_titles ) %]
|
||||
[% cf_new_table_definition( cf_table="cf_table",
|
||||
cf_table_src='/contact/ajax',
|
||||
cf_update_field='contact\\\\.contact' ) %]
|
||||
|
||||
[%- END %]
|
||||
|
||||
[%- END %]
|
||||
|
||||
[% cf_form.render %]
|
||||
|
||||
[% END %]
|
||||
|
||||
[% MACRO cf_new_table_html BLOCK %]
|
||||
<table class="table table-bordered table-striped table-highlight table-hover" id="[% cf_table %]">
|
||||
<thead>
|
||||
<tr>
|
||||
[% FOREACH t IN cf_table_fields -%]
|
||||
<th>[% t %]</th>
|
||||
[% END -%]
|
||||
[% # one for actions -%]
|
||||
<th class="span2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="sw_action_row">
|
||||
<td>Loading</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
[% END %]
|
||||
|
||||
[% MACRO cf_new_table_definition BLOCK %]
|
||||
|
||||
[% PROCESS "helpers/defines.tt" %]
|
||||
[% ifndef_include_dt %]
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#[% cf_table %]')
|
||||
.dataTable( {
|
||||
"bProcessing": true,
|
||||
"bServerSide": true,
|
||||
"bPaginate": true,
|
||||
"bLengthChange": false,
|
||||
"bSort": true,
|
||||
"bInfo": true,
|
||||
"iDisplayLength": 4,
|
||||
"sAjaxSource": "[% c.uri_for( cf_table_src ) %]",
|
||||
|
||||
"aoColumns": [
|
||||
[% FOREACH f IN helper.column_fields -%]
|
||||
{ "sName": "[% f %]" },
|
||||
[% END -%]
|
||||
{ "mRender": function ( data, type, full ) {
|
||||
return '' +
|
||||
'<input type="checkbox"></input>' +
|
||||
'<div class="sw_actions pull-right">' +
|
||||
'<a style="display:inline;line-height:16px;" class="btn btn-small btn-primary">' +
|
||||
'<i class="icon-check" style="line-height:1em;margin-top:2px"></i> Select' +
|
||||
'</a>' +
|
||||
'</div>';
|
||||
},
|
||||
"mData": null,
|
||||
"bSortable": false
|
||||
}
|
||||
],
|
||||
"fnDrawCallback": function( oSettings ) {
|
||||
$('.sw_actions').hide();
|
||||
$('.sw_action_row').hover(
|
||||
function() { $(this).find('.sw_actions').show(); },
|
||||
function() { $(this).find('.sw_actions').hide(); }
|
||||
);
|
||||
},
|
||||
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
|
||||
nRow.className = "sw_action_row";
|
||||
return nRow;
|
||||
},
|
||||
} );
|
||||
|
||||
$('#[% cf_table %] tbody tr').live('click', function () {
|
||||
var id = $(this).find("td:first").text();
|
||||
//alert(".."+id+"..");
|
||||
$("input#[% cf_update_field %]").val(id);
|
||||
$(this).addClass('highlight').siblings().removeClass('highlight');
|
||||
$(this).find("td:eq(4) input[type='checkbox']").attr("checked", true);
|
||||
$(this).siblings().find("td:eq(4) input[type='checkbox']").attr("checked", false);
|
||||
});
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
[% END %]
|
||||
|
||||
|
||||
[% # vim: set tabstop=4 syntax=html expandtab: -%]
|
||||
|
@ -0,0 +1,68 @@
|
||||
<script type="text/javascript" language="javascript" src="http://localhost:5000/js/libs/jquery.dataTables.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#myformtable')
|
||||
.dataTable( {
|
||||
"bProcessing": true,
|
||||
"bServerSide": true,
|
||||
"bPaginate": true,
|
||||
"bLengthChange": false,
|
||||
"bSort": true,
|
||||
"bInfo": true,
|
||||
"iDisplayLength": 5,
|
||||
"sAjaxSource": "http://localhost:5000/reseller/ajax",
|
||||
|
||||
"aoColumns": [
|
||||
{ "sName": "id" },
|
||||
{ "sName": "name" },
|
||||
{ "sName": "contract.id" },
|
||||
{ "sName": "status" },
|
||||
{ "mRender": function ( data, type, full ) {
|
||||
return '' +
|
||||
'<div class="sw_actions pull-right">' +
|
||||
'<a style="display:inline;line-height:16px;" class="btn btn-small btn-primary" href="http://localhost:5000/reseller/' + full[0] + '/edit">' +
|
||||
'<i class="icon-edit" style="line-height:1em;margin-top:2px"></i> Edit' +
|
||||
'</a>' +
|
||||
'<a style="display:inline;line-height:16px;margin-left:5px;" class="btn btn-small btn-secondary" href="http://localhost:5000/reseller/' + full[0] + '/delete">' +
|
||||
'<i class="icon-trash" style="line-height:1em;margin-top:2px"></i> Delete' +
|
||||
'</a>' +
|
||||
'</div>';
|
||||
},
|
||||
"mData": null,
|
||||
"bSortable": false
|
||||
}
|
||||
],
|
||||
"fnDrawCallback": function( oSettings ) {
|
||||
$('.sw_actions').hide();
|
||||
$('.sw_action_row').hover(
|
||||
function() { $(this).find('.sw_actions').show(); },
|
||||
function() { $(this).find('.sw_actions').hide(); }
|
||||
);
|
||||
},
|
||||
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
|
||||
nRow.className = "sw_action_row";
|
||||
return nRow;
|
||||
},
|
||||
} );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
<table class="table table-bordered table-striped table-highlight table-hover" id="myformtable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Name</th>
|
||||
<th>Contract #</th>
|
||||
<th>Status</th>
|
||||
<th class="span3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="sw_action_row">
|
||||
<td>Loading</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
[% # vim: set tabstop=4 syntax=html expandtab: -%]
|
@ -0,0 +1,8 @@
|
||||
[% MACRO ifndef_include_dt BLOCK -%]
|
||||
|
||||
[% # UNLESS global.ifndef_include_dt_flag ;
|
||||
# global.ifndef_include_dt_flag="true" %]
|
||||
<script type="text/javascript" language="javascript" src="[% c.uri_for('/js/libs/jquery.dataTables.min.js') %]"></script>
|
||||
[% # END %]
|
||||
|
||||
[%- END %]
|
@ -0,0 +1,2 @@
|
||||
Yeah!
|
||||
[% c.log.debug("****** am in widgets/data_table.tt now ****** ") %]
|
Loading…
Reference in new issue