Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #9 from nshiddqui/deployee-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
allanmcarvalho committed Jun 30, 2022
2 parents 2fb13dc + 7de339a commit 32bd6c8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;

Router::plugin('DataTables', ['path' => '/data-tables'], function (RouteBuilder $builder) {
$routes->plugin('DataTables', ['path' => '/data-tables'], function (RouteBuilder $builder) {
$builder->connect('/images/*', ['controller' => 'Assets', 'action' => 'images']);
$builder->fallbacks(DashedRoute::class);
});
2 changes: 1 addition & 1 deletion src/Controller/ProviderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function getI18nTranslation() {
* @return \Cake\Http\Response|null|void Renders view
*/
public function getTablesData(string $tablesCass) {
$configBundle = Builder::getInstance()->getConfigBundle(Inflector::camelize($tablesCass), $this->_cache);
$configBundle = Builder::getInstance()->getConfigBundle(Inflector::camelize(str_replace('-','_',$tablesCass)), $this->_cache);
$tableDataUtils = new TableDataUtils($configBundle, $this->getRequest());
$find = $tableDataUtils->getFind();
$data = $find->toArray();
Expand Down
2 changes: 2 additions & 0 deletions src/Table/TableDataUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Cake\ORM\Query;
use Cake\Utility\Hash;
use DataTables\Tools\Functions;
use Cake\Datasource\ConnectionManager;

/**
* Class AjaxData
Expand Down Expand Up @@ -135,6 +136,7 @@ private function doSearch(Query $query): void {
*/
private function insertSearchInArray(array &$conditions, string $databaseColumn, string $searchValue, bool $searchRegex): void {
if (!empty($searchValue)) {
$databaseColumn = ConnectionManager::get('default')->getDriver()->quoteIdentifier($databaseColumn);
$conditions += ["CONVERT($databaseColumn,char) LIKE" => "%$searchValue%"];
if ($searchRegex === true && Functions::getInstance()->checkRegexFormat($searchValue)) {
$conditions += ["CONVERT($databaseColumn,char) REGEXP" => "$searchValue"];
Expand Down
4 changes: 3 additions & 1 deletion src/Tools/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public function getPluginCurrentCommit(): string {
$filePath = $filePath . $subPath;
if (is_file($filePath)) {
$packages = json_decode(file_get_contents($filePath));
if(isset($packages->packages)){
$packages = $packages->packages;
}
} else {
continue;
}
Expand Down Expand Up @@ -208,7 +211,6 @@ public function getAssociationPath($table, string $neededAssociation, array $cur
return $result;
}
}

return false;
}

Expand Down
5 changes: 4 additions & 1 deletion templates/element/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
$body = '';
foreach ($configBundles as $configBundle) {
$bodyJson = Functions::getInstance()->increaseTabOnString($configBundle->Options->getConfigAsJson(), 3, true);
if (!empty($configBundle->Options->getConfig('id'))) {
$body .= "window['" . $configBundle->Options->getConfig('id') . "'] = ";
}
$body .= " $('#{$configBundle->getUniqueId()}').DataTable($bodyJson);\n";
$currentPage = $configBundle->Options->getCurrentPage();
if ($currentPage !== null) {
$body .= " $('#{$configBundle->getUniqueId()}').on('init.dt', function ( e, settings, json ) {\n";
$body .= "window[{$configBundle->getUniqueId()}] = $('#{$configBundle->getUniqueId()}').on('init.dt', function ( e, settings, json ) {\n";
$body .= " setTimeout( function () {\n";
$body .= " (new $.fn.dataTable.Api(settings)).page($currentPage).draw(false);\n";
$body .= " }, 5 );\n";
Expand Down

0 comments on commit 32bd6c8

Please sign in to comment.