mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 21:25:42 +00:00 
			
		
		
		
	no message
This commit is contained in:
		| @@ -31,25 +31,25 @@ | ||||
| </div> | ||||
| {% endif %} | ||||
|  | ||||
| <div id='button-toolbar'> | ||||
| <div id='button-toolbar' class="btn-group" role="group" aria-label="..."> | ||||
|     {% if editing_enabled %} | ||||
|     <div class='btn-group' style='float: right;'> | ||||
|         <button class='btn btn-info' type='button' id='bom-item-new'>New BOM Item</button> | ||||
|         <button class='btn btn-success' type='button' id='editing-finished'>Finish Editing</button> | ||||
|     </div> | ||||
|     <button class='btn btn-danger' type='button' title='Remove selected BOM items' id='bom-item-delete'><span class='glyphicon glyphicon-trash'></span></button> | ||||
|     <button class='btn btn-primary' type='button' title='New BOM Item' id='bom-item-new'><span class='glyphicon glyphicon-plus'></span></button> | ||||
|     <button class='btn btn-success' type='button' title='Finish Editing' id='editing-finished'><span class='glyphicon glyphicon-ok'></span></button> | ||||
|     {% else %} | ||||
|     <div class='dropdown' style="float: right;"> | ||||
|         <button class='btn btn-primary dropdown-toggle' type='button' data-toggle='dropdown'> | ||||
|             Options | ||||
|             <span class='caret'></span> | ||||
|         </button> | ||||
|         <ul class='dropdown-menu'> | ||||
|             {% if part.is_bom_valid == False %} | ||||
|             <li><a href='#' id='validate-bom' title='Validate BOM'>Validate BOM</a></li> | ||||
|             {% endif %} | ||||
|             <li><a href='#' id='edit-bom' title='Edit BOM'>Edit BOM</a></li> | ||||
|             <li><a href='#' id='export-bom' title='Export BOM'>Export BOM</a></li> | ||||
|         </ul> | ||||
|     <button class='btn btn-default' type='button' title='Edit BOM' id='edit-bom'><span class='glyphicon glyphicon-edit'></span></button> | ||||
|     {% if part.is_bom_valid == False %} | ||||
|     <button class='btn btn-default' type='button'><span class='glyphicon glyphicon-check'></span></button> | ||||
|     {% endif %} | ||||
|     <div class='btn-group' role='group'> | ||||
|         <div class='dropdown'> | ||||
|             <button title='Export BOM' class='btn btn-default dropdown-toggle' data-toggle='dropdown' type='button'><span class='glyphicon glyphicon-download-alt'></span></button> | ||||
|             <ul class='dropdown-menu'> | ||||
|                 <li><a href='#' class='download-bom' format='csv'>CSV</a></li> | ||||
|                 <li><a href='#' class='download-bom' format='xlsx'>XLSX</a></li> | ||||
|                 <li><a href='#' class='download-bom' format='json'>JSON</a></li> | ||||
|             </ul> | ||||
|         </div> | ||||
|     </div> | ||||
|     {% endif %} | ||||
| </div> | ||||
| @@ -76,6 +76,12 @@ | ||||
|         sub_part_detail: true, | ||||
|     }); | ||||
|  | ||||
|     linkButtonsToSelection($("#bom-table"), | ||||
|         [ | ||||
|             "#bom-item-delete", | ||||
|         ] | ||||
|     ); | ||||
|  | ||||
|     {% if editing_enabled %} | ||||
|     $("#editing-finished").click(function() { | ||||
|         location.href = "{% url 'part-bom' part.id %}"; | ||||
| @@ -115,12 +121,8 @@ | ||||
|         location.href = "{% url 'part-bom' part.id %}?edit=True"; | ||||
|     }); | ||||
|  | ||||
|     $("#export-bom").click(function () { | ||||
|         downloadBom({ | ||||
|             modal: '#modal-form', | ||||
|             url: "{% url 'bom-export' part.id %}" | ||||
|         }); | ||||
|  | ||||
|     $(".download-bom").click(function () { | ||||
|         location.href = "{% url 'bom-export' part.id %}?format=" + $(this).attr('format'); | ||||
|     }); | ||||
|  | ||||
|     {% endif %} | ||||
|   | ||||
| @@ -616,38 +616,6 @@ class BomValidate(AjaxUpdateView): | ||||
|         return self.renderJsonResponse(request, form, data, context=self.get_context()) | ||||
|  | ||||
|  | ||||
| class BomExport(AjaxView): | ||||
|  | ||||
|     model = Part | ||||
|     ajax_form_title = 'Export BOM' | ||||
|     ajax_template_name = 'part/bom_export.html' | ||||
|     form_class = part_forms.BomExportForm | ||||
|  | ||||
|     def get_object(self): | ||||
|         return get_object_or_404(Part, pk=self.kwargs['pk']) | ||||
|  | ||||
|     def get(self, request, *args, **kwargs): | ||||
|         form = self.form_class() | ||||
|  | ||||
|         return self.renderJsonResponse(request, form) | ||||
|  | ||||
|     def post(self, request, *args, **kwargs): | ||||
|         """ | ||||
|         User has now submitted the BOM export data | ||||
|         """ | ||||
|  | ||||
|         # part = self.get_object() | ||||
|  | ||||
|         return super(AjaxView, self).post(request, *args, **kwargs) | ||||
|  | ||||
|     def get_data(self): | ||||
|         return { | ||||
|             # 'form_valid': True, | ||||
|             # 'redirect': '/' | ||||
|             # 'redirect': reverse('bom-download', kwargs={'pk': self.request.GET.get('pk')}) | ||||
|         } | ||||
|  | ||||
|  | ||||
| class BomDownload(AjaxView): | ||||
|     """ | ||||
|     Provide raw download of a BOM file. | ||||
|   | ||||
| @@ -12,52 +12,6 @@ function reloadBomTable(table, options) { | ||||
| } | ||||
|  | ||||
|  | ||||
| function downloadBom(options = {}) { | ||||
|  | ||||
|     var modal = options.modal || "#modal-form"; | ||||
|      | ||||
|     var content = ` | ||||
|         <b>Select file format</b><br> | ||||
|         <div class='controls'> | ||||
|         <select id='bom-format' class='select'> | ||||
|             <option value='csv'>CSV</option> | ||||
|             <option value='tsv'>TSV</option> | ||||
|             <option value='xls'>XLS</option> | ||||
|             <option value='xlsx'>XLSX</option> | ||||
|             <option value='ods'>ODS</option> | ||||
|             <option value='yaml'>YAML</option> | ||||
|             <option value='json'>JSON</option> | ||||
|             <option value='xml'>XML</option> | ||||
|             <option value='html'>HTML</option> | ||||
|         </select> | ||||
|         </div> | ||||
|     `; | ||||
|  | ||||
|     openModal({ | ||||
|         modal: modal, | ||||
|         title: "Export Bill of Materials", | ||||
|         submit_text: "Download", | ||||
|         close_text: "Cancel", | ||||
|     }); | ||||
|  | ||||
|     modalSetContent(modal, content); | ||||
|  | ||||
|     modalEnable(modal, true); | ||||
|  | ||||
|     $(modal).on('click', '#modal-form-submit', function() { | ||||
|         $(modal).modal('hide'); | ||||
|  | ||||
|         var format = $(modal).find('#bom-format :selected').val(); | ||||
|  | ||||
|         if (options.url) { | ||||
|             var url = options.url + "?format=" + format; | ||||
|  | ||||
|             location.href = url; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
|  | ||||
|  | ||||
| function loadBomTable(table, options) { | ||||
|     /* Load a BOM table with some configurable options. | ||||
|      *  | ||||
| @@ -192,7 +146,7 @@ function loadBomTable(table, options) { | ||||
|                 var bEdit = "<button title='Edit BOM Item' class='bom-edit-button btn btn-default btn-glyph' type='button' url='/part/bom/" + row.pk + "/edit'><span class='glyphicon glyphicon-edit'/></button>"; | ||||
|                 var bDelt = "<button title='Delete BOM Item' class='bom-delete-button btn btn-default btn-glyph' type='button' url='/part/bom/" + row.pk + "/delete'><span class='glyphicon glyphicon-trash'/></button>"; | ||||
|                  | ||||
|                 return "<div class='btn-group'>" + bEdit + bDelt + "</div>"; | ||||
|                 return "<div class='btn-group' role='group'>" + bEdit + bDelt + "</div>"; | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user