ソースを参照

added searchinfos

Bachir Soussi Chiadmi 5 年 前
コミット
058aed796a

+ 6 - 0
web/modules/custom/materio_sapi/src/Controller/Base.php

@@ -91,6 +91,12 @@ class Base extends ControllerBase {
       $this->sapiQuery();
 
       $resp['count'] = $this->results->getResultCount();
+      $resp['infos'] = t('The search found @count result(s) with keywords @keys.', array(
+        "@count" => $resp['count'],
+        "@keys" => $this->keys
+      ));
+      
+      
       $resp['options'] = $this->query->getOptions();
 
       $items = [];

ファイルの差分が大きいため隠しています
+ 0 - 0
web/themes/custom/materiotheme/assets/dist/main.js


+ 14 - 2
web/themes/custom/materiotheme/vuejs/components/Content/Base.vue

@@ -1,6 +1,9 @@
 <template>
   <div id="Base">
-    <h1>Base</h1>
+    <h1 class="page-title">{{ pagetitle }}</h1>
+    <aside class="search-info">
+      {{ searchinfos }}
+    </aside>
     <div class="results">
       <ul>
         <li v-for="item in items" v-bind:key="item.nid">
@@ -20,9 +23,16 @@ import { mapState, mapActions } from 'vuex'
 
 export default {
   name: "Base",
+  data() {
+    return {
+      pagetitle:"Base",
+      // searchinfos: null
+    }
+  },
   computed: {
     ...mapState({
-      items: state => state.Search.items
+      items: state => state.Search.items,
+      searchinfos: state =>  state.Search.infos
     })
   },
   methods: {
@@ -37,6 +47,7 @@ export default {
     if(params.has('keys') || params.has('term')){
       this.$store.commit('Search/setKeys', params.get('keys'))
       this.$store.commit('Search/setTerm', params.get('term'))
+      this.pagetitle = params.get('keys')
       this.newSearch()
     }
   },
@@ -45,6 +56,7 @@ export default {
     console.log('Base beforeRouteUpdate', to, from, next);
     this.$store.commit('Search/setKeys', to.query.keys)
     this.$store.commit('Search/setTerm', to.query.term)
+    this.pagetitle = to.query.keys
     this.newSearch()
     next()
   },

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

@@ -11,7 +11,9 @@ export default {
     term: "",
     items: [],
     offset: 0,
-    limit: 15
+    limit: 15,
+    infos: null,
+    count: 0
   },
 
   // getters
@@ -28,6 +30,12 @@ export default {
     setTerm (state, term) {
       state.term = term
     },
+    setInfos (state, infos) {
+      state.infos = infos
+    },
+    setCount (state, count) {
+      state.count = count
+    },
     resetOffset(state) {
       state.offset = 0
     },
@@ -56,6 +64,8 @@ export default {
         .then(({ data }) => {
           console.log('search MA getresults data', data)
           commit('setItems', data.items)
+          commit('setInfos', data.infos)
+          commit('setCount', data.count)
         })
         .catch(( error ) => {
             console.warn('Issue with getResults', error)

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません