@paris-ias/list 1.0.169 → 1.0.170
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/events/View.vue +1 -1
- package/dist/runtime/components/list/atoms/SortMenu.vue +50 -60
- package/dist/runtime/components/list/atoms/ViewMenu.vue +1 -0
- package/dist/runtime/stores/root.d.ts +3 -1
- package/dist/runtime/stores/root.js +7 -11
- package/package.json +2 -2
package/dist/module.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<template v-if="$stores[type].loading">
|
|
7
7
|
<v-skeleton-loader type="button" :class="{ 'mt-3': isXsDisplay }" />
|
|
8
8
|
</template>
|
|
9
|
+
|
|
9
10
|
<template v-else>
|
|
10
11
|
<v-btn
|
|
11
12
|
x-large
|
|
@@ -16,40 +17,28 @@
|
|
|
16
17
|
:class="{ 'mt-3': isXsDisplay }"
|
|
17
18
|
v-bind="mergeProps(menu, tooltip)"
|
|
18
19
|
>
|
|
19
|
-
<v-icon>mdi-{{
|
|
20
|
+
<v-icon>mdi-{{ currentSort?.icon || defaultSort?.icon }}</v-icon>
|
|
20
21
|
</v-btn>
|
|
21
22
|
</template>
|
|
22
23
|
</template>
|
|
24
|
+
|
|
23
25
|
<div
|
|
24
26
|
v-html="
|
|
25
27
|
$t('list.sort-mode') +
|
|
26
|
-
$t('list.' + (
|
|
28
|
+
$t('list.' + (currentSort?.text || defaultSort?.text))
|
|
27
29
|
"
|
|
28
30
|
/>
|
|
29
31
|
</v-tooltip>
|
|
30
32
|
</template>
|
|
31
|
-
<v-list density="compact">
|
|
32
|
-
<!-- <template v-for="(item, index) in $stores[props.type].sort">
|
|
33
|
-
<v-list-item
|
|
34
|
-
v-if="item.text !== current.text"
|
|
35
|
-
:key="index"
|
|
36
|
-
:disabled="$stores[type].loading"
|
|
37
|
-
@click="updateSort(item.value)"
|
|
38
|
-
>
|
|
39
|
-
<template #prepend>
|
|
40
|
-
<v-icon>mdi-{{ item.icon }}</v-icon>
|
|
41
|
-
</template>
|
|
42
|
-
<v-list-item-title>{{ $t("list." + item.text) }}</v-list-item-title>
|
|
43
|
-
</v-list-item>
|
|
44
|
-
</template> -->
|
|
45
33
|
|
|
34
|
+
<v-list density="compact">
|
|
46
35
|
<v-list-item
|
|
47
|
-
v-for="(item,
|
|
48
|
-
:key="
|
|
49
|
-
:disabled="$stores[type].loading || isActiveSort(
|
|
50
|
-
:active="isActiveSort(
|
|
36
|
+
v-for="(item, key) in $stores[type].sort"
|
|
37
|
+
:key="key"
|
|
38
|
+
:disabled="$stores[type].loading || isActiveSort(key)"
|
|
39
|
+
:active="isActiveSort(key)"
|
|
51
40
|
active-class="bg-black text-white"
|
|
52
|
-
@click="
|
|
41
|
+
@click="onSelectSort(key)"
|
|
53
42
|
>
|
|
54
43
|
<template #prepend>
|
|
55
44
|
<v-icon>mdi-{{ item.icon }}</v-icon>
|
|
@@ -62,59 +51,60 @@
|
|
|
62
51
|
</template>
|
|
63
52
|
|
|
64
53
|
<script setup>
|
|
54
|
+
import { computed } from "vue"
|
|
65
55
|
import { mergeProps } from "vue"
|
|
66
56
|
import { useDisplay } from "vuetify"
|
|
67
57
|
import { useRootStore } from "../../../stores/root"
|
|
68
|
-
import { useNuxtApp,
|
|
58
|
+
import { useNuxtApp, useI18n } from "#imports"
|
|
59
|
+
|
|
69
60
|
const { $stores } = useNuxtApp()
|
|
70
61
|
const { xs: isXsDisplay } = useDisplay()
|
|
71
62
|
const { locale } = useI18n()
|
|
72
63
|
const rootStore = useRootStore()
|
|
73
64
|
|
|
74
65
|
const props = defineProps({
|
|
75
|
-
type: {
|
|
76
|
-
type: String,
|
|
77
|
-
default: "articles",
|
|
78
|
-
required: true,
|
|
79
|
-
},
|
|
66
|
+
type: { type: String, default: "articles", required: true },
|
|
80
67
|
})
|
|
81
|
-
const items = ref()
|
|
82
|
-
const defaultSort = ref(
|
|
83
|
-
$stores[props.type].sort[
|
|
84
|
-
Object.keys($stores[props.type].sort).find(
|
|
85
|
-
(item) => $stores[props.type].sort[item].default === true,
|
|
86
|
-
)
|
|
87
|
-
],
|
|
88
|
-
)
|
|
89
68
|
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
})
|
|
101
|
-
]
|
|
102
|
-
} catch (error) {
|
|
103
|
-
console.log("error: ", error)
|
|
104
|
-
return items[Object.keys(items).find((item) => item.default)]
|
|
105
|
-
}
|
|
69
|
+
const sortObj = computed(() => $stores[props.type]?.sort || {})
|
|
70
|
+
|
|
71
|
+
const defaultSortKey = computed(() => {
|
|
72
|
+
const keys = Object.keys(sortObj.value)
|
|
73
|
+
return keys.find((k) => sortObj.value[k]?.default) || keys[0]
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const activeSortKey = computed(() => {
|
|
77
|
+
const keys = Object.keys(sortObj.value)
|
|
78
|
+
return keys.find((k) => sortObj.value[k]?.active) || defaultSortKey.value
|
|
106
79
|
})
|
|
107
80
|
|
|
108
|
-
const
|
|
109
|
-
|
|
81
|
+
const defaultSort = computed(() =>
|
|
82
|
+
defaultSortKey.value ? sortObj.value[defaultSortKey.value] : undefined
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
const currentSort = computed(() =>
|
|
86
|
+
activeSortKey.value ? sortObj.value[activeSortKey.value] : defaultSort.value
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
const isActiveSort = (key) => activeSortKey.value === key
|
|
90
|
+
|
|
91
|
+
const onSelectSort = async (key) => {
|
|
92
|
+
setActiveSort(key)
|
|
93
|
+
|
|
94
|
+
const item = sortObj.value[key]
|
|
95
|
+
if (!item?.value) return
|
|
96
|
+
|
|
97
|
+
rootStore.updateSort({
|
|
98
|
+
value: item.value,
|
|
99
|
+
type: props.type,
|
|
100
|
+
lang: locale.value,
|
|
101
|
+
sort: key,
|
|
102
|
+
})
|
|
110
103
|
}
|
|
111
104
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
)
|
|
105
|
+
const setActiveSort = (activeKey) => {
|
|
106
|
+
for (const k of Object.keys(sortObj.value)) {
|
|
107
|
+
sortObj.value[k].active = k === activeKey
|
|
108
|
+
}
|
|
117
109
|
}
|
|
118
110
|
</script>
|
|
119
|
-
|
|
120
|
-
<style lang="scss"></style>
|
|
@@ -65,6 +65,7 @@ const items = computed(() => store.value?.views ?? {})
|
|
|
65
65
|
|
|
66
66
|
const current = computed(() => store.value?.view ?? null)
|
|
67
67
|
|
|
68
|
+
console.log("current", current.value)
|
|
68
69
|
const defaultView = computed(() => {
|
|
69
70
|
const views = store.value?.views ?? {}
|
|
70
71
|
const key = Object.keys(views).find((k) => views[k]?.default === true)
|
|
@@ -21,6 +21,7 @@ interface RootStoreState {
|
|
|
21
21
|
numberOfPages: number;
|
|
22
22
|
search: string;
|
|
23
23
|
results: SearchResults;
|
|
24
|
+
sort: string;
|
|
24
25
|
}
|
|
25
26
|
export declare const useRootStore: import("pinia").StoreDefinition<"rootStore", RootStoreState, {}, {
|
|
26
27
|
setLoading(value: boolean, type?: string): void;
|
|
@@ -29,10 +30,11 @@ export declare const useRootStore: import("pinia").StoreDefinition<"rootStore",
|
|
|
29
30
|
setFiltersCount(type: string): void;
|
|
30
31
|
updateRouteQuery(type: string): void;
|
|
31
32
|
resetState(type: string, lang?: string): void;
|
|
32
|
-
updateSort({ value, type, }: {
|
|
33
|
+
updateSort({ value, type, lang, sortKey, }: {
|
|
33
34
|
value: (number | string)[];
|
|
34
35
|
type: string;
|
|
35
36
|
lang?: string;
|
|
37
|
+
sort: string;
|
|
36
38
|
}): void;
|
|
37
39
|
updateView({ value, type, lang, }: {
|
|
38
40
|
value: string;
|
|
@@ -22,7 +22,8 @@ export const useRootStore = defineStore("rootStore", {
|
|
|
22
22
|
files: {},
|
|
23
23
|
mailing: {},
|
|
24
24
|
tags: {}
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
|
+
sort: ""
|
|
26
27
|
}),
|
|
27
28
|
actions: {
|
|
28
29
|
setLoading(value, type = "") {
|
|
@@ -102,18 +103,17 @@ export const useRootStore = defineStore("rootStore", {
|
|
|
102
103
|
},
|
|
103
104
|
updateSort({
|
|
104
105
|
value,
|
|
105
|
-
type
|
|
106
|
+
type,
|
|
107
|
+
lang,
|
|
108
|
+
sortKey
|
|
106
109
|
}) {
|
|
107
110
|
console.log("Z - updateSort", {
|
|
108
111
|
value,
|
|
109
112
|
type
|
|
110
113
|
});
|
|
111
114
|
const { $stores } = useNuxtApp();
|
|
112
|
-
if ($stores[type]) {
|
|
113
|
-
$stores[type].sortBy = [String(value[0])];
|
|
114
|
-
$stores[type].sortDesc = [Number(value[1])];
|
|
115
|
-
}
|
|
116
115
|
this.page = 1;
|
|
116
|
+
this.sort = sort;
|
|
117
117
|
$stores[type].loading = true;
|
|
118
118
|
this.updateRouteQuery(type);
|
|
119
119
|
},
|
|
@@ -204,9 +204,6 @@ export const useRootStore = defineStore("rootStore", {
|
|
|
204
204
|
buildListVariables(type, lang = "en") {
|
|
205
205
|
const { $stores } = useNuxtApp();
|
|
206
206
|
const itemsPerPage = type === "all" ? 3 : $stores[type]?.itemsPerPage || 10;
|
|
207
|
-
const _viewName = $stores[type]?.view && $stores[type].view.name;
|
|
208
|
-
const _sortByName = $stores[type]?.sortBy && $stores[type].sortBy;
|
|
209
|
-
const _sortDescName = $stores[type]?.sortDesc && $stores[type].sortDesc;
|
|
210
207
|
const filters = {};
|
|
211
208
|
if (type !== "all") {
|
|
212
209
|
const storeFilters = $stores[type]?.filters ?? {};
|
|
@@ -222,8 +219,7 @@ export const useRootStore = defineStore("rootStore", {
|
|
|
222
219
|
options: {
|
|
223
220
|
skip: +$stores[type]?.page === 1 ? 0 : (+$stores[type]?.page - 1) * itemsPerPage,
|
|
224
221
|
limit: itemsPerPage,
|
|
225
|
-
sortBy:
|
|
226
|
-
sortDesc: type === "all" ? -1 : ($stores[type]?.sortDesc?.[0] || 0) > 0 ? true : false,
|
|
222
|
+
// sortBy: this.sort,
|
|
227
223
|
...this.search?.length && type !== "all" && { search: this.search },
|
|
228
224
|
filters
|
|
229
225
|
},
|
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.
|
|
4
|
+
"version": "1.0.170",
|
|
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/trees": "^2.0.
|
|
11
|
+
"@paris-ias/trees": "^2.0.37"
|
|
12
12
|
},
|
|
13
13
|
"description": "Paris IAS List Module",
|
|
14
14
|
"peerDependencies": {
|