Store instance data when performing an "update"

This commit is contained in:
Oliver 2021-06-28 09:28:38 +10:00
parent 0e9b82c475
commit 6335372208
2 changed files with 9 additions and 2 deletions

View File

@ -155,6 +155,9 @@ function constructChangeForm(fields, options) {
} }
} }
// Store the entire data object
options.instance = data;
constructFormBody(fields, options); constructFormBody(fields, options);
}, },
error: function(request, status, error) { error: function(request, status, error) {
@ -570,7 +573,7 @@ function initializeRelatedFields(fields, options) {
* - field: Field definition from the OPTIONS request * - field: Field definition from the OPTIONS request
* - options: Original options object provided by the client * - options: Original options object provided by the client
*/ */
function initializeRelatedField(modal, name, field, options) { function initializeRelatedField(name, field, options) {
// Find the select element and attach a select2 to it // Find the select element and attach a select2 to it
var select = $(options.modal).find(`#id_${name}`); var select = $(options.modal).find(`#id_${name}`);

View File

@ -1,3 +1,5 @@
{% load i18n %}
/* /*
* This file contains functions for rendering various InvenTree database models, * This file contains functions for rendering various InvenTree database models,
* in particular for displaying them in modal forms in a 'select2' context. * in particular for displaying them in modal forms in a 'select2' context.
@ -69,12 +71,14 @@ function renderPart(name, data, parameters, options) {
// Renderer for "PartCategory" model // Renderer for "PartCategory" model
function renderPartCategory(name, data, parameters, options) { function renderPartCategory(name, data, parameters, options) {
var html = `<span>${data.name}</span>`; var html = `<span><b>${data.name}</b></span>`;
if (data.description) { if (data.description) {
html += ` - <i>${data.description}</i>`; html += ` - <i>${data.description}</i>`;
} }
html += `<span class='float-right'>{% trans "Location ID" %}: ${data.pk}</span>`;
if (data.pathstring) { if (data.pathstring) {
html += `<p><small>${data.pathstring}</small></p>`; html += `<p><small>${data.pathstring}</small></p>`;
} }