Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dashboards-3295719
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
dashboards-3295719
Commits
c6ed4853
Commit
c6ed4853
authored
5 years ago
by
Erik Seifert
Browse files
Options
Downloads
Patches
Plain Diff
Fix: add possibility to select a webform
parent
6cdf35fd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/dashboards_webform/src/Plugin/Dashboard/Submissions.php
+23
-2
23 additions, 2 deletions
...s/dashboards_webform/src/Plugin/Dashboard/Submissions.php
with
23 additions
and
2 deletions
modules/dashboards_webform/src/Plugin/Dashboard/Submissions.php
+
23
−
2
View file @
c6ed4853
...
...
@@ -4,6 +4,7 @@ namespace Drupal\dashboards_webform\Plugin\Dashboard;
use
Drupal\Core\Cache\CacheBackendInterface
;
use
Drupal\Core\Database\Connection
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\dashboards\Plugin\DashboardBase
;
use
Drupal\dashboards\Plugin\Dashboard\ChartTrait
;
...
...
@@ -28,12 +29,20 @@ class Submissions extends DashboardBase {
*/
protected
$database
;
/**
* EntityTypeManagerInterface definition.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected
$entityTypeManager
;
/**
* {@inheritdoc}
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
CacheBackendInterface
$cache_backend
,
Connection
$database
)
{
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
CacheBackendInterface
$cache_backend
,
Connection
$database
,
EntityTypeManagerInterface
$entity_type_manager
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$cache_backend
);
$this
->
database
=
$database
;
$this
->
entityTypeManager
=
$entity_type_manager
;
}
/**
...
...
@@ -45,7 +54,8 @@ class Submissions extends DashboardBase {
$plugin_id
,
$plugin_definition
,
$container
->
get
(
'dashboards.cache'
),
$container
->
get
(
'database'
)
$container
->
get
(
'database'
),
$container
->
get
(
'entity_type.manager'
)
);
}
...
...
@@ -53,6 +63,13 @@ class Submissions extends DashboardBase {
* {@inheritdoc}
*/
public
function
buildSettingsForm
(
array
$form
,
FormStateInterface
$form_state
,
array
$configuration
):
array
{
$webform
=
$this
->
entityTypeManager
->
getStorage
(
'webform'
)
->
load
(
$configuration
[
'webform'
]);
$form
[
'webform'
]
=
[
'#type'
=>
'entity_autocomplete'
,
'#target_type'
=>
'webform'
,
'#selection_handler'
=>
'default'
,
'#default_value'
=>
(
$webform
)
?
$webform
:
'null'
,
];
$form
[
'period'
]
=
[
'#type'
=>
'select'
,
'#options'
=>
[
...
...
@@ -88,6 +105,7 @@ class Submissions extends DashboardBase {
* {@inheritdoc}
*/
public
function
buildRenderArray
(
$configuration
):
array
{
dsm
(
$configuration
);
$field
=
$configuration
[
'period'
];
$cid
=
md5
(
serialize
([
$configuration
[
'period'
],
...
...
@@ -99,6 +117,9 @@ class Submissions extends DashboardBase {
$cache
=
FALSE
;
if
(
!
$cache
)
{
$query
=
$this
->
database
->
select
(
'webform_submission'
,
'ws'
);
if
(
isset
(
$configuration
[
'webform'
]))
{
$query
->
condition
(
'webform_id'
,
$configuration
[
'webform'
]);
}
switch
(
$configuration
[
'date'
])
{
case
'yesterday'
:
$query
->
condition
(
'ws.created'
,
[
strtotime
(
'yesterday'
),
strtotime
(
'today'
)],
'BETWEEN'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment