Timezone warning / add entry no-reload

This commit is contained in:
Malishev Dmitry 2011-12-29 16:38:42 +03:00
parent 511703fa3e
commit 79699b83be
3 changed files with 16 additions and 10 deletions

View file

@ -1,5 +1,7 @@
<?php <?php
date_default_timezone_set('Europe/Moscow');
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vesta/core/utils/error_logger.php'; require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vesta/core/utils/error_logger.php';
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vesta/app.init.php'; require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vesta/app.init.php';

View file

@ -252,6 +252,12 @@ App.Actions.save_form = function(evt) {
} }
if (elm.attr('id') == App.Constants[elm_id]) { // NEW ITEM if (elm.attr('id') == App.Constants[elm_id]) { // NEW ITEM
if ($('.b-new-entry').length > 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); var values = App.Helpers.getFormValues(elm);
if(App.Validate.form(values, $('#'+elm_id))) { if(App.Validate.form(values, $('#'+elm_id))) {
App.Model.add(values, source); App.Model.add(values, source);
@ -259,6 +265,8 @@ App.Actions.save_form = function(evt) {
$('#'+form_id).remove(); $('#'+form_id).remove();
} }
} }
}
}
else { // OLD ITEM, UPDATING IT else { // OLD ITEM, UPDATING IT
var source = $(elm).find('.source').val(); var source = $(elm).find('.source').val();
var values = App.Helpers.getFormValues(elm); var values = App.Helpers.getFormValues(elm);

View file

@ -82,6 +82,7 @@ App.Model.CRON.loadList = function(callback)
App.Model.add = function(values, source_json) App.Model.add = function(values, source_json)
{ {
var method = App.Settings.getMethodName('add'); var method = App.Settings.getMethodName('add');
App.Ajax.request(method, { App.Ajax.request(method, {
spell: $.toJSON(values) spell: $.toJSON(values)
}, function(reply){ }, 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) ); App.Helpers.Warn('Changes were not applied ' + App.Helpers.toJSON(reply.errors) );
} }
else { 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.Pages.prepareHTML();
App.Helpers.updateScreen();
} }
}); });
} }