2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 05:46:34 +00:00

Move "attachments" and "notes" to "Part Detail" page

(cherry picked from commit daf0a082dc04c04cfd68cab70148a7d7cf28460f)
This commit is contained in:
Oliver
2021-07-12 23:27:11 +10:00
parent 6af05b2b83
commit 77d80f5c0f
3 changed files with 152 additions and 17 deletions

View File

@ -1,6 +1,7 @@
{% extends "part/part_base.html" %}
{% load static %}
{% load i18n %}
{% load markdownify %}
{% block menubar %}
@ -135,11 +136,38 @@
{% endif %}
{% if part.responsible %}
<tr>
<td><span class='fas fa-user'>d</span></td>
<td><span class='fas fa-user'></span></td>
<td><strong>{% trans "Responsible User" %}</strong></td>
<td>{{ part.responsible }}</td>
</tr>
{% endif %}
<tr><td colspan="3"></td></tr>
<tr>
<td><span class='fas fa-sticky-note'></span></td>
<td>
<strong>{% trans "Notes" %}</strong>
</td>
<td>
<div class='btn-group float-right'>
<button type='button' id='edit-notes' title='{% trans "Edit Notes" %}' class='btn btn-small btn-default'>
<span class='fas fa-edit'>
</span>
</button>
</div>
</td>
</tr>
<tr>
<td colspan='3'>
{% if part.notes %}
<div class='notes'>
{{ part.notes | markdownify }}
</div>
{% endif %}
</td>
</tr>
</table>
</div>
<div class='col-sm-6'>
@ -240,23 +268,35 @@
{% block post_content_panel %}
<div class='panel panel-default panel-inventree'>
<div class='panel-heading'>
<h4>
{% trans "Part Parameters" %}
</h4>
</div>
<div class='panel-content'>
<div id='param-button-toolbar'>
<div class='button-toolbar container-fluid' style='float: right;'>
{% if roles.part.add %}
<button title='{% trans "Add new parameter" %}' class='btn btn-success' id='param-create'>
<span class='fas fa-plus-circle'></span> {% trans "New Parameter" %}
</button>
{% endif %}
<div class='row'>
<div class='col-sm-6'>
<div class='panel panel-default panel-inventree'>
<div class='panel-heading'>
<h4>{% trans "Parameters" %}</h4>
</div>
<div class='panel-content'>
<div id='param-button-toolbar'>
<div class='button-toolbar container-fluid' style='float: right;'>
{% if roles.part.add %}
<button title='{% trans "Add new parameter" %}' class='btn btn-success' id='param-create'>
<span class='fas fa-plus-circle'></span> {% trans "New Parameter" %}
</button>
{% endif %}
</div>
</div>
<table id='parameter-table' class='table table-condensed table-striped' data-toolbar="#param-button-toolbar"></table>
</div>
</div>
</div>
<div class='col-sm-6'>
<div class='panel panel-default panel-inventree'>
<div class='panel-heading'>
<h4>{% trans "Attachments" %}</h4>
</div>
<div class='panel-content'>
{% include "attachment_table.html" %}
</div>
</div>
<table id='parameter-table' class='table table-condensed table-striped' data-toolbar="#param-button-toolbar"></table>
</div>
</div>
@ -269,6 +309,18 @@
{% block js_ready %}
{{ block.super }}
$('#edit-notes').click(function() {
constructForm('{% url "api-part-detail" part.pk %}', {
fields: {
notes: {
multiline: true,
}
},
title: '{% trans "Edit Part Notes" %}',
reload: true,
});
});
$(".slidey").change(function() {
var field = $(this).attr('fieldname');
@ -337,4 +389,68 @@
});
});
loadAttachmentTable(
'{% url "api-part-attachment-list" %}',
{
filters: {
part: {{ part.pk }},
},
onEdit: function(pk) {
var url = `/api/part/attachment/${pk}/`;
constructForm(url, {
fields: {
comment: {},
},
title: '{% trans "Edit Attachment" %}',
onSuccess: reloadAttachmentTable,
});
},
onDelete: function(pk) {
var url = `/api/part/attachment/${pk}/`;
constructForm(url, {
method: 'DELETE',
confirmMessage: '{% trans "Confirm Delete Operation" %}',
title: '{% trans "Delete Attachment" %}',
onSuccess: reloadAttachmentTable,
});
}
}
);
enableDragAndDrop(
'#attachment-dropzone',
'{% url "api-part-attachment-list" %}',
{
data: {
part: {{ part.id }},
},
label: 'attachment',
success: function(data, status, xhr) {
reloadAttachmentTable();
}
}
);
$("#new-attachment").click(function() {
constructForm(
'{% url "api-part-attachment-list" %}',
{
method: 'POST',
fields: {
attachment: {},
comment: {},
part: {
value: {{ part.pk }},
hidden: true,
}
},
onSuccess: reloadAttachmentTable,
title: '{% trans "Add Attachment" %}',
}
)
});
{% endblock %}