Commit 179d70d4 by Van

fix(all) : autocomplete first item fixed. Exclude and include empty . All fields bt contenttypes

parent fe66bb39
...@@ -73,10 +73,11 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -73,10 +73,11 @@ class CustomQueriesExtension extends SimpleExtension
public function getQueriesResults($input) public function getQueriesResults($input)
{ {
if($input == '') { if($input == '') {
return ''; return '';
} }
$json = json_decode($input, true); $json = json_decode($input, true);
if(!$json || empty($json)) { if(!$json || empty($json)) {
return ''; return '';
} }
...@@ -85,7 +86,11 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -85,7 +86,11 @@ class CustomQueriesExtension extends SimpleExtension
$storage = $this->getContainer()['storage']; $storage = $this->getContainer()['storage'];
foreach ($json as $contentType => $fields) { foreach ($json as $contentType => $fields) {
$query = $this->_buildQuery($contentType, $fields); $query = false;
if ($contentType != 'all'){
$query = $this->_buildQuery($json, $contentType, $fields);
}
if(!empty($query)) if(!empty($query))
{ {
...@@ -97,24 +102,24 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -97,24 +102,24 @@ class CustomQueriesExtension extends SimpleExtension
$contents = $storage->getContent($contentType, ['id' => implode(' || ', $ids), 'paging' => true, 'limit' => 99999]); $contents = $storage->getContent($contentType, ['id' => implode(' || ', $ids), 'paging' => true, 'limit' => 99999]);
if(is_array($contents)) { if(is_array($contents)) {
$records = array_merge($records, $contents); $records = array_merge($records, $contents);
} else { } else {
$records = array_merge($records, [$contents]); $records = array_merge($records, [$contents]);
} }
} }
} }
return $this->getContainer()['twig']->render("custom_queries.twig", ['records' => $records]); return $this->getContainer()['twig']->render("custom_queries.twig", ['records' => $records]);
} }
/** /**
* @return false|mixed * @return false|mixed
*/ */
public function queriesArrayResults($input) public function queriesArrayResults($input)
{ {
if($input == '') { if($input == '') {
return ''; return '';
} }
$json = json_decode($input, true); $json = json_decode($input, true);
...@@ -149,13 +154,13 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -149,13 +154,13 @@ class CustomQueriesExtension extends SimpleExtension
return ['records' => $records]; return ['records' => $records];
} }
/** /**
* @return false|mixed * @return false|mixed
*/ */
public function countResults($input) public function countResults($input)
{ {
if($input == '') { if($input == '') {
return ''; return '';
} }
$json = json_decode($input, true); $json = json_decode($input, true);
...@@ -189,32 +194,38 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -189,32 +194,38 @@ class CustomQueriesExtension extends SimpleExtension
return count($records); return count($records);
} }
/** /**
* @param array $json
* @param $contentType
* @param array $fields * @param array $fields
* @return string * @return string
*/ */
protected function _buildQuery($contentType, array $fields = []) { protected function _buildQuery(array $json, $contentType, array $fields = []) {
if(!$contentType) { if(!$contentType) {
return ''; return '';
} }
$storage = $this->getContainer()['storage']; $storage = $this->getContainer()['storage'];
$tableName = $storage->getContenttypeTablename($contentType); $tableName = $storage->getContenttypeTablename($contentType);
if(!$tableName) { if(!$tableName) {
return ''; return '';
} }
$query = 'SELECT id FROM '.$tableName; $query = 'SELECT id FROM '.$tableName;
$where = $this->_buildWhere($fields); if(!isset($json['all']) || !\in_array($contentType, $json['all'])) {
if($where) { $where = $this->_buildWhere($fields);
$query .= $where; if($where) {
$query .= $where;
}
} }
return $query; return $query;
} }
/** /**
* @param array $fields * @param array $fields
* @return bool * @return bool
*/ */
...@@ -257,7 +268,7 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -257,7 +268,7 @@ class CustomQueriesExtension extends SimpleExtension
} }
} }
} }
return $where; return $where;
} }
......
...@@ -15,13 +15,15 @@ ...@@ -15,13 +15,15 @@
margin-right: 1em; margin-right: 1em;
} }
/* Autocomplete css */
.chooseField { .chooseField {
height: 26px !important; height: 26px !important;
width: 20em !important;
text-align: center !important;
} }
.select span{ .select2-container {
width: 20em; text-align: left;
text-align: center;
} }
.addContentTypeContainer { .addContentTypeContainer {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment