mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add option to focus on a particular field when launching
This commit is contained in:
parent
c7f834e547
commit
746a0210fe
@ -227,6 +227,8 @@ function constructDeleteForm(fields, options) {
|
||||
* options:
|
||||
* - method: The HTTP method e.g. 'PUT', 'POST', 'DELETE' (default='PATCH')
|
||||
* - title: The form title
|
||||
* - submitText: Text for the "submit" button
|
||||
* - closeText: Text for the "close" button
|
||||
* - fields: list of fields to display, with the following options
|
||||
* - filters: API query filters
|
||||
* - onEdit: callback when field is edited
|
||||
@ -237,6 +239,7 @@ function constructDeleteForm(fields, options) {
|
||||
* - hidden: Set to true to hide the field
|
||||
* - icon: font-awesome icon to display before the field
|
||||
* - prefix: Custom HTML prefix to display before the field
|
||||
* - focus: Name of field to focus on when modal is displayed
|
||||
* - preventClose: Set to true to prevent form from closing on success
|
||||
* - onSuccess: callback function when form action is successful
|
||||
* - follow: If a 'url' is provided by the API on success, redirect to it
|
||||
|
@ -3,6 +3,12 @@
|
||||
|
||||
/*
|
||||
* Create and display a new modal dialog
|
||||
*
|
||||
* options:
|
||||
* - title: Form title to render
|
||||
* - submitText: Text to render on 'submit' button (default = "Submit")
|
||||
* - closeText: Text to render on 'close' button (default = "Cancel")
|
||||
* - focus: Name of field to focus on after launching
|
||||
*/
|
||||
function createNewModal(options={}) {
|
||||
|
||||
@ -11,8 +17,8 @@ function createNewModal(options={}) {
|
||||
|
||||
// Check out what modal forms are already being displayed
|
||||
$('.inventree-modal').each(function() {
|
||||
|
||||
var split = this.id.split('-');
|
||||
console.log('existing form:', split);
|
||||
var modal_id = parseInt(split[2]);
|
||||
|
||||
if (modal_id >= id) {
|
||||
@ -64,6 +70,10 @@ function createNewModal(options={}) {
|
||||
|
||||
$(modal_name).on('shown.bs.modal', function() {
|
||||
$(modal_name + ' .modal-form-content').scrollTop(0);
|
||||
|
||||
if (options.focus) {
|
||||
getFieldByName(modal_name, options.focus).focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Automatically remove the modal when it is deleted!
|
||||
|
Loading…
Reference in New Issue
Block a user