You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcp-panel/share/templates/helpers/datatables.tt

138 lines
4.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<script src="/js/libs/datatables-bootstrap-paging.js"></script>
<script type="text/javascript">
$.extend( $.fn.dataTableExt.oStdClasses, {
"sSortAsc": "header headerSortDown",
"sSortDesc": "header headerSortUp",
"sSortable": "header",
} );
$(document).ready(function() {
$('#[% helper.name.remove('[\s+\.]') %]_table')
.dataTable( {
"sDom": "<'row'<'span6'r><'span6'f>>t<'row'<'span6'i><'span6'p>>",
"bProcessing": true,
"bServerSide": true,
"bPaginate": true,
"sPaginationType": "bootstrap",
"bLengthChange": true,
"bSort": true,
"bInfo": true,
"iDisplayLength": 5,
"sAjaxSource": "[% helper.ajax_uri %]",
"aoColumns": [
[% FOREACH f IN helper.column_fields -%]
{ "sName": "[% f %]" },
[% END -%]
{ "mRender": function ( data, type, full ) {
return '' +
'<div class="sw_actions pull-right">' +
[%- IF helper.has_edit != 0 %]
'<a class="btn btn-small btn-primary" href="[% helper.base_uri %]/' + full[0] + '/edit">' +
'<i class="icon-edit"></i> Edit' +
'</a>' +
[%- END %]
'<a class="btn btn-small btn-secondary" href="[% helper.base_uri %]/' + full[0] + '/delete" data-confirm="Delete">' +
'<i class="icon-trash"></i> Delete' +
'</a>' +
[%- IF helper.extra_buttons.size %]
[% FOR b IN helper.extra_buttons %]
'<a class="btn btn-small btn-tertiary" href="[% helper.base_uri %]/' + full[0] + '/' +
'[% b.1 %]' + '">' +
'[% b.0 %]' +
'</a>' +
[% END %]
[% END %]
'</div>';
},
"mData": null,
"bSortable": false,
"sClass": "ngcp-actions-column",
}
],
"aoColumnDefs": [
[%- IF helper.has_preferences %]
{
"aTargets": [ 0 ],
"mRender": function ( data, type, full ) {
return '<a href="[% helper.base_uri %]/'+
full[0]+
'/preferences">'+data+'</a>';
}
},
[%- END %]
],
"fnDrawCallback": function( oSettings ) {
$('.sw_actions').css('visibility','hidden');
$('.sw_action_row').hover(
function() { $(this).find('.sw_actions').css('visibility','visible'); },
function() { $(this).find('.sw_actions').css('visibility','hidden'); }
);
},
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
nRow.className = "sw_action_row";
return nRow;
},
} );
} );
</script>
<div class="row">
<a class="btn btn-primary btn-large" href="[% c.uri_for(c.action, c.req.captures, 'create') %]"><i class="icon-star"></i> Create [% helper.name %]</a>
</div>
[% IF helper.messages -%]
<div class="row">
[% FOREACH m IN helper.messages -%]
<div class="alert alert-[% m.type %]">[% m.text %]</div>
[% END -%]
</div>
[% END -%]
<div class="ngcp-separator"></div>
<table class="table table-bordered table-striped table-highlight table-hover ngcp-datatable" id="[% helper.name.remove('[\s+\.]') %]_table">
<thead>
<tr>
[% FOREACH t IN helper.column_titles -%]
<th>[% t %]</th>
[% END -%]
[% # one for actions -%]
<th class="ngcp-actions-column"></th>
</tr>
</thead>
<tbody>
<tr class="sw_action_row">
<td colspan="[% helper.column_titles.size + 1 %]">Loading...</td>
</tr>
</tbody>
</table>
[% IF helper.edit_flag || helper.create_flag == 1 -%]
<div id="mod_edit" class="modal hide ngcp-modal">
<div class="modal-header">
<button id="mod_close" type="button" class="close">×</button>
<h3>[% helper.create_flag == 1 ? 'Create' : 'Edit' %] [% helper.name %]</h3>
</div>
[% helper.form_object.render -%]
</div>
<script>
$(function () {
$('#mod_edit').modal({keyboard: false, backdrop: 'static'});
$('#mod_close').click(function(event) {
window.location.href="[% helper.close_target ? helper.close_target : c.uri_for() %]";
});
// on clicking a button within the form, add a hidden field "submitid"
// determining the name of the button being clicked
$('input[type=button]').click(function() {
$(this).parents('form').find('#submitid').attr('value', $(this).attr('name'));
$(this).parents('form').submit();
});
});
</script>
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]