|
|
|
@ -2,6 +2,8 @@ var categories = [];
|
|
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
loadTable();
|
|
|
|
|
bindEditModal();
|
|
|
|
|
bindModalCancelCallback();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -34,7 +36,17 @@ function loadTable() {
|
|
|
|
|
var $template = $($('#category-row-template').html());
|
|
|
|
|
|
|
|
|
|
$template.find('span[data-property="id"]').text(this.id).attr('data-value', this.id);
|
|
|
|
|
$template.find('span[data-property="category-name"]').text(this.name);
|
|
|
|
|
var $nameField = $template.find('span[data-property="category-name"]');
|
|
|
|
|
if (this.foregroundColor === 'AUTO') {
|
|
|
|
|
$nameField.addClass('background-volatile');
|
|
|
|
|
} else {
|
|
|
|
|
$nameField.css('color', this.foregroundColor);
|
|
|
|
|
}
|
|
|
|
|
$nameField.css('background', this.backgroundColor);
|
|
|
|
|
if (this.displayBorder && this.foregroundColor !== 'AUTO') {
|
|
|
|
|
$nameField.css('border', 'solid 1px ' + this.foregroundColor);
|
|
|
|
|
}
|
|
|
|
|
$nameField.html(this.name);
|
|
|
|
|
var $priority = $template.find('span[data-property="priority"]');
|
|
|
|
|
if (this.priority === 0) {
|
|
|
|
|
// Critical
|
|
|
|
@ -57,6 +69,8 @@ function loadTable() {
|
|
|
|
|
$template.find('div.progress').attr('title', percentText.replace('%s', percentage + '%'));
|
|
|
|
|
$template.find('div.progress-bar').attr('aria-value-now', percentage).css('width', percentage + '%');
|
|
|
|
|
|
|
|
|
|
$template.find('[data-property="generate-link"]').find('i').attr('title', mfhLang.text('geco'));
|
|
|
|
|
|
|
|
|
|
if (this.usage === 1) {
|
|
|
|
|
// Tickets only
|
|
|
|
|
$template.find('.fa-calendar').removeClass('fa-calendar');
|
|
|
|
@ -65,7 +79,28 @@ function loadTable() {
|
|
|
|
|
$template.find('.fa-ticket').removeClass('fa-ticket');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO Action buttons
|
|
|
|
|
if (this.autoAssign) {
|
|
|
|
|
$template.find('[data-property="autoassign-link"]').attr('href', '#on')
|
|
|
|
|
.find('i').attr('title', mfhLang.text('aaon')).addClass('orange');
|
|
|
|
|
} else {
|
|
|
|
|
$template.find('[data-property="autoassign-link"]').attr('href', '#off')
|
|
|
|
|
.find('i').attr('title', mfhLang.text('aaoff')).addClass('gray');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.type === 1) {
|
|
|
|
|
// Private
|
|
|
|
|
$template.find('[data-property="type-link"]').attr('href', '#private')
|
|
|
|
|
.find('i').addClass('fa-lock').attr('title', mfhLang.text('cat_private')).addClass('gray');
|
|
|
|
|
$template.find('[data-property="generate-link"]')
|
|
|
|
|
.find('i').removeClass('fa-code').addClass('fa-ban').addClass('red')
|
|
|
|
|
.attr('title', mfhLang.text('cpric'));
|
|
|
|
|
} else {
|
|
|
|
|
// Public
|
|
|
|
|
$template.find('[data-property="type-link"]').attr('href', '#public')
|
|
|
|
|
.find('i').addClass('fa-unlock-alt').attr('title', mfhLang.text('cat_public')).addClass('blue');
|
|
|
|
|
$template.find('[data-property="generate-link"]')
|
|
|
|
|
.find('i').addClass('green').attr('title', mfhLang.text('geco'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tableBody.append($template);
|
|
|
|
|
|
|
|
|
@ -90,7 +125,88 @@ function loadTable() {
|
|
|
|
|
console.error(data);
|
|
|
|
|
},
|
|
|
|
|
complete: function() {
|
|
|
|
|
refreshBackgroundVolatileItems();
|
|
|
|
|
$('#overlay').hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function bindEditModal() {
|
|
|
|
|
$(document).on('click', '[data-action="edit"]', function() {
|
|
|
|
|
var element = categories[$(this).parent().parent().find('[data-property="id"]').text()];
|
|
|
|
|
var $modal = $('#category-modal');
|
|
|
|
|
|
|
|
|
|
$modal.find('#title-edit-category').show();
|
|
|
|
|
$modal.find('#title-add-category').hide();
|
|
|
|
|
|
|
|
|
|
$modal.find('input[name="name"]').val(element.name).end()
|
|
|
|
|
.find('select[name="priority"]').val(element.priority).end()
|
|
|
|
|
.find('input[name="id"]').val(element.id).end()
|
|
|
|
|
.find('select[name="usage"]').val(element.usage).end();
|
|
|
|
|
|
|
|
|
|
var backgroundColor = element.backgroundColor;
|
|
|
|
|
var foregroundColor = element.foregroundColor;
|
|
|
|
|
var colorpickerOptions = {
|
|
|
|
|
format: 'hex',
|
|
|
|
|
color: backgroundColor
|
|
|
|
|
};
|
|
|
|
|
$modal.find('input[name="background-color"]')
|
|
|
|
|
.colorpicker(colorpickerOptions).end().modal('show');
|
|
|
|
|
|
|
|
|
|
colorpickerOptions = {
|
|
|
|
|
format: 'hex'
|
|
|
|
|
};
|
|
|
|
|
if (foregroundColor != '' && foregroundColor !== 'AUTO') {
|
|
|
|
|
colorpickerOptions.color = foregroundColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$modal.find('input[name="foreground-color"]')
|
|
|
|
|
.colorpicker(colorpickerOptions).end().modal('show');
|
|
|
|
|
|
|
|
|
|
/*$modal.find('select[name="place"]').val(element.place);
|
|
|
|
|
$modal.find('input[name="id"]').val(element.id);
|
|
|
|
|
$modal.find('input[name="url"]').val(element.url);
|
|
|
|
|
var $textLanguages = $modal.find('[data-text-language]');
|
|
|
|
|
$.each($textLanguages, function() {
|
|
|
|
|
var language = $(this).data('text-language');
|
|
|
|
|
|
|
|
|
|
$(this).val(element.text[language]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var $subtextLanguages = $modal.find('[data-subtext-language]');
|
|
|
|
|
$.each($subtextLanguages, function() {
|
|
|
|
|
var language = $(this).data('subtext-language');
|
|
|
|
|
|
|
|
|
|
$(this).val(element.subtext[language]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (element.place === 1) {
|
|
|
|
|
$('#subtext').show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#subtext').hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (element.imageUrl !== null) {
|
|
|
|
|
$modal.find('select[name="image-type"]').val('image-url');
|
|
|
|
|
$modal.find('input[name="image-url"]').val(element.imageUrl);
|
|
|
|
|
$modal.find('#font-icon-group').hide();
|
|
|
|
|
$modal.find('#image-url-group').show();
|
|
|
|
|
} else {
|
|
|
|
|
$modal.find('select[name="image-type"]').val('font-icon');
|
|
|
|
|
$('[data-toggle="nav-iconpicker"]').iconpicker('setIcon', element.fontIcon);
|
|
|
|
|
$modal.find('#font-icon-group').show();
|
|
|
|
|
$modal.find('#image-url-group').hide();
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
$modal.modal('show');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function bindModalCancelCallback() {
|
|
|
|
|
$('.cancel-callback').click(function() {
|
|
|
|
|
var $editCategoryModal = $('#category-modal');
|
|
|
|
|
|
|
|
|
|
$editCategoryModal.find('input[name="background-color"]').val('').colorpicker('destroy').end();
|
|
|
|
|
$editCategoryModal.find('input[name="foreground-color"]').val('').colorpicker('destroy').end();
|
|
|
|
|
});
|
|
|
|
|
}
|