mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
Simplified modal calls
- Default modal target supplied (can be overridden in options)
This commit is contained in:
parent
c5155d5ac7
commit
3f1c6e2059
@ -83,16 +83,14 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
$("#edit-build").click(function () {
|
$("#edit-build").click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm("{% url 'build-edit' build.id %}",
|
||||||
"{% url 'build-edit' build.id %}",
|
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#cancel-build").click(function() {
|
$("#cancel-build").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm("{% url 'build-cancel' build.id %}",
|
||||||
"{% url 'build-cancel' build.id %}",
|
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
});
|
});
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
$("#new-build").click(function() {
|
$("#new-build").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'build-create' %}",
|
"{% url 'build-create' %}",
|
||||||
{
|
{
|
||||||
follow: true
|
follow: true
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
|
|
||||||
$("#company-thumb").click(function() {
|
$("#company-thumb").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'company-image' company.id %}",
|
"{% url 'company-image' company.id %}",
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
$('#edit-company').click(function() {
|
$('#edit-company').click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'company-edit' company.id %}",
|
"{% url 'company-edit' company.id %}",
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
@ -54,7 +54,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#delete-company').click(function() {
|
$('#delete-company').click(function() {
|
||||||
launchDeleteForm("#modal-delete",
|
launchDeleteForm(
|
||||||
"{% url 'company-delete' company.id %}",
|
"{% url 'company-delete' company.id %}",
|
||||||
{
|
{
|
||||||
redirect: "{% url 'company-index' %}"
|
redirect: "{% url 'company-index' %}"
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
$("#part-create").click(function () {
|
$("#part-create").click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'supplier-part-create' %}",
|
"{% url 'supplier-part-create' %}",
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
$('#part-edit').click(function () {
|
$('#part-edit').click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'supplier-part-edit' part.id %}",
|
"{% url 'supplier-part-edit' part.id %}",
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
@ -50,7 +50,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#part-delete').click(function() {
|
$('#part-delete').click(function() {
|
||||||
launchDeleteForm("#modal-delete",
|
launchDeleteForm(
|
||||||
"{% url 'supplier-part-delete' part.id %}",
|
"{% url 'supplier-part-delete' part.id %}",
|
||||||
{
|
{
|
||||||
redirect: "{% url 'company-index' %}"
|
redirect: "{% url 'company-index' %}"
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
$('#bom-table').on('click', '.delete-button', function () {
|
$('#bom-table').on('click', '.delete-button', function () {
|
||||||
var button = $(this);
|
var button = $(this);
|
||||||
|
|
||||||
launchDeleteForm("#modal-delete",
|
launchDeleteForm(
|
||||||
button.attr('url'),
|
button.attr('url'),
|
||||||
{
|
{
|
||||||
success: reloadBom
|
success: reloadBom
|
||||||
@ -38,7 +38,7 @@
|
|||||||
$("#bom-table").on('click', '.edit-button', function () {
|
$("#bom-table").on('click', '.edit-button', function () {
|
||||||
var button = $(this);
|
var button = $(this);
|
||||||
|
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
button.attr('url'),
|
button.attr('url'),
|
||||||
{
|
{
|
||||||
success: reloadBom
|
success: reloadBom
|
||||||
@ -47,7 +47,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#new-bom-item").click(function () {
|
$("#new-bom-item").click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'bom-item-create' %}",
|
"{% url 'bom-item-create' %}",
|
||||||
{
|
{
|
||||||
reload: true,
|
reload: true,
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
$("#start-build").click(function() {
|
$("#start-build").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'build-create' %}",
|
"{% url 'build-create' %}",
|
||||||
{
|
{
|
||||||
follow: true,
|
follow: true,
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
$("#cat-create").click(function() {
|
$("#cat-create").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'category-create' %}",
|
"{% url 'category-create' %}",
|
||||||
{
|
{
|
||||||
follow: true,
|
follow: true,
|
||||||
@ -66,7 +66,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
$("#part-create").click(function() {
|
$("#part-create").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'part-create' %}",
|
"{% url 'part-create' %}",
|
||||||
{
|
{
|
||||||
follow: true,
|
follow: true,
|
||||||
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
{% if category %}
|
{% if category %}
|
||||||
$("#cat-edit").click(function () {
|
$("#cat-edit").click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'category-edit' category.id %}",
|
"{% url 'category-edit' category.id %}",
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
@ -96,8 +96,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
$('#cat-delete').click(function() {
|
$('#cat-delete').click(function() {
|
||||||
launchDeleteForm('#modal-delete',
|
launchDeleteForm("{% url 'category-delete' category.id %}",
|
||||||
"{% url 'category-delete' category.id %}",
|
|
||||||
{
|
{
|
||||||
redirect: redirect
|
redirect: redirect
|
||||||
});
|
});
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
$("#edit-part").click(function() {
|
$("#edit-part").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'part-edit' part.id %}",
|
"{% url 'part-edit' part.id %}",
|
||||||
{
|
{
|
||||||
reload: true,
|
reload: true,
|
||||||
@ -110,7 +110,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#delete-part').click(function() {
|
$('#delete-part').click(function() {
|
||||||
launchDeleteForm("#modal-delete",
|
launchDeleteForm(
|
||||||
"{% url 'part-delete' part.id %}",
|
"{% url 'part-delete' part.id %}",
|
||||||
{
|
{
|
||||||
redirect: {% if part.category %}"{% url 'category-detail' part.category.id %}"{% else %}"{% url 'part-index' %}"{% endif %}
|
redirect: {% if part.category %}"{% url 'category-detail' part.category.id %}"{% else %}"{% url 'part-index' %}"{% endif %}
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
$("#part-thumb").click(function() {
|
$("#part-thumb").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'part-image' part.id %}",
|
"{% url 'part-image' part.id %}",
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
$('#add-stock-item').click(function () {
|
$('#add-stock-item').click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'stock-item-create' %}",
|
"{% url 'stock-item-create' %}",
|
||||||
{
|
{
|
||||||
reload: true,
|
reload: true,
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
$('#supplier-create').click(function () {
|
$('#supplier-create').click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'supplier-part-create' %}",
|
"{% url 'supplier-part-create' %}",
|
||||||
{
|
{
|
||||||
reload: true,
|
reload: true,
|
||||||
|
@ -94,12 +94,22 @@ function openModal(modal, title='', content='') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function launchDeleteForm(modal, url, options = {}) {
|
function launchDeleteForm(url, options = {}) {
|
||||||
|
|
||||||
|
var modal = '#modal-delete';
|
||||||
|
|
||||||
|
if (options.modal) {
|
||||||
|
modal = options.modal;
|
||||||
|
}
|
||||||
|
|
||||||
$(modal).on('shown.bs.modal', function() {
|
$(modal).on('shown.bs.modal', function() {
|
||||||
$(modal + ' .modal-form-content').scrollTop(0);
|
$(modal + ' .modal-form-content').scrollTop(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Un-bind any attached click listeners
|
||||||
|
$(modal).off('click', '#modal-form-delete');
|
||||||
|
|
||||||
|
// Request delete form data
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
type: 'get',
|
type: 'get',
|
||||||
@ -125,9 +135,6 @@ function launchDeleteForm(modal, url, options = {}) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Un-bind any attached click listeners
|
|
||||||
$(modal).off('click', '#modal-form-delete');
|
|
||||||
|
|
||||||
$(modal).on('click', '#modal-form-delete', function() {
|
$(modal).on('click', '#modal-form-delete', function() {
|
||||||
|
|
||||||
var form = $(modal).find('#delete-form');
|
var form = $(modal).find('#delete-form');
|
||||||
@ -155,7 +162,13 @@ function injectModalForm(modal, form_html) {
|
|||||||
attachSelect(modal);
|
attachSelect(modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleModalForm(modal, url, options) {
|
function handleModalForm(url, options) {
|
||||||
|
|
||||||
|
var modal = '#modal-form';
|
||||||
|
|
||||||
|
if (options.modal) {
|
||||||
|
modal = options.modal;
|
||||||
|
}
|
||||||
|
|
||||||
var form = $(modal).find('.js-modal-form');
|
var form = $(modal).find('.js-modal-form');
|
||||||
|
|
||||||
@ -217,7 +230,13 @@ function handleModalForm(modal, url, options) {
|
|||||||
* Opens a model window and fills it with a requested form
|
* Opens a model window and fills it with a requested form
|
||||||
* If the form is loaded successfully, calls handleModalForm
|
* If the form is loaded successfully, calls handleModalForm
|
||||||
*/
|
*/
|
||||||
function launchModalForm(modal, url, options = {}) {
|
function launchModalForm(url, options = {}) {
|
||||||
|
|
||||||
|
var modal = '#modal-form';
|
||||||
|
|
||||||
|
if (options.modal) {
|
||||||
|
modal = options.modal;
|
||||||
|
}
|
||||||
|
|
||||||
// Form the ajax request to retrieve the django form data
|
// Form the ajax request to retrieve the django form data
|
||||||
ajax_data = {
|
ajax_data = {
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
$("#stock-edit").click(function () {
|
$("#stock-edit").click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'stock-item-edit' item.id %}",
|
"{% url 'stock-item-edit' item.id %}",
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
@ -141,7 +141,7 @@
|
|||||||
|
|
||||||
{% if item.in_stock %}
|
{% if item.in_stock %}
|
||||||
$("#stock-move").click(function() {
|
$("#stock-move").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'stock-item-move' item.id %}",
|
"{% url 'stock-item-move' item.id %}",
|
||||||
{
|
{
|
||||||
reload: true,
|
reload: true,
|
||||||
@ -149,7 +149,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#stock-stocktake").click(function() {
|
$("#stock-stocktake").click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm(
|
||||||
"{% url 'stock-item-stocktake' item.id %}",
|
"{% url 'stock-item-stocktake' item.id %}",
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
@ -159,7 +159,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
$("#stock-delete").click(function () {
|
$("#stock-delete").click(function () {
|
||||||
launchDeleteForm("#modal-delete",
|
launchDeleteForm(
|
||||||
"{% url 'stock-item-delete' item.id %}",
|
"{% url 'stock-item-delete' item.id %}",
|
||||||
{
|
{
|
||||||
redirect: "{% url 'part-stock' item.part.id %}"
|
redirect: "{% url 'part-stock' item.part.id %}"
|
||||||
|
@ -65,8 +65,7 @@
|
|||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
$('#location-create').click(function () {
|
$('#location-create').click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm("{% url 'stock-location-create' %}",
|
||||||
"{% url 'stock-location-create' %}",
|
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
{% if location %}
|
{% if location %}
|
||||||
@ -80,8 +79,7 @@
|
|||||||
|
|
||||||
{% if location %}
|
{% if location %}
|
||||||
$('#location-edit').click(function() {
|
$('#location-edit').click(function() {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm("{% url 'stock-location-edit' location.id %}",
|
||||||
"{% url 'stock-location-edit' location.id %}",
|
|
||||||
{
|
{
|
||||||
reload: true
|
reload: true
|
||||||
});
|
});
|
||||||
@ -89,8 +87,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#location-delete').click(function() {
|
$('#location-delete').click(function() {
|
||||||
launchDeleteForm("#modal-delete",
|
launchDeleteForm("{% url 'stock-location-delete' location.id %}",
|
||||||
"{% url 'stock-location-delete' location.id %}",
|
|
||||||
{
|
{
|
||||||
redirect: "{% url 'stock-index' %}"
|
redirect: "{% url 'stock-index' %}"
|
||||||
});
|
});
|
||||||
@ -100,8 +97,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
$('#item-create').click(function () {
|
$('#item-create').click(function () {
|
||||||
launchModalForm("#modal-form",
|
launchModalForm("{% url 'stock-item-create' %}",
|
||||||
"{% url 'stock-item-create' %}",
|
|
||||||
{
|
{
|
||||||
success: function() {
|
success: function() {
|
||||||
$("#stock-table").bootstrapTable('refresh');
|
$("#stock-table").bootstrapTable('refresh');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user