Browse Source

wip - addTableClass

jqh 4 years ago
parent
commit
5359b24871

+ 9 - 1
resources/assets/dcat/sass/components/_table.scss

@@ -9,6 +9,15 @@
   }
 }
 
+.table-text-center {
+  th {
+    text-align: center;
+  }
+  td {
+    text-align: center;
+  }
+}
+
 table.dataTable thead tr {
   background: transparent;
 }
@@ -107,7 +116,6 @@ table.table-bordered.dataTable.complex-headers {
   margin-top: 12px!important;
 
   thead th {
-    text-align: center;
     vertical-align: middle;
     font-size: 1rem!important;
   }

File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/css/dcat-app-blue-dark.css


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/css/dcat-app-blue-light.css


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/css/dcat-app-blue.css


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/css/dcat-app-green.css


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/css/dcat-app.css


+ 1 - 6
resources/views/grid/data-table.blade.php

@@ -32,12 +32,7 @@
     {!! $grid->renderHeader() !!}
 
     <div class="table-responsive table-wrapper">
-            <table
-                class="table custom-data-table dataTable dt-checkboxes-select
-                {{ $grid->option('table_class') }}
-                {{ $grid->option('show_bordered') ? 'table-bordered complex-headers' : '' }} "
-                id="{{ $tableId }}"
-            >
+            <table class="custom-data-table dataTable {{ $grid->formatTableClass() }}" id="{{ $tableId }}">
                 <thead>
                 @if ($headers = $grid->getComplexHeaders())
                     <tr>

+ 1 - 7
resources/views/grid/table.blade.php

@@ -32,13 +32,7 @@
     {!! $grid->renderHeader() !!}
 
     <div class="table-responsive table-wrapper complex-container table-middle" style="{!! $grid->option('show_bordered') ? 'padding:3px 10px 10px' : '' !!};border-bottom: 1px solid #f8f8f8!important;">
-        <table
-                class="table dt-checkboxes-select
-                {{ $grid->getComplexHeaders() ? 'complex-headers' : ''}}
-                {{ $grid->option('table_class') }}
-                {{ $grid->option('show_bordered') ? 'table-bordered complex-headers dataTable' : '' }} "
-                id="{{ $tableId }}"
-        >
+        <table class="{{ $grid->formatTableClass() }}" id="{{ $tableId }}" >
             <thead>
             @if ($headers = $grid->getComplexHeaders())
                 <tr>

+ 25 - 1
src/Grid.php

@@ -169,7 +169,7 @@ class Grid
         'show_toolbar'           => true,
         'create_mode'            => self::CREATE_MODE_DEFAULT,
         'dialog_form_area'       => ['700px', '670px'],
-        'table_class'            => null,
+        'table_class'            => ['table', 'dt-checkboxes-select'],
     ];
 
     /**
@@ -351,6 +351,30 @@ class Grid
         $this->columns->each->bindFilterQuery($this->model());
     }
 
+    /**
+     * @param string|array $class
+     *
+     * @return $this
+     */
+    public function addTableClass($class)
+    {
+        $this->options['table_class'] = array_merge((array) $this->options['table_class'], (array) $class);
+
+        return $this;
+    }
+
+    public function formatTableClass()
+    {
+        if ($this->options['show_bordered']) {
+            $this->addTableClass(['table-bordered', 'complex-headers', 'dataTable']);
+        }
+        if ($this->getComplexHeaders()) {
+            $this->addTableClass('table-text-center');
+        }
+
+        return implode(' ', array_unique((array) $this->options['table_class']));
+    }
+
     /**
      * Build the grid.
      *

Some files were not shown because too many files changed in this diff