Hi there, I was a developer in a previous life so I'm not adverse to writing a bit of PHP or JavaScript but just need a bit of advice where to start. I would like to implement the following little quality of life change for new tickets:

  1. Agent clicks to create a new ticket
  2. Use the "Lookup or Create User" dialog to select a user
  3. On click of "continue" or "create new user" the user details are populated "Subject" text field is highlighted/focussed

As the functionality needs to hook off this new user function I'm not sure exactly where it would be best to implement? Are there client events to hook into with JS or could anyone suggest another way?

Many thanks in advance

Olly

  • Figured it out, it is all in ticket-open.inc.php. All the page load stuff is at the bottom of the file. I made the following edit around line 513:

    <?php
    } else { ?>
    setTimeout(function() {
    $('#dynamic-form input[type=text]')[0].focus();
    }, 500);
    <?php
    } ?>

    All the usual caveats apply around making edits like this to your source code, dont do it unless you have a vague idea what you're doing and be aware it will all break when you update your OsTicket

I'm really close now I think but not quite there. I can (nearly) get it to do it by hacking about with ticket-open.inc.php.

There are a few lines like the below:

<tr id="userRow">
<td width="120"><?php echo __('User'); ?>:</td>
<td>
<span>
<select class="userSelection" name="name" id="user-name"
data-placeholder="<?php echo __('Select User'); ?>">
</select>
</span>

            <a class="inline button" style="overflow:inherit" href="#"
            onclick="javascript:
            $.userLookup('ajax.php/users/lookup/form', function (user) {

The userLookup control passes a callback function as above and you can add a line to do the focus:

//OLLY
$('#dynamic-form input[type=text]')[0].focus();

Which highlights the first text fields in the response zone which is great.

The problem I'm having is that this only works when changing user and doesn't seem to fire with the userlookup that appears when the page first loads. Does anyone know where the code is for this one?

As a further update I've discovered the "user-lookup.tmpl.php" file but I can't seem to get anything to trigger off here so still at a dead end

Figured it out, it is all in ticket-open.inc.php. All the page load stuff is at the bottom of the file. I made the following edit around line 513:

<?php
} else { ?>
setTimeout(function() {
$('#dynamic-form input[type=text]')[0].focus();
}, 500);
<?php
} ?>

All the usual caveats apply around making edits like this to your source code, dont do it unless you have a vague idea what you're doing and be aware it will all break when you update your OsTicket

Write a Reply...