mirror of
https://github.com/itflow-org/itflow
synced 2026-11-11 07:01:16 +00:00
Restore the ability to manually typc a value in select boxes with data-tags=true including add ticket watcher
This commit is contained in:
@@ -288,7 +288,7 @@ ob_start();
|
||||
<label>Additional Assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="additional_assets[]" data-tags="true" data-placeholder="- Select Additional Assets -" multiple>
|
||||
<select class="form-select select2" name="additional_assets[]" data-placeholder="- Select Additional Assets -" multiple>
|
||||
<option value=""></option>
|
||||
<?php
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ ob_start();
|
||||
<label>Additional Assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="additional_assets[]" data-tags="true" data-placeholder="- Select Additional Assets -" multiple>
|
||||
<select class="form-select select2" name="additional_assets[]" data-placeholder="- Select Additional Assets -" multiple>
|
||||
<option value=""></option>
|
||||
<?php
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ ob_start();
|
||||
<label>Additional Assets</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-desktop"></i></span>
|
||||
<select class="form-select select2" name="additional_assets[]" data-tags="true" data-placeholder="- Select Additional Assets -" multiple>
|
||||
<select class="form-select select2" name="additional_assets[]" data-placeholder="- Select Additional Assets -" multiple>
|
||||
<option value=""></option>
|
||||
<?php
|
||||
|
||||
|
||||
@@ -95,6 +95,10 @@ if (isset($_POST['add_ticket'])) {
|
||||
// Add Watchers
|
||||
if (isset($_POST['watchers'])) {
|
||||
foreach ($_POST['watchers'] as $watcher) {
|
||||
// Watchers is free-entry, so anything can arrive here - same check add_ticket_watcher makes
|
||||
if (!filter_var($watcher, FILTER_VALIDATE_EMAIL)) {
|
||||
continue;
|
||||
}
|
||||
$watcher_email = escapeSql($watcher);
|
||||
mysqli_query($mysqli, "INSERT INTO ticket_watchers SET watcher_email = '$watcher_email', watcher_ticket_id = $ticket_id");
|
||||
}
|
||||
|
||||
@@ -61,8 +61,22 @@ function initTomSelect(el, options) {
|
||||
if (el.tagName !== 'SELECT' && el.tagName !== 'INPUT') {
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* data-tags="true" is the select2 attribute for "the user can type a value
|
||||
* that is not in the list". select2 read data-* attributes as options on
|
||||
* its own, so the old bare $('.select2').select2() honoured it with no
|
||||
* code; Tom Select does not, and every data-tags field quietly became a
|
||||
* pick-from-list-only control in the migration (ticket watchers, trip
|
||||
* destination, client referral, invoice scope, default start page).
|
||||
*
|
||||
* createOnBlur commits whatever is typed when focus leaves the control, so
|
||||
* typing an address and clicking the modal's submit button posts it,
|
||||
* rather than posting the empty value because Enter was never pressed.
|
||||
*/
|
||||
var tags = el.getAttribute('data-tags') === 'true';
|
||||
var settings = Object.assign({
|
||||
create: false,
|
||||
create: tags,
|
||||
createOnBlur: tags,
|
||||
allowEmptyOption: true,
|
||||
plugins: el.multiple ? ['remove_button'] : [],
|
||||
placeholder: el.getAttribute('data-placeholder') || undefined
|
||||
|
||||
Reference in New Issue
Block a user