Skip to content

Commit dab92a4

Browse files
Merged in feature/BKL-73-RefactorSearchComponent (pull request #61)
Feature/BKL-73 RefactorSearchComponent
2 parents 4d5b09c + c2a504f commit dab92a4

31 files changed

+263
-117
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
label: Kommentar
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
label: Vedhæft
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
label: Svar
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
label: Vedhæft

config/sync/language/da/views.view.os2loop_search_db.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ display:
1111
filters:
1212
search_api_fulltext:
1313
expose:
14+
label: 'Søg'
1415
placeholder: 'Søg efter indhold eller emner'
1516
title: Søg
1617
header:

config/sync/system.site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: OS2Loop
33
44
slogan: ''
55
page:
6-
front: /front-page
6+
front: /node/1
77
403: ''
88
404: ''
99
admin_compact_mode: false

config/sync/views.view.os2loop_search_db.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ display:
153153
exposed: true
154154
expose:
155155
operator_id: search_api_fulltext_op
156-
label: 'Fulltext search'
156+
label: 'Search'
157157
description: ''
158158
use_operator: false
159159
operator: search_api_fulltext_op

web/profiles/custom/os2loop/modules/os2loop_post/src/Helper/Helper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
use Drupal\Core\Form\FormStateInterface;
66
use Drupal\os2loop_post\Form\SettingsForm;
77
use Drupal\os2loop_settings\Settings;
8+
use Drupal\Core\StringTranslation\StringTranslationTrait;
89

910
/**
1011
* Helper for posts.
1112
*/
1213
class Helper {
14+
use StringTranslationTrait;
15+
1316
/**
1417
* The config.
1518
*
@@ -48,6 +51,7 @@ public function alterForm(array &$form, FormStateInterface $form_state, string $
4851
* The id of the the form.
4952
*/
5053
private function alterCommentForm(array &$form, FormStateInterface $form_state, string $form_id) {
54+
$form['actions']['submit']['#value'] = $this->t('Add');
5155
$form['actions']['preview']['#access'] = FALSE;
5256
$form['os2loop_post_comment']['widget']['#after_build'][] =
5357
[$this, 'fieldAfterBuild'];

web/profiles/custom/os2loop/modules/os2loop_question/src/Helper/Helper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
use Drupal\Core\Form\FormStateInterface;
66
use Drupal\os2loop_question\Form\SettingsForm;
77
use Drupal\os2loop_settings\Settings;
8+
use Drupal\Core\StringTranslation\StringTranslationTrait;
89

910
/**
1011
* Helper for questions.
1112
*/
1213
class Helper {
14+
use StringTranslationTrait;
1315
public const MODULE = 'os2loop_question';
1416

1517
/**
@@ -129,6 +131,7 @@ private function hideMetadata(array &$form, FormStateInterface $form_state, stri
129131
* The id of the the form.
130132
*/
131133
private function alterCommentForm(array &$form, FormStateInterface $form_state, string $form_id) {
134+
$form['actions']['submit']['#value'] = $this->t('Add');
132135
$form['actions']['preview']['#access'] = FALSE;
133136
$form['os2loop_question_answer']['widget']['#after_build'][] =
134137
[$this, 'fieldAfterBuild'];

web/profiles/custom/os2loop/modules/os2loop_user/src/Helper/Helper.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Drupal\Core\Form\FormStateInterface;
66
use Drupal\Core\Session\AccountInterface;
77
use Drupal\views\ViewExecutable;
8+
use Drupal\views\Plugin\views\query\QueryPluginBase;
89
use Drupal\views\Plugin\views\query\Sql;
910

1011
/**
@@ -27,19 +28,10 @@ public function __construct(AccountInterface $currentUser) {
2728

2829
/**
2930
* Implements hook_views_query_alter().
30-
*
31-
* Change the order of the tables in a LEFT JOIN to preserve NULLs from
32-
* content type.
3331
*/
34-
public function queryAlter(ViewExecutable $view, Sql $query) {
32+
public function queryAlter(ViewExecutable $view, QueryPluginBase $query) {
3533
if ($view->id() === 'os2loop_user_answers') {
36-
$node_table = $query->getTableInfo('node_field_data_comment_field_data');
37-
38-
if (isset($node_table) && $node_table['join']->type === 'LEFT') {
39-
$node_table['join']->type = 'RIGHT';
40-
$query->where[0]['type'] = 'OR';
41-
$query->addWhereExpression(0, 'comment_field_data.uid IS NULL');
42-
}
34+
$this->sqlQueryAlter($view, $query);
4335
}
4436
}
4537

@@ -61,4 +53,20 @@ public function alterForm(array &$form, FormStateInterface $form_state, string $
6153
}
6254
}
6355

56+
/**
57+
* Helper function for SQL queries.
58+
*
59+
* Change the order of the tables in a LEFT JOIN to preserve NULLs from
60+
* content type.
61+
*/
62+
private function sqlQueryAlter(ViewExecutable $view, Sql $query) {
63+
$node_table = $query->getTableInfo('node_field_data_comment_field_data');
64+
65+
if (isset($node_table) && $node_table['join']->type === 'LEFT') {
66+
$node_table['join']->type = 'RIGHT';
67+
$query->where[0]['type'] = 'OR';
68+
$query->addWhereExpression(0, 'comment_field_data.uid IS NULL');
69+
}
70+
}
71+
6472
}

0 commit comments

Comments
 (0)