@paris-ias/list 1.0.112 → 1.0.113

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 (151) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/list/molecules/Pagination.vue +2 -0
  3. package/dist/runtime/components/list/organisms/List.vue +11 -1
  4. package/dist/runtime/runtime/components/actions/ExpandedItem.vue +14 -0
  5. package/dist/runtime/runtime/components/actions/RowsItem.vue +12 -0
  6. package/dist/runtime/runtime/components/actions/View.vue +20 -0
  7. package/dist/runtime/runtime/components/affiliations/ExpandedItem.vue +14 -0
  8. package/dist/runtime/runtime/components/affiliations/RowsItem.vue +12 -0
  9. package/dist/runtime/runtime/components/affiliations/View.vue +20 -0
  10. package/dist/runtime/runtime/components/apps/ExpandedItem.vue +14 -0
  11. package/dist/runtime/runtime/components/apps/RowsItem.vue +12 -0
  12. package/dist/runtime/runtime/components/apps/View.vue +20 -0
  13. package/dist/runtime/runtime/components/disciplines/ExpandedItem.vue +14 -0
  14. package/dist/runtime/runtime/components/disciplines/RowsItem.vue +12 -0
  15. package/dist/runtime/runtime/components/disciplines/View.vue +20 -0
  16. package/dist/runtime/runtime/components/events/Badges.vue +73 -0
  17. package/dist/runtime/runtime/components/events/DateTimePlace.vue +77 -0
  18. package/dist/runtime/runtime/components/events/DenseItem.vue +60 -0
  19. package/dist/runtime/runtime/components/events/ExpandedItem.vue +9 -0
  20. package/dist/runtime/runtime/components/events/RegisterModal.vue +50 -0
  21. package/dist/runtime/runtime/components/events/RelatedItem.vue +44 -0
  22. package/dist/runtime/runtime/components/events/RowsItem.vue +118 -0
  23. package/dist/runtime/runtime/components/events/SlidingItem.vue +63 -0
  24. package/dist/runtime/runtime/components/events/View.vue +333 -0
  25. package/dist/runtime/runtime/components/fellowships/Badges.vue +47 -0
  26. package/dist/runtime/runtime/components/fellowships/DenseItem.vue +42 -0
  27. package/dist/runtime/runtime/components/fellowships/ExpandedItem.vue +7 -0
  28. package/dist/runtime/runtime/components/fellowships/RegisterModal.vue +41 -0
  29. package/dist/runtime/runtime/components/fellowships/RowsItem.vue +58 -0
  30. package/dist/runtime/runtime/components/fellowships/View.vue +203 -0
  31. package/dist/runtime/runtime/components/files/ExpandedItem.vue +14 -0
  32. package/dist/runtime/runtime/components/files/RowsItem.vue +12 -0
  33. package/dist/runtime/runtime/components/files/View.vue +20 -0
  34. package/dist/runtime/runtime/components/list/atoms/FiltersMenu.vue +44 -0
  35. package/dist/runtime/runtime/components/list/atoms/ResetButton.vue +33 -0
  36. package/dist/runtime/runtime/components/list/atoms/ResultsList.vue +27 -0
  37. package/dist/runtime/runtime/components/list/atoms/SearchInput.vue +59 -0
  38. package/dist/runtime/runtime/components/list/atoms/SearchItem.vue +65 -0
  39. package/dist/runtime/runtime/components/list/atoms/SearchString.vue +160 -0
  40. package/dist/runtime/runtime/components/list/atoms/SortMenu.vue +80 -0
  41. package/dist/runtime/runtime/components/list/atoms/ViewMenu.vue +63 -0
  42. package/dist/runtime/runtime/components/list/atoms/itemsPerPage.vue +33 -0
  43. package/dist/runtime/runtime/components/list/inputs/AutoComplete.vue +24 -0
  44. package/dist/runtime/runtime/components/list/inputs/BooleanSwitch.vue +20 -0
  45. package/dist/runtime/runtime/components/list/inputs/Checkbox.vue +20 -0
  46. package/dist/runtime/runtime/components/list/inputs/Select.vue +28 -0
  47. package/dist/runtime/runtime/components/list/molecules/Filters.vue +98 -0
  48. package/dist/runtime/runtime/components/list/molecules/GlobalSearchInput.vue +131 -0
  49. package/dist/runtime/runtime/components/list/molecules/Header.vue +51 -0
  50. package/dist/runtime/runtime/components/list/molecules/Pagination.vue +194 -0
  51. package/dist/runtime/runtime/components/list/molecules/ResultsContainer.vue +78 -0
  52. package/dist/runtime/runtime/components/list/organisms/List.vue +110 -0
  53. package/dist/runtime/runtime/components/list/organisms/Results.vue +72 -0
  54. package/dist/runtime/runtime/components/list/organisms/Slider.vue +180 -0
  55. package/dist/runtime/runtime/components/list/views/Dense.vue +12 -0
  56. package/dist/runtime/runtime/components/list/views/Expanded.vue +10 -0
  57. package/dist/runtime/runtime/components/list/views/Grid.vue +13 -0
  58. package/dist/runtime/runtime/components/list/views/Rows.vue +12 -0
  59. package/dist/runtime/runtime/components/list/views/Slider.vue +147 -0
  60. package/dist/runtime/runtime/components/list/views/Table.vue +13 -0
  61. package/dist/runtime/runtime/components/mailing/ExpandedItem.vue +14 -0
  62. package/dist/runtime/runtime/components/mailing/RowsItem.vue +12 -0
  63. package/dist/runtime/runtime/components/mailing/View.vue +20 -0
  64. package/dist/runtime/runtime/components/misc/atoms/DateStamp.vue +101 -0
  65. package/dist/runtime/runtime/components/misc/atoms/ImageContainer.vue +127 -0
  66. package/dist/runtime/runtime/components/misc/atoms/ShareMenu.vue +61 -0
  67. package/dist/runtime/runtime/components/misc/atoms/Socials.vue +120 -0
  68. package/dist/runtime/runtime/components/misc/molecules/ChipContainer.vue +31 -0
  69. package/dist/runtime/runtime/components/misc/molecules/Related.vue +28 -0
  70. package/dist/runtime/runtime/components/misc/molecules/RelatedItems.vue +27 -0
  71. package/dist/runtime/runtime/components/misc/molecules/SearchItem.vue +26 -0
  72. package/dist/runtime/runtime/components/news/DenseItem.vue +73 -0
  73. package/dist/runtime/runtime/components/news/ExpandedItem.vue +145 -0
  74. package/dist/runtime/runtime/components/news/Header.vue +7 -0
  75. package/dist/runtime/runtime/components/news/RelatedItem.vue +44 -0
  76. package/dist/runtime/runtime/components/news/RowsItem.vue +182 -0
  77. package/dist/runtime/runtime/components/news/View.vue +174 -0
  78. package/dist/runtime/runtime/components/people/DenseItem.vue +60 -0
  79. package/dist/runtime/runtime/components/people/ExpandedItem.vue +14 -0
  80. package/dist/runtime/runtime/components/people/GroupBadges.vue +54 -0
  81. package/dist/runtime/runtime/components/people/RelatedItem.vue +41 -0
  82. package/dist/runtime/runtime/components/people/RowsItem.vue +93 -0
  83. package/dist/runtime/runtime/components/people/View.vue +172 -0
  84. package/dist/runtime/runtime/components/projects/DenseItem.vue +77 -0
  85. package/dist/runtime/runtime/components/projects/ExpandedItem.vue +12 -0
  86. package/dist/runtime/runtime/components/projects/RelatedItem.vue +44 -0
  87. package/dist/runtime/runtime/components/projects/RowsItem.vue +103 -0
  88. package/dist/runtime/runtime/components/projects/View.vue +130 -0
  89. package/dist/runtime/runtime/components/publications/DenseItem.vue +89 -0
  90. package/dist/runtime/runtime/components/publications/RelatedItem.vue +44 -0
  91. package/dist/runtime/runtime/components/publications/RowsItem.vue +105 -0
  92. package/dist/runtime/runtime/components/publications/View.vue +132 -0
  93. package/dist/runtime/runtime/components/tags/ExpandedItem.vue +14 -0
  94. package/dist/runtime/runtime/components/tags/RowsItem.vue +12 -0
  95. package/dist/runtime/runtime/components/tags/View.vue +20 -0
  96. package/dist/runtime/runtime/components/users/ExpandedItem.vue +14 -0
  97. package/dist/runtime/runtime/components/users/RowsItem.vue +12 -0
  98. package/dist/runtime/runtime/components/users/View.vue +20 -0
  99. package/dist/runtime/runtime/composables/useFetchItem.d.ts +6 -0
  100. package/dist/runtime/runtime/composables/useFetchItem.js +49 -0
  101. package/dist/runtime/runtime/composables/useIcons.d.ts +1 -0
  102. package/dist/runtime/runtime/composables/useIcons.js +30 -0
  103. package/dist/runtime/runtime/composables/useUtils.d.ts +12 -0
  104. package/dist/runtime/runtime/composables/useUtils.js +48 -0
  105. package/dist/runtime/runtime/graphql/buildFiltersValues.gql +35 -0
  106. package/dist/runtime/runtime/graphql/item/action.gql +22 -0
  107. package/dist/runtime/runtime/graphql/item/affiliations.gql +37 -0
  108. package/dist/runtime/runtime/graphql/item/apps.gql +34 -0
  109. package/dist/runtime/runtime/graphql/item/disciplines.gql +17 -0
  110. package/dist/runtime/runtime/graphql/item/events.gql +120 -0
  111. package/dist/runtime/runtime/graphql/item/fellowships.gql +164 -0
  112. package/dist/runtime/runtime/graphql/item/files.gql +25 -0
  113. package/dist/runtime/runtime/graphql/item/mailing.gql +10 -0
  114. package/dist/runtime/runtime/graphql/item/news.gql +129 -0
  115. package/dist/runtime/runtime/graphql/item/people.gql +174 -0
  116. package/dist/runtime/runtime/graphql/item/projects.gql +171 -0
  117. package/dist/runtime/runtime/graphql/item/publications.gql +169 -0
  118. package/dist/runtime/runtime/graphql/item/tags.gql +13 -0
  119. package/dist/runtime/runtime/graphql/item/users.gql +14 -0
  120. package/dist/runtime/runtime/graphql/list/action.gql +31 -0
  121. package/dist/runtime/runtime/graphql/list/affiliations.gql +42 -0
  122. package/dist/runtime/runtime/graphql/list/apps.gql +42 -0
  123. package/dist/runtime/runtime/graphql/list/disciplines.gql +22 -0
  124. package/dist/runtime/runtime/graphql/list/events.gql +44 -0
  125. package/dist/runtime/runtime/graphql/list/fellowships.gql +53 -0
  126. package/dist/runtime/runtime/graphql/list/files.gql +37 -0
  127. package/dist/runtime/runtime/graphql/list/mailing.gql +22 -0
  128. package/dist/runtime/runtime/graphql/list/news.gql +40 -0
  129. package/dist/runtime/runtime/graphql/list/people.gql +50 -0
  130. package/dist/runtime/runtime/graphql/list/projects.gql +37 -0
  131. package/dist/runtime/runtime/graphql/list/publications.gql +38 -0
  132. package/dist/runtime/runtime/graphql/list/search.gql +161 -0
  133. package/dist/runtime/runtime/graphql/list/tags.gql +22 -0
  134. package/dist/runtime/runtime/graphql/list/users.gql +38 -0
  135. package/dist/runtime/runtime/graphql/login.gql +0 -0
  136. package/dist/runtime/runtime/plugins/pinia.d.ts +2 -0
  137. package/dist/runtime/runtime/plugins/pinia.js +134 -0
  138. package/dist/runtime/runtime/plugins/vuetify.d.ts +2 -0
  139. package/dist/runtime/runtime/plugins/vuetify.js +21 -0
  140. package/dist/runtime/runtime/public/default.png +0 -0
  141. package/dist/runtime/runtime/public/filters.json +72 -0
  142. package/dist/runtime/runtime/server/tsconfig.json +3 -0
  143. package/dist/runtime/runtime/stores/factory.d.ts +25 -0
  144. package/dist/runtime/runtime/stores/factory.js +19 -0
  145. package/dist/runtime/runtime/stores/root.d.ts +60 -0
  146. package/dist/runtime/runtime/stores/root.js +315 -0
  147. package/dist/runtime/runtime/translations/en.json +350 -0
  148. package/dist/runtime/runtime/translations/fr.json +349 -0
  149. package/dist/runtime/runtime/types/imports.d.ts +13 -0
  150. package/dist/runtime/runtime/types/stores.d.ts +11 -0
  151. package/package.json +1 -1
@@ -0,0 +1,134 @@
1
+ import { createDynamicStore } from "../stores/factory.js";
2
+ import { useRootStore } from "../stores/root.js";
3
+ import { defineNuxtPlugin, useAppConfig } from "#app";
4
+ export default defineNuxtPlugin(async (nuxtApp) => {
5
+ const appConfig = useAppConfig();
6
+ const moduleImports = {
7
+ events: () => ({
8
+ model: import("@paris-ias/data/dist/list/events.js"),
9
+ queries: {
10
+ list: import("../graphql/list/events.gql"),
11
+ get: import("../graphql/item/events.gql")
12
+ }
13
+ }),
14
+ news: () => ({
15
+ model: import("@paris-ias/data/dist/list/news.js"),
16
+ queries: {
17
+ list: import("../graphql/list/news.gql"),
18
+ get: import("../graphql/item/news.gql")
19
+ }
20
+ }),
21
+ people: () => ({
22
+ model: import("@paris-ias/data/dist/list/people.js"),
23
+ queries: {
24
+ list: import("../graphql/list/people.gql"),
25
+ get: import("../graphql/item/people.gql")
26
+ }
27
+ }),
28
+ projects: () => ({
29
+ model: import("@paris-ias/data/dist/list/projects.js"),
30
+ queries: {
31
+ list: import("../graphql/list/projects.gql"),
32
+ get: import("../graphql/item/projects.gql")
33
+ }
34
+ }),
35
+ fellowships: () => ({
36
+ model: import("@paris-ias/data/dist/list/fellowships.js"),
37
+ queries: {
38
+ list: import("../graphql/list/fellowships.gql"),
39
+ get: import("../graphql/item/fellowships.gql")
40
+ }
41
+ }),
42
+ publications: () => ({
43
+ model: import("@paris-ias/data/dist/list/publications.js"),
44
+ queries: {
45
+ list: import("../graphql/list/publications.gql"),
46
+ get: import("../graphql/item/publications.gql")
47
+ }
48
+ }),
49
+ actions: () => ({
50
+ model: import("@paris-ias/data/dist/list/action.js"),
51
+ queries: {
52
+ list: import("../graphql/list/action.gql"),
53
+ get: import("../graphql/item/action.gql")
54
+ }
55
+ }),
56
+ affiliations: () => ({
57
+ model: import("@paris-ias/data/dist/list/affiliations.js"),
58
+ queries: {
59
+ list: import("../graphql/list/affiliations.gql"),
60
+ get: import("../graphql/item/affiliations.gql")
61
+ }
62
+ }),
63
+ disciplines: () => ({
64
+ model: import("@paris-ias/data/dist/list/disciplines.js"),
65
+ queries: {
66
+ list: import("../graphql/list/disciplines.gql"),
67
+ get: import("../graphql/item/disciplines.gql")
68
+ }
69
+ }),
70
+ files: () => ({
71
+ model: import("@paris-ias/data/dist/list/files.js"),
72
+ queries: {
73
+ list: import("../graphql/list/files.gql"),
74
+ get: import("../graphql/item/files.gql")
75
+ }
76
+ }),
77
+ mailing: () => ({
78
+ model: import("@paris-ias/data/dist/list/mailing.js"),
79
+ queries: {
80
+ list: import("../graphql/list/mailing.gql"),
81
+ get: import("../graphql/item/mailing.gql")
82
+ }
83
+ }),
84
+ tags: () => ({
85
+ model: import("@paris-ias/data/dist/list/tags.js"),
86
+ queries: {
87
+ list: import("../graphql/list/tags.gql"),
88
+ get: import("../graphql/item/tags.gql")
89
+ }
90
+ }),
91
+ apps: () => ({
92
+ model: import("@paris-ias/data/dist/list/apps.js"),
93
+ queries: {
94
+ list: import("../graphql/list/apps.gql"),
95
+ get: import("../graphql/item/apps.gql")
96
+ }
97
+ }),
98
+ users: () => ({
99
+ model: import("@paris-ias/data/dist/list/users.js"),
100
+ queries: {
101
+ list: import("../graphql/list/users.gql"),
102
+ get: import("../graphql/item/users.gql")
103
+ }
104
+ })
105
+ // Add other modules similarly...
106
+ };
107
+ const stores = {};
108
+ const queries = {};
109
+ const models = {};
110
+ const builtFilters = await import("../public/filters.json");
111
+ console.log("INITIALIZING STORES");
112
+ await Promise.all(
113
+ appConfig.list.modules.map(async (type) => {
114
+ try {
115
+ const imports = await moduleImports[type]();
116
+ const model = (await imports.model).default;
117
+ queries[type] = {
118
+ list: (await imports.queries.list).default,
119
+ get: (await imports.queries.get).default
120
+ };
121
+ models[type] = model;
122
+ stores[type] = createDynamicStore(type, model)();
123
+ } catch (error) {
124
+ console.error(`Failed to initialize ${type} store:`, error);
125
+ }
126
+ })
127
+ );
128
+ const rootStore = useRootStore();
129
+ nuxtApp.provide("models", models);
130
+ nuxtApp.provide("rootStore", rootStore);
131
+ nuxtApp.provide("stores", stores);
132
+ nuxtApp.provide("queries", queries);
133
+ nuxtApp.provide("filters", builtFilters);
134
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import { createVuetify } from "vuetify";
2
+ import * as components from "vuetify/components";
3
+ import * as directives from "vuetify/directives";
4
+ import { defineNuxtPlugin } from "nuxt/app";
5
+ export default defineNuxtPlugin((nuxtApp) => {
6
+ const vuetify = createVuetify({
7
+ ssr: true,
8
+ components,
9
+ directives,
10
+ mobileBreakpoint: "sm",
11
+ /* thresholds: {
12
+ xs: 0,
13
+ sm: 340,
14
+ md: 540,
15
+ lg: 800,
16
+ xl: 1280,
17
+ }, */
18
+ });
19
+
20
+ nuxtApp.vueApp.use(vuetify);
21
+ });
@@ -0,0 +1,72 @@
1
+ {
2
+ "events": {
3
+ "disciplines": [
4
+ "archeology",
5
+ "architecture-and-spatial-planning",
6
+ "art-and-art-history",
7
+ "classical-studies",
8
+ "cultural-heritage-and-museology",
9
+ "digital-humanities",
10
+ "economics-and-finance",
11
+ "education",
12
+ "environment",
13
+ "gender-studies",
14
+ "geography",
15
+ "history",
16
+ "history-philosophy-and-sociology-of-science",
17
+ "information-and-communication-studies",
18
+ "law",
19
+ "linguistics",
20
+ "literature",
21
+ "medicine-pharmacy",
22
+ "music-musicology-and-performance-arts",
23
+ "neuroscience",
24
+ "others",
25
+ "philosophy",
26
+ "physics-and-mathematics",
27
+ "political-science",
28
+ "psychology",
29
+ "religious-studies",
30
+ "sciences-of-the-universe",
31
+ "social-anthropology-and-ethnology",
32
+ "sociology"
33
+ ],
34
+ "fellowships": [],
35
+ "tags": [],
36
+ "category": [
37
+ "CALL",
38
+ "COLLOQUIUM",
39
+ "CONFERENCE",
40
+ "CONFERENCE_CYCLE",
41
+ "EXHIBITION",
42
+ "LECTURE",
43
+ "OTHER",
44
+ "SEMINAR"
45
+ ]
46
+ },
47
+ "fellowships": { "disciplines": [], "tags": [], "affiliations": [] },
48
+ "news": { "tags": [], "category": ["LIFE_AT_THE_INSTITUTE", "VIDEO"] },
49
+ "projects": { "tags": [] },
50
+ "people": {
51
+ "disciplines": [],
52
+ "fellowships": [],
53
+ "vintage": [
54
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
55
+ 2019, 2020, 2021, 2022, 2023, 2024, 2025
56
+ ],
57
+ "members": []
58
+ },
59
+ "publications": {
60
+ "affiliations": [],
61
+ "disciplines": [],
62
+ "tags": [],
63
+ "type": ["ARTICLE", "VIDEO"],
64
+ "eventCategory": [
65
+ "COLLOQUIUM",
66
+ "CONFERENCE",
67
+ "CONFERENCE_CYCLE",
68
+ "LECTURE",
69
+ "OTHER"
70
+ ]
71
+ }
72
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../../.nuxt/tsconfig.server.json",
3
+ }
@@ -0,0 +1,25 @@
1
+ export declare const createDynamicStore: (storeName: string, moduleState: object) => import("pinia").StoreDefinition<string, Pick<{
2
+ loading: import("vue").Ref<boolean, boolean>;
3
+ total: import("vue").Ref<number, number>;
4
+ skip: import("vue").Ref<number, number>;
5
+ page: import("vue").Ref<number, number>;
6
+ numberOfPages: import("vue").Ref<number, number>;
7
+ search: import("vue").Ref<string, string>;
8
+ error: import("vue").Ref<string | null, string | null>;
9
+ }, "error" | "search" | "loading" | "total" | "skip" | "page" | "numberOfPages">, Pick<{
10
+ loading: import("vue").Ref<boolean, boolean>;
11
+ total: import("vue").Ref<number, number>;
12
+ skip: import("vue").Ref<number, number>;
13
+ page: import("vue").Ref<number, number>;
14
+ numberOfPages: import("vue").Ref<number, number>;
15
+ search: import("vue").Ref<string, string>;
16
+ error: import("vue").Ref<string | null, string | null>;
17
+ }, never>, Pick<{
18
+ loading: import("vue").Ref<boolean, boolean>;
19
+ total: import("vue").Ref<number, number>;
20
+ skip: import("vue").Ref<number, number>;
21
+ page: import("vue").Ref<number, number>;
22
+ numberOfPages: import("vue").Ref<number, number>;
23
+ search: import("vue").Ref<string, string>;
24
+ error: import("vue").Ref<string | null, string | null>;
25
+ }, never>>;
@@ -0,0 +1,19 @@
1
+ import { defineStore } from "pinia";
2
+ import { reactive, toRefs } from "vue";
3
+ export const createDynamicStore = (storeName, moduleState) => {
4
+ return defineStore(storeName, () => {
5
+ const state = reactive({
6
+ loading: false,
7
+ total: 0,
8
+ skip: 0,
9
+ page: 1,
10
+ numberOfPages: 0,
11
+ search: "",
12
+ error: null,
13
+ ...moduleState
14
+ });
15
+ return {
16
+ ...toRefs(state)
17
+ };
18
+ });
19
+ };
@@ -0,0 +1,60 @@
1
+ interface SearchResults {
2
+ events: Record<string, unknown>;
3
+ news: Record<string, unknown>;
4
+ people: Record<string, unknown>;
5
+ projects: Record<string, unknown>;
6
+ fellowships: Record<string, unknown>;
7
+ publications: Record<string, unknown>;
8
+ actions: Record<string, unknown>;
9
+ affiliations: Record<string, unknown>;
10
+ disciplines: Record<string, unknown>;
11
+ files: Record<string, unknown>;
12
+ mailing: Record<string, unknown>;
13
+ tags: Record<string, unknown>;
14
+ }
15
+ interface RootStoreState {
16
+ scrolled: boolean;
17
+ loading: boolean;
18
+ total: number;
19
+ skip: number;
20
+ page: number;
21
+ numberOfPages: number;
22
+ search: string;
23
+ results: SearchResults;
24
+ }
25
+ export declare const useRootStore: import("pinia").StoreDefinition<"rootStore", RootStoreState, {}, {
26
+ setLoading(value: boolean, type?: string): void;
27
+ setScrolled(): void;
28
+ loadRouteQuery(type: string): void;
29
+ setFiltersCount(type: string): void;
30
+ updateRouteQuery(type: string): void;
31
+ resetState(type: string, lang: string): void;
32
+ updateSort({ value, type, lang, }: {
33
+ value: (number | string)[];
34
+ type: string;
35
+ lang?: string;
36
+ }): void;
37
+ updateView({ value, type, lang, }: {
38
+ value: string;
39
+ type: string;
40
+ lang?: string;
41
+ }): void;
42
+ updateFilter(key: string, val: unknown, type: string, lang: string): void;
43
+ updateItemsPerPage({ value, type, lang, }: {
44
+ value: number;
45
+ type: string;
46
+ lang?: string;
47
+ }): void;
48
+ updatePage({ page, type, lang, }: {
49
+ page: number;
50
+ type: string;
51
+ lang?: string;
52
+ }): Promise<void>;
53
+ updateSearch({ type, search, lang, }: {
54
+ type: string;
55
+ search: string;
56
+ lang: string;
57
+ }): Promise<void>;
58
+ update(type: string, lang?: string): Promise<boolean>;
59
+ }>;
60
+ export {};
@@ -0,0 +1,315 @@
1
+ import { defineStore } from "pinia";
2
+ import SEARCH from "../graphql/list/search.gql";
3
+ import { useNuxtApp, useRouter, useAsyncQuery } from "#imports";
4
+ export const useRootStore = defineStore("rootStore", {
5
+ state: () => ({
6
+ scrolled: typeof window !== "undefined" ? window.scrollY > 0 : false,
7
+ loading: false,
8
+ total: 0,
9
+ skip: 0,
10
+ page: 1,
11
+ numberOfPages: 0,
12
+ search: "",
13
+ results: {
14
+ events: {},
15
+ news: {},
16
+ people: {},
17
+ projects: {},
18
+ fellowships: {},
19
+ publications: {},
20
+ actions: {},
21
+ affiliations: {},
22
+ disciplines: {},
23
+ files: {},
24
+ mailing: {},
25
+ tags: {}
26
+ }
27
+ }),
28
+ actions: {
29
+ setLoading(value, type = "") {
30
+ console.log("setLoading", { value, type });
31
+ const { $stores } = useNuxtApp();
32
+ this.loading = value;
33
+ if (type.length && type !== "all" && $stores[type]) {
34
+ $stores[type].loading = value;
35
+ }
36
+ },
37
+ setScrolled() {
38
+ if (typeof window !== "undefined") {
39
+ this.scrolled = window.scrollY > 0;
40
+ }
41
+ },
42
+ /* saveFiltersToLocalStorage(type: string): void {
43
+ const { $stores } = useNuxtApp() as {
44
+ $stores: Record<string, ModuleStore>;
45
+ };
46
+ const filters = $stores[type]?.filters ?? {};
47
+ const values = Object.fromEntries(
48
+ Object.entries(filters).map(([key, filter]) => [key, filter.value])
49
+ );
50
+
51
+ const local = JSON.parse(localStorage.getItem("PARIS_IAS") || "{}");
52
+ local[`${type}_filters`] = values;
53
+ localStorage.setItem("PARIS_IAS", JSON.stringify(local));
54
+ }, */
55
+ loadRouteQuery(type) {
56
+ console.log("loadRouteQuery", type);
57
+ const { $stores } = useNuxtApp();
58
+ const { currentRoute } = useRouter();
59
+ const query = currentRoute.value.query;
60
+ const filters = $stores[type]?.filters ?? {};
61
+ console.log("filters: ", filters);
62
+ if (Object.keys(query)?.length) {
63
+ Object.keys(query).forEach((filter) => {
64
+ if (filter in filters) {
65
+ console.log("filter: ", filter, query[filter]);
66
+ const queryValue = query[filter];
67
+ if (typeof queryValue === "string") {
68
+ filters[filter].value = filters[filter].multiple ? JSON.parse(queryValue) : queryValue;
69
+ }
70
+ } else {
71
+ console.log("unknown filter: ", filter);
72
+ }
73
+ });
74
+ }
75
+ console.log("query loaded");
76
+ },
77
+ /* loadFiltersFromLocalStorage(type: string): void {
78
+ const { $stores } = useNuxtApp() as {
79
+ $stores: Record<string, ModuleStore>
80
+ }
81
+ const local = JSON.parse(localStorage.getItem("PARIS_IAS") || "{}")
82
+ const saved = local[`${type}_filters`] ?? null
83
+
84
+ if (!saved) {
85
+ console.log(`[${type}] No data to restore.`)
86
+ return
87
+ }
88
+
89
+ const filters = $stores[type]?.filters ?? {}
90
+ for (const [key, value] of Object.entries(saved)) {
91
+ if (filters[key]) {
92
+ filters[key].value = value
93
+ }
94
+ }
95
+
96
+ this.setFiltersCount(type)
97
+ this.updateRouteQuery(type)
98
+ console.log(`[${type}] Filters restored from localStorage`, saved)
99
+ }, */
100
+ setFiltersCount(type) {
101
+ console.log("setFiltersCount", type);
102
+ const { $stores } = useNuxtApp();
103
+ const filters = $stores[type]?.filters ?? {};
104
+ const count = Object.values(filters).reduce((acc, filter) => {
105
+ const value = filter?.value;
106
+ const isEmpty = value === void 0 || value === null || Array.isArray(value) && value.length === 0 || typeof value === "string" && value.trim() === "";
107
+ return isEmpty ? acc : acc + 1;
108
+ }, 0);
109
+ if ($stores[type]) {
110
+ $stores[type].filtersCount = count;
111
+ }
112
+ },
113
+ updateRouteQuery(type) {
114
+ console.log("updateRouteQuery", type);
115
+ const router = useRouter();
116
+ const { $stores } = useNuxtApp();
117
+ const routeQuery = {
118
+ ...this.search ? { search: this.search } : {},
119
+ ...this.page > 1 ? { page: this.page.toString() } : {},
120
+ ...Object.entries($stores[type]?.filters ?? {}).reduce(
121
+ (acc, [key, filter]) => {
122
+ const value = filter?.value;
123
+ const isEmpty = value === void 0 || value === null || value === false || Array.isArray(value) && value.length === 0 || typeof value === "string" && value.trim() === "";
124
+ if (isEmpty) return acc;
125
+ return {
126
+ ...acc,
127
+ [key]: Array.isArray(value) ? JSON.stringify(value) : String(value)
128
+ };
129
+ },
130
+ {}
131
+ )
132
+ };
133
+ router.replace({ query: routeQuery });
134
+ },
135
+ async resetState(type, lang) {
136
+ console.log("resetState", { type, lang });
137
+ const { $stores, $models } = useNuxtApp();
138
+ console.log("$models[type]: ", $models[type]);
139
+ console.log("$stores[type]: ", $stores[type]);
140
+ if ($models[type] && $stores[type]) {
141
+ $stores[type].filters = $models[type].filters;
142
+ }
143
+ console.log("resetState");
144
+ this.search = "";
145
+ this.page = 1;
146
+ this.scrolled = false;
147
+ this.loading = false;
148
+ this.total = 0;
149
+ this.skip = 0;
150
+ this.numberOfPages = 0;
151
+ await this.update(type, lang);
152
+ },
153
+ async updateSort({
154
+ value,
155
+ type,
156
+ lang = "en"
157
+ }) {
158
+ console.log("updateSort", {
159
+ value,
160
+ type
161
+ });
162
+ const { $stores } = useNuxtApp();
163
+ if ($stores[type]) {
164
+ $stores[type].sortBy = [String(value[0])];
165
+ $stores[type].sortDesc = [Number(value[1])];
166
+ }
167
+ this.page = 1;
168
+ await this.update(type, lang);
169
+ },
170
+ async updateView({
171
+ value,
172
+ type,
173
+ lang
174
+ }) {
175
+ console.log("updateView", { value, type });
176
+ const { $stores } = useNuxtApp();
177
+ if ($stores[type]?.views?.[value]) {
178
+ $stores[type].view = {
179
+ ...$stores[type].views[value],
180
+ name: value
181
+ };
182
+ }
183
+ await this.update(type, lang);
184
+ },
185
+ /* updateLocalStorage(key: string, value: string): void {
186
+ const local = JSON.parse(localStorage.getItem("PARIS_IAS") || "{}")
187
+ local[key] = value
188
+ localStorage.setItem("PARIS_IAS", JSON.stringify(local))
189
+ }, */
190
+ async updateFilter(key, val, type, lang) {
191
+ const { $stores } = useNuxtApp();
192
+ console.log("update filter: ", { key, val, type });
193
+ if ($stores[type]?.filters?.[key]) {
194
+ $stores[type].filters[key].value = val;
195
+ }
196
+ this.page = 1;
197
+ await this.update(type, lang);
198
+ },
199
+ async updateItemsPerPage({
200
+ value,
201
+ type,
202
+ lang
203
+ }) {
204
+ console.log("updateItemsPerPage", { value, type });
205
+ const { $stores } = useNuxtApp();
206
+ this.page = 1;
207
+ if ($stores[type]) {
208
+ $stores[type].itemsPerPage = value;
209
+ }
210
+ await this.update(type, lang);
211
+ },
212
+ async updatePage({
213
+ page,
214
+ type,
215
+ lang = "en"
216
+ }) {
217
+ console.log("updatePage", { page, type });
218
+ const router = useRouter();
219
+ const currentQuery = router.currentRoute.value.query;
220
+ const newQuery = { ...currentQuery };
221
+ if (page > 1) {
222
+ newQuery.page = page.toString();
223
+ } else {
224
+ delete newQuery.page;
225
+ }
226
+ this.page = page;
227
+ await this.update(type, lang);
228
+ },
229
+ /*
230
+ initializePageFromRoute(): void {
231
+ const { query } = useRouter().currentRoute.value
232
+ const page = Number.parseInt(query.page as string, 10)
233
+ this.page = isNaN(page) || page < 1 ? 1 : page
234
+ }, */
235
+ async updateSearch({
236
+ type = "all",
237
+ search = "",
238
+ lang = "en"
239
+ }) {
240
+ console.log("updateSearch", { type, search, lang });
241
+ this.search = search;
242
+ await this.update(type, lang);
243
+ },
244
+ async update(type, lang = "en") {
245
+ const { $stores, $queries } = useNuxtApp();
246
+ console.log("update", { type, lang });
247
+ this.setLoading(true);
248
+ if (type !== "all" && $stores[type]) {
249
+ $stores[type].loading = true;
250
+ }
251
+ const itemsPerPage = type === "all" ? 3 : $stores[type]?.itemsPerPage || 10;
252
+ const filters = {};
253
+ if (type !== "all") {
254
+ const storeFilters = $stores[type]?.filters ?? {};
255
+ for (const filter in storeFilters) {
256
+ const filterValue = storeFilters[filter]?.value;
257
+ if (typeof filterValue !== "undefined" && filterValue !== null && (Array.isArray(filterValue) ? filterValue.length > 0 : true)) {
258
+ filters[filter] = filterValue;
259
+ }
260
+ }
261
+ }
262
+ const args = JSON.parse(
263
+ JSON.stringify({
264
+ options: {
265
+ // skip
266
+ skip: +this.page === 1 ? 0 : (+this.page - 1) * itemsPerPage,
267
+ // limit
268
+ limit: itemsPerPage,
269
+ // sort, array of keys and array of directions - to have x tie breakers if necessary
270
+ sortBy: type === "all" ? "searchScore" : $stores[type]?.sortBy || ["created"],
271
+ sortDesc: type === "all" ? -1 : ($stores[type]?.sortDesc?.[0] || 0) > 0 ? true : false,
272
+ // search (if set)
273
+ ...this.search?.length && type !== "all" && { search: this.search },
274
+ // add the store module filters
275
+ filters
276
+ },
277
+ ...this.search?.length && type === "all" && { search: this.search },
278
+ appId: "iea",
279
+ lang
280
+ })
281
+ );
282
+ args.options.filters = JSON.stringify(args.options.filters);
283
+ console.log("args: ", args);
284
+ const { data, error } = await useAsyncQuery(
285
+ type === "all" ? SEARCH : $queries[type]?.list,
286
+ args
287
+ );
288
+ console.log("data: ", data);
289
+ if (error.value) console.log(error.value);
290
+ const key = type === "all" ? "search" : "list" + type.charAt(0).toUpperCase() + type.slice(1);
291
+ if (type === "all") {
292
+ this.results = data?.value?.[key] || this.results;
293
+ } else {
294
+ const items = data?.value?.[key]?.items ?? [];
295
+ if ($stores[type]) {
296
+ $stores[type].total = data?.value?.[key]?.total || 0;
297
+ const result = {
298
+ ...data?.value?.[key],
299
+ items: items.map(({ id, ...rest }) => ({
300
+ ...rest,
301
+ _path: `/${id}`
302
+ }))
303
+ };
304
+ $stores[type].items = result.items;
305
+ const lastPage = Math.ceil((result.total || 0) / itemsPerPage);
306
+ this.setFiltersCount(type);
307
+ $stores[type].numberOfPages = lastPage;
308
+ }
309
+ }
310
+ this.updateRouteQuery(type);
311
+ this.setLoading(false, type);
312
+ return true;
313
+ }
314
+ }
315
+ });