Преглед на файлове

Merge pull request #794 from EmmanuelVella/batch-action

Add elements count in batch action confirmation message
Thomas преди 13 години
родител
ревизия
bf26f2e88f

+ 4 - 0
CHANGELOG.md

@@ -1,6 +1,10 @@
 CHANGELOG
 =========
 
+### 2012-05-31
+
+* Update batch action confirmation message (breaks some translations)
+
 ### 2012-05-02
 
 * [BC BREAK] add ProxyQueryInterface hint into the FilterInterface class

+ 1 - 1
Controller/CRUDController.php

@@ -376,7 +376,7 @@ class CRUDController extends Controller
                 'action'   => 'list',
                 'datagrid' => $datagrid,
                 'form'     => $formView,
-                'data'     => json_encode($data),
+                'data'     => $data,
             ));
         }
 

+ 5 - 1
Resources/translations/SonataAdminBundle.en.xliff

@@ -184,7 +184,11 @@
             </trans-unit>
             <trans-unit id="message_batch_confirmation">
                 <source>message_batch_confirmation</source>
-                <target>Are you sure you want to confirm this action and execute it for all of the selected elements?</target>
+                <target>Are you sure you want to confirm this action and execute it for the selected element?|Are you sure you want to confirm this action and execute it for the %count% selected elements?</target>
+            </trans-unit>
+            <trans-unit id="message_batch_all_confirmation">
+                <source>message_batch_all_confirmation</source>
+                <target>Are you sure you want to confirm this action and execute it for all the elements?</target>
             </trans-unit>
             <trans-unit id="btn_execute_batch_action">
                 <source>btn_execute_batch_action</source>

+ 5 - 1
Resources/translations/SonataAdminBundle.fr.xliff

@@ -184,7 +184,11 @@
             </trans-unit>
             <trans-unit id="message_batch_confirmation">
                 <source>message_batch_confirmation</source>
-                <target>Êtes-vous sûre de vouloir confirmer cette action et de l'exécuter pour tous les éléments sélectionnés?</target>
+                <target>Êtes-vous sûr de vouloir confirmer cette action et de l'exécuter pour l'élément sélectionné?|Êtes-vous sûr de vouloir confirmer cette action et de l'exécuter pour les %count% éléments sélectionnés?</target>
+            </trans-unit>
+            <trans-unit id="message_batch_all_confirmation">
+                <source>message_batch_all_confirmation</source>
+                <target>Êtes-vous sûr de vouloir confirmer cette action et de l'exécuter pour tous les éléments?</target>
             </trans-unit>
             <trans-unit id="btn_execute_batch_action">
                 <source>btn_execute_batch_action</source>

+ 6 - 2
Resources/views/CRUD/batch_confirmation.html.twig

@@ -32,12 +32,16 @@ file that was distributed with this source code.
 
         <h1>{% trans from 'SonataAdminBundle' %}title_batch_confirmation{% endtrans %}</h1>
 
-        {% trans from 'SonataAdminBundle' %}message_batch_confirmation{% endtrans %}
+        {% if data.all_elements %}
+            {% trans from 'SonataAdminBundle' %}message_batch_all_confirmation{% endtrans %}
+        {% else %}
+            {% transchoice data.idx|length with {'%count%': data.idx|length} from 'SonataAdminBundle' %}message_batch_confirmation{% endtranschoice %}
+        {% endif %}
 
         <div class="actions">
             <form action="{{ admin.generateUrl('batch', admin.filterParameters) }}" method="POST" >
                 <input type="hidden" name="confirmation" value="ok" />
-                <input type="hidden" name="data" value="{{ data }}" />
+                <input type="hidden" name="data" value="{{ data|json_encode }}" />
 
                 <div style="display: none">
                     {{ form_rest(form) }}