mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Consolidated modal code
- Default modal passed down through the chain
This commit is contained in:
		| @@ -65,7 +65,9 @@ function closeModal(modal='#modal-form') { | |||||||
|     $(modal).modal('hide'); |     $(modal).modal('hide'); | ||||||
| } | } | ||||||
|  |  | ||||||
| function openModal(modal, title='', content='') { | function openModal(options) { | ||||||
|  |  | ||||||
|  |     var modal = options.modal || '#modal-form'; | ||||||
|  |  | ||||||
|     $(modal).on('shown.bs.modal', function() { |     $(modal).on('shown.bs.modal', function() { | ||||||
|         $(modal + ' .modal-form-content').scrollTop(0); |         $(modal + ' .modal-form-content').scrollTop(0); | ||||||
| @@ -83,8 +85,17 @@ function openModal(modal, title='', content='') { | |||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     modalSetTitle(modal, title); |     if (options.title) { | ||||||
|     modalSetContent(modal, content); |         modalSetTitle(modal, options.title); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (options.content) { | ||||||
|  |         modalSetContent(modal, options.content); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (options.buttonText) { | ||||||
|  |         modalSetButtonText(modal, options.buttonText); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     $(modal).modal({ |     $(modal).modal({ | ||||||
|         backdrop: 'static', |         backdrop: 'static', | ||||||
| @@ -111,7 +122,7 @@ function launchDeleteForm(url, options = {}) { | |||||||
|         type: 'get', |         type: 'get', | ||||||
|         dataType: 'json', |         dataType: 'json', | ||||||
|         beforeSend: function() { |         beforeSend: function() { | ||||||
|             openModal(modal); |             openModal({modal: modal}); | ||||||
|         }, |         }, | ||||||
|         success: function (response) { |         success: function (response) { | ||||||
|             if (response.title) { |             if (response.title) { | ||||||
| @@ -232,7 +243,7 @@ function launchModalForm(url, options = {}) { | |||||||
|         type: 'get', |         type: 'get', | ||||||
|         dataType: 'json', |         dataType: 'json', | ||||||
|         beforeSend: function () { |         beforeSend: function () { | ||||||
|             openModal(modal); |             openModal({modal: modal}); | ||||||
|         }, |         }, | ||||||
|         success: function(response) { |         success: function(response) { | ||||||
|             if (response.title) { |             if (response.title) { | ||||||
| @@ -245,7 +256,7 @@ function launchModalForm(url, options = {}) { | |||||||
|  |  | ||||||
|             if (response.html_form) { |             if (response.html_form) { | ||||||
|                 injectModalForm(modal, response.html_form); |                 injectModalForm(modal, response.html_form); | ||||||
|                 handleModalForm(modal, url, options); |                 handleModalForm(url, options); | ||||||
|  |  | ||||||
|             } else { |             } else { | ||||||
|                 alert('JSON response missing form data'); |                 alert('JSON response missing form data'); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user