Browse Source

added default base page

bach 1 month ago
parent
commit
f4174fac16

+ 2 - 2
config/sync/autologout.settings.yml

@@ -2,8 +2,8 @@ timeout: 3600
 max_timeout: 172800
 padding: 360
 role_logout: true
-redirect_url: /
-no_dialog: false
+redirect_url: /node/1
+no_dialog: true
 message: 'Your session is about to expire. Do you want to reset it?'
 inactivity_message: ''
 enforce_admin: false

+ 1 - 1
config/sync/genpass.settings.yml

@@ -1,6 +1,6 @@
 genpass_length: 12
 genpass_algorithm: user
-genpass_mode: 2
+genpass_mode: 1
 genpass_display: 3
 _core:
   default_config_hash: HNSTwPQM5lvXFeH4cVlcB2gZFJ5S--Nbmfj7651HK24

+ 22 - 22
config/sync/search_api.index.database.yml

@@ -8,8 +8,8 @@ dependencies:
     - taxonomy
     - search_api
   config:
-    - field.storage.node.field_famille
     - field.storage.node.body
+    - field.storage.node.field_famille
     - field.storage.node.field_tags
     - field.storage.taxonomy_term.field_synonyms
     - field.storage.node.field_thesaurus
@@ -194,12 +194,11 @@ datasource_settings:
         - fr
 processor_settings:
   add_url: {  }
-  entity_status: {  }
-  rendered_item: {  }
+  aggregated_field: {  }
   content_access:
     weights:
       preprocess_query: -50
-  html_filter:
+  double_quote_workaround:
     all_fields: true
     fields:
       - field_famille
@@ -212,23 +211,13 @@ processor_settings:
       - thesaurus_tid
       - title
       - uuid
-    title: true
-    alt: true
-    tags:
-      b: 2
-      h1: 5
-      h2: 3
-      h3: 2
-      strong: 2
+    replacement: '|9999999998|'
     weights:
+      postprocess_query: 0
       preprocess_index: -15
-      preprocess_query: -49
-  language_with_fallback: {  }
-  aggregated_field: {  }
-  solr_date_range:
-    weights:
-      preprocess_index: 0
-  double_quote_workaround:
+      preprocess_query: -48
+  entity_status: {  }
+  html_filter:
     all_fields: true
     fields:
       - field_famille
@@ -241,11 +230,22 @@ processor_settings:
       - thesaurus_tid
       - title
       - uuid
-    replacement: '|9999999998|'
+    title: true
+    alt: true
+    tags:
+      b: 2
+      h1: 5
+      h2: 3
+      h3: 2
+      strong: 2
     weights:
-      postprocess_query: 0
       preprocess_index: -15
-      preprocess_query: -48
+      preprocess_query: -49
+  language_with_fallback: {  }
+  rendered_item: {  }
+  solr_date_range:
+    weights:
+      preprocess_index: 0
 tracker_settings:
   default:
     indexing_order: fifo

+ 1 - 0
config/sync/user.role.adherent.yml

@@ -10,6 +10,7 @@ permissions:
   - 'access materio search'
   - 'add flag lists'
   - 'create member profile'
+  - 'create workflow workflow_transition'
   - 'edit own flag lists'
   - 'flag dossier other items'
   - 'unflag dossier other items'

+ 13 - 29
config/sync/workflow_access.role.yml

@@ -1,4 +1,8 @@
 workflow_edited:
+  adherent:
+    grant_view: true
+    grant_update: 0
+    grant_delete: 0
   admin:
     grant_view: true
     grant_update: true
@@ -15,15 +19,11 @@ workflow_edited:
     grant_view: 0
     grant_update: 0
     grant_delete: 0
-  authenticated:
-    grant_view: 0
-    grant_update: 0
-    grant_delete: 0
-  user:
+workflow_hidden:
+  adherent:
     grant_view: 0
     grant_update: 0
     grant_delete: 0
-workflow_hidden:
   admin:
     grant_view: true
     grant_update: true
@@ -40,21 +40,17 @@ workflow_hidden:
     grant_view: 0
     grant_update: 0
     grant_delete: 0
-  authenticated:
-    grant_view: 0
-    grant_update: 0
-    grant_delete: 0
-  user:
-    grant_view: 0
+workflow_visible:
+  adherent:
+    grant_view: true
     grant_update: 0
     grant_delete: 0
-workflow_visible:
   admin:
-    grant_view: 0
+    grant_view: true
     grant_update: true
     grant_delete: 0
   root:
-    grant_view: 0
+    grant_view: true
     grant_update: true
     grant_delete: true
   workflow_author:
@@ -65,15 +61,11 @@ workflow_visible:
     grant_view: true
     grant_update: 0
     grant_delete: 0
-  authenticated:
+workflow_imported:
+  adherent:
     grant_view: true
     grant_update: 0
     grant_delete: 0
-  user:
-    grant_view: 0
-    grant_update: 0
-    grant_delete: 0
-workflow_imported:
   admin:
     grant_view: true
     grant_update: true
@@ -90,14 +82,6 @@ workflow_imported:
     grant_view: 0
     grant_update: 0
     grant_delete: 0
-  authenticated:
-    grant_view: 0
-    grant_update: 0
-    grant_delete: 0
-  user:
-    grant_view: 0
-    grant_update: 0
-    grant_delete: 0
 migration_new:
   anonymous:
     grant_view: true

+ 39 - 3
web/modules/custom/materio_sapi/src/Controller/Base.php

@@ -17,6 +17,8 @@ use Drupal\search_api\Entity\Index;
  */
 class Base extends ControllerBase {
 
+
+
   private $limit = 15;
   private $offset = 0;
 
@@ -56,6 +58,24 @@ class Base extends ControllerBase {
 
   }
 
+  private function defaultQuery(){
+    $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
+    $this->query = $entity_storage->getQuery()
+      ->condition('type', 'materiau')
+      // ->condition('status', '1')
+      ->range($this->offset, $this->limit)
+      ->accessCheck(TRUE)
+      ->sort('changed', 'DESC');
+      // ->condition('field_example', 'test_value')
+    $this->results = $this->query->execute();
+
+    $this->count_query = $entity_storage->getQuery()
+      ->condition('type', 'materiau')
+      ->accessCheck(TRUE)
+      // ->condition('status', '1')
+      ->count();
+    $this->count = $this->count_query->execute();
+  }
   /**
    * get params from request
    */
@@ -79,8 +99,6 @@ class Base extends ControllerBase {
     $this->parseRequest($request);
 
     $resp = [
-      'keys' => $this->keys,
-      'term' => $this->term,
       'range' => array(
         'offset' => $this->offset,
         'limit' => $this->limit
@@ -90,6 +108,8 @@ class Base extends ControllerBase {
     if ($this->keys) {
       $this->sapiQuery();
 
+      $resp['keys'] = $this->keys;
+      $resp['term'] = $this->term;
       $resp['count'] = $this->results->getResultCount();
       $resp['infos'] = t('The search found @count result(s) with keywords @keys.', array(
         "@count" => $resp['count'],
@@ -117,6 +137,22 @@ class Base extends ControllerBase {
       // $resp['items'] = $items;
       $resp['uuids'] = $uuids;
       $resp['nids'] = $nids;
+    } else {
+      // no keys or terms to search for
+      // display the default base page
+      $this->defaultQuery();
+      // $uuids = [];
+      $nids = [];
+      foreach ($this->results as $result) {
+        // $uuids[] = $result->getField('uuid')->getValues()[0];
+        $nids[] = $result;
+      }
+      // $resp['uuids'] = $uuids;
+      $resp['nids'] = $nids;
+      $resp['count'] = $this->count;
+      $resp['infos'] = t('Please use the search form to search from our @count materials.', array(
+        "@count" => $resp['count']
+      ));
     }
 
     return new JsonResponse($resp);
@@ -163,7 +199,7 @@ class Base extends ControllerBase {
 
       $resp['items'] = $this->items;
     }else{
-      $resp['#markup'] = "no keys to search for";
+      $resp['#markup'] = t("no keys to search for");
     }
 
     return $resp;

File diff suppressed because it is too large
+ 3 - 3
web/themes/custom/materiotheme/assets/dist/main.js


+ 5 - 2
web/themes/custom/materiotheme/assets/scripts/main.js

@@ -140,8 +140,11 @@ import 'theme/assets/styles/main.scss'
         if (to.path == '/') {
           classes.push('path-home')
         } else {
-          const path_parts = to.path.replace(/^\//, '').split('/')
-          // TODO: remove language relative prefix from path classes (fr, en, etc)
+          const path_parts = to.path
+            .replace(/^\//, '')
+              // remove language relative prefix from path classes (fr, en, etc)
+              .replace(/^\D{2,3}\//, '')
+                .split('/')
           for (var i = 0; i < path_parts.length; i++) {
             if (i == 0) {
               var c = 'path-' + path_parts[i]

+ 6 - 0
web/themes/custom/materiotheme/vuejs/components/Pages/Base.vue

@@ -70,6 +70,12 @@ export default {
       this.$store.commit('Search/setTerm', params.get('term'))
       this.pagetitle = params.get('keys')
       this.newSearch()
+    }else{
+      // load default base page
+      this.$store.commit('Search/setKeys', '')
+      this.$store.commit('Search/setTerm', '')
+      this.pagetitle = 'Base'
+      this.newSearch()
     }
   },
   beforeRouteUpdate (to, from, next) {

+ 5 - 1
web/themes/custom/materiotheme/vuejs/store/modules/search.js

@@ -86,7 +86,11 @@ export default {
       commit('resetCount')
       commit('resetNoresults')
       commit('resetOffset')
-      this.commit('Common/setPagetitle', state.keys)
+      if(state.keys || state.term){
+        this.commit('Common/setPagetitle', state.keys)
+      }else{
+        this.commit('Common/setPagetitle', 'Base')
+      }
       dispatch('getResults')
     },
     nextPage ({ dispatch, commit, state }, $infiniteLoadingstate) {