From 4bdfe78c24d4374fae338d3e0c8088ed89f12644 Mon Sep 17 00:00:00 2001 From: Toni Pinel Date: Tue, 26 May 2015 11:51:18 +0200 Subject: [PATCH] Reactivate master language if error --- .../public/js/modules/on-off-table.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Elcodi/Admin/CoreBundle/Resources/public/js/modules/on-off-table.js b/src/Elcodi/Admin/CoreBundle/Resources/public/js/modules/on-off-table.js index bb441ce7..91e93cf9 100644 --- a/src/Elcodi/Admin/CoreBundle/Resources/public/js/modules/on-off-table.js +++ b/src/Elcodi/Admin/CoreBundle/Resources/public/js/modules/on-off-table.js @@ -1,9 +1,17 @@ FrontendCore.define('on-off-table', ['devicePackage' ], function () { return { + oMasterLanguage : '', + setMasterLanguage: function() { + this.oMasterLanguage = $('[name=language-master]:checked')[0]; + }, onStart: function () { FrontendCore.requireAndStart('notification'); + var self = this; + + self.setMasterLanguage(); + $('.switch input').each( function(){ var oTarget = this; @@ -15,8 +23,10 @@ FrontendCore.define('on-off-table', ['devicePackage' ], function () { sUrl = this.checked === true ? document.getElementById('enable-' + this.id).value : document.getElementById('disable-' + this.id).value; $.ajax({ - url: sUrl, - type: 'post' + url: sUrl, + type: 'post' + }).done( function() { + self.setMasterLanguage(); }).fail( function( response ) { if ( sValue === true ) { @@ -25,6 +35,10 @@ FrontendCore.define('on-off-table', ['devicePackage' ], function () { oInput.checked = true; } + if ( oInput.name === 'language-master' ) { + self.oMasterLanguage.checked = true; + } + var sMessage = response.responseJSON.message !== undefined ? response.responseJSON.message : 'Sorry, something was wrong.'; FrontendMediator.publish( 'notification', { type : 'ko', message: sMessage } );