mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Added modal form success messages
- More to be done, just a start - Create / edit / delete
This commit is contained in:
parent
a2c1eda5c0
commit
a9c20f5d95
@ -43,6 +43,11 @@ class CompanyEdit(AjaxUpdateView):
|
|||||||
ajax_template_name = 'modal_form.html'
|
ajax_template_name = 'modal_form.html'
|
||||||
ajax_form_title = 'Edit Company'
|
ajax_form_title = 'Edit Company'
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
return {
|
||||||
|
'info': 'Edited company information',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class CompanyCreate(AjaxCreateView):
|
class CompanyCreate(AjaxCreateView):
|
||||||
model = Company
|
model = Company
|
||||||
@ -52,9 +57,19 @@ class CompanyCreate(AjaxCreateView):
|
|||||||
ajax_template_name = 'modal_form.html'
|
ajax_template_name = 'modal_form.html'
|
||||||
ajax_form_title = "Create new Company"
|
ajax_form_title = "Create new Company"
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
return {
|
||||||
|
'success': "Created new company",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class CompanyDelete(AjaxDeleteView):
|
class CompanyDelete(AjaxDeleteView):
|
||||||
model = Company
|
model = Company
|
||||||
success_url = '/company/'
|
success_url = '/company/'
|
||||||
template_name = 'company/delete.html'
|
template_name = 'company/delete.html'
|
||||||
ajax_form_title = 'Delete Company'
|
ajax_form_title = 'Delete Company'
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
return {
|
||||||
|
'danger': 'Company was deleted',
|
||||||
|
}
|
||||||
|
@ -99,7 +99,8 @@
|
|||||||
$('#delete-part').click(function() {
|
$('#delete-part').click(function() {
|
||||||
launchDeleteForm("#modal-delete",
|
launchDeleteForm("#modal-delete",
|
||||||
"{% url 'part-delete' part.id %}",
|
"{% url 'part-delete' part.id %}",
|
||||||
{redirect: "{% url 'part-index' %}"}
|
{
|
||||||
);
|
redirect: {% if part.category %}"{% url 'category-detail' part.category.id %}"{% else %}"{% url 'part-index' %}"}{% endif %}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -52,6 +52,11 @@ class PartCreate(AjaxCreateView):
|
|||||||
ajax_form_title = 'Create new part'
|
ajax_form_title = 'Create new part'
|
||||||
ajax_template_name = 'modal_form.html'
|
ajax_template_name = 'modal_form.html'
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
return {
|
||||||
|
'success': "Created new part",
|
||||||
|
}
|
||||||
|
|
||||||
def get_category_id(self):
|
def get_category_id(self):
|
||||||
return self.request.GET.get('category', None)
|
return self.request.GET.get('category', None)
|
||||||
|
|
||||||
@ -108,13 +113,10 @@ class PartDelete(AjaxDeleteView):
|
|||||||
|
|
||||||
success_url = '/part/'
|
success_url = '/part/'
|
||||||
|
|
||||||
"""
|
def get_data(self):
|
||||||
def post(self, request, *args, **kwargs):
|
return {
|
||||||
if 'confirm' in request.POST:
|
'danger': 'Part was deleted',
|
||||||
return super(PartDelete, self).post(request, *args, **kwargs)
|
}
|
||||||
else:
|
|
||||||
return HttpResponseRedirect(self.get_object().get_absolute_url())
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class CategoryDetail(DetailView):
|
class CategoryDetail(DetailView):
|
||||||
@ -145,6 +147,11 @@ class CategoryDelete(AjaxDeleteView):
|
|||||||
context_object_name = 'category'
|
context_object_name = 'category'
|
||||||
success_url = '/part/'
|
success_url = '/part/'
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
return {
|
||||||
|
'danger': 'Part category was deleted',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class CategoryCreate(AjaxCreateView):
|
class CategoryCreate(AjaxCreateView):
|
||||||
model = PartCategory
|
model = PartCategory
|
||||||
|
@ -9,7 +9,7 @@ function showAlert(target, message, timeout=5000) {
|
|||||||
|
|
||||||
function showAlertOrCache(alertType, message, cache, timeout=5000) {
|
function showAlertOrCache(alertType, message, cache, timeout=5000) {
|
||||||
if (cache) {
|
if (cache) {
|
||||||
sessionStorage.setItem(alertType, message);
|
sessionStorage.setItem("inventree-" + alertType, message);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
showAlert('#' + alertType, message, timeout);
|
showAlert('#' + alertType, message, timeout);
|
||||||
@ -19,26 +19,26 @@ function showAlertOrCache(alertType, message, cache, timeout=5000) {
|
|||||||
function showCachedAlerts() {
|
function showCachedAlerts() {
|
||||||
|
|
||||||
// Success Message
|
// Success Message
|
||||||
if (sessionStorage.getItem("alert-success")) {
|
if (sessionStorage.getItem("inventree-alert-success")) {
|
||||||
showAlert("#alert-success", sessionStorage.getItem("alert-success"));
|
showAlert("#alert-success", sessionStorage.getItem("inventree-alert-success"));
|
||||||
sessionStorage.removeItem("alert-success");
|
sessionStorage.removeItem("inventree-alert-success");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info Message
|
// Info Message
|
||||||
if (sessionStorage.getItem("alert-info")) {
|
if (sessionStorage.getItem("inventree-alert-info")) {
|
||||||
showAlert("#alert-info", sessionStorage.getItem("alert-info"));
|
showAlert("#alert-info", sessionStorage.getItem("inventree-alert-info"));
|
||||||
sessionStorage.removeItem("alert-info");
|
sessionStorage.removeItem("inventree-alert-info");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warning Message
|
// Warning Message
|
||||||
if (sessionStorage.getItem("alert-warning")) {
|
if (sessionStorage.getItem("inventree-alert-warning")) {
|
||||||
showAlert("#alert-warning", sessionStorage.getItem("alert-warning"));
|
showAlert("#alert-warning", sessionStorage.getItem("inventree-alert-warning"));
|
||||||
sessionStorage.removeItem("alert-warning");
|
sessionStorage.removeItem("inventree-alert-warning");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Danger Message
|
// Danger Message
|
||||||
if (sessionStorage.getItem("alert-danger")) {
|
if (sessionStorage.getItem("inventree-alert-danger")) {
|
||||||
showAlert("#alert-danger", sessionStorage.getItem("alert-danger"));
|
showAlert("#alert-danger", sessionStorage.getItem("inventree-alert-danger"));
|
||||||
sessionStorage.removeItem("alert-danger");
|
sessionStorage.removeItem("inventree-alert-danger");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user