@paris-ias/list 1.0.137 → 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 +1 -1
- package/dist/runtime/components/actions/DenseItem.vue +64 -0
- package/dist/runtime/components/actions/ExpandedItem.vue +17 -14
- package/dist/runtime/components/actions/RowsItem.vue +56 -10
- package/dist/runtime/components/actions/View.vue +5 -17
- package/dist/runtime/components/affiliation/DenseItem.vue +26 -10
- package/dist/runtime/components/affiliation/RowsItem.vue +26 -10
- package/dist/runtime/components/apps/DenseItem.vue +26 -10
- package/dist/runtime/components/apps/RowsItem.vue +26 -10
- package/dist/runtime/components/disciplines/DenseItem.vue +26 -10
- package/dist/runtime/components/disciplines/RowsItem.vue +26 -10
- package/dist/runtime/components/events/DenseItem.vue +12 -3
- package/dist/runtime/components/events/RowsItem.vue +12 -5
- package/dist/runtime/components/fellowships/DenseItem.vue +14 -0
- package/dist/runtime/components/fellowships/RowsItem.vue +16 -2
- package/dist/runtime/components/fellowships/View.vue +2 -2
- package/dist/runtime/components/files/DenseItem.vue +25 -10
- package/dist/runtime/components/files/RowsItem.vue +26 -10
- package/dist/runtime/components/list/atoms/FiltersMenu.vue +9 -0
- package/dist/runtime/components/list/atoms/PerPage.vue +3 -2
- package/dist/runtime/components/list/atoms/ResetButton.vue +5 -1
- package/dist/runtime/components/list/atoms/SearchInput.vue +15 -2
- package/dist/runtime/components/list/atoms/SearchString.vue +169 -133
- package/dist/runtime/components/list/atoms/SortMenu.vue +22 -18
- package/dist/runtime/components/list/atoms/ViewMenu.vue +26 -14
- package/dist/runtime/components/list/molecules/Filters.vue +4 -4
- package/dist/runtime/components/list/molecules/GlobalSearchInput.vue +12 -14
- package/dist/runtime/components/list/molecules/Header.vue +11 -20
- package/dist/runtime/components/list/molecules/Pagination.vue +51 -48
- package/dist/runtime/components/list/molecules/ResultsContainer.vue +5 -2
- package/dist/runtime/components/list/organisms/List.vue +105 -74
- package/dist/runtime/components/list/organisms/Results.vue +31 -17
- package/dist/runtime/components/mailing/RowsItem.vue +26 -10
- package/dist/runtime/components/news/DenseItem.vue +59 -45
- package/dist/runtime/components/news/RowsItem.vue +11 -7
- package/dist/runtime/components/people/DenseItem.vue +10 -8
- package/dist/runtime/components/people/RowsItem.vue +11 -2
- package/dist/runtime/components/projects/DenseItem.vue +11 -4
- package/dist/runtime/components/projects/RowsItem.vue +10 -3
- package/dist/runtime/components/publications/DenseItem.vue +12 -8
- package/dist/runtime/components/publications/RowsItem.vue +12 -4
- package/dist/runtime/components/tags/RowsItem.vue +23 -10
- package/dist/runtime/components/users/DenseItem.vue +24 -10
- package/dist/runtime/components/users/RowsItem.vue +24 -10
- package/dist/runtime/composables/useUtils.js +1 -1
- package/dist/runtime/plugins/pinia.js +5 -2
- package/dist/runtime/stores/root.d.ts +10 -9
- package/dist/runtime/stores/root.js +82 -117
- package/package.json +1 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { defineStore } from "pinia";
|
|
2
|
-
import SEARCH from "../graphql/list/search.gql";
|
|
3
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:
|
|
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
|
-
|
|
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,28 +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
48
|
if (Object.keys(query)?.length) {
|
|
49
49
|
Object.keys(query).forEach((filter) => {
|
|
50
50
|
if (filter in filters) {
|
|
51
|
-
console.log("filter: ", filter, query[filter]);
|
|
52
51
|
const queryValue = query[filter];
|
|
53
52
|
if (typeof queryValue === "string") {
|
|
54
53
|
filters[filter].value = filters[filter].multiple ? JSON.parse(queryValue) : queryValue;
|
|
55
54
|
}
|
|
56
55
|
} else {
|
|
57
|
-
console.log("unknown filter: ", filter);
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
58
|
}
|
|
61
|
-
|
|
59
|
+
if (query.page && query.page > 1)
|
|
60
|
+
$stores[type].page = parseInt(query.page, 10) || 1;
|
|
62
61
|
},
|
|
63
62
|
setFiltersCount(type) {
|
|
64
|
-
console.log("setFiltersCount", type);
|
|
63
|
+
console.log("6- setFiltersCount", type);
|
|
65
64
|
const { $stores } = useNuxtApp();
|
|
66
65
|
const filters = $stores[type]?.filters ?? {};
|
|
67
66
|
const count = Object.values(filters).reduce((acc, filter) => {
|
|
@@ -69,12 +68,10 @@ export const useRootStore = defineStore("rootStore", {
|
|
|
69
68
|
const isEmpty = value === void 0 || value === null || Array.isArray(value) && value.length === 0 || typeof value === "string" && value.trim() === "";
|
|
70
69
|
return isEmpty ? acc : acc + 1;
|
|
71
70
|
}, 0);
|
|
72
|
-
|
|
73
|
-
$stores[type].filtersCount = count;
|
|
74
|
-
}
|
|
71
|
+
$stores[type].filtersCount = count;
|
|
75
72
|
},
|
|
76
73
|
updateRouteQuery(type) {
|
|
77
|
-
console.log("updateRouteQuery", type);
|
|
74
|
+
console.log("5- updateRouteQuery", type);
|
|
78
75
|
const router = useRouter();
|
|
79
76
|
const { $stores } = useNuxtApp();
|
|
80
77
|
const routeQuery = {
|
|
@@ -95,44 +92,19 @@ export const useRootStore = defineStore("rootStore", {
|
|
|
95
92
|
};
|
|
96
93
|
router.replace({ query: routeQuery });
|
|
97
94
|
},
|
|
98
|
-
|
|
95
|
+
resetState(type, lang = "en") {
|
|
96
|
+
console.log("Y - resetState", { type, lang });
|
|
99
97
|
const { $stores, $models } = useNuxtApp();
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
moduleState.search = "";
|
|
105
|
-
moduleState.filters = clone(model.filters ?? {});
|
|
106
|
-
moduleState.view = model.views ? {
|
|
107
|
-
...clone(model.views[Object.keys(model.views)[0]]),
|
|
108
|
-
name: Object.keys(model.views)[0]
|
|
109
|
-
} : void 0;
|
|
110
|
-
moduleState.sortBy = clone(model.sortBy ?? ["date"]);
|
|
111
|
-
moduleState.sortDesc = clone(model.sortDesc ?? [0]);
|
|
112
|
-
moduleState.itemsPerPage = model.itemsPerPage ?? 10;
|
|
113
|
-
moduleState.items = [];
|
|
114
|
-
moduleState.total = 0;
|
|
115
|
-
moduleState.numberOfPages = 0;
|
|
116
|
-
moduleState.loading = false;
|
|
117
|
-
}
|
|
118
|
-
this.$patch({
|
|
119
|
-
search: "",
|
|
120
|
-
page: 1,
|
|
121
|
-
scrolled: false,
|
|
122
|
-
loading: false,
|
|
123
|
-
total: 0,
|
|
124
|
-
skip: 0,
|
|
125
|
-
numberOfPages: 0
|
|
126
|
-
});
|
|
127
|
-
this.updateRouteQuery(type);
|
|
128
|
-
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;
|
|
129
102
|
},
|
|
130
|
-
|
|
103
|
+
updateSort({
|
|
131
104
|
value,
|
|
132
|
-
type
|
|
133
|
-
lang = "en"
|
|
105
|
+
type
|
|
134
106
|
}) {
|
|
135
|
-
console.log("updateSort", {
|
|
107
|
+
console.log("Z - updateSort", {
|
|
136
108
|
value,
|
|
137
109
|
type
|
|
138
110
|
});
|
|
@@ -142,97 +114,100 @@ export const useRootStore = defineStore("rootStore", {
|
|
|
142
114
|
$stores[type].sortDesc = [Number(value[1])];
|
|
143
115
|
}
|
|
144
116
|
this.page = 1;
|
|
145
|
-
|
|
117
|
+
$stores[type].loading = true;
|
|
118
|
+
this.updateRouteQuery(type);
|
|
146
119
|
},
|
|
147
|
-
|
|
120
|
+
updateView({
|
|
148
121
|
value,
|
|
149
122
|
type,
|
|
150
123
|
lang
|
|
151
124
|
}) {
|
|
152
|
-
console.log("updateView", { value, type });
|
|
125
|
+
console.log("W - updateView", { value, type });
|
|
153
126
|
const { $stores } = useNuxtApp();
|
|
154
127
|
if ($stores[type]?.views?.[value]) {
|
|
155
128
|
$stores[type].view = {
|
|
156
129
|
...$stores[type].views[value],
|
|
157
130
|
name: value
|
|
158
131
|
};
|
|
132
|
+
$stores[type].loading = true;
|
|
159
133
|
}
|
|
160
|
-
|
|
134
|
+
this.updateRouteQuery(type);
|
|
161
135
|
},
|
|
162
136
|
/* updateLocalStorage(key: string, value: string): void {
|
|
163
137
|
const local = JSON.parse(localStorage.getItem("PARIS_IAS") || "{}")
|
|
164
138
|
local[key] = value
|
|
165
139
|
localStorage.setItem("PARIS_IAS", JSON.stringify(local))
|
|
166
140
|
}, */
|
|
167
|
-
|
|
141
|
+
updateFilter(key, val, type, lang) {
|
|
168
142
|
const { $stores } = useNuxtApp();
|
|
169
|
-
console.log("update filter: ", { key, val, type });
|
|
143
|
+
console.log("R - update filter: ", { key, val, type });
|
|
170
144
|
if ($stores[type]?.filters?.[key]) {
|
|
171
145
|
$stores[type].filters[key].value = val;
|
|
172
146
|
}
|
|
173
147
|
this.page = 1;
|
|
174
|
-
|
|
148
|
+
$stores[type].loading = true;
|
|
149
|
+
this.setFiltersCount(type);
|
|
150
|
+
this.updateRouteQuery(type);
|
|
175
151
|
},
|
|
176
|
-
|
|
152
|
+
updateItemsPerPage({
|
|
177
153
|
value,
|
|
178
154
|
type,
|
|
179
155
|
lang
|
|
180
156
|
}) {
|
|
181
|
-
console.log("updateItemsPerPage", { value, type });
|
|
157
|
+
console.log("H - updateItemsPerPage", { value, type });
|
|
182
158
|
const { $stores } = useNuxtApp();
|
|
183
159
|
this.page = 1;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
await this.update(type, lang);
|
|
160
|
+
$stores[type].itemsPerPage = value;
|
|
161
|
+
$stores[type].loading = true;
|
|
162
|
+
this.updateRouteQuery(type);
|
|
188
163
|
},
|
|
189
|
-
|
|
164
|
+
updatePage({
|
|
190
165
|
page,
|
|
191
166
|
type,
|
|
192
167
|
lang = "en"
|
|
193
168
|
}) {
|
|
194
|
-
console.log("
|
|
169
|
+
console.log("update page: ", page);
|
|
195
170
|
const router = useRouter();
|
|
196
171
|
const currentQuery = router.currentRoute.value.query;
|
|
197
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
|
+
}
|
|
198
180
|
if (page > 1) {
|
|
199
181
|
newQuery.page = page.toString();
|
|
200
182
|
} else {
|
|
201
183
|
delete newQuery.page;
|
|
202
184
|
}
|
|
203
|
-
|
|
204
|
-
await this.update(type, lang);
|
|
185
|
+
router.replace({ query: newQuery });
|
|
205
186
|
},
|
|
206
|
-
|
|
207
|
-
initializePageFromRoute(): void {
|
|
208
|
-
const { query } = useRouter().currentRoute.value
|
|
209
|
-
const page = Number.parseInt(query.page as string, 10)
|
|
210
|
-
this.page = isNaN(page) || page < 1 ? 1 : page
|
|
211
|
-
}, */
|
|
212
|
-
async updateSearch({
|
|
187
|
+
updateSearch({
|
|
213
188
|
type = "all",
|
|
214
189
|
search = "",
|
|
215
190
|
lang = "en"
|
|
216
191
|
}) {
|
|
217
|
-
const { $stores } = useNuxtApp();
|
|
218
|
-
console.log("updateSearch", { type, search, lang });
|
|
219
192
|
if (type === "all") {
|
|
220
193
|
this.search = search;
|
|
221
194
|
} else {
|
|
195
|
+
const { $stores } = useNuxtApp();
|
|
222
196
|
if ($stores[type]) {
|
|
223
|
-
|
|
197
|
+
;
|
|
198
|
+
$stores[type].search = search;
|
|
199
|
+
$stores[type].loading = true;
|
|
224
200
|
}
|
|
225
201
|
}
|
|
226
|
-
|
|
202
|
+
this.page = 1;
|
|
203
|
+
this.updateRouteQuery(type);
|
|
227
204
|
},
|
|
228
|
-
|
|
229
|
-
const { $stores
|
|
230
|
-
console.log("update", { type, lang });
|
|
231
|
-
this.setLoading(true);
|
|
232
|
-
if (type !== "all" && $stores[type]) {
|
|
233
|
-
$stores[type].loading = true;
|
|
234
|
-
}
|
|
205
|
+
buildListVariables(type, lang = "en") {
|
|
206
|
+
const { $stores } = useNuxtApp();
|
|
235
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;
|
|
236
211
|
const filters = {};
|
|
237
212
|
if (type !== "all") {
|
|
238
213
|
const storeFilters = $stores[type]?.filters ?? {};
|
|
@@ -246,16 +221,11 @@ export const useRootStore = defineStore("rootStore", {
|
|
|
246
221
|
const args = JSON.parse(
|
|
247
222
|
JSON.stringify({
|
|
248
223
|
options: {
|
|
249
|
-
|
|
250
|
-
skip: +this.page === 1 ? 0 : (+this.page - 1) * itemsPerPage,
|
|
251
|
-
// limit
|
|
224
|
+
skip: +$stores[type]?.page === 1 ? 0 : (+$stores[type]?.page - 1) * itemsPerPage,
|
|
252
225
|
limit: itemsPerPage,
|
|
253
|
-
// sort, array of keys and array of directions - to have x tie breakers if necessary
|
|
254
226
|
sortBy: type === "all" ? "searchScore" : $stores[type]?.sortBy || ["created"],
|
|
255
227
|
sortDesc: type === "all" ? -1 : ($stores[type]?.sortDesc?.[0] || 0) > 0 ? true : false,
|
|
256
|
-
// search (if set)
|
|
257
228
|
...this.search?.length && type !== "all" && { search: this.search },
|
|
258
|
-
// add the store module filters
|
|
259
229
|
filters
|
|
260
230
|
},
|
|
261
231
|
...type === "all" && this.search?.length && { search: this.search },
|
|
@@ -267,36 +237,31 @@ export const useRootStore = defineStore("rootStore", {
|
|
|
267
237
|
})
|
|
268
238
|
);
|
|
269
239
|
args.options.filters = JSON.stringify(args.options.filters);
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
);
|
|
275
|
-
console.log("data: ", data);
|
|
276
|
-
if (error.value) console.log(error.value);
|
|
240
|
+
return args;
|
|
241
|
+
},
|
|
242
|
+
applyListResult(type, data, itemsPerPageOverride) {
|
|
243
|
+
const { $stores } = useNuxtApp();
|
|
277
244
|
const key = type === "all" ? "search" : "list" + type.charAt(0).toUpperCase() + type.slice(1);
|
|
278
245
|
if (type === "all") {
|
|
279
|
-
this.results = data?.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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;
|
|
296
264
|
}
|
|
297
|
-
this.updateRouteQuery(type);
|
|
298
|
-
this.setLoading(false, type);
|
|
299
|
-
return true;
|
|
300
265
|
}
|
|
301
266
|
}
|
|
302
267
|
});
|