More progress'
This commit is contained in:
parent
a8abfcd4a1
commit
d897fa2a4b
@ -93,6 +93,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th style="display: none"><?php echo $hesklang['id']; ?></th>
|
||||||
<th><?php echo $hesklang['sm_mtitle']; ?></th>
|
<th><?php echo $hesklang['sm_mtitle']; ?></th>
|
||||||
<th><?php echo $hesklang['sm_author']; ?></th>
|
<th><?php echo $hesklang['sm_author']; ?></th>
|
||||||
<th><?php echo $hesklang['sm_type']; ?></th>
|
<th><?php echo $hesklang['sm_type']; ?></th>
|
||||||
@ -121,7 +122,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
<span id="create-label"><?php echo $hesklang['new_sm']; ?></span>
|
<span id="create-label"><?php echo $hesklang['new_sm']; ?></span>
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<form id="manage-category" class="form-horizontal" data-toggle="validator" method="post">
|
<form id="service-message" class="form-horizontal" data-toggle="validator" method="post">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="row" style="padding-bottom: 10px;">
|
<div class="row" style="padding-bottom: 10px;">
|
||||||
@ -224,7 +225,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
|
|
||||||
<div class="col-md-10">
|
<div class="col-md-10">
|
||||||
<textarea placeholder="<?php echo htmlspecialchars($hesklang['sm_msg']); ?>"
|
<textarea placeholder="<?php echo htmlspecialchars($hesklang['sm_msg']); ?>"
|
||||||
class="form-control" name="message" rows="25" cols="70" id="content"></textarea>
|
class="form-control" name="message" id="content"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -240,7 +241,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<input type="hidden" name="id">
|
<input type="hidden" name="id">
|
||||||
<input type="hidden" name="cat-order">
|
<input type="hidden" name="order">
|
||||||
<div id="action-buttons" class="btn-group">
|
<div id="action-buttons" class="btn-group">
|
||||||
<button type="button" class="btn btn-default cancel-button cancel-callback" data-dismiss="modal">
|
<button type="button" class="btn btn-default cancel-button cancel-callback" data-dismiss="modal">
|
||||||
<i class="fa fa-times-circle"></i>
|
<i class="fa fa-times-circle"></i>
|
||||||
@ -293,7 +294,8 @@ echo '</script>';
|
|||||||
?>
|
?>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="service-message-template">
|
<script type="text/html" id="service-message-template">
|
||||||
<tr data-property="id" data-value="x">
|
<tr>
|
||||||
|
<td style="display: none"><span data-property="id" data-value="x"></span></td>
|
||||||
<td><span data-property="title"></span></td>
|
<td><span data-property="title"></span></td>
|
||||||
<td><span data-property="author"></span></td>
|
<td><span data-property="author"></span></td>
|
||||||
<td><span data-property="type"></span></td>
|
<td><span data-property="type"></span></td>
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
var serviceMessages = [];
|
var serviceMessages = [];
|
||||||
|
|
||||||
|
var g_styles = [];
|
||||||
|
g_styles["ERROR"] = 4;
|
||||||
|
g_styles["NOTICE"] = 3;
|
||||||
|
g_styles["INFO"] = 2;
|
||||||
|
g_styles["SUCCESS"] = 1;
|
||||||
|
g_styles["NONE"] = 0;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
loadTable();
|
loadTable();
|
||||||
bindEditModal();
|
bindEditModal();
|
||||||
@ -33,7 +40,7 @@ function loadTable() {
|
|||||||
$.each(data, function() {
|
$.each(data, function() {
|
||||||
var $template = $($('#service-message-template').html());
|
var $template = $($('#service-message-template').html());
|
||||||
|
|
||||||
$template.find('span[data-property="id"]').attr('data-value', this.id);
|
$template.find('[data-property="id"]').attr('data-value', this.id);
|
||||||
$template.find('span[data-property="title"]').html(
|
$template.find('span[data-property="title"]').html(
|
||||||
getFormattedTitle(this.icon, this.title, this.style));
|
getFormattedTitle(this.icon, this.title, this.style));
|
||||||
$template.find('span[data-property="author"]').text(users[this.createdBy].name);
|
$template.find('span[data-property="author"]').text(users[this.createdBy].name);
|
||||||
@ -127,50 +134,21 @@ function getServiceMessagePreview(icon, title, message, style) {
|
|||||||
|
|
||||||
function bindEditModal() {
|
function bindEditModal() {
|
||||||
$(document).on('click', '[data-action="edit"]', function() {
|
$(document).on('click', '[data-action="edit"]', function() {
|
||||||
var element = categories[$(this).parent().parent().find('[data-property="id"]').text()];
|
console.log(serviceMessages);
|
||||||
var $modal = $('#category-modal');
|
var element = serviceMessages[$(this).parent().parent().find('[data-property="id"]').data('value')];
|
||||||
|
var $modal = $('#service-message-modal');
|
||||||
|
|
||||||
$modal.find('#edit-label').show();
|
$modal.find('#edit-label').show();
|
||||||
$modal.find('#create-label').hide();
|
$modal.find('#create-label').hide();
|
||||||
|
|
||||||
$modal.find('input[name="name"]').val(element.name).end()
|
$modal.find('input[name="style"][value="' + (g_styles[element.style]) + '"]').prop('checked', 'checked').end()
|
||||||
.find('select[name="priority"]').val(element.priority).end()
|
.find('input[name="type"][value="' + (element.published ? 0 : 1) + '"]')
|
||||||
.find('select[name="manager"]').val(element.manager === null ? 0 : element.manager).end()
|
.prop('checked', 'checked').end()
|
||||||
|
.find('input[name="title"]').val(element.title).end()
|
||||||
.find('input[name="id"]').val(element.id).end()
|
.find('input[name="id"]').val(element.id).end()
|
||||||
.find('select[name="usage"]').val(element.usage).end()
|
.find('input[name="order"]').val(element.order).end();
|
||||||
.find('input[name="display-border"][value="' + (element.displayBorder ? 1 : 0) + '"]')
|
setIcon(element.icon);
|
||||||
.prop('checked', 'checked').end();
|
tinyMCE.get('content').setContent(element.message);
|
||||||
|
|
||||||
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');
|
|
||||||
|
|
||||||
if (foregroundColor === '' || foregroundColor === 'AUTO') {
|
|
||||||
$modal.find('input[name="foreground-color"]').colorpicker('setValue', '#fff');
|
|
||||||
$modal.find('input[name="foreground-color"]').val('');
|
|
||||||
}
|
|
||||||
|
|
||||||
$modal.find('input[name="cat-order"]').val(element.catOrder);
|
|
||||||
$modal.find('input[name="autoassign"][value="' + (element.autoAssign ? 1 : 0) + '"]')
|
|
||||||
.prop('checked', 'checked');
|
|
||||||
$modal.find('input[name="type"][value="' + (element.type ? 1 : 0) + '"]')
|
|
||||||
.prop('checked', 'checked');
|
|
||||||
$modal.find('textarea[name="description"]').val(element.description === null ? '' : element.description);
|
|
||||||
|
|
||||||
$modal.modal('show');
|
$modal.modal('show');
|
||||||
});
|
});
|
||||||
@ -183,7 +161,9 @@ function bindCreateModal() {
|
|||||||
.find('#create-label').show().end()
|
.find('#create-label').show().end()
|
||||||
.find('input[name="style"][value="0"]').prop('checked', 'checked').end() // "None" style
|
.find('input[name="style"][value="0"]').prop('checked', 'checked').end() // "None" style
|
||||||
.find('input[name="type"][value="0"]').prop('checked', 'checked').end() // Published
|
.find('input[name="type"][value="0"]').prop('checked', 'checked').end() // Published
|
||||||
.find('input[name="title"]').val('').end();
|
.find('input[name="title"]').val('').end()
|
||||||
|
.find('input[name="id"]').val(-1).end()
|
||||||
|
.find('input[name="order"]').val('').end();
|
||||||
setIcon('');
|
setIcon('');
|
||||||
tinyMCE.get('content').setContent('');
|
tinyMCE.get('content').setContent('');
|
||||||
|
|
||||||
@ -192,34 +172,34 @@ function bindCreateModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bindFormSubmit() {
|
function bindFormSubmit() {
|
||||||
$('form#manage-category').submit(function(e) {
|
$('form#service-message').submit(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var heskUrl = $('p#hesk-path').text();
|
var heskUrl = $('p#hesk-path').text();
|
||||||
|
|
||||||
var $modal = $('#category-modal');
|
var $modal = $('#service-message-modal');
|
||||||
|
|
||||||
|
var styles = [];
|
||||||
|
styles[0] = "NONE";
|
||||||
|
styles[1] = "SUCCESS";
|
||||||
|
styles[2] = "INFO";
|
||||||
|
styles[3] = "NOTICE";
|
||||||
|
styles[4] = "ERROR";
|
||||||
|
|
||||||
var foregroundColor = $modal.find('input[name="foreground-color"]').val();
|
|
||||||
var manager = parseInt($modal.find('select[name="manager"]').val());
|
|
||||||
var data = {
|
var data = {
|
||||||
autoassign: $modal.find('input[name="autoassign"]').val() === 'true',
|
icon: $modal.find('input[name="icon"]').val(),
|
||||||
backgroundColor: $modal.find('input[name="background-color"]').val(),
|
title: $modal.find('input[name="title"]').val(),
|
||||||
description: $modal.find('textarea[name="description"]').val(),
|
message: tinyMCE.get('content').getContent(),
|
||||||
displayBorder: $modal.find('input[name="display-border"]:checked').val() === '1',
|
published: $modal.find('input[name="type"]:checked').val() === "0",
|
||||||
foregroundColor: foregroundColor === '' ? 'AUTO' : foregroundColor,
|
style: styles[$modal.find('input[name="style"]:checked').val()],
|
||||||
name: $modal.find('input[name="name"]').val(),
|
order: $modal.find('input[name="order"]').val()
|
||||||
priority: parseInt($modal.find('select[name="priority"]').val()),
|
|
||||||
manager: manager === 0 ? null : manager,
|
|
||||||
type: parseInt($modal.find('input[name="type"]:checked').val()),
|
|
||||||
usage: parseInt($modal.find('select[name="usage"]').val()),
|
|
||||||
catOrder: parseInt($modal.find('input[name="cat-order"]').val())
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var url = heskUrl + 'api/index.php/v1/categories/';
|
var url = heskUrl + 'api/index.php/v1/service-messages/';
|
||||||
var method = 'POST';
|
var method = 'POST';
|
||||||
|
|
||||||
var categoryId = parseInt($modal.find('input[name="id"]').val());
|
var serviceMessageId = parseInt($modal.find('input[name="id"]').val());
|
||||||
if (categoryId !== -1) {
|
if (serviceMessageId !== -1) {
|
||||||
url += categoryId;
|
url += serviceMessageId;
|
||||||
method = 'PUT';
|
method = 'PUT';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user