mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	JS cleanup
This commit is contained in:
		| @@ -1,4 +1,3 @@ | ||||
| {% load i18n %} | ||||
| {% load inventree_extras %} | ||||
|  | ||||
| /* globals | ||||
| @@ -141,6 +140,7 @@ function inventreeDocReady() { | ||||
|                     offset: 0 | ||||
|                 }, | ||||
|                 success: function(data) { | ||||
|  | ||||
|                     var transformed = $.map(data.results, function(el) { | ||||
|                         return { | ||||
|                             label: el.full_name, | ||||
| @@ -168,11 +168,12 @@ function inventreeDocReady() { | ||||
|  | ||||
|                 html += '</span>'; | ||||
|                  | ||||
|                 if (item.data.in_stock > 0) { | ||||
|                     html += `<span class='label label-right label-success'>{% trans "Stock" %}: ${item.data.in_stock}</span>`; | ||||
|                 } else { | ||||
|                     html += `<span class='label label-right label-danger'>{% trans "No Stock" %}</span>`; | ||||
|                 } | ||||
|                 html += partStockLabel( | ||||
|                     item.data, | ||||
|                     { | ||||
|                         label_class: 'label-right', | ||||
|                     } | ||||
|                 ); | ||||
|                  | ||||
|                 html += '</a>'; | ||||
|  | ||||
|   | ||||
| @@ -168,11 +168,7 @@ function renderPart(name, data, parameters, options) { | ||||
|  | ||||
|     // Display available part quantity | ||||
|     if (user_settings.PART_SHOW_QUANTITY_IN_FORMS) { | ||||
|         if (data.in_stock == 0) { | ||||
|             extra += `<span class='label-form label-red'>{% trans "No Stock" %}</span>`; | ||||
|         } else { | ||||
|             extra += `<span class='label-form label-green'>{% trans "Stock" %}: ${data.in_stock}</span>`; | ||||
|         } | ||||
|         extra += partStockLabel(data); | ||||
|     } | ||||
|  | ||||
|     if (!data.active) { | ||||
|   | ||||
| @@ -35,6 +35,7 @@ | ||||
|     loadSellPricingChart, | ||||
|     loadSimplePartTable, | ||||
|     loadStockPricingChart, | ||||
|     partStockLabel, | ||||
|     toggleStar, | ||||
| */ | ||||
|  | ||||
| @@ -409,6 +410,18 @@ function toggleStar(options) { | ||||
| } | ||||
|  | ||||
|  | ||||
| function partStockLabel(part, options={}) { | ||||
|  | ||||
|     var label_class = options.label_class || 'label-form'; | ||||
|  | ||||
|     if (part.in_stock) { | ||||
|         return `<span class='label ${label_class} label-green'>{% trans "Stock" %}: ${part.in_stock}</span>`; | ||||
|     } else { | ||||
|         return `<span class='label ${label_class} label-red'>{% trans "No Stock" %}</span>`; | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| function makePartIcons(part) { | ||||
|     /* Render a set of icons for the given part. | ||||
|      */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user