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_form_title = 'Edit Company'
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'info': 'Edited company information',
|
||||
}
|
||||
|
||||
|
||||
class CompanyCreate(AjaxCreateView):
|
||||
model = Company
|
||||
@ -52,9 +57,19 @@ class CompanyCreate(AjaxCreateView):
|
||||
ajax_template_name = 'modal_form.html'
|
||||
ajax_form_title = "Create new Company"
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'success': "Created new company",
|
||||
}
|
||||
|
||||
|
||||
class CompanyDelete(AjaxDeleteView):
|
||||
model = Company
|
||||
success_url = '/company/'
|
||||
template_name = 'company/delete.html'
|
||||
ajax_form_title = 'Delete Company'
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'danger': 'Company was deleted',
|
||||
}
|
||||
|
@ -99,7 +99,8 @@
|
||||
$('#delete-part').click(function() {
|
||||
launchDeleteForm("#modal-delete",
|
||||
"{% 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 %}
|
||||
|
@ -52,6 +52,11 @@ class PartCreate(AjaxCreateView):
|
||||
ajax_form_title = 'Create new part'
|
||||
ajax_template_name = 'modal_form.html'
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'success': "Created new part",
|
||||
}
|
||||
|
||||
def get_category_id(self):
|
||||
return self.request.GET.get('category', None)
|
||||
|
||||
@ -108,13 +113,10 @@ class PartDelete(AjaxDeleteView):
|
||||
|
||||
success_url = '/part/'
|
||||
|
||||
"""
|
||||
def post(self, request, *args, **kwargs):
|
||||
if 'confirm' in request.POST:
|
||||
return super(PartDelete, self).post(request, *args, **kwargs)
|
||||
else:
|
||||
return HttpResponseRedirect(self.get_object().get_absolute_url())
|
||||
"""
|
||||
def get_data(self):
|
||||
return {
|
||||
'danger': 'Part was deleted',
|
||||
}
|
||||
|
||||
|
||||
class CategoryDetail(DetailView):
|
||||
@ -145,6 +147,11 @@ class CategoryDelete(AjaxDeleteView):
|
||||
context_object_name = 'category'
|
||||
success_url = '/part/'
|
||||
|
||||
def get_data(self):
|
||||
return {
|
||||
'danger': 'Part category was deleted',
|
||||
}
|
||||
|
||||
|
||||
class CategoryCreate(AjaxCreateView):
|
||||
model = PartCategory
|
||||
|
@ -9,7 +9,7 @@ function showAlert(target, message, timeout=5000) {
|
||||
|
||||
function showAlertOrCache(alertType, message, cache, timeout=5000) {
|
||||
if (cache) {
|
||||
sessionStorage.setItem(alertType, message);
|
||||
sessionStorage.setItem("inventree-" + alertType, message);
|
||||
}
|
||||
else {
|
||||
showAlert('#' + alertType, message, timeout);
|
||||
@ -19,26 +19,26 @@ function showAlertOrCache(alertType, message, cache, timeout=5000) {
|
||||
function showCachedAlerts() {
|
||||
|
||||
// Success Message
|
||||
if (sessionStorage.getItem("alert-success")) {
|
||||
showAlert("#alert-success", sessionStorage.getItem("alert-success"));
|
||||
sessionStorage.removeItem("alert-success");
|
||||
if (sessionStorage.getItem("inventree-alert-success")) {
|
||||
showAlert("#alert-success", sessionStorage.getItem("inventree-alert-success"));
|
||||
sessionStorage.removeItem("inventree-alert-success");
|
||||
}
|
||||
|
||||
// Info Message
|
||||
if (sessionStorage.getItem("alert-info")) {
|
||||
showAlert("#alert-info", sessionStorage.getItem("alert-info"));
|
||||
sessionStorage.removeItem("alert-info");
|
||||
if (sessionStorage.getItem("inventree-alert-info")) {
|
||||
showAlert("#alert-info", sessionStorage.getItem("inventree-alert-info"));
|
||||
sessionStorage.removeItem("inventree-alert-info");
|
||||
}
|
||||
|
||||
// Warning Message
|
||||
if (sessionStorage.getItem("alert-warning")) {
|
||||
showAlert("#alert-warning", sessionStorage.getItem("alert-warning"));
|
||||
sessionStorage.removeItem("alert-warning");
|
||||
if (sessionStorage.getItem("inventree-alert-warning")) {
|
||||
showAlert("#alert-warning", sessionStorage.getItem("inventree-alert-warning"));
|
||||
sessionStorage.removeItem("inventree-alert-warning");
|
||||
}
|
||||
|
||||
// Danger Message
|
||||
if (sessionStorage.getItem("alert-danger")) {
|
||||
showAlert("#alert-danger", sessionStorage.getItem("alert-danger"));
|
||||
sessionStorage.removeItem("alert-danger");
|
||||
if (sessionStorage.getItem("inventree-alert-danger")) {
|
||||
showAlert("#alert-danger", sessionStorage.getItem("inventree-alert-danger"));
|
||||
sessionStorage.removeItem("inventree-alert-danger");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user