@paris-ias/list 1.0.180 → 1.0.182

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.
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <v-row v-ripple no-gutters class="cursor-pointer highlight-on-hover my-2">
2
+ <v-row v-ripple no-gutters class="cursor-pointer highlight-on-hover pa-2">
3
3
  <v-col v-if="mdAndUp" align-self="center" cols="1">
4
4
  <MiscAtomsImageContainer
5
5
  cover
@@ -8,10 +8,10 @@
8
8
  item && item.image && item.image.url ? item.image.url : '/default.png'
9
9
  "
10
10
  :ratio="1 / 1"
11
- width="80px"
11
+ :width="70"
12
12
  />
13
13
  </v-col>
14
- <v-col align-self="start" class="text-h5 dense px-2 paragraph">
14
+ <v-col align-self="start" class="text-h5 dense mx-2 paragraph">
15
15
  <v-skeleton-loader v-if="loading" type="heading" />
16
16
  <template v-else>
17
17
  <v-skeleton-loader
@@ -25,7 +25,7 @@
25
25
 
26
26
  <template v-else>
27
27
  <v-chip
28
- class="ma-2"
28
+ class="mb-2"
29
29
  style="background-color: white; color: black"
30
30
  size="small"
31
31
  variant="outlined"
@@ -68,7 +68,7 @@
68
68
  </v-col>
69
69
 
70
70
  <v-col v-if="lgAndUp" cols="12" lg="5">
71
- <v-skeleton-loader v-if="isLoading" type="text@8, ossein, button" />
71
+ <v-skeleton-loader v-if="loading" type="text@8, ossein, button" />
72
72
 
73
73
  <template v-else>
74
74
  <div
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <v-row v-ripple no-gutters class="cursor-pointer highlight-on-hover my-2">
2
+ <v-row v-ripple no-gutters class="cursor-pointer highlight-on-hover">
3
3
  <v-col v-if="mdAndUp" cols="1">
4
4
  <MiscAtomsImageContainer
5
5
  cover
@@ -8,7 +8,8 @@
8
8
  item && item.image && item.image.url ? item.image.url : '/default.png'
9
9
  "
10
10
  :ratio="1 / 1"
11
- :width="80"
11
+ :width="70"
12
+ class="ma-1"
12
13
  />
13
14
  </v-col>
14
15
  <v-col align-self="start" class="text-h6 dense px-2">
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <v-row v-ripple no-gutters class="cursor-pointer highlight-on-hover">
2
+ <v-row v-ripple no-gutters class="cursor-pointer highlight-on-hover px-4">
3
3
  <v-col v-if="mdAndUp" align-self="center" cols="1">
4
4
  <MiscAtomsImageContainer
5
5
  cover
@@ -8,10 +8,10 @@
8
8
  item && item.image && item.image.url ? item.image.url : '/default.png'
9
9
  "
10
10
  :ratio="1 / 1"
11
- :width="50"
11
+ :width="70"
12
12
  />
13
13
  </v-col>
14
- <v-col align-self="center" class="text-h5 dense pl-2">
14
+ <v-col align-self="center" class="text-h5 dense pl-4 pt-2">
15
15
  <v-skeleton-loader v-if="loading" type="heading" width="50%" />
16
16
  <span
17
17
  v-else
@@ -32,7 +32,7 @@
32
32
 
33
33
  <MDC
34
34
  v-else-if="item.summary"
35
- class="text-caption font-weight-light paragraph"
35
+ class="text-caption font-weight-light paragraph mt-n2"
36
36
  :value="`${highlightAndTruncate(
37
37
  150,
38
38
  item.summary,
@@ -8,7 +8,7 @@
8
8
  item && item.image && item.image.url ? item.image.url : '/default.png'
9
9
  "
10
10
  :ratio="1 / 1"
11
- width="80px"
11
+ :width="70"
12
12
  />
13
13
  </v-col>
14
14
  <v-col class="pl-2">
@@ -5,7 +5,6 @@ export const useFetchItem = () => {
5
5
  key,
6
6
  variables
7
7
  }) => {
8
- console.log("useFetchItem2 called with:", { query, key, variables });
9
8
  try {
10
9
  const { $apollo } = useNuxtApp();
11
10
  const route = useRoute();
@@ -54,8 +54,20 @@ export const useRootStore = defineStore("rootStore", {
54
54
  }
55
55
  });
56
56
  }
57
- if (query.page && query.page > 1)
58
- $stores[type].page = parseInt(query.page, 10) || 1;
57
+ if (query.search && typeof query.search === "string") {
58
+ if (type === "all") {
59
+ this.search = query.search;
60
+ } else if ($stores[type]) {
61
+ ;
62
+ $stores[type].search = query.search;
63
+ }
64
+ }
65
+ const page = parseInt(query.page, 10) || 1;
66
+ if (type === "all") {
67
+ this.page = page;
68
+ } else if ($stores[type]) {
69
+ $stores[type].page = page;
70
+ }
59
71
  },
60
72
  setFiltersCount(type) {
61
73
  const { $stores } = useNuxtApp();
@@ -70,9 +82,12 @@ export const useRootStore = defineStore("rootStore", {
70
82
  updateRouteQuery(type) {
71
83
  const router = useRouter();
72
84
  const { $stores } = useNuxtApp();
85
+ const isGlobal = type === "all";
86
+ const searchValue = isGlobal ? this.search : $stores[type]?.search || "";
87
+ const pageValue = isGlobal ? this.page : $stores[type]?.page || 1;
73
88
  const routeQuery = {
74
- ...this.search ? { search: this.search } : {},
75
- ...this.page > 1 ? { page: this.page.toString() } : {},
89
+ ...searchValue ? { search: searchValue } : {},
90
+ ...pageValue > 1 ? { page: pageValue.toString() } : {},
76
91
  ...Object.entries($stores[type]?.filters ?? {}).reduce(
77
92
  (acc, [key, filter]) => {
78
93
  const value = filter?.value;
@@ -125,7 +140,11 @@ export const useRootStore = defineStore("rootStore", {
125
140
  if ($stores[type]?.filters?.[key]) {
126
141
  $stores[type].filters[key].value = val;
127
142
  }
128
- this.page = 1;
143
+ if (type === "all") {
144
+ this.page = 1;
145
+ } else {
146
+ $stores[type].page = 1;
147
+ }
129
148
  $stores[type].loading = true;
130
149
  this.setFiltersCount(type);
131
150
  this.updateRouteQuery(type);
@@ -136,7 +155,11 @@ export const useRootStore = defineStore("rootStore", {
136
155
  lang
137
156
  }) {
138
157
  const { $stores } = useNuxtApp();
139
- this.page = 1;
158
+ if (type === "all") {
159
+ this.page = 1;
160
+ } else {
161
+ $stores[type].page = 1;
162
+ }
140
163
  $stores[type].itemsPerPage = value;
141
164
  $stores[type].loading = true;
142
165
  this.updateRouteQuery(type);
@@ -170,15 +193,16 @@ export const useRootStore = defineStore("rootStore", {
170
193
  }) {
171
194
  if (type === "all") {
172
195
  this.search = search;
196
+ this.page = 1;
173
197
  } else {
174
198
  const { $stores } = useNuxtApp();
175
199
  if ($stores[type]) {
176
200
  ;
177
201
  $stores[type].search = search;
202
+ $stores[type].page = 1;
178
203
  $stores[type].loading = true;
179
204
  }
180
205
  }
181
- this.page = 1;
182
206
  this.updateRouteQuery(type);
183
207
  },
184
208
  buildListVariables(type, lang = "en") {
@@ -194,21 +218,20 @@ export const useRootStore = defineStore("rootStore", {
194
218
  }
195
219
  }
196
220
  }
221
+ const localSearch = $stores[type]?.search || "";
197
222
  const args = JSON.parse(
198
223
  JSON.stringify({
199
224
  options: {
200
225
  skip: +$stores[type]?.page === 1 ? 0 : (+$stores[type]?.page - 1) * itemsPerPage,
201
226
  limit: itemsPerPage,
202
- ...this.search?.length && type !== "all" && { search: this.search },
227
+ ...type !== "all" && localSearch?.length && { search: localSearch },
203
228
  filters,
204
229
  sort: $stores[type]?.sortKey || ($stores[type]?.sort ? Object.keys($stores[type].sort).find(
205
230
  (key) => $stores[type].sort[key].default
206
231
  ) : void 0)
207
232
  },
208
233
  ...type === "all" && this.search?.length && { search: this.search },
209
- ...type !== "all" && $stores[type] && $stores[type].search?.length && {
210
- search: $stores[type].search
211
- },
234
+ ...type !== "all" && localSearch?.length && { search: localSearch },
212
235
  appId: "iea",
213
236
  lang
214
237
  })
@@ -220,7 +243,27 @@ export const useRootStore = defineStore("rootStore", {
220
243
  const { $stores } = useNuxtApp();
221
244
  const key = type === "all" ? "search" : "list" + type.charAt(0).toUpperCase() + type.slice(1);
222
245
  if (type === "all") {
223
- this.results = data?.[key] || this.results;
246
+ const searchData = data?.[key];
247
+ if (searchData) {
248
+ for (const moduleType of Object.keys(searchData)) {
249
+ if (moduleType in this.results) {
250
+ ;
251
+ this.results[moduleType] = searchData[moduleType];
252
+ }
253
+ }
254
+ }
255
+ for (const category of Object.keys(this.results)) {
256
+ const categoryData = this.results[category];
257
+ if (categoryData?.items?.length) {
258
+ ;
259
+ this.results[category] = {
260
+ ...categoryData,
261
+ items: [...categoryData.items].sort(
262
+ (a, b) => (b.score ?? 0) - (a.score ?? 0)
263
+ )
264
+ };
265
+ }
266
+ }
224
267
  return;
225
268
  }
226
269
  const items = data?.[key]?.items ?? [];
@@ -384,5 +384,7 @@
384
384
  "list.by-vintage-from-old-to-recent": "By Year, from old to recent",
385
385
  "no-biography": "No biography available",
386
386
  "search": "Search",
387
- "items-per-page": "Items per page"
387
+ "items-per-page": "Items per page",
388
+ "click-here-to-search": "Click here to search",
389
+ "filter-by-type": "Filter by type"
388
390
  }
@@ -292,7 +292,7 @@
292
292
  },
293
293
  "list": "Liste",
294
294
  "page-0-of-1": "Page {0} sur {1}",
295
- "pls-x-more": "{0} Plus",
295
+ "pls-x-more": "+ {0} de plus | + {0} supplémentaires",
296
296
  "rows": "Rangées",
297
297
  "search-type": "Rechercher parmi les {0}",
298
298
  "search-type-f": "Rechercher parmi les {0}",
@@ -385,5 +385,7 @@
385
385
  "list.by-vintage-from-recent-to-old": "Par année, du plus récent au plus vieux",
386
386
  "list.by-vintage-from-old-to-recent": "Par année, du plus vieux au plus récent",
387
387
  "search": "Rechercher",
388
- "items-per-page": "Éléments par page"
388
+ "items-per-page": "Éléments par page",
389
+ "click-here-to-search": "Cliquez ici pour rechercher",
390
+ "filter-by-type": "Filtrer par type"
389
391
  }
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.180",
4
+ "version": "1.0.182",
5
5
  "name": "@paris-ias/list",
6
6
  "repository": {
7
7
  "url": "git+https://github.com/IEA-Paris/list.git",