diff --git a/web/dispatch.php b/web/dispatch.php index 6733f2d7..36788a21 100644 --- a/web/dispatch.php +++ b/web/dispatch.php @@ -1,5 +1,7 @@ 1) { + var confirmed = confirm('You were editing other entries and those changes will be discarded. Click cancel if you want to save updated entries before adding new one.'); + if (!confirmed) { + return true; + } + else { + var values = App.Helpers.getFormValues(elm); + if(App.Validate.form(values, $('#'+elm_id))) { + App.Model.add(values, source); + var form_id = App.Constants[App.Env.world + '_FORM_ID']; + $('#'+form_id).remove(); + } + } } } else { // OLD ITEM, UPDATING IT diff --git a/web/js/model.js b/web/js/model.js index be0f8a28..65053e54 100644 --- a/web/js/model.js +++ b/web/js/model.js @@ -82,6 +82,7 @@ App.Model.CRON.loadList = function(callback) App.Model.add = function(values, source_json) { var method = App.Settings.getMethodName('add'); + App.Ajax.request(method, { spell: $.toJSON(values) }, function(reply){ @@ -89,12 +90,7 @@ App.Model.add = function(values, source_json) App.Helpers.Warn('Changes were not applied ' + App.Helpers.toJSON(reply.errors) ); } else { - /*var build_method = App.Env.getWorldName() + '_entry'; - var tpl = App.HTML.Build[build_method](values, 'new'); - App.Ref.CONTENT..replaceWith(tpl);*/ - // todo: reply.data; App.Pages.prepareHTML(); - App.Helpers.updateScreen(); } }); }