From 7fb7a8bec479955a62db746876f90db27b3c2028 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 22 Aug 2017 22:03:11 -0400 Subject: [PATCH] Table being loaded. Need to handle proper name display though --- admin/manage_categories.php | 64 ++++++++++++++++++++-- internal-api/js/manage-categories.js | 80 ++++++++++++---------------- 2 files changed, 93 insertions(+), 51 deletions(-) diff --git a/admin/manage_categories.php b/admin/manage_categories.php index 725178ac..32c7b4a6 100644 --- a/admin/manage_categories.php +++ b/admin/manage_categories.php @@ -271,13 +271,12 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) - + - @@ -631,9 +630,66 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) }); }); - +'); - 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(''); + $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 += '
  • ' + escape(key) + ': ' + escape(value) + '
  • '; - }); - $template.find('ul[data-property="text"]').html(text); - - var subtext = '-'; - if (this.place === 1) { - subtext = ''; - $.each(this.subtext, function(key, value) { - subtext += '
  • ' + escape(key) + ': ' + escape(value) + '
  • '; - }); + $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() {
    ' + places[this.place] + '