Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
customQueries
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bolt Extensions
customQueries
Commits
179d70d4
Commit
179d70d4
authored
Dec 04, 2018
by
Van
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(all) : autocomplete first item fixed. Exclude and include empty . All fields bt contenttypes
parent
fe66bb39
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
CustomQueriesExtension.php
src/CustomQueriesExtension.php
+16
-5
app.css
web/css/app.css
+5
-3
app.js
web/js/app.js
+0
-0
No files found.
src/CustomQueriesExtension.php
View file @
179d70d4
...
...
@@ -77,6 +77,7 @@ class CustomQueriesExtension extends SimpleExtension
}
$json
=
json_decode
(
$input
,
true
);
if
(
!
$json
||
empty
(
$json
))
{
return
''
;
}
...
...
@@ -85,7 +86,11 @@ class CustomQueriesExtension extends SimpleExtension
$storage
=
$this
->
getContainer
()[
'storage'
];
foreach
(
$json
as
$contentType
=>
$fields
)
{
$query
=
$this
->
_buildQuery
(
$contentType
,
$fields
);
$query
=
false
;
if
(
$contentType
!=
'all'
){
$query
=
$this
->
_buildQuery
(
$json
,
$contentType
,
$fields
);
}
if
(
!
empty
(
$query
))
{
...
...
@@ -97,12 +102,12 @@ class CustomQueriesExtension extends SimpleExtension
$contents
=
$storage
->
getContent
(
$contentType
,
[
'id'
=>
implode
(
' || '
,
$ids
),
'paging'
=>
true
,
'limit'
=>
99999
]);
if
(
is_array
(
$contents
))
{
$records
=
array_merge
(
$records
,
$contents
);
}
else
{
$records
=
array_merge
(
$records
,
[
$contents
]);
}
}
}
return
$this
->
getContainer
()[
'twig'
]
->
render
(
"custom_queries.twig"
,
[
'records'
=>
$records
]);
...
...
@@ -191,26 +196,32 @@ class CustomQueriesExtension extends SimpleExtension
}
/**
* @param array $json
* @param $contentType
* @param array $fields
* @return string
*/
protected
function
_buildQuery
(
$contentType
,
array
$fields
=
[])
{
protected
function
_buildQuery
(
array
$json
,
$contentType
,
array
$fields
=
[])
{
if
(
!
$contentType
)
{
return
''
;
}
$storage
=
$this
->
getContainer
()[
'storage'
];
$tableName
=
$storage
->
getContenttypeTablename
(
$contentType
);
if
(
!
$tableName
)
{
return
''
;
}
$query
=
'SELECT id FROM '
.
$tableName
;
if
(
!
isset
(
$json
[
'all'
])
||
!
\in_array
(
$contentType
,
$json
[
'all'
]))
{
$where
=
$this
->
_buildWhere
(
$fields
);
if
(
$where
)
{
$query
.=
$where
;
}
}
return
$query
;
}
...
...
web/css/app.css
View file @
179d70d4
...
...
@@ -15,13 +15,15 @@
margin-right
:
1em
;
}
/* Autocomplete css */
.chooseField
{
height
:
26px
!important
;
width
:
20em
!important
;
text-align
:
center
!important
;
}
.select
span
{
width
:
20em
;
text-align
:
center
;
.select2-container
{
text-align
:
left
;
}
.addContentTypeContainer
{
...
...
web/js/app.js
View file @
179d70d4
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment