diff --git a/InvenTree/part/templates/part/bom.html b/InvenTree/part/templates/part/bom.html index 90d7dd4b61..1f019bd205 100644 --- a/InvenTree/part/templates/part/bom.html +++ b/InvenTree/part/templates/part/bom.html @@ -86,6 +86,7 @@ { _pk: row.pk, _title: 'Quantity', + enabled: {{ editing_enabled }}, } ); } @@ -101,6 +102,7 @@ _pk: row.pk, _title: 'Note', _empty: 'Enter note', + enabled: {{ editing_enabled }}, }); } }, @@ -127,29 +129,6 @@ url: "{% url 'api-bom-list' %}" }); - /* - $('#bom-table').on('click', '.delete-button', function () { - var button = $(this); - - launchDeleteForm( - button.attr('url'), - { - success: reloadBom - }); - }); - - $("#bom-table").on('click', '.edit-button', function () { - var button = $(this); - - launchModalForm( - button.attr('url'), - { - success: reloadBom - }); - - }); - */ - {% if editing_enabled %} $("#editing-finish").click(function() { alert("Finished!"); @@ -161,9 +140,6 @@ location.href = "{% url 'part-bom' part.id %}"; }); - // Inline mode - //$.fn.editable.defaults.mode = 'inline'; - $("#bom-table").on('load-success.bs.table', function() { // Make the table elements editable $("#bom-table").find('.editable-item').editable(); diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index f956c28ddc..13cb274a7c 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -95,9 +95,9 @@ class PartDetail(DetailView): context = super(PartDetail, self).get_context_data(**kwargs) if str(self.request.GET.get('edit', None)) == '1': - context['editing_enabled'] = True + context['editing_enabled'] = 1 else: - context['editing_enabled'] = False + context['editing_enabled'] = 0 return context diff --git a/InvenTree/static/script/tables.js b/InvenTree/static/script/tables.js index 0d3f129273..13bb6dc7b9 100644 --- a/InvenTree/static/script/tables.js +++ b/InvenTree/static/script/tables.js @@ -25,8 +25,16 @@ function renderEditable(text, options) { * _empty - placeholder text to show when field is empty * _class - html class (default = 'editable-item') * _id - id + * + * And some further parameters: + * enabled - if 1 or true, render the editable. + * otherwise, just return the supplied text */ + if (!options.enabled) { + return text; + } + // Default values (if not supplied) var _type = options._type || 'text'; var _class = options._class || 'editable-item';