fixed the default base page lang code bug

This commit is contained in:
Bachir Soussi Chiadmi 2021-02-22 16:05:54 +01:00
parent e993963e1c
commit 59e02b93ee
6 changed files with 581 additions and 1171 deletions

View File

@ -62,7 +62,7 @@ class Base extends ControllerBase {
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
$this->query = $entity_storage->getQuery()
->condition('type', 'materiau')
// ->condition('status', '1')
->condition('status', '1')
->range($this->offset, $this->limit)
->accessCheck(TRUE)
->sort('changed', 'DESC');
@ -72,7 +72,7 @@ class Base extends ControllerBase {
$this->count_query = $entity_storage->getQuery()
->condition('type', 'materiau')
->accessCheck(TRUE)
// ->condition('status', '1')
->condition('status', '1')
->count();
$this->count = $this->count_query->execute();
}
@ -143,9 +143,21 @@ class Base extends ControllerBase {
$this->defaultQuery();
// $uuids = [];
$nids = [];
// Using entityTypeManager
// Get a node storage object.
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
foreach ($this->results as $result) {
// $uuids[] = $result->getField('uuid')->getValues()[0];
$nids[] = $result;
$lang = \Drupal::languageManager()->getCurrentLanguage()->getId();
// Load a single node.
$node = $node_storage->load($result);
// check if has translation
if ($node->hasTranslation($lang)) {
// $uuids[] = $result->getField('uuid')->getValues()[0];
$nids[] = $result;
}
}
// $resp['uuids'] = $uuids;
$resp['nids'] = $nids;

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,69 @@
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is not neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./web/themes/custom/materiotheme/assets/styles/print.scss":
/*!*****************************************************************!*\
!*** ./web/themes/custom/materiotheme/assets/styles/print.scss ***!
\*****************************************************************/
/*! namespace exports */
/*! exports [not provided] [no usage info] */
/*! runtime requirements: __webpack_require__.r, __webpack_exports__, __webpack_require__.* */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n// extracted by mini-css-extract-plugin\n\n\n//# sourceURL=webpack://materio.com/./web/themes/custom/materiotheme/assets/styles/print.scss?");
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
/******/ // startup
/******/ // Load entry module
/******/ __webpack_require__("./web/themes/custom/materiotheme/assets/styles/print.scss");
/******/ // This entry module used 'exports' so it can't be inlined
/******/ })()
;

View File

@ -1,5 +1,6 @@
fragment SearchResultFields on SearchResult {
id
uuid
bundle
title
short_description

View File

@ -11,7 +11,7 @@
<span>Loading ...</span>
</div>
<ul v-else>
<li v-for="item in items" v-bind:key="item.uuid">
<li v-for="item in items" v-bind:key="item.id">
<Card v-if="item.bundle == 'materiau'" :item="item"/>
<CardThematique v-if="item.bundle == 'thematique'" :item="item"/>
</li>

View File

@ -40,7 +40,11 @@ export default {
state.uuids = []
},
setResults (state, items) {
state.items = state.items.concat(items)
// console.log('setResults, items', items);
if(items){ // avoid bug like items = [null]
state.items = state.items.concat(items)
}
// console.log('setResults, state.items', state.items);
},
resetItems (state) {
state.items = []
@ -131,7 +135,7 @@ export default {
${ searchresultGQL }
`
MGQ.post('', { query: print(ast) })
.then(( resp ) => {
.then(resp => {
console.log('loadSearchResultsGQL resp', resp )
dispatch("loadSearchResultsCallBack", { items: resp.data.data.searchresults})
})