Ver Fonte

Merge pull request #664 from pulzarraider/visualize_selected_list_rows

Visualize selected rows in a table
Thomas há 13 anos atrás
pai
commit
281731101a

+ 12 - 0
Resources/public/css/layout.css

@@ -96,6 +96,18 @@ body.sonata-bc {
     width: 75px;
 }
 
+.sonata-bc .zebra-striped tbody tr.sonata-ba-list-row-selected td, .sonata-bc .zebra-striped tbody tr.sonata-ba-list-row-selected th {
+    background-color:#fcffc4;
+}
+
+.sonata-bc .zebra-striped tbody tr.sonata-ba-list-row-selected:nth-child(odd) td, .sonata-bc .zebra-striped tbody tr.sonata-ba-list-row-selected:nth-child(odd) th {
+    background-color:#fdffd8;
+}
+
+.sonata-bc .zebra-striped tbody tr.sonata-ba-list-row-selected:hover td, .sonata-bc .zebra-striped tbody tr.sonata-ba-list-row-selected:hover th {
+    background-color:#faff9e;
+}
+
 .sonata-bc table.sonata-ba-list td img{
     vertical-align: bottom
 }

+ 4 - 1
Resources/views/CRUD/base_list.html.twig

@@ -135,11 +135,14 @@ file that was distributed with this source code.
                 <script type="text/javascript">
                     jQuery(document).ready(function($){
                        $('#list_batch_checkbox').click(function(){
-                           $(this).closest('table').find("td input[type='checkbox']").attr('checked', $(this).is(':checked'));
+                           $(this).closest('table').find("td input[type='checkbox']").attr('checked', $(this).is(':checked')).parent().parent().toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'));
                        });
                        $('.delete_link').click(function(e){
                           if (!confirm('{% trans from 'SonataAdminBundle' %}confirm_msg{% endtrans %}')) e.preventDefault();
                        });
+                       $("td.sonata-ba-list-field-batch input[type='checkbox']").change(function(){
+                           $(this).parent().parent().toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'));
+                       });
                     });
                 </script>