mountain-ui 1.0.35 → 1.0.37

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 (21) hide show
  1. package/package.json +1 -1
  2. package/src/lib/registry/entityRegistry/registry.svelte.js +17 -0
  3. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/View.svelte +6 -3
  4. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/View.svelte +2 -2
  5. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationLine/View.svelte +2 -2
  6. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/View.svelte +1 -1
  7. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/View.svelte +1 -1
  8. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/View.svelte +1 -1
  9. package/src/lib/registry/projectRegistry/components/ProjectButton.svelte +14 -0
  10. package/src/lib/registry/projectRegistry/components/ProjectCard.svelte +43 -0
  11. package/src/lib/registry/projectRegistry/components/ProjectDropdown.svelte +117 -0
  12. package/src/lib/registry/projectRegistry/createProject.js +17 -0
  13. package/src/lib/registry/projectRegistry/registry.svelte.js +50 -0
  14. package/src/routes/+layout.svelte +600 -596
  15. package/src/routes/+page.svelte +2 -2
  16. package/src/routes/exemple/+layout.svelte +43 -0
  17. package/src/routes/exemple/+page.svelte +0 -0
  18. package/src/routes/exemple/[project_normalized_name]/+layout.svelte +98 -0
  19. package/src/routes/exemple/[project_normalized_name]/[entity_slug]/+layout.svelte +44 -0
  20. package/src/routes/exemple/[project_normalized_name]/[entity_slug]/+page.svelte +1 -0
  21. package/src/routes/exemple/[project_normalized_name]/home/+page.svelte +1 -0
@@ -121,11 +121,11 @@
121
121
  <h3>Vues</h3>
122
122
  <div class="view">
123
123
  <h3>{tableView.name}</h3>
124
- <ViewTypeComponent type="table" entityId={51}></ViewTypeComponent>
124
+ <ViewTypeComponent type="table" entityId={82}></ViewTypeComponent>
125
125
  </div>
126
126
  <h3>Entré</h3>
127
127
  <div class="entry">
128
- <EntityPage entityId={51} entryId={1}></EntityPage>
128
+ <EntityPage entityId={82} entryId={2}></EntityPage>
129
129
  </div>
130
130
  <h3>Entité</h3>
131
131
  {#each $entities as entity}
@@ -0,0 +1,43 @@
1
+ <script>
2
+ import { page } from '$app/stores';
3
+ import { entityRegistry } from '$lib/registry/entityRegistry/registry.svelte';
4
+ import ProjectDropdown from '$lib/registry/projectRegistry/components/ProjectDropdown.svelte';
5
+ import { projectRegistry } from '$lib/registry/projectRegistry/registry.svelte';
6
+
7
+ let {children} = $props()
8
+
9
+
10
+
11
+ function getHref(project) {
12
+ return "/exemple/" + project.normalized_name + "/home"
13
+ }
14
+ function isActive(project) {
15
+ return project.normalized_name === $page.params.project_normalized_name
16
+ }
17
+
18
+ </script>
19
+
20
+ <nav class="top-bar">
21
+ <h3>Mountain UI</h3>
22
+ <div class="project-selector">
23
+ <ProjectDropdown projectId={projectRegistry.getFromNormalizedName($page.params.project_normalized_name).id} hubHref="/exemple" {getHref} {isActive}></ProjectDropdown>
24
+ </div>
25
+
26
+ </nav>
27
+ {@render children()}
28
+
29
+ <style>
30
+ .top-bar {
31
+ position: sticky;
32
+ top: 0px;
33
+ width: 100%;
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: space-between;
37
+ padding: var(--pad-s);
38
+ border-bottom: 1px solid var(--stroke);
39
+ }
40
+ .project-selector {
41
+ width: min(100%, 300px);
42
+ }
43
+ </style>
File without changes
@@ -0,0 +1,98 @@
1
+ <script>
2
+ import { afterNavigate, beforeNavigate } from '$app/navigation';
3
+ import { page } from '$app/stores';
4
+ import EntityButton from '$lib/registry/entityRegistry/components/EntityButton.svelte';
5
+ import { createEntity } from '$lib/registry/entityRegistry/createEntity';
6
+ import { entityRegistry } from '$lib/registry/entityRegistry/registry.svelte';
7
+ import { init, RotativeLoader, sendRequest } from 'hamzus-ui';
8
+ import { onMount } from 'svelte';
9
+
10
+ let { children } = $props();
11
+
12
+ let loading = $state(true);
13
+
14
+ const entities = entityRegistry.getAll();
15
+
16
+ beforeNavigate((test) => {
17
+ if (test.from.params.project_normalized_name === test.to.params.project_normalized_name) return
18
+
19
+ loading = true;
20
+ });
21
+
22
+ afterNavigate(getData);
23
+
24
+ onMount(getData);
25
+
26
+ async function getData() {
27
+ console.log(loading);
28
+
29
+ if (loading === false) return
30
+ // set le projet
31
+ init({
32
+ requestWithCredentials: true,
33
+ on401: async () => {
34
+ const response = await sendRequest({
35
+ path: '/refresh-session'
36
+ });
37
+
38
+ if (!response || response.statusType === 'error') {
39
+ // si il est pas encore dans la page de login on redirige
40
+ const path = '/login';
41
+
42
+ window.location.href = defaultUnlogged;
43
+ }
44
+ },
45
+ replayAfter401: true,
46
+ addData: () => {
47
+ return {
48
+ __project_normalized_name: $page.params.project_normalized_name
49
+ };
50
+ }
51
+ });
52
+
53
+ entityRegistry.unregisterAll();
54
+
55
+ // recuperer les entités du projet
56
+ const requestStructures = await sendRequest({
57
+ path: '/get-all-entities'
58
+ });
59
+
60
+ for (const entity of requestStructures.data) {
61
+ entityRegistry.register(createEntity(entity));
62
+ }
63
+
64
+ loading = false;
65
+ }
66
+ </script>
67
+
68
+ <div class="entities">
69
+ {#each $entities as entity}
70
+ <EntityButton
71
+ id={entity.id}
72
+ href={entity.slug}
73
+ variant={entity.slug === $page.params.entity_slug ? 'secondary' : 'ghost'}
74
+ ></EntityButton>
75
+ {/each}
76
+ </div>
77
+ {#if loading}
78
+ <div class="loader">
79
+ <RotativeLoader></RotativeLoader>
80
+ </div>
81
+ {:else}
82
+ {@render children()}
83
+ {/if}
84
+
85
+ <style>
86
+ .entities {
87
+ width: 100%;
88
+ height: 40px;
89
+ position: sticky;
90
+ top: 0px;
91
+ display: flex;
92
+ align-items: center;
93
+ column-gap: var(--pad-m);
94
+ padding: var(--pad-s);
95
+ border-bottom: 1px solid var(--stroke);
96
+ overflow-x: auto;
97
+ }
98
+ </style>
@@ -0,0 +1,44 @@
1
+ <script>
2
+ import { afterNavigate, beforeNavigate } from '$app/navigation';
3
+ import { page } from '$app/stores';
4
+ import { entityRegistry } from '$lib/registry/entityRegistry/registry.svelte';
5
+ import { RotativeLoader } from 'hamzus-ui';
6
+ import { onMount } from 'svelte';
7
+
8
+ let {children} = $props()
9
+
10
+ let loading = $state(true);
11
+
12
+ let entityNotFound = $state(false);
13
+
14
+ beforeNavigate((page) => {
15
+ if (page.from.params.entity_slug === page.to.params.entity_slug) return
16
+ entityNotFound = false
17
+ loading = true;
18
+ });
19
+
20
+ afterNavigate(getData);
21
+
22
+ onMount(getData);
23
+
24
+ function getData() {
25
+ if (loading === false) return
26
+
27
+ if (!entityRegistry.getFromSlug($page.params.entity_slug)) entityNotFound = true
28
+
29
+ loading = false;
30
+ }
31
+ </script>
32
+
33
+ {#if loading}
34
+ <div class="loader">
35
+ <RotativeLoader></RotativeLoader>
36
+ </div>
37
+ {:else if entityNotFound}
38
+ <div class="not-found">
39
+ <h3>Entité introuvable !</h3>
40
+ <p>L'entité n'a pas peu être trouvé !</p>
41
+ </div>
42
+ {:else}
43
+ {@render children()}
44
+ {/if}