Table being loaded. Need to handle proper name display though

master
Mike Koch 7 years ago
parent 38cea82821
commit 7fb7a8bec4

@ -271,13 +271,12 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
<table class="table table-striped">
<thead>
<tr>
<th style="display: none"><?php echo $hesklang['id']; ?></th>
<th><?php echo $hesklang['id']; ?></th>
<th><?php echo $hesklang['cat_name']; ?></th>
<th><?php echo $hesklang['priority']; ?></th>
<th><?php echo $hesklang['not']; ?></th>
<th><?php echo $hesklang['graph']; ?></th>
<th><?php echo $hesklang['usage']; ?></th>
<th><?php echo $hesklang['manager']; ?></th>
<th><?php echo $hesklang['opt']; ?></th>
</tr>
</thead>
@ -631,9 +630,66 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
});
});
</script>
<script type="text/html" id="category-row-template">
<tr>
<td><span data-property="id" data-value="x"></span></td>
<td><span data-property="category-name"></span></td>
<td><span data-property="priority"></span></td>
<td><a data-property="number-of-tickets" href="#"></a></td>
<td>
<div class="progress" style="width: 160px; margin-bottom: 0" title="Width tooltip" data-toggle="tooltip">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100">
</div>
</div>
</td>
<td>
<i class="fa fa-fw fa-ticket icon-link" data-toggle="tooltip" title="<?php echo $hesklang['tickets']; ?>"></i>
<i class="fa fa-fw fa-calendar icon-link" data-toggle="tooltip" title="<?php echo $hesklang['events']; ?>"></i>
</td>
<td>
<a data-property="generate-link" href="#">
<i class="fa fa-fw fa-code icon-link" style="color: green" data-toggle="tooltip"
data-placement="top" title="<?php $hesklang['geco']; ?>"></i>
</a>
<a data-property="autoassign-link" href="#">
<i class="fa fa-fw fa-bolt icon-link orange"
data-toggle="tooltip" data-placement="top" title="Category autoassign tooltip"></i>
</a>
<a data-property="type-link" href="#">
<?php // fa-lock or fa-unlock-alt ?>
<i class="fa fa-fw fa-lock gray" data-toggle="tooltip" data-placement="top" title="Category type tooltip"></i>
</a>
<span class="sort-arrows">
<a href="#" data-action="sort"
data-direction="up">
<i class="fa fa-fw fa-arrow-up icon-link green"
data-toggle="tooltip" title="<?php echo $hesklang['move_up']; ?>"></i>
</a>
<a href="#" data-action="sort"
data-direction="down">
<i class="fa fa-fw fa-arrow-down icon-link green"
data-toggle="tooltip" title="<?php echo $hesklang['move_dn'] ?>"></i>
</a>
</span>
<a href="#" data-action="edit">
<i class="fa fa-fw fa-pencil icon-link orange"
data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i>
</a>
<a href="#" data-action="delete">
<i class="fa fa-fw fa-times icon-link red"
data-toggle="tooltip" title="<?php echo $hesklang['delete']; ?>"></i>
</a>
</td>
</tr>
</script>
<?php
echo mfh_get_hidden_fields_for_language(array());
echo mfh_get_hidden_fields_for_language(array(
'critical',
'high',
'medium',
'low',
'perat',
));
require_once(HESK_PATH . 'inc/footer.inc.php');
exit();

@ -16,7 +16,6 @@ function loadTable() {
headers: { 'X-Internal-Call': true },
success: function(data) {
$tableBody.html('');
elements = [];
if (data.length === 0) {
mfhAlert.error("I couldn't find any categories :(", "No categories found");
@ -24,67 +23,54 @@ function loadTable() {
return;
}
var sortedElements = [];
var totalNumberOfTickets = 0;
$.each(data, function() {
totalNumberOfTickets += this.numberOfTickets;
});
var currentPlace = 0;
var addedElementToPlace = false;
var first = true;
var lastElement = null;
$.each(data, function() {
if (this.place !== currentPlace) {
if (lastElement !== null) {
//-- Hide the down arrow on the last element
$('[data-value="' + lastElement.id + '"]').parent().parent()
.find('[data-direction="down"]').css('visibility', 'hidden');
lastElement = null;
}
$('#table-body').append('<tr><td colspan="6" class="bg-gray"><i><b>' + places[this.place] + '</b></i></td></tr>');
currentPlace = this.place;
addedElementToPlace = false;
first = true;
}
var $template = $($('#nav-element-template').html());
var $template = $($('#category-row-template').html());
$template.find('span[data-property="id"]').text(this.id).attr('data-value', this.id);
if (this.imageUrl === null) {
$template.find('span[data-property="image-or-font"]').html('<i class="' + escape(this.fontIcon) + '"></i>');
$template.find('span[data-property="category-name"]').text(this.name);
var $priority = $template.find('span[data-property="priority"]');
if (this.priority === 0) {
// Critical
$priority.text(mfhLang.text('critical')).addClass('critical');
} else if (this.priority === 1) {
// High
$priority.text(mfhLang.text('high')).addClass('important');
} else if (this.priority === 2) {
// Medium
$priority.text(mfhLang.text('medium')).addClass('medium');
} else {
$template.find('span[data-property="image-or-font"]').text(this.imageUrl);
// Low
$priority.text(mfhLang.text('low')).addClass('normal');
}
$template.find('span[data-property="url"]').text(this.url);
var text = '';
$.each(this.text, function(key, value) {
text += '<li><b>' + escape(key) + ':</b> ' + escape(value) + '</li>';
});
$template.find('ul[data-property="text"]').html(text);
var subtext = '-';
if (this.place === 1) {
subtext = '';
$.each(this.subtext, function(key, value) {
subtext += '<li><b>' + escape(key) + ':</b> ' + escape(value) + '</li>';
});
$template.find('a[data-property="number-of-tickets"]')
.text(this.numberOfTickets)
.attr('href', '#' + this.numberOfTickets);
var percentText = mfhLang.text('perat');
var percentage = Math.round(this.numberOfTickets / totalNumberOfTickets * 100);
$template.find('div.progress').attr('title', percentText.replace('%s', percentage + '%'));
$template.find('div.progress-bar').attr('aria-value-now', percentage).css('width', percentage + '%');
if (this.usage === 1) {
// Tickets only
$template.find('.fa-calendar').removeClass('fa-calendar');
} else if (this.usage === 2) {
// Events only
$template.find('.fa-ticket').removeClass('fa-ticket');
}
$template.find('ul[data-property="subtext"]').html(subtext);
if (first) {
$template.find('[data-direction="up"]').css('visibility', 'hidden');
first = false;
}
// TODO Action buttons
$tableBody.append($template);
elements[this.id] = this;
categories[this.id] = this;
addedElementToPlace = true;
lastElement = this;
});
@ -95,7 +81,7 @@ function loadTable() {
}
},
error: function(data) {
mfhAlert.errorWithLog(mfhLang.text('failed_to_load_custom_nav_elements'), data.responseJSON);
mfhAlert.errorWithLog(mfhLang.text('Something bad happened...'), data.responseJSON);
console.error(data);
},
complete: function() {

Loading…
Cancel
Save