Files
caotek_monaa/caotek_mesavoirs/templates/contents/doc_search.pt

99 lines
2.3 KiB
XML

<div metal:use-macro="load: ../global_layout.pt">
<div metal:fill-slot="content">
<div class="row">
<form id="search-form" class="form-horizontal" role="form" action="/doc_search" method="post">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-8">
<div class="input-group" align="center">
<input type="text" class="form-control" name="critere" value="${critere}" />
<span class="input-group-btn">
<button id="submitButton" class="btn btn-primary" type="submit" name="form.submitted">
Rechercher
</button>
</span>
</div>
</div>
</div>
</form>
</div><!-- row -->
<div class="row">
<div tal:condition="dt_data != '[]'">
<table id="folder_list" class="table">
<thead>
<tr>
<th>Titre</th>
<th>Tags</th>
<th>Date</th>
<th></th>
</tr>
</thead>
</table>
</div>
<div tal:condition="dt_data == '[]'">
<h3 class="text-center">Aucun élément trouvé pour ce critère</h3>
</div>
</div>
<br />
<br />
<script type="text/javascript">
var dataSet = ${dt_data};
$(document).ready(function() {
$('#search-form').formValidation({
framework: 'bootstrap',
message: 'This value is not valid',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
critere: {
validators: {
notEmpty: {
message: 'Veuillez saisir le texte à rechercher'
},
stringLength: {
min: 3,
max: 30,
message: 'Le texte doit avoir de 3 à 30 caractères de long'
},
}
},
}
});
$.fn.dataTable.moment('DD/MM/YYYY - HH:mm');
$('#folder_list').DataTable({
data: dataSet,
pageLength: 50,
bLengthChange: false,
language: {
url: 'https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json'
},
columnDefs: [
{ "targets": 0,
"render": function (data, type, row, meta) {
// ajouter un link vers le formulaire
return '<a href="/doc_view/' + row[3] + '">' + data + '</a>';
},
},
]
});
$('form input').on('keypress', function(e) {
var code = e.keyCode || e.which;
if (code === 13) {
e.preventDefault();
// simuler clic bouton submit
document.getElementById("submitButton").click();
}
});
});
</script>
</div>
</div>