Newer
Older
// scroll up to avoid having the form input
// hidden under the navbar
// Showdown extension to render links to JIRA TAG project
var jira_tag = {
type: 'lang',
regex: /(TAG-\d+)/g,
replace: '[$1](https://jira.esss.lu.se/browse/$1)'
};
// Register the extension
showdown.extension('jira_tag', jira_tag);
var converter = new showdown.Converter({
simplifiedAutoLink: true
});
// Live rendering of markdown comment to HTML
$("#body").keyup(function(event) {
var comment = $(this).val();
$("#commentLivePreview").html(converter.makeHtml(comment));
});
// render existing comments to HTML
$(".item-comment").each(function() {
var raw = $(this).html();
$(this).html(converter.makeHtml(raw));
});
// export all items to excel file
function download_excel() {
var $modal = $("#downloadExcelModal");
$.ajax({
url: $SCRIPT_ROOT + "/inventory/items/_generate_excel_file",
method: "GET",
success: function(data, status, request) {
$modal.modal({
backdrop: "static",
keyboard: false
});
status_url = request.getResponseHeader('Location');
check_job_status(status_url, $modal);
},
error: function(jqXHR, textStatus, errorThrown) {
$modal.modal('hide');
flash_alert(JSON.parse(jqXHR.responseText).message, "danger", false);
}
});
}
dom: "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-3 text-right'><'col-sm-12 col-md-3'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
"ajax": {
"url": $SCRIPT_ROOT + "/inventory/_retrieve_items"
"processing": true,
"serverSide": true,
"searchDelay": 500,
"orderMulti": false,
"pagingType": "full_numbers",
"pageLength": 20,
"lengthMenu": [[20, 50, 100, -1], [20, 50, 100, "All"]],
"columnDefs": [
{
"targets": [0],
"visible": false,
"searchable": false
"render": function(data, type, row) {
// render funtion to create link to Item view page
if ( data === null ) {
return data;
}
var url = $SCRIPT_ROOT + "/inventory/items/view/" + data;
return '<a href="'+ url + '">' + data + '</a>';
}
if( $("#items_table").length ) {
new $.fn.dataTable.Buttons(items_table, {
buttons: [
{
text: '<span class="oi oi-data-transfer-download" title="Export to excel file" aria-hidden="true"></span> Excel',
className: "btn-outline-secondary",
action: function ( e, dt, node, conf ) {
download_excel();
}
items_table.buttons().container().appendTo("#items_table_wrapper .col-md-3:eq(0)");
}