Categories can be created, modify modal
This commit is contained in:
parent
f7272e8549
commit
24cdb08449
@ -297,17 +297,18 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
<div class="modal-header" style="cursor: move">
|
||||
<button type="button" class="close cancel-callback" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">
|
||||
<span id="title-edit-category"><?php echo $hesklang['edit_category']; ?></span>
|
||||
<span id="title-add-category"><?php echo $hesklang['create_cat']; ?></span>
|
||||
<span id="edit-label"><?php echo $hesklang['edit_category']; ?></span>
|
||||
<span id="create-label"><?php echo $hesklang['create_cat']; ?></span>
|
||||
</h4>
|
||||
</div>
|
||||
<form id="manage-category" class="form-horizontal" data-toggle="validator" method="post">
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-6">
|
||||
<h4><?php echo $hesklang['basicProperties']; ?></h4>
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-sm-3 control-label"><?php echo $hesklang['cat_name']; ?></label>
|
||||
<div class="col-sm-9">
|
||||
<label for="name" class="col-sm-5 control-label"><?php echo $hesklang['cat_name']; ?></label>
|
||||
<div class="col-sm-7">
|
||||
<input type="text" name="name" class="form-control" placeholder="<?php echo $hesklang['cat_name']; ?>"
|
||||
data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>"
|
||||
required>
|
||||
@ -315,13 +316,24 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="background-color" class="col-sm-3 control-label">
|
||||
<label for="description" class="col-sm-5 control-label">
|
||||
<?php echo $hesklang['description']; ?>
|
||||
</label>
|
||||
<div class="col-sm-7">
|
||||
<textarea class="form-control" name="description" placeholder="<?php echo $hesklang['description']; ?>"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h4><?php echo $hesklang['color']; ?></h4>
|
||||
<div class="form-group">
|
||||
<label for="background-color" class="col-sm-5 control-label">
|
||||
<?php echo $hesklang['category_background_color']; ?>
|
||||
<i class="fa fa-question-circle settingsquestionmark" data-toggle="popover"
|
||||
title="<?php echo htmlspecialchars($hesklang['category_background_color']); ?>"
|
||||
data-content="<?php echo htmlspecialchars($hesklang['category_background_color_help']); ?>"></i>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="col-sm-7">
|
||||
<input type="text" name="background-color" class="form-control category-colorpicker"
|
||||
placeholder="<?php echo $hesklang['category_background_color']; ?>"
|
||||
data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>"
|
||||
@ -330,26 +342,26 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="foreground-color" class="col-sm-3 control-label">
|
||||
<label for="foreground-color" class="col-sm-5 control-label">
|
||||
<?php echo $hesklang['category_foreground_color']; ?>
|
||||
<i class="fa fa-question-circle settingsquestionmark" data-toggle="popover"
|
||||
title="<?php echo htmlspecialchars($hesklang['category_foreground_color']); ?>"
|
||||
data-content="<?php echo htmlspecialchars($hesklang['category_foreground_color_help']); ?>"></i>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="col-sm-7">
|
||||
<input type="text" name="foreground-color" class="form-control category-colorpicker"
|
||||
placeholder="<?php echo $hesklang['category_foreground_color']; ?>">
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="display-border" class="col-sm-3 control-label">
|
||||
<label for="display-border" class="col-sm-5 control-label">
|
||||
<?php echo $hesklang['category_display_border']; ?>
|
||||
<i class="fa fa-question-circle settingsquestionmark" data-toggle="htmlpopover"
|
||||
title="<?php echo htmlspecialchars($hesklang['category_display_border']); ?>"
|
||||
data-content="<?php echo htmlspecialchars($hesklang['category_display_border_help']); ?>"></i>
|
||||
</label>
|
||||
<div class="col-sm-9 form-inline">
|
||||
<div class="col-sm-7 form-inline">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="display-border" value="1">
|
||||
@ -364,14 +376,21 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4>PROPERTIES [!]</h4>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="priority" class="col-sm-3 control-label">
|
||||
<label for="priority" class="col-sm-5 control-label">
|
||||
<?php echo $hesklang['priority']; ?>
|
||||
<a href="#"
|
||||
onclick="alert('<?php echo hesk_makeJsString($hesklang['cat_pri']); ?>')"><i
|
||||
class="fa fa-question-circle settingsquestionmark"></i> </a>
|
||||
class="fa fa-question-circle settingsquestionmark"></i> </a>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="col-sm-7">
|
||||
<select name="priority" class="form-control">
|
||||
<?php
|
||||
// List possible priorities
|
||||
@ -384,10 +403,10 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="usage" class="col-sm-3 control-label">
|
||||
<label for="usage" class="col-sm-5 control-label">
|
||||
<?php echo $hesklang['usage']; ?>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="col-sm-7">
|
||||
<select name="usage" class="form-control">
|
||||
<option value="0"><?php echo $hesklang['tickets_and_events']; ?></option>
|
||||
<option value="1"><?php echo $hesklang['tickets_only']; ?></option>
|
||||
@ -395,12 +414,36 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="description" class="col-sm-3 control-label">
|
||||
<?php echo $hesklang['description']; ?>
|
||||
<label for="autoassign" class="col-sm-5 control-label">
|
||||
<?php echo $hesklang['aass']; ?>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<textarea class="form-control" name="description"></textarea>
|
||||
<div class="col-sm-7 form-inline">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="autoassign" value="1">
|
||||
<?php echo $hesklang['yes']; ?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="autoassign" value="0" checked>
|
||||
<?php echo $hesklang['no']; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="type" class="col-sm-5 control-label">
|
||||
<?php echo $hesklang['visibility']; ?>
|
||||
</label>
|
||||
<div class="col-sm-7">
|
||||
<select name="type" class="form-control">
|
||||
<option value="0"><?php echo $hesklang['cat_public']; ?></option>
|
||||
<option value="1"><?php echo $hesklang['cat_private']; ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -408,11 +451,7 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<input type="hidden" name="id">
|
||||
<input type="hidden" name="a" value="edit">
|
||||
<input type="hidden" name="token" value="<?php hesk_token_echo(); ?>">
|
||||
<input type="hidden" name="cat-order">
|
||||
<input type="hidden" name="type">
|
||||
<input type="hidden" name="autoassign">
|
||||
<div id="action-buttons" class="btn-group">
|
||||
<button type="button" class="btn btn-default cancel-button cancel-callback" data-dismiss="modal">
|
||||
<i class="fa fa-times-circle"></i>
|
||||
@ -498,6 +537,8 @@ echo mfh_get_hidden_fields_for_language(array(
|
||||
'aaoff',
|
||||
'cat_private',
|
||||
'cat_public',
|
||||
'cat_removed',
|
||||
'error_deleting_category',
|
||||
));
|
||||
|
||||
require_once(HESK_PATH . 'inc/footer.inc.php');
|
||||
|
@ -5,6 +5,8 @@ $(document).ready(function() {
|
||||
bindEditModal();
|
||||
bindModalCancelCallback();
|
||||
bindFormSubmit();
|
||||
bindDeleteButton();
|
||||
bindCreateModal();
|
||||
});
|
||||
|
||||
|
||||
@ -165,15 +167,54 @@ function bindEditModal() {
|
||||
|
||||
$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"]').val(element.autoAssign);
|
||||
$modal.find('input[name="type"]').val(element.type);
|
||||
$modal.find('input[name="autoassign"][value="' + (element.autoAssign ? 1 : 0) + '"]')
|
||||
.prop('checked', 'checked');
|
||||
$modal.find('input[name="type"][value="' + (element.type ? 1 : 0) + '"]');
|
||||
$modal.find('textarea[name="description"]').val(element.description === null ? '' : element.description);
|
||||
|
||||
$modal.modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
function bindCreateModal() {
|
||||
$('#create-button').click(function() {
|
||||
var $modal = $('#category-modal');
|
||||
$modal.find('#edit-label').hide();
|
||||
$modal.find('#create-label').show();
|
||||
|
||||
$modal.find('input[name="name"]').val('');
|
||||
$modal.find('select[name="priority"]').val(3); // Low priority
|
||||
$modal.find('select[name="usage"]').val(0); // Tickets and events
|
||||
$modal.find('input[name="id"]').val(-1);
|
||||
$modal.find('textarea[name="description"]').val('');
|
||||
$modal.find('input[name="cat-order"]').val('');
|
||||
$modal.find('input[name="type"][value="0"]').prop('checked', 'checked');
|
||||
$modal.find('input[name="autoassign"][value="0"]').prop('checked', 'checked');
|
||||
$modal.find('input[name="display-border"][value="0"]')
|
||||
.prop('checked', 'checked');
|
||||
|
||||
var colorpickerOptions = {
|
||||
format: 'hex',
|
||||
color: '#fff'
|
||||
};
|
||||
$modal.find('input[name="background-color"]')
|
||||
.colorpicker(colorpickerOptions).end().modal('show');
|
||||
$modal.find('input[name="background-color"]').val('');
|
||||
$modal.find('input[name="foreground-color"]')
|
||||
.colorpicker(colorpickerOptions).end().modal('show');
|
||||
$modal.find('input[name="foreground-color"]').val('');
|
||||
|
||||
$modal.modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
function bindModalCancelCallback() {
|
||||
$('.cancel-callback').click(function() {
|
||||
var $editCategoryModal = $('#category-modal');
|
||||
@ -182,6 +223,8 @@ function bindModalCancelCallback() {
|
||||
$editCategoryModal.find('input[name="foreground-color"]').val('').colorpicker('destroy').end();
|
||||
$editCategoryModal.find('input[name="display-border"][value="1"]').prop('checked');
|
||||
$editCategoryModal.find('input[name="display-border"][value="0"]').prop('checked');
|
||||
$editCategoryModal.find('input[name="autoassign"][value="1"]').prop('checked');
|
||||
$editCategoryModal.find('input[name="autoassign"][value="0"]').prop('checked');
|
||||
});
|
||||
}
|
||||
|
||||
@ -244,4 +287,31 @@ function bindFormSubmit() {
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function bindDeleteButton() {
|
||||
$(document).on('click', '[data-action="delete"]', function() {
|
||||
$('#overlay').show();
|
||||
|
||||
var heskUrl = $('p#hesk-path').text();
|
||||
var element = categories[$(this).parent().parent().find('[data-property="id"]').text()];
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: heskUrl + 'api/index.php/v1/categories/' + element.id,
|
||||
headers: {
|
||||
'X-Internal-Call': true,
|
||||
'X-HTTP-Method-Override': 'DELETE'
|
||||
},
|
||||
success: function() {
|
||||
mfhAlert.success(mfhLang.text('cat_removed'));
|
||||
loadTable();
|
||||
},
|
||||
error: function(data) {
|
||||
$('#overlay').hide();
|
||||
mfhAlert.errorWithLog(mfhLang.text('error_deleting_category'), data.responseJSON);
|
||||
console.error(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
@ -2173,6 +2173,9 @@ $hesklang['url_rewrite_help'] = 'Remove the need to include /index.php in API UR
|
||||
$hesklang['url_rewrite_saved'] = 'URL rewrite setting saved!';
|
||||
$hesklang['api_settings_saved'] = 'API settings saved!';
|
||||
$hesklang['an_error_occurred'] = 'An error occurred. Check the logs for more information';
|
||||
$hesklang['error_deleting_category'] = 'An error occurred when trying to delete the category.';
|
||||
$hesklang['cat_private'] = 'Private';
|
||||
$hesklang['cat_public'] = 'Public';
|
||||
|
||||
// DO NOT CHANGE BELOW
|
||||
if (!defined('IN_SCRIPT')) die('PHP syntax OK!');
|
||||
|
Loading…
x
Reference in New Issue
Block a user