From 93db8d79db599aac096eaf0a83361ffea4d4d676 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 17 Jul 2013 12:18:32 +0200 Subject: [PATCH] Fix #1339 : Fix admin file upload callback --- lib/Alchemy/Phrasea/Controller/Admin/Root.php | 22 +++++++++++- .../web/admin/collection/collection.html.twig | 7 +--- templates/web/admin/databox/databox.html.twig | 7 +--- templates/web/admin/index.html.twig | 34 ++++++++----------- templates/web/admin/statusbit/edit.html.twig | 3 +- .../web/admin/user/import/file.html.twig | 7 +--- 6 files changed, 39 insertions(+), 41 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Root.php b/lib/Alchemy/Phrasea/Controller/Admin/Root.php index 039d147190..d068654b63 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Root.php @@ -286,8 +286,28 @@ class Root implements ControllerProviderInterface break; } + if (isset($status[$bit])) { + $status = $status[$bit]; + } else { + $status = array( + "labeloff" => '', + "labelon" => '', + "img_off" => '', + "img_on" => '', + "path_off" => '', + "path_on" => '', + "searchable" => false, + "printable" => false, + ); + + foreach ($app['locales.I18n.available'] as $code => $language) { + $status['labels_on'][$code] = null; + $status['labels_off'][$code] = null; + } + } + return $app['twig']->render('admin/statusbit/edit.html.twig', array( - 'status' => isset($status[$bit]) ? $status[$bit] : array(), + 'status' => $status, 'errorMsg' => $errorMsg )); })->assert('databox_id', '\d+') diff --git a/templates/web/admin/collection/collection.html.twig b/templates/web/admin/collection/collection.html.twig index f163d36f20..c612341e60 100644 --- a/templates/web/admin/collection/collection.html.twig +++ b/templates/web/admin/collection/collection.html.twig @@ -323,12 +323,7 @@ $('#right-ajax').empty().addClass('loading'); }, done: function (e, data) { - $('#right-ajax').removeClass('loading').html(data.result); - enableForms($('#right-ajax form:not(.no-ajax)')); - - $.each($('#right-ajax a'),function(i, el){ - enableLink($(el)); - }); + enableFormsCallback(data.result); } }); }); diff --git a/templates/web/admin/databox/databox.html.twig b/templates/web/admin/databox/databox.html.twig index 7f8abbc3c0..2944472308 100644 --- a/templates/web/admin/databox/databox.html.twig +++ b/templates/web/admin/databox/databox.html.twig @@ -385,12 +385,7 @@ $('#right-ajax').empty().addClass('loading'); }, done: function (e, data) { - $('#right-ajax').removeClass('loading').html(data.result); - enableForms($('#right-ajax form:not(.no-ajax)')); - - $.each($('#right-ajax a'),function(i, el){ - enableLink($(el)); - }); + enableFormsCallback(data.result); } }); }); diff --git a/templates/web/admin/index.html.twig b/templates/web/admin/index.html.twig index 010197c466..545b3274ee 100644 --- a/templates/web/admin/index.html.twig +++ b/templates/web/admin/index.html.twig @@ -78,21 +78,24 @@ type: method, url: url, data: datas, - success: function(datas){ - $('#right-ajax').removeClass('loading').html(datas); - enableForms($('#right-ajax form:not(.no-ajax)')); - - $.each($('#right-ajax a'),function(i, el){ - enableLink($(el)); - }); - return; - } + success: enableFormsCallback }); return false; } }); } + function enableFormsCallback(datas) + { + $('#right-ajax').removeClass('loading').html(datas); + enableForms($('#right-ajax form:not(.no-ajax)')); + + $.each($('#right-ajax a'),function(i, el){ + enableLink($(el)); + }); + return; + } + function enableLink(link) { $(link).bind('click',function(event){ @@ -103,11 +106,7 @@ $('#right-ajax').empty().addClass('loading').parent().show(); $.get(dest, function(data) { - $('#right-ajax').removeClass('loading').html(data); - enableForms($('#right-ajax form:not(.no-ajax)')); - $.each($('#right-ajax a:not(.no-ajax)'),function(i, el){ - enableLink($(el)); - }); + enableFormsCallback(data); }); return false; } @@ -129,12 +128,7 @@ $('#right-ajax').empty().addClass('loading').parent().show(); $.get(dest, function(data) { - $('#right-ajax').removeClass('loading').html(data); - enableForms($('#right-ajax form:not(.no-ajax)')); - - $.each($('#right-ajax a'),function(i, el){ - enableLink($(el)); - }); + enableFormsCallback(data); }); $('#tree .selected').removeClass('selected'); $(this).parent().addClass('selected'); diff --git a/templates/web/admin/statusbit/edit.html.twig b/templates/web/admin/statusbit/edit.html.twig index 958a9552a7..9ffc14b2ea 100644 --- a/templates/web/admin/statusbit/edit.html.twig +++ b/templates/web/admin/statusbit/edit.html.twig @@ -192,8 +192,7 @@ $(document).ready(function(){ $('#right-ajax').empty().addClass('loading'); }, done: function (e, data) { - $('#right-ajax').removeClass('loading').html(data.result); - + enableFormsCallback(data.result); } }); diff --git a/templates/web/admin/user/import/file.html.twig b/templates/web/admin/user/import/file.html.twig index 7f0a6910ee..924984489b 100644 --- a/templates/web/admin/user/import/file.html.twig +++ b/templates/web/admin/user/import/file.html.twig @@ -62,12 +62,7 @@ $(function () { $('#right-ajax').empty().addClass('loading'); }, done: function (e, data) { - $('#right-ajax').removeClass('loading').html(data.result); - enableForms($('#right-ajax form:not(.no-ajax)')); - - $.each($('#right-ajax a'),function(i, el){ - enableLink($(el)); - }); + enableFormsCallback(data.result); } }); });