From 3b168047c45cb2c3982e9cb6d510f9382af96ec3 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Fri, 1 Mar 2019 17:06:32 +0700 Subject: [PATCH] Fix domain datatable. #468 --- app/templates/domain.html | 11 +++++++++-- app/templates/template_edit.html | 13 ++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/templates/domain.html b/app/templates/domain.html index 68c9e15..d7e4ebc 100644 --- a/app/templates/domain.html +++ b/app/templates/domain.html @@ -68,14 +68,14 @@ {% if domain.type != 'Slave' %} {% if record.is_allowed_edit() %} - + {% else %} {% endif %} {% if record.is_allowed_delete() %} - + {% endif %} {% else %} @@ -201,6 +201,13 @@ // handle apply changes button $(document.body).on("click",".button_apply_changes", function() { + if (nNew || nEditing) { + var modal = $("#modal_error"); + modal.find('.modal-body p').text("Previous record not saved. Please save it before applying the changes."); + modal.modal('show'); + return; + } + var modal = $("#modal_apply_changes"); var table = $("#tbl_records").DataTable(); var domain = $(this).prop('id'); diff --git a/app/templates/template_edit.html b/app/templates/template_edit.html index 5983a34..bba6f67 100644 --- a/app/templates/template_edit.html +++ b/app/templates/template_edit.html @@ -48,7 +48,7 @@ {% for record in records %} - + {{ record.name }} @@ -65,12 +65,12 @@ {{ record.data }} - - @@ -187,6 +187,13 @@ // handle apply changes button $(document.body).on("click",".button_apply_changes", function() { + if (nNew || nEditing) { + var modal = $("#modal_error"); + modal.find('.modal-body p').text("Previous record not saved. Please save it before applying the changes."); + modal.modal('show'); + return; + } + var modal = $("#modal_apply_changes"); var table = $("#tbl_records").DataTable(); var template = $(this).prop('id');