mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 20:46:47 +00:00
Refactorin'
This commit is contained in:
parent
2f1dea1123
commit
3ff19f8c75
@ -237,11 +237,6 @@ function constructForm(url, options) {
|
|||||||
// Default HTTP method
|
// Default HTTP method
|
||||||
options.method = options.method || 'PATCH';
|
options.method = options.method || 'PATCH';
|
||||||
|
|
||||||
// Create a new modal if one does not exists
|
|
||||||
if (!options.modal) {
|
|
||||||
options.modal = createNewModal();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request OPTIONS endpoint from the API
|
// Request OPTIONS endpoint from the API
|
||||||
getApiEndpointOptions(url, function(OPTIONS) {
|
getApiEndpointOptions(url, function(OPTIONS) {
|
||||||
|
|
||||||
@ -396,17 +391,15 @@ function constructFormBody(fields, options) {
|
|||||||
// TODO: Dynamically create the modals,
|
// TODO: Dynamically create the modals,
|
||||||
// so that we can have an infinite number of stacks!
|
// so that we can have an infinite number of stacks!
|
||||||
|
|
||||||
options.modal = options.modal || '#modal-form';
|
// Create a new modal if one does not exists
|
||||||
|
if (!options.modal) {
|
||||||
|
options.modal = createNewModal(options);
|
||||||
|
}
|
||||||
|
|
||||||
var modal = options.modal;
|
var modal = options.modal;
|
||||||
|
|
||||||
modalEnable(modal, true);
|
modalEnable(modal, true);
|
||||||
|
|
||||||
// Set the form title and button labels
|
|
||||||
modalSetTitle(modal, options.title || '{% trans "Form Title" %}');
|
|
||||||
modalSetSubmitText(modal, options.submitText || '{% trans "Submit" %}');
|
|
||||||
modalSetCloseText(modal, options.cancelText || '{% trans "Cancel" %}');
|
|
||||||
|
|
||||||
// Insert generated form content
|
// Insert generated form content
|
||||||
$(modal).find('.modal-form-content').html(html);
|
$(modal).find('.modal-form-content').html(html);
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ function createNewModal(options={}) {
|
|||||||
</div>
|
</div>
|
||||||
<div class='modal-footer'>
|
<div class='modal-footer'>
|
||||||
<div id='modal-footer-buttons'></div>
|
<div id='modal-footer-buttons'></div>
|
||||||
<button type='button' class='btn btn-default' id='modal-form-cancel' data-dismiss='modal'>{% trans "Cancel" %}</button>
|
<button type='button' class='btn btn-default' id='modal-form-close' data-dismiss='modal'>{% trans "Cancel" %}</button>
|
||||||
<button type='button' class='btn btn-primary' id='modal-form-submit'>{% trans "Submit" %}</button>
|
<button type='button' class='btn btn-primary' id='modal-form-submit'>{% trans "Submit" %}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -48,6 +48,11 @@ function createNewModal(options={}) {
|
|||||||
$(modal_name).remove();
|
$(modal_name).remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set labels based on supplied options
|
||||||
|
modalSetTitle(modal_name, options.title || '{% trans "Form Title" %}');
|
||||||
|
modalSetSubmitText(modal_name, options.submitText || '{% trans "Submit" %}');
|
||||||
|
modalSetCloseText(modal_name, options.cancelText || '{% trans "Cancel" %}');
|
||||||
|
|
||||||
// Return the "name" of the modal
|
// Return the "name" of the modal
|
||||||
return modal_name;
|
return modal_name;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user