mirror of
https://github.com/itflow-org/itflow
synced 2026-09-07 23:35:13 +00:00
All Jquery removed replaced with stand JS and non jqery dependent libs
This commit is contained in:
@@ -460,18 +460,24 @@ ob_start();
|
||||
</form>
|
||||
|
||||
<!-- JSON Autocomplete / type ahead -->
|
||||
<link rel="stylesheet" href="/libs/jquery-ui/jquery-ui.min.css">
|
||||
<script src="/libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
var operatingSystems = <?= $json_os ?>;
|
||||
$("#os").autocomplete({
|
||||
source: operatingSystems, // Should be an array of objects with 'label' and 'value'
|
||||
select: function(event, ui) {
|
||||
$("#os").val(ui.item.label); // Set the input field value to the selected label
|
||||
return false;
|
||||
|
||||
var osInput = document.getElementById('os');
|
||||
if (!osInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
itflowAutocomplete(osInput, {
|
||||
minLength: 1,
|
||||
source: operatingSystems,
|
||||
onSelect: function (item) {
|
||||
osInput.value = item.label;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -296,17 +296,23 @@ function generatePassword() {
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.authMethod').on('change', function() {
|
||||
var $form = $(this).closest('.authForm');
|
||||
if ($(this).val() === 'local') {
|
||||
$form.find('.passwordGroup').show();
|
||||
} else {
|
||||
$form.find('.passwordGroup').hide();
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
function syncAuthForm(select) {
|
||||
var form = select.closest('.authForm');
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
$('.authMethod').trigger('change');
|
||||
form.querySelectorAll('.passwordGroup').forEach(function (group) {
|
||||
group.style.display = select.value === 'local' ? '' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll('.authMethod').forEach(function (select) {
|
||||
select.addEventListener('change', function () {
|
||||
syncAuthForm(this);
|
||||
});
|
||||
syncAuthForm(select);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -336,17 +336,23 @@ function generatePassword() {
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.authMethod').on('change', function() {
|
||||
var $form = $(this).closest('.authForm');
|
||||
if ($(this).val() === 'local') {
|
||||
$form.find('.passwordGroup').show();
|
||||
} else {
|
||||
$form.find('.passwordGroup').hide();
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
function syncAuthForm(select) {
|
||||
var form = select.closest('.authForm');
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
$('.authMethod').trigger('change');
|
||||
form.querySelectorAll('.passwordGroup').forEach(function (group) {
|
||||
group.style.display = select.value === 'local' ? '' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll('.authMethod').forEach(function (select) {
|
||||
select.addEventListener('change', function () {
|
||||
syncAuthForm(this);
|
||||
});
|
||||
syncAuthForm(select);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -248,8 +248,6 @@ ob_start();
|
||||
|
||||
|
||||
<!-- Recurring Ticket Client/Contact JS -->
|
||||
<link rel="stylesheet" href="/libs/jquery-ui/jquery-ui.min.css">
|
||||
<script src="/libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="/agent/js/tickets_add_modal.js"></script>
|
||||
|
||||
<script src="/agent/js/ticket_tasks_modal.js"></script>
|
||||
|
||||
@@ -285,8 +285,6 @@ ob_start();
|
||||
|
||||
|
||||
<!-- Ticket Client/Contact JS -->
|
||||
<link rel="stylesheet" href="/libs/jquery-ui/jquery-ui.min.css">
|
||||
<script src="/libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="/agent/js/tickets_add_modal.js"></script>
|
||||
|
||||
<script src="/agent/js/ticket_tasks_modal.js"></script>
|
||||
|
||||
@@ -19,18 +19,30 @@ ob_start();
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$.ajax({
|
||||
url: 'ajax.php?ai_ticket_summary',
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var target = document.getElementById('summaryContent');
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch('ajax.php?ai_ticket_summary', {
|
||||
method: 'POST',
|
||||
data: { ticket_id: <?= $ticket_id ?> },
|
||||
success: function(response) {
|
||||
$('#summaryContent').html(response);
|
||||
},
|
||||
error: function() {
|
||||
$('#summaryContent').html('Error generating summary.');
|
||||
}
|
||||
});
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
credentials: 'same-origin',
|
||||
body: new URLSearchParams({ ticket_id: '<?= $ticket_id ?>' }).toString()
|
||||
})
|
||||
.then(function (res) {
|
||||
if (!res.ok) {
|
||||
throw new Error('HTTP ' + res.status);
|
||||
}
|
||||
return res.text();
|
||||
})
|
||||
.then(function (html) {
|
||||
target.innerHTML = html;
|
||||
})
|
||||
.catch(function () {
|
||||
target.textContent = 'Error generating summary.';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -81,57 +81,93 @@ ob_start();
|
||||
|
||||
<!-- JS to make the correct boxes appear depending on if internal/client approval) -->
|
||||
<script>
|
||||
$('#approval_scope').on('change', function() {
|
||||
const scope = $(this).val();
|
||||
const typeSelect = $('#approval_type');
|
||||
const wrapper = $('#approval_type_wrapper');
|
||||
(function () {
|
||||
var scopeSelect = document.getElementById('approval_scope');
|
||||
var typeSelect = document.getElementById('approval_type');
|
||||
var typeWrapper = document.getElementById('approval_type_wrapper');
|
||||
var userWrapper = document.getElementById('specific_user_wrapper');
|
||||
var userSelect = document.getElementById('specific_user_select');
|
||||
|
||||
typeSelect.empty();
|
||||
$('#specific_user_wrapper').addClass('d-none');
|
||||
|
||||
if (!scope) {
|
||||
wrapper.addClass('d-none');
|
||||
if (!scopeSelect || !typeSelect) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.removeClass('d-none');
|
||||
|
||||
if (scope === 'internal') {
|
||||
typeSelect.append('<option value="">Select...</option>');
|
||||
typeSelect.append('<option value="any">Any internal reviewer</option>');
|
||||
typeSelect.append('<option value="specific">Specific agent</option>');
|
||||
}
|
||||
|
||||
if (scope === 'client') {
|
||||
typeSelect.append('<option value="">Select...</option>');
|
||||
typeSelect.append('<option value="any">Ticket contact</option>');
|
||||
typeSelect.append('<option value="technical">Technical contacts</option>');
|
||||
typeSelect.append('<option value="billing">Billing contacts</option>');
|
||||
}
|
||||
});
|
||||
|
||||
// Specific user (internal only for now)
|
||||
$('#approval_type').on('change', function() {
|
||||
const type = $(this).val();
|
||||
const scope = $('#approval_scope').val();
|
||||
const userSelect = $('#specific_user_select');
|
||||
|
||||
if (type !== 'specific' || scope !== 'internal') {
|
||||
$('#specific_user_wrapper').addClass('d-none');
|
||||
return;
|
||||
}
|
||||
|
||||
$('#specific_user_wrapper').removeClass('d-none');
|
||||
userSelect.empty().append('<option value="">Loading...</option>');
|
||||
|
||||
$.getJSON('ajax.php?get_internal_users=true', function(data) {
|
||||
userSelect.empty().append('<option value="">Select user...</option>');
|
||||
data.users.forEach(function(u) {
|
||||
userSelect.append(`<option value="${u.user_id}">${u.user_name}</option>`);
|
||||
function setOptions(select, pairs) {
|
||||
select.innerHTML = '';
|
||||
pairs.forEach(function (pair) {
|
||||
// new Option() assigns text, so nothing here is parsed as markup
|
||||
select.appendChild(new Option(pair[1], pair[0]));
|
||||
});
|
||||
});
|
||||
});
|
||||
// the selects are Tom Select enhanced, so it has to re-read them
|
||||
refreshTomSelect(select);
|
||||
}
|
||||
|
||||
scopeSelect.addEventListener('change', function () {
|
||||
var scope = this.value;
|
||||
|
||||
setOptions(typeSelect, []);
|
||||
userWrapper.classList.add('d-none');
|
||||
|
||||
if (!scope) {
|
||||
typeWrapper.classList.add('d-none');
|
||||
return;
|
||||
}
|
||||
|
||||
typeWrapper.classList.remove('d-none');
|
||||
|
||||
if (scope === 'internal') {
|
||||
setOptions(typeSelect, [
|
||||
['', 'Select...'],
|
||||
['any', 'Any internal reviewer'],
|
||||
['specific', 'Specific agent']
|
||||
]);
|
||||
}
|
||||
|
||||
if (scope === 'client') {
|
||||
setOptions(typeSelect, [
|
||||
['', 'Select...'],
|
||||
['any', 'Ticket contact'],
|
||||
['technical', 'Technical contacts'],
|
||||
['billing', 'Billing contacts']
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
// Specific user (internal only for now)
|
||||
typeSelect.addEventListener('change', function () {
|
||||
var type = this.value;
|
||||
var scope = scopeSelect.value;
|
||||
|
||||
if (type !== 'specific' || scope !== 'internal') {
|
||||
userWrapper.classList.add('d-none');
|
||||
return;
|
||||
}
|
||||
|
||||
userWrapper.classList.remove('d-none');
|
||||
setOptions(userSelect, [['', 'Loading...']]);
|
||||
|
||||
fetch('ajax.php?get_internal_users=true', {
|
||||
headers: { 'Accept': 'application/json' },
|
||||
credentials: 'same-origin'
|
||||
})
|
||||
.then(function (res) {
|
||||
if (!res.ok) {
|
||||
throw new Error('HTTP ' + res.status);
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
var pairs = [['', 'Select user...']];
|
||||
data.users.forEach(function (u) {
|
||||
pairs.push([u.user_id, u.user_name]);
|
||||
});
|
||||
setOptions(userSelect, pairs);
|
||||
})
|
||||
.catch(function () {
|
||||
setOptions(userSelect, [['', 'Failed to load users']]);
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user