mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Modal fixes
This commit is contained in:
parent
8cd8581dbf
commit
141b764b94
@ -246,7 +246,7 @@ class PurchaseOrderLineItemSerializer(InvenTreeModelSerializer):
|
|||||||
total_price = serializers.FloatField(read_only=True)
|
total_price = serializers.FloatField(read_only=True)
|
||||||
|
|
||||||
part_detail = PartBriefSerializer(source='get_base_part', many=False, read_only=True)
|
part_detail = PartBriefSerializer(source='get_base_part', many=False, read_only=True)
|
||||||
|
|
||||||
supplier_part_detail = SupplierPartSerializer(source='part', many=False, read_only=True)
|
supplier_part_detail = SupplierPartSerializer(source='part', many=False, read_only=True)
|
||||||
|
|
||||||
purchase_price = InvenTreeMoneySerializer(
|
purchase_price = InvenTreeMoneySerializer(
|
||||||
|
@ -129,7 +129,7 @@ function constructBomUploadTable(data, options={}) {
|
|||||||
|
|
||||||
var modal = createNewModal({
|
var modal = createNewModal({
|
||||||
title: '{% trans "Row Data" %}',
|
title: '{% trans "Row Data" %}',
|
||||||
cancelText: '{% trans "Close" %}',
|
closeText: '{% trans "Close" %}',
|
||||||
hideSubmitButton: true
|
hideSubmitButton: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -617,7 +617,7 @@ function bomSubstitutesDialog(bom_item_id, substitutes, options={}) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
preFormContent: html,
|
preFormContent: html,
|
||||||
cancelText: '{% trans "Close" %}',
|
closeText: '{% trans "Close" %}',
|
||||||
submitText: '{% trans "Add Substitute" %}',
|
submitText: '{% trans "Add Substitute" %}',
|
||||||
title: '{% trans "Edit BOM Item Substitutes" %}',
|
title: '{% trans "Edit BOM Item Substitutes" %}',
|
||||||
afterRender: function(fields, opts) {
|
afterRender: function(fields, opts) {
|
||||||
|
@ -85,12 +85,25 @@ function createNewModal(options={}) {
|
|||||||
|
|
||||||
var modal_name = `#modal-form-${id}`;
|
var modal_name = `#modal-form-${id}`;
|
||||||
|
|
||||||
|
// Callback *after* the modal has been rendered
|
||||||
$(modal_name).on('shown.bs.modal', function() {
|
$(modal_name).on('shown.bs.modal', function() {
|
||||||
$(modal_name + ' .modal-form-content').scrollTop(0);
|
$(modal_name + ' .modal-form-content').scrollTop(0);
|
||||||
|
|
||||||
if (options.focus) {
|
if (options.focus) {
|
||||||
getFieldByName(modal_name, options.focus).focus();
|
getFieldByName(modal_name, options.focus).focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Steal keyboard focus
|
||||||
|
$(modal_name).focus();
|
||||||
|
|
||||||
|
if (options.hideCloseButton) {
|
||||||
|
$(modal_name).find('#modal-form-cancel').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.preventSubmit || options.hideSubmitButton) {
|
||||||
|
$(modal_name).find('#modal-form-submit').hide();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Automatically remove the modal when it is deleted!
|
// Automatically remove the modal when it is deleted!
|
||||||
@ -102,8 +115,11 @@ function createNewModal(options={}) {
|
|||||||
$(modal_name).on('keydown', 'input', function(event) {
|
$(modal_name).on('keydown', 'input', function(event) {
|
||||||
if (event.keyCode == 13) {
|
if (event.keyCode == 13) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
// Simulate a click on the 'Submit' button
|
|
||||||
$(modal_name).find('#modal-form-submit').click();
|
if (!options.preventSubmit) {
|
||||||
|
// Simulate a click on the 'Submit' button
|
||||||
|
$(modal_name).find('#modal-form-submit').click();
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -117,18 +133,7 @@ function createNewModal(options={}) {
|
|||||||
// Set labels based on supplied options
|
// Set labels based on supplied options
|
||||||
modalSetTitle(modal_name, options.title || '{% trans "Form Title" %}');
|
modalSetTitle(modal_name, options.title || '{% trans "Form Title" %}');
|
||||||
modalSetSubmitText(modal_name, options.submitText || '{% trans "Submit" %}');
|
modalSetSubmitText(modal_name, options.submitText || '{% trans "Submit" %}');
|
||||||
modalSetCloseText(modal_name, options.cancelText || '{% trans "Cancel" %}');
|
modalSetCloseText(modal_name, options.closeText || '{% trans "Cancel" %}');
|
||||||
|
|
||||||
if (options.hideSubmitButton) {
|
|
||||||
$(modal_name).find('#modal-form-submit').hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.hideCloseButton) {
|
|
||||||
$(modal_name).find('#modal-form-cancel').hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Steal keyboard focus
|
|
||||||
$(modal_name).focus();
|
|
||||||
|
|
||||||
// Return the "name" of the modal
|
// Return the "name" of the modal
|
||||||
return modal_name;
|
return modal_name;
|
||||||
@ -581,7 +586,7 @@ function showAlertDialog(title, content, options={}) {
|
|||||||
|
|
||||||
var modal = createNewModal({
|
var modal = createNewModal({
|
||||||
title: title,
|
title: title,
|
||||||
cancelText: '{% trans "Close" %}',
|
closeText: '{% trans "Close" %}',
|
||||||
hideSubmitButton: true,
|
hideSubmitButton: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -607,7 +612,7 @@ function showQuestionDialog(title, content, options={}) {
|
|||||||
var modal = createNewModal({
|
var modal = createNewModal({
|
||||||
title: title,
|
title: title,
|
||||||
submitText: options.accept_text || '{% trans "Accept" %}',
|
submitText: options.accept_text || '{% trans "Accept" %}',
|
||||||
cancelText: options.cancel_text || '{% trans "Cancel" %}',
|
closeText: options.cancel_text || '{% trans "Cancel" %}',
|
||||||
});
|
});
|
||||||
|
|
||||||
modalSetContent(modal, content);
|
modalSetContent(modal, content);
|
||||||
|
@ -625,7 +625,8 @@ function orderParts(parts_list, options={}) {
|
|||||||
constructFormBody({}, {
|
constructFormBody({}, {
|
||||||
preFormContent: html,
|
preFormContent: html,
|
||||||
title: '{% trans "Order Parts" %}',
|
title: '{% trans "Order Parts" %}',
|
||||||
hideSubmitButton: true,
|
preventSubmit: true,
|
||||||
|
closeText: '{% trans "Close" %}',
|
||||||
afterRender: function(fields, opts) {
|
afterRender: function(fields, opts) {
|
||||||
// TODO
|
// TODO
|
||||||
parts.forEach(function(part) {
|
parts.forEach(function(part) {
|
||||||
|
Loading…
Reference in New Issue
Block a user