@paris-ias/list 1.0.136 → 1.0.138

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.
Files changed (78) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/actions/DenseItem.vue +64 -0
  3. package/dist/runtime/components/actions/ExpandedItem.vue +17 -10
  4. package/dist/runtime/components/actions/RowsItem.vue +57 -7
  5. package/dist/runtime/components/actions/View.vue +5 -17
  6. package/dist/runtime/components/affiliation/DenseItem.vue +26 -6
  7. package/dist/runtime/components/affiliation/ExpandedItem.vue +4 -0
  8. package/dist/runtime/components/affiliation/RowsItem.vue +27 -7
  9. package/dist/runtime/components/affiliation/View.vue +4 -4
  10. package/dist/runtime/components/apps/DenseItem.vue +26 -6
  11. package/dist/runtime/components/apps/ExpandedItem.vue +5 -1
  12. package/dist/runtime/components/apps/RowsItem.vue +27 -7
  13. package/dist/runtime/components/apps/View.vue +4 -4
  14. package/dist/runtime/components/disciplines/DenseItem.vue +26 -6
  15. package/dist/runtime/components/disciplines/ExpandedItem.vue +4 -0
  16. package/dist/runtime/components/disciplines/RowsItem.vue +27 -7
  17. package/dist/runtime/components/disciplines/View.vue +4 -4
  18. package/dist/runtime/components/events/Badges.vue +8 -12
  19. package/dist/runtime/components/events/DenseItem.vue +26 -16
  20. package/dist/runtime/components/events/ExpandedItem.vue +4 -0
  21. package/dist/runtime/components/events/RelatedItem.vue +4 -13
  22. package/dist/runtime/components/events/RowsItem.vue +20 -20
  23. package/dist/runtime/components/events/SlidingItem.vue +39 -47
  24. package/dist/runtime/components/events/View.vue +1 -1
  25. package/dist/runtime/components/fellowships/Badges.vue +15 -11
  26. package/dist/runtime/components/fellowships/DenseItem.vue +22 -11
  27. package/dist/runtime/components/fellowships/ExpandedItem.vue +8 -1
  28. package/dist/runtime/components/fellowships/RowsItem.vue +22 -15
  29. package/dist/runtime/components/fellowships/View.vue +2 -2
  30. package/dist/runtime/components/files/DenseItem.vue +26 -6
  31. package/dist/runtime/components/files/ExpandedItem.vue +4 -0
  32. package/dist/runtime/components/files/RowsItem.vue +27 -7
  33. package/dist/runtime/components/files/View.vue +4 -4
  34. package/dist/runtime/components/list/atoms/FiltersMenu.vue +9 -0
  35. package/dist/runtime/components/list/atoms/PerPage.vue +3 -2
  36. package/dist/runtime/components/list/atoms/ResetButton.vue +5 -1
  37. package/dist/runtime/components/list/atoms/SearchInput.vue +15 -2
  38. package/dist/runtime/components/list/atoms/SearchString.vue +169 -133
  39. package/dist/runtime/components/list/atoms/SortMenu.vue +22 -18
  40. package/dist/runtime/components/list/atoms/ViewMenu.vue +26 -14
  41. package/dist/runtime/components/list/molecules/Filters.vue +8 -8
  42. package/dist/runtime/components/list/molecules/Header.vue +10 -19
  43. package/dist/runtime/components/list/molecules/Pagination.vue +51 -48
  44. package/dist/runtime/components/list/organisms/List.vue +104 -69
  45. package/dist/runtime/components/mailing/DenseItem.vue +4 -0
  46. package/dist/runtime/components/mailing/ExpandedItem.vue +4 -0
  47. package/dist/runtime/components/mailing/RowsItem.vue +27 -7
  48. package/dist/runtime/components/mailing/View.vue +4 -4
  49. package/dist/runtime/components/misc/atoms/ImageContainer.vue +3 -45
  50. package/dist/runtime/components/misc/molecules/Related.vue +1 -1
  51. package/dist/runtime/components/news/DenseItem.vue +63 -54
  52. package/dist/runtime/components/news/ExpandedItem.vue +11 -17
  53. package/dist/runtime/components/news/RelatedItem.vue +4 -13
  54. package/dist/runtime/components/news/RowsItem.vue +21 -42
  55. package/dist/runtime/components/news/View.vue +7 -7
  56. package/dist/runtime/components/people/DenseItem.vue +16 -20
  57. package/dist/runtime/components/people/RelatedItem.vue +4 -14
  58. package/dist/runtime/components/people/RowsItem.vue +14 -23
  59. package/dist/runtime/components/projects/DenseItem.vue +17 -17
  60. package/dist/runtime/components/projects/RelatedItem.vue +4 -13
  61. package/dist/runtime/components/projects/RowsItem.vue +16 -16
  62. package/dist/runtime/components/projects/View.vue +6 -6
  63. package/dist/runtime/components/publications/DenseItem.vue +17 -15
  64. package/dist/runtime/components/publications/RelatedItem.vue +4 -13
  65. package/dist/runtime/components/publications/RowsItem.vue +18 -18
  66. package/dist/runtime/components/tags/DenseItem.vue +4 -0
  67. package/dist/runtime/components/tags/ExpandedItem.vue +4 -0
  68. package/dist/runtime/components/tags/RowsItem.vue +24 -7
  69. package/dist/runtime/components/tags/View.vue +4 -4
  70. package/dist/runtime/components/users/DenseItem.vue +24 -6
  71. package/dist/runtime/components/users/ExpandedItem.vue +5 -1
  72. package/dist/runtime/components/users/RowsItem.vue +25 -7
  73. package/dist/runtime/components/users/View.vue +4 -4
  74. package/dist/runtime/composables/useUtils.js +1 -1
  75. package/dist/runtime/plugins/pinia.js +5 -2
  76. package/dist/runtime/stores/root.d.ts +10 -9
  77. package/dist/runtime/stores/root.js +83 -119
  78. package/package.json +3 -4
@@ -28,33 +28,34 @@ export declare const useRootStore: import("pinia").StoreDefinition<"rootStore",
28
28
  loadRouteQuery(type: string): void;
29
29
  setFiltersCount(type: string): void;
30
30
  updateRouteQuery(type: string): void;
31
- resetState(type: string, lang?: string): Promise<void>;
32
- updateSort({ value, type, lang, }: {
31
+ resetState(type: string, lang?: string): void;
32
+ updateSort({ value, type, }: {
33
33
  value: (number | string)[];
34
34
  type: string;
35
35
  lang?: string;
36
- }): Promise<void>;
36
+ }): void;
37
37
  updateView({ value, type, lang, }: {
38
38
  value: string;
39
39
  type: string;
40
40
  lang?: string;
41
- }): Promise<void>;
42
- updateFilter(key: string, val: unknown, type: string, lang: string): Promise<void>;
41
+ }): void;
42
+ updateFilter(key: string, val: unknown, type: string, lang: string): void;
43
43
  updateItemsPerPage({ value, type, lang, }: {
44
44
  value: number;
45
45
  type: string;
46
46
  lang?: string;
47
- }): Promise<void>;
47
+ }): void;
48
48
  updatePage({ page, type, lang, }: {
49
49
  page: number;
50
50
  type: string;
51
51
  lang?: string;
52
- }): Promise<void>;
52
+ }): void;
53
53
  updateSearch({ type, search, lang, }: {
54
54
  type: string;
55
55
  search: string;
56
56
  lang: string;
57
- }): Promise<void>;
58
- update(type: string, lang?: string): Promise<boolean>;
57
+ }): void;
58
+ buildListVariables(type: string, lang?: string): any;
59
+ applyListResult(type: string, data: Record<string, any>, itemsPerPageOverride?: number): void;
59
60
  }>;
60
61
  export {};
@@ -1,10 +1,9 @@
1
1
  import { defineStore } from "pinia";
2
- import SEARCH from "../graphql/list/search.gql";
3
- import { useNuxtApp, useRouter, useAsyncQuery } from "#imports";
2
+ import { useNuxtApp, useRouter } from "#imports";
4
3
  export const useRootStore = defineStore("rootStore", {
5
4
  state: () => ({
6
5
  scrolled: typeof window !== "undefined" ? window.scrollY > 0 : false,
7
- loading: false,
6
+ loading: true,
8
7
  total: 0,
9
8
  skip: 0,
10
9
  page: 1,
@@ -27,11 +26,12 @@ export const useRootStore = defineStore("rootStore", {
27
26
  }),
28
27
  actions: {
29
28
  setLoading(value, type = "") {
30
- console.log("setLoading", { value, type });
29
+ console.log("X - setLoading", { value, type });
31
30
  const { $stores } = useNuxtApp();
32
- this.loading = value;
33
- if (type.length && type !== "all" && $stores[type]) {
31
+ if (type.length && $stores[type]) {
34
32
  $stores[type].loading = value;
33
+ } else {
34
+ this.loading = value;
35
35
  }
36
36
  },
37
37
  setScrolled() {
@@ -40,29 +40,27 @@ export const useRootStore = defineStore("rootStore", {
40
40
  }
41
41
  },
42
42
  loadRouteQuery(type) {
43
- console.log("loadRouteQuery", type);
44
- const { $stores } = useNuxtApp();
43
+ console.log("0 - loadRouteQuery", type);
45
44
  const { currentRoute } = useRouter();
45
+ const { $stores } = useNuxtApp();
46
46
  const query = currentRoute.value.query;
47
47
  const filters = $stores[type]?.filters ?? {};
48
- console.log("filters: ", filters);
49
48
  if (Object.keys(query)?.length) {
50
49
  Object.keys(query).forEach((filter) => {
51
50
  if (filter in filters) {
52
- console.log("filter: ", filter, query[filter]);
53
51
  const queryValue = query[filter];
54
52
  if (typeof queryValue === "string") {
55
53
  filters[filter].value = filters[filter].multiple ? JSON.parse(queryValue) : queryValue;
56
54
  }
57
55
  } else {
58
- console.log("unknown filter: ", filter);
59
56
  }
60
57
  });
61
58
  }
62
- console.log("query loaded");
59
+ if (query.page && query.page > 1)
60
+ $stores[type].page = parseInt(query.page, 10) || 1;
63
61
  },
64
62
  setFiltersCount(type) {
65
- console.log("setFiltersCount", type);
63
+ console.log("6- setFiltersCount", type);
66
64
  const { $stores } = useNuxtApp();
67
65
  const filters = $stores[type]?.filters ?? {};
68
66
  const count = Object.values(filters).reduce((acc, filter) => {
@@ -70,12 +68,10 @@ export const useRootStore = defineStore("rootStore", {
70
68
  const isEmpty = value === void 0 || value === null || Array.isArray(value) && value.length === 0 || typeof value === "string" && value.trim() === "";
71
69
  return isEmpty ? acc : acc + 1;
72
70
  }, 0);
73
- if ($stores[type]) {
74
- $stores[type].filtersCount = count;
75
- }
71
+ $stores[type].filtersCount = count;
76
72
  },
77
73
  updateRouteQuery(type) {
78
- console.log("updateRouteQuery", type);
74
+ console.log("5- updateRouteQuery", type);
79
75
  const router = useRouter();
80
76
  const { $stores } = useNuxtApp();
81
77
  const routeQuery = {
@@ -96,44 +92,19 @@ export const useRootStore = defineStore("rootStore", {
96
92
  };
97
93
  router.replace({ query: routeQuery });
98
94
  },
99
- async resetState(type, lang = "en") {
95
+ resetState(type, lang = "en") {
96
+ console.log("Y - resetState", { type, lang });
100
97
  const { $stores, $models } = useNuxtApp();
101
- const moduleState = $stores[type];
102
- const model = $models[type];
103
- if (moduleState && model) {
104
- const clone = (o) => typeof structuredClone === "function" ? structuredClone(o) : JSON.parse(JSON.stringify(o));
105
- moduleState.search = "";
106
- moduleState.filters = clone(model.filters ?? {});
107
- moduleState.view = model.views ? {
108
- ...clone(model.views[Object.keys(model.views)[0]]),
109
- name: Object.keys(model.views)[0]
110
- } : void 0;
111
- moduleState.sortBy = clone(model.sortBy ?? ["date"]);
112
- moduleState.sortDesc = clone(model.sortDesc ?? [0]);
113
- moduleState.itemsPerPage = model.itemsPerPage ?? 10;
114
- moduleState.items = [];
115
- moduleState.total = 0;
116
- moduleState.numberOfPages = 0;
117
- moduleState.loading = false;
118
- }
119
- this.$patch({
120
- search: "",
121
- page: 1,
122
- scrolled: false,
123
- loading: false,
124
- total: 0,
125
- skip: 0,
126
- numberOfPages: 0
127
- });
128
- this.updateRouteQuery(type);
129
- await this.update(type, lang);
98
+ const model = structuredClone($models[type]);
99
+ $stores[type].filters = model?.filters;
100
+ $stores[type].search = "";
101
+ $stores[type].page = 1;
130
102
  },
131
- async updateSort({
103
+ updateSort({
132
104
  value,
133
- type,
134
- lang = "en"
105
+ type
135
106
  }) {
136
- console.log("updateSort", {
107
+ console.log("Z - updateSort", {
137
108
  value,
138
109
  type
139
110
  });
@@ -143,97 +114,100 @@ export const useRootStore = defineStore("rootStore", {
143
114
  $stores[type].sortDesc = [Number(value[1])];
144
115
  }
145
116
  this.page = 1;
146
- await this.update(type, lang);
117
+ $stores[type].loading = true;
118
+ this.updateRouteQuery(type);
147
119
  },
148
- async updateView({
120
+ updateView({
149
121
  value,
150
122
  type,
151
123
  lang
152
124
  }) {
153
- console.log("updateView", { value, type });
125
+ console.log("W - updateView", { value, type });
154
126
  const { $stores } = useNuxtApp();
155
127
  if ($stores[type]?.views?.[value]) {
156
128
  $stores[type].view = {
157
129
  ...$stores[type].views[value],
158
130
  name: value
159
131
  };
132
+ $stores[type].loading = true;
160
133
  }
161
- await this.update(type, lang);
134
+ this.updateRouteQuery(type);
162
135
  },
163
136
  /* updateLocalStorage(key: string, value: string): void {
164
137
  const local = JSON.parse(localStorage.getItem("PARIS_IAS") || "{}")
165
138
  local[key] = value
166
139
  localStorage.setItem("PARIS_IAS", JSON.stringify(local))
167
140
  }, */
168
- async updateFilter(key, val, type, lang) {
141
+ updateFilter(key, val, type, lang) {
169
142
  const { $stores } = useNuxtApp();
170
- console.log("update filter: ", { key, val, type });
143
+ console.log("R - update filter: ", { key, val, type });
171
144
  if ($stores[type]?.filters?.[key]) {
172
145
  $stores[type].filters[key].value = val;
173
146
  }
174
147
  this.page = 1;
175
- await this.update(type, lang);
148
+ $stores[type].loading = true;
149
+ this.setFiltersCount(type);
150
+ this.updateRouteQuery(type);
176
151
  },
177
- async updateItemsPerPage({
152
+ updateItemsPerPage({
178
153
  value,
179
154
  type,
180
155
  lang
181
156
  }) {
182
- console.log("updateItemsPerPage", { value, type });
157
+ console.log("H - updateItemsPerPage", { value, type });
183
158
  const { $stores } = useNuxtApp();
184
159
  this.page = 1;
185
- if ($stores[type]) {
186
- $stores[type].itemsPerPage = value;
187
- }
188
- await this.update(type, lang);
160
+ $stores[type].itemsPerPage = value;
161
+ $stores[type].loading = true;
162
+ this.updateRouteQuery(type);
189
163
  },
190
- async updatePage({
164
+ updatePage({
191
165
  page,
192
166
  type,
193
167
  lang = "en"
194
168
  }) {
195
- console.log("updatePage", { page, type });
169
+ console.log("update page: ", page);
196
170
  const router = useRouter();
197
171
  const currentQuery = router.currentRoute.value.query;
198
172
  const newQuery = { ...currentQuery };
173
+ if (type !== "all") {
174
+ const { $stores } = useNuxtApp();
175
+ $stores[type].page = page;
176
+ $stores[type].loading = true;
177
+ } else {
178
+ this.page = page;
179
+ }
199
180
  if (page > 1) {
200
181
  newQuery.page = page.toString();
201
182
  } else {
202
183
  delete newQuery.page;
203
184
  }
204
- this.page = page;
205
- await this.update(type, lang);
185
+ router.replace({ query: newQuery });
206
186
  },
207
- /*
208
- initializePageFromRoute(): void {
209
- const { query } = useRouter().currentRoute.value
210
- const page = Number.parseInt(query.page as string, 10)
211
- this.page = isNaN(page) || page < 1 ? 1 : page
212
- }, */
213
- async updateSearch({
187
+ updateSearch({
214
188
  type = "all",
215
189
  search = "",
216
190
  lang = "en"
217
191
  }) {
218
- const { $stores } = useNuxtApp();
219
- console.log("updateSearch", { type, search, lang });
220
192
  if (type === "all") {
221
193
  this.search = search;
222
194
  } else {
195
+ const { $stores } = useNuxtApp();
223
196
  if ($stores[type]) {
224
- $stores[type].$patch({ search });
197
+ ;
198
+ $stores[type].search = search;
199
+ $stores[type].loading = true;
225
200
  }
226
201
  }
227
- await this.update(type, lang);
202
+ this.page = 1;
203
+ this.updateRouteQuery(type);
228
204
  },
229
- async update(type, lang = "en") {
230
- const { $stores, $queries } = useNuxtApp();
231
- console.log("update", { type, lang });
232
- this.setLoading(true);
233
- if (type !== "all" && $stores[type]) {
234
- $stores[type].loading = true;
235
- }
205
+ buildListVariables(type, lang = "en") {
206
+ const { $stores } = useNuxtApp();
236
207
  const itemsPerPage = type === "all" ? 3 : $stores[type]?.itemsPerPage || 10;
208
+ const _viewName = $stores[type]?.view && $stores[type].view.name;
209
+ const _sortByName = $stores[type]?.sortBy && $stores[type].sortBy;
210
+ const _sortDescName = $stores[type]?.sortDesc && $stores[type].sortDesc;
237
211
  const filters = {};
238
212
  if (type !== "all") {
239
213
  const storeFilters = $stores[type]?.filters ?? {};
@@ -247,16 +221,11 @@ export const useRootStore = defineStore("rootStore", {
247
221
  const args = JSON.parse(
248
222
  JSON.stringify({
249
223
  options: {
250
- // skip
251
- skip: +this.page === 1 ? 0 : (+this.page - 1) * itemsPerPage,
252
- // limit
224
+ skip: +$stores[type]?.page === 1 ? 0 : (+$stores[type]?.page - 1) * itemsPerPage,
253
225
  limit: itemsPerPage,
254
- // sort, array of keys and array of directions - to have x tie breakers if necessary
255
226
  sortBy: type === "all" ? "searchScore" : $stores[type]?.sortBy || ["created"],
256
227
  sortDesc: type === "all" ? -1 : ($stores[type]?.sortDesc?.[0] || 0) > 0 ? true : false,
257
- // search (if set)
258
228
  ...this.search?.length && type !== "all" && { search: this.search },
259
- // add the store module filters
260
229
  filters
261
230
  },
262
231
  ...type === "all" && this.search?.length && { search: this.search },
@@ -268,36 +237,31 @@ export const useRootStore = defineStore("rootStore", {
268
237
  })
269
238
  );
270
239
  args.options.filters = JSON.stringify(args.options.filters);
271
- console.log("args: ", args);
272
- const { data, error } = await useAsyncQuery(
273
- type === "all" ? SEARCH : $queries[type]?.list,
274
- args
275
- );
276
- console.log("data: ", data);
277
- if (error.value) console.log(error.value);
240
+ return args;
241
+ },
242
+ applyListResult(type, data, itemsPerPageOverride) {
243
+ const { $stores } = useNuxtApp();
278
244
  const key = type === "all" ? "search" : "list" + type.charAt(0).toUpperCase() + type.slice(1);
279
245
  if (type === "all") {
280
- this.results = data?.value?.[key] || this.results;
281
- } else {
282
- const items = data?.value?.[key]?.items ?? [];
283
- if ($stores[type]) {
284
- $stores[type].total = data?.value?.[key]?.total || 0;
285
- const result = {
286
- ...data?.value?.[key],
287
- items: items.map(({ id, ...rest }) => ({
288
- ...rest,
289
- _path: `/${id}`
290
- }))
291
- };
292
- $stores[type].items = result.items;
293
- const lastPage = Math.ceil((result.total || 0) / itemsPerPage);
294
- this.setFiltersCount(type);
295
- $stores[type].numberOfPages = lastPage;
296
- }
246
+ this.results = data?.[key] || this.results;
247
+ return;
248
+ }
249
+ const items = data?.[key]?.items ?? [];
250
+ if ($stores[type]) {
251
+ const itemsPerPage = itemsPerPageOverride || $stores[type].itemsPerPage || 10;
252
+ $stores[type].total = data?.[key]?.total || 0;
253
+ const result = {
254
+ ...data?.[key],
255
+ items: items.map(({ id, ...rest }) => ({
256
+ ...rest,
257
+ _path: `/${id}`
258
+ }))
259
+ };
260
+ $stores[type].items = result.items;
261
+ const lastPage = Math.ceil((result.total || 0) / itemsPerPage);
262
+ this.setFiltersCount(type);
263
+ $stores[type].numberOfPages = lastPage;
297
264
  }
298
- this.updateRouteQuery(type);
299
- this.setLoading(false, type);
300
- return true;
301
265
  }
302
266
  }
303
267
  });
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "license": "AGPL-3.0-only",
3
3
  "main": "./dist/module.mjs",
4
- "version": "1.0.136",
4
+ "version": "1.0.138",
5
5
  "name": "@paris-ias/list",
6
6
  "repository": {
7
7
  "url": "git+https://github.com/IEA-Paris/list.git",
8
8
  "type": "git"
9
9
  },
10
10
  "dependencies": {
11
- "@paris-ias/data": "^1.8.52"
11
+ "@paris-ias/data": "^1.8.54"
12
12
  },
13
13
  "description": "Paris IAS List Module",
14
14
  "peerDependencies": {
@@ -19,7 +19,6 @@
19
19
  "@nuxt/module-builder": "^0.8.4",
20
20
  "@nuxt/schema": "^3.16.2",
21
21
  "@nuxt/test-utils": "^3.17.2",
22
- "@nuxtjs/apollo": "^5.0.0-alpha.14",
23
22
  "@nuxtjs/i18n": "^9.5.2",
24
23
  "@nuxtjs/mdc": "0.16.1",
25
24
  "@pinia/nuxt": "^0.5.4",
@@ -69,6 +68,6 @@
69
68
  },
70
69
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
71
70
  "devDependencies": {
72
- "@nuxt/devtools": "^2.6.3"
71
+ "@nuxtjs/apollo": "^5.0.0-alpha.15"
73
72
  }
74
73
  }