File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed
Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 11<?php
22
3+ date_default_timezone_set ('Europe/Moscow ' );
4+
35require dirname (__FILE__ ) . DIRECTORY_SEPARATOR . 'vesta/core/utils/error_logger.php ' ;
46require dirname (__FILE__ ) . DIRECTORY_SEPARATOR . 'vesta/app.init.php ' ;
57
Original file line number Diff line number Diff line change @@ -252,11 +252,19 @@ App.Actions.save_form = function(evt) {
252252 }
253253
254254 if ( elm . attr ( 'id' ) == App . Constants [ elm_id ] ) { // NEW ITEM
255- var values = App . Helpers . getFormValues ( elm ) ;
256- if ( App . Validate . form ( values , $ ( '#' + elm_id ) ) ) {
257- App . Model . add ( values , source ) ;
258- var form_id = App . Constants [ App . Env . world + '_FORM_ID' ] ;
259- $ ( '#' + form_id ) . remove ( ) ;
255+ if ( $ ( '.b-new-entry' ) . length > 1 ) {
256+ 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.' ) ;
257+ if ( ! confirmed ) {
258+ return true ;
259+ }
260+ else {
261+ var values = App . Helpers . getFormValues ( elm ) ;
262+ if ( App . Validate . form ( values , $ ( '#' + elm_id ) ) ) {
263+ App . Model . add ( values , source ) ;
264+ var form_id = App . Constants [ App . Env . world + '_FORM_ID' ] ;
265+ $ ( '#' + form_id ) . remove ( ) ;
266+ }
267+ }
260268 }
261269 }
262270 else { // OLD ITEM, UPDATING IT
Original file line number Diff line number Diff line change @@ -82,19 +82,15 @@ App.Model.CRON.loadList = function(callback)
8282App . Model . add = function ( values , source_json )
8383{
8484 var method = App . Settings . getMethodName ( 'add' ) ;
85+
8586 App . Ajax . request ( method , {
8687 spell : $ . toJSON ( values )
8788 } , function ( reply ) {
8889 if ( ! reply . result ) {
8990 App . Helpers . Warn ( 'Changes were not applied ' + App . Helpers . toJSON ( reply . errors ) ) ;
9091 }
9192 else {
92- /*var build_method = App.Env.getWorldName() + '_entry';
93- var tpl = App.HTML.Build[build_method](values, 'new');
94- App.Ref.CONTENT..replaceWith(tpl);*/
95- // todo: reply.data;
9693 App . Pages . prepareHTML ( ) ;
97- App . Helpers . updateScreen ( ) ;
9894 }
9995 } ) ;
10096}
You can’t perform that action at this time.
0 commit comments