@paris-ias/list 1.0.138 → 1.0.139

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@paris-ias/list",
3
3
  "configKey": "list",
4
- "version": "1.0.138",
4
+ "version": "1.0.139",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
@@ -2,6 +2,7 @@
2
2
  <div class="d-flex flex-grow-1 flex-column">
3
3
  <div class="d-flex align-center">
4
4
  <v-text-field
5
+ :id="`global-search-input-${type}`"
5
6
  v-model.trim="search"
6
7
  :placeholder="
7
8
  type === 'all'
@@ -24,11 +25,7 @@
24
25
  $store.state.scrolled }" -->
25
26
  <template v-if="!search" #label>
26
27
  <div class="searchLabel">
27
- {{
28
- type === "all"
29
- ? $t("search")
30
- : $t("list.search-type", [$t("items." + type, 2)])
31
- }}
28
+ {{ $t("search") }}
32
29
  </div>
33
30
  </template>
34
31
  </v-text-field>
@@ -78,16 +75,14 @@
78
75
  </v-card>
79
76
  </v-menu>
80
77
  <v-btn
81
- v-bind="attrs"
82
78
  :rounded="0"
83
- variant="test"
79
+ variant="outlined"
84
80
  size="large"
85
81
  height="56"
86
- v-on="on"
87
82
  @keyup.enter="$router.push(localePath('/search'))"
88
83
  @click="$router.push(localePath('/search'))"
89
84
  >
90
- <v-icon>mdi-magnify</v-icon>
85
+ <v-icon size="large">mdi-magnify</v-icon>
91
86
  <v-tooltip activator="parent" location="start">{{
92
87
  $t("click-here-to-search")
93
88
  }}</v-tooltip>
@@ -99,15 +94,14 @@
99
94
  <script setup>
100
95
  import { useDebounceFn } from "@vueuse/core"
101
96
  import { useRootStore } from "../../../stores/root"
102
- import { computed, useI18n, ref } from "#imports"
97
+ import { computed, useI18n, ref, useLocalePath } from "#imports"
98
+ const localePath = useLocalePath()
103
99
  const { locale, t } = useI18n()
104
100
  const rootStore = useRootStore()
105
101
 
106
102
  // Utility function to capitalize first letter
107
103
  const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1)
108
-
109
104
  const emit = defineEmits(["filter-change"])
110
-
111
105
  const props = defineProps({
112
106
  type: {
113
107
  type: String,
@@ -162,8 +156,12 @@ const search = computed({
162
156
  get() {
163
157
  return rootStore.search
164
158
  },
165
- set: await useDebounceFn(async function (v) {
166
- await rootStore.updateSearch({
159
+ set: useDebounceFn(function (v) {
160
+ emit("change", {
161
+ name: "search",
162
+ value: v,
163
+ })
164
+ rootStore.updateSearch({
167
165
  type: props.type,
168
166
  search: v || "",
169
167
  lang: locale.value,
@@ -30,7 +30,7 @@
30
30
  </template>
31
31
 
32
32
  <script setup>
33
- import { ref, computed } from "vue"
33
+ import { ref, unref, computed } from "vue"
34
34
  import { useNuxtApp } from "#imports"
35
35
  const { $stores } = useNuxtApp()
36
36
 
@@ -6,6 +6,7 @@
6
6
  size="large"
7
7
  class=""
8
8
  @click="$emit('toggle', type)"
9
+ :disabled="$rootStore.results[type]?.total === 0"
9
10
  >
10
11
  <v-icon size="large">{{
11
12
  open ? "mdi-chevron-down" : "mdi-chevron-right"
@@ -16,9 +17,9 @@
16
17
  @click="$emit('toggle', type)"
17
18
  >
18
19
  <div
19
- class="text-h4"
20
+ class="text-h5 font-weight-medium"
20
21
  :class="
21
- $rootStore.results[type].total > 0 ? '' : 'text-grey darken-2'
22
+ $rootStore.results[type].total > 0 ? 'black' : 'text-grey darken-2'
22
23
  "
23
24
  >
24
25
  {{ capitalize($t("items." + props.type, 2)) }}
@@ -53,11 +54,13 @@
53
54
  color="default"
54
55
  variant="text"
55
56
  rounded="0"
57
+ v-if="$rootStore.results[type]?.total > 0"
56
58
  :to="localePath(type === 'people' ? '/people' : '/activities/' + type)"
57
59
  >
58
60
  {{ $t("list.pls-x-more", [$rootStore.results[type].total]) }}
59
61
  </v-btn>
60
62
  </div>
63
+ <v-divider></v-divider>
61
64
  </template>
62
65
  <script setup>
63
66
  import { useNuxtApp, useLocalePath } from "#imports"
@@ -171,17 +171,28 @@ onMounted(() => {
171
171
  onBeforeUnmount(() => {
172
172
  rootStore.resetState(props.type, locale.value)
173
173
  })
174
-
175
174
  async function onPageChange(newPage) {
176
175
  console.log("onPageChange: ", newPage)
176
+
177
+ // Set loading state first
178
+ rootStore.setLoading(true, props.type)
179
+
180
+ // Update the page in the store
177
181
  rootStore.updatePage({
178
182
  page: newPage,
179
183
  type: props.type,
180
184
  lang: locale.value,
181
185
  })
182
- if (typeof window !== "undefined") {
183
- window.scrollTo({ top: 0, behavior: "smooth" })
184
- }
186
+
187
+ // Wait for the next tick to ensure DOM updates
188
+ await nextTick()
189
+
190
+ // Use setTimeout to ensure the scroll happens after route transition completes
191
+ setTimeout(() => {
192
+ if (typeof window !== "undefined") {
193
+ window.scrollTo({ top: 0, behavior: "smooth" })
194
+ }
195
+ }, 0)
185
196
  }
186
197
  /*
187
198
  onUpdated(() => {
@@ -4,6 +4,7 @@
4
4
  :placeholder="$t('search')"
5
5
  variant="outlined"
6
6
  :categories="selectedCategories"
7
+ @change="updateSearch($event)"
7
8
  @filter-change="handleFilterChange"
8
9
  />
9
10
  <ListMoleculesResultsContainer
@@ -31,8 +32,9 @@ import {
31
32
  useAppConfig,
32
33
  ref,
33
34
  computed,
35
+ watch,
34
36
  } from "#imports"
35
-
37
+ import SEARCH from "../../../graphql/list/search.gql"
36
38
  // Component name for linting
37
39
  defineOptions({
38
40
  name: "SearchResults",
@@ -70,24 +72,36 @@ const filteredSortedModules = computed(() => {
70
72
  )
71
73
  })
72
74
 
73
- onMounted(async () => {
74
- // Initialize the page from the route
75
- console.log("mounted list")
76
-
77
- try {
78
- await $rootStore.update("all", locale.value)
75
+ // Apollo GraphQL query with proper reactivity
76
+ const { data, pending, error, refresh } = await useAsyncQuery(
77
+ SEARCH,
78
+ { search: $rootStore.search, appId: "iea", locale: locale.value },
79
+ {
80
+ key: `search-${$rootStore.search}`, // Unique key for caching
81
+ server: true, // Enable SSR
82
+ },
83
+ )
84
+ if (error.value) {
85
+ console.error("GraphQL query error: ", error.value)
86
+ } else {
87
+ console.log("Query result data: ", data.value.items?.length)
88
+ }
79
89
 
80
- // Set all types to be expanded by default when they have results
81
- appConfig.list.modules.forEach((type) => {
82
- if ($rootStore.results[type]?.total > 0) {
83
- open.value[type] = true
84
- }
85
- })
86
- } catch (error) {
87
- console.log("error fetching update list: ", error)
90
+ // Apply data to store immediately if available
91
+ if (data.value) {
92
+ console.log("Applying data to store directly [first load scenario]")
93
+ $rootStore.applyListResult("all", data.value)
94
+ }
95
+ const updateSearch = async (newSearch) => {
96
+ console.log("update search")
97
+ if (newSearch !== $rootStore.search) {
98
+ await refresh()
99
+ if (data.value) {
100
+ console.log("Applying data to store directly [first load scenario]")
101
+ $rootStore.applyListResult("all", data.value)
102
+ }
88
103
  }
89
- })
90
-
104
+ }
91
105
  onBeforeUnmount(() => {
92
106
  /* rootStore.resetState("all", locale.value) */
93
107
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "license": "AGPL-3.0-only",
3
3
  "main": "./dist/module.mjs",
4
- "version": "1.0.138",
4
+ "version": "1.0.139",
5
5
  "name": "@paris-ias/list",
6
6
  "repository": {
7
7
  "url": "git+https://github.com/IEA-Paris/list.git",