Commit 179d70d4 by Van

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

parent fe66bb39
...@@ -77,6 +77,7 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -77,6 +77,7 @@ class CustomQueriesExtension extends SimpleExtension
} }
$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,12 +102,12 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -97,12 +102,12 @@ 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]);
...@@ -191,26 +196,32 @@ class CustomQueriesExtension extends SimpleExtension ...@@ -191,26 +196,32 @@ class CustomQueriesExtension extends SimpleExtension
} }
/** /**
* @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;
if(!isset($json['all']) || !\in_array($contentType, $json['all'])) {
$where = $this->_buildWhere($fields); $where = $this->_buildWhere($fields);
if($where) { if($where) {
$query .= $where; $query .= $where;
} }
}
return $query; return $query;
} }
......
...@@ -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