@bexis2/bexis2-core-ui 0.4.10 → 0.4.11

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/README.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # bexis-core-ui
2
+ ## 0.4.11
3
+ - Menu
4
+ - fix log off
5
+
2
6
  ## 0.4.10
3
7
  - Table:
4
8
  - Fixes issue with sticky Tables not rendering the filters correctly.
@@ -2,6 +2,7 @@
2
2
  import { getMenuItems } from "./MenuDataCaller";
3
3
  import { menuStore } from "../../../stores/pageStores";
4
4
  import MenuBar from "./MenuBar.svelte";
5
+ import MenuAccountBar from "./MenuAccountBar.svelte";
5
6
  import SettingsBar from "./SettingsBar.svelte";
6
7
  import Fa from "svelte-fa";
7
8
  import { faBars } from "@fortawesome/free-solid-svg-icons";
@@ -45,7 +46,7 @@ let hamburger = true;
45
46
  <!-- </div> -->
46
47
  <!-- <div class="sm:flex items-center sm:gap-5 px-1 text-lg justify-end gap-2"> -->
47
48
  <div class="grid w-full sm:flex gap-2 justify-auto sm:justify-end">
48
- <MenuBar menuBar={$menuStore.AccountBar} />
49
+ <MenuAccountBar menuBar={$menuStore.AccountBar} />
49
50
  <MenuBar menuBar={$menuStore.LaunchBar} />
50
51
  <SettingsBar menuBar={$menuStore.Settings} />
51
52
  <!-- </div> -->
@@ -0,0 +1,19 @@
1
+ <script>import { computePosition, autoUpdate, offset, shift, flip, arrow } from "@floating-ui/dom";
2
+ import { storePopup } from "@skeletonlabs/skeleton";
3
+ storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
4
+ import Item from "./MenuItem.svelte";
5
+ export let menuBar;
6
+ let comboboxValue;
7
+ </script>
8
+
9
+ {#if menuBar}
10
+ <div class="h-full place-self-center sm:flex gap-2 w-full sm:w-auto">
11
+
12
+ {#each menuBar as menubarItem}
13
+
14
+ <Item {menubarItem} {comboboxValue} />
15
+
16
+ {/each}
17
+
18
+ </div>
19
+ {/if}
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { menuItemType } from '../../../models/Page';
3
+ declare const __propDef: {
4
+ props: {
5
+ menuBar: menuItemType[];
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type MenuAccountBarProps = typeof __propDef.props;
13
+ export type MenuAccountBarEvents = typeof __propDef.events;
14
+ export type MenuAccountBarSlots = typeof __propDef.slots;
15
+ export default class MenuAccountBar extends SvelteComponent<MenuAccountBarProps, MenuAccountBarEvents, MenuAccountBarSlots> {
16
+ }
17
+ export {};
@@ -1,8 +1,8 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import type { MenuItem } from './menu';
2
+ import type { menuItemType } from '../../../models/Page';
3
3
  declare const __propDef: {
4
4
  props: {
5
- menuBar: MenuItem[];
5
+ menuBar: menuItemType[];
6
6
  };
7
7
  events: {
8
8
  [evt: string]: CustomEvent<any>;
@@ -29,7 +29,8 @@ let popupCombobox = {
29
29
  >
30
30
  <svelte:fragment slot="content"
31
31
  ><MenuSublist {id} items={menubarItem.Items} /></svelte:fragment
32
- ></AccordionItem
32
+ >
33
+ </AccordionItem
33
34
  >
34
35
  </div>
35
36
  <div class="hidden sm:block place-self-center" use:popup={popupCombobox}>
@@ -15,19 +15,51 @@ function isNewModule(module) {
15
15
  return true;
16
16
  }
17
17
  }
18
+ function clickFn(item) {
19
+ if (item.Title == "Logoff") {
20
+ logOffFn();
21
+ return;
22
+ } else {
23
+ goTo(item.Url);
24
+ }
25
+ }
26
+ async function logOffFn() {
27
+ console.log("logoff");
28
+ let bodyContent = "__RequestVerificationToken=" + window.antiForgeryToken;
29
+ try {
30
+ const response = await fetch("/Account/logoff", {
31
+ method: "POST",
32
+ credentials: "include",
33
+ // Include cookies for authentication
34
+ headers: {
35
+ "Content-Type": "application/x-www-form-urlencoded"
36
+ },
37
+ body: bodyContent
38
+ });
39
+ if (response.ok) {
40
+ window.location.href = "/Account/Login";
41
+ } else {
42
+ console.error("Logout failed");
43
+ }
44
+ } catch (error) {
45
+ console.error("Error during logout:", error);
46
+ }
47
+ }
18
48
  </script>
19
49
 
20
50
  <ListBox class="sm:bg-white sm:border overflow-y-auto max-h-[500px]">
21
51
  {#each items as item}
22
52
  {#if isNewModule(item.Module)}<hr class="text-surface-800" />{/if}
53
+
23
54
  <ListBoxItem
24
55
  class="text-md sm:text-sm text-surface-800 py-1 hover:text-secondary-500 bg-transparent hover:bg-surface-200"
25
56
  bind:group={item.Title}
26
57
  name="medium"
27
58
  value={item.Title}
28
- on:click={() => goTo(item.Url)}
59
+ on:click={() => clickFn(item)}
29
60
  >
30
61
  {item.Title}
31
62
  </ListBoxItem>
63
+
32
64
  {/each}
33
65
  </ListBox>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -1,9 +1,10 @@
1
1
  <script lang="ts">
2
2
  import { onMount } from 'svelte';
3
3
  import { getMenuItems } from './MenuDataCaller';
4
- import { menuStore } from '$store/pageStores';
4
+ import { menuStore } from "../../../stores/pageStores";
5
5
 
6
6
  import MenuBar from './MenuBar.svelte';
7
+ import MenuAccountBar from './MenuAccountBar.svelte';
7
8
  import SettingsBar from './SettingsBar.svelte';
8
9
  import Fa from 'svelte-fa';
9
10
  import { faBars } from '@fortawesome/free-solid-svg-icons';
@@ -49,7 +50,7 @@
49
50
  <!-- </div> -->
50
51
  <!-- <div class="sm:flex items-center sm:gap-5 px-1 text-lg justify-end gap-2"> -->
51
52
  <div class="grid w-full sm:flex gap-2 justify-auto sm:justify-end">
52
- <MenuBar menuBar={$menuStore.AccountBar} />
53
+ <MenuAccountBar menuBar={$menuStore.AccountBar} />
53
54
  <MenuBar menuBar={$menuStore.LaunchBar} />
54
55
  <SettingsBar menuBar={$menuStore.Settings} />
55
56
  <!-- </div> -->
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom';
3
+ import { storePopup } from '@skeletonlabs/skeleton';
4
+ storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
5
+
6
+ import type { menuItemType } from '../../../models/Page';
7
+ import Item from './MenuItem.svelte';
8
+
9
+ export let menuBar: menuItemType[];
10
+
11
+ let comboboxValue: string;
12
+
13
+ </script>
14
+
15
+ {#if menuBar}
16
+ <div class="h-full place-self-center sm:flex gap-2 w-full sm:w-auto">
17
+
18
+ {#each menuBar as menubarItem}
19
+
20
+ <Item {menubarItem} {comboboxValue} />
21
+
22
+ {/each}
23
+
24
+ </div>
25
+ {/if}
@@ -3,10 +3,10 @@
3
3
  import { storePopup } from '@skeletonlabs/skeleton';
4
4
  storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
5
5
 
6
- import type { MenuItem } from './menu';
6
+ import type { menuItemType } from '../../../models/Page';
7
7
  import Item from './MenuItem.svelte';
8
8
 
9
- export let menuBar: MenuItem[];
9
+ export let menuBar: menuItemType[];
10
10
 
11
11
  let comboboxValue: string;
12
12
  </script>
@@ -6,9 +6,9 @@
6
6
 
7
7
  //types
8
8
  import type { PopupSettings } from '@skeletonlabs/skeleton';
9
- import type { menuItemType } from '$models/Page';
9
+ import type { menuItemType } from '../../../models/Page';
10
10
 
11
- import { goTo } from '$services/BaseCaller';
11
+ import { goTo } from '../../../services/BaseCaller';
12
12
 
13
13
  export let menubarItem: menuItemType;
14
14
  export let comboboxValue;
@@ -40,7 +40,8 @@
40
40
  >
41
41
  <svelte:fragment slot="content"
42
42
  ><MenuSublist {id} items={menubarItem.Items} /></svelte:fragment
43
- ></AccordionItem
43
+ >
44
+ </AccordionItem
44
45
  >
45
46
  </div>
46
47
  <div class="hidden sm:block place-self-center" use:popup={popupCombobox}>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { ListBox, ListBoxItem } from '@skeletonlabs/skeleton';
3
- import type { menuItemType } from '$models/Page';
4
- import { goTo } from '$services/BaseCaller';
3
+ import type { menuItemType } from '../../../models/Page';
4
+ import { goTo } from '../../../services/BaseCaller';
5
5
 
6
6
  export let items: menuItemType[];
7
7
 
@@ -22,19 +22,64 @@
22
22
  return true;
23
23
  }
24
24
  }
25
+
26
+ function clickFn(item)
27
+ {
28
+ if(item.Title =="Logoff")
29
+ {
30
+ logOffFn();
31
+ return;
32
+ }
33
+ else{
34
+ goTo(item.Url)
35
+ }
36
+ }
37
+
38
+
39
+ async function logOffFn() {
40
+
41
+ console.log('logoff');
42
+ // Prepare the body content for the POST request
43
+
44
+
45
+ let bodyContent = '__RequestVerificationToken='+ window.antiForgeryToken;
46
+
47
+ try {
48
+ const response = await fetch('/Account/logoff', {
49
+ method: 'POST',
50
+ credentials: 'include', // Include cookies for authentication
51
+ headers: {
52
+ 'Content-Type': 'application/x-www-form-urlencoded'
53
+ },
54
+ body:bodyContent
55
+ });
56
+ if (response.ok) {
57
+ // Redirect to login page after logout
58
+ window.location.href = '/Account/Login';
59
+ } else {
60
+ console.error('Logout failed');
61
+ }
62
+ } catch (error) {
63
+ console.error('Error during logout:', error);
64
+ }
65
+ }
66
+
67
+
25
68
  </script>
26
69
 
27
70
  <ListBox class="sm:bg-white sm:border overflow-y-auto max-h-[500px]">
28
71
  {#each items as item}
29
72
  {#if isNewModule(item.Module)}<hr class="text-surface-800" />{/if}
73
+
30
74
  <ListBoxItem
31
75
  class="text-md sm:text-sm text-surface-800 py-1 hover:text-secondary-500 bg-transparent hover:bg-surface-200"
32
76
  bind:group={item.Title}
33
77
  name="medium"
34
78
  value={item.Title}
35
- on:click={() => goTo(item.Url)}
79
+ on:click={() => clickFn(item)}
36
80
  >
37
81
  {item.Title}
38
82
  </ListBoxItem>
83
+
39
84
  {/each}
40
85
  </ListBox>