@bexis2/bexis2-core-ui 0.2.16 → 0.2.18

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.
@@ -1,184 +1,189 @@
1
- <script lang="ts">
2
- import type { fileUploaderModel, fileInfoType, filesType, fileUploaderType } from '../../models/Models.js';
3
-
4
- import DropZone from 'svelte-file-dropzone/Dropzone.svelte';
5
- import Fa from 'svelte-fa/src/fa.svelte';
6
-
7
- import Spinner from '../page/Spinner.svelte';
8
- import { createEventDispatcher } from 'svelte';
9
- import { faTrash } from '@fortawesome/free-solid-svg-icons';
10
- import { faSave } from '@fortawesome/free-regular-svg-icons';
11
- import { faFileUpload } from '@fortawesome/free-solid-svg-icons';
12
-
13
- import { Api } from '../../services/Api.js';
14
-
15
- export let id = 0;
16
- export let version = 1;
17
-
18
- import { onMount } from 'svelte';
19
-
20
- // export let description="";
21
- // export let status=0;
22
-
23
- //action to load fileupload model
24
- export let start = '';
25
- //action to save selected file
26
- export let submit = '';
27
-
28
- export let context = '';
29
-
30
- export let data: fileUploaderType | undefined;
31
-
32
- $: model = data;
33
- $: submitBt = 'submit';
34
-
35
- let maxSize = 0;
36
-
37
- const dispatch = createEventDispatcher();
38
-
39
- let fx: fileInfoType[];
40
-
41
- let files: filesType = { accepted: [], rejected: [] };
42
- $: files;
43
-
44
- onMount(async () => {
45
- //console.log('fileupload - OnMount', data);
46
-
47
- if (!data) {
48
- load();
49
- } else {
50
- model = data;
51
- }
52
-
53
- if (model) {
54
- submitBt += context;
55
- maxSize = model.maxSize * 1024 * 1024;
56
- }
57
- });
58
-
59
- // load modal from server
60
- async function load() {
61
- let url = start + '?id=' + id + '&version=' + version;
62
-
63
- // load menu froms server
64
- const res = await Api.get(url);
65
- model = await res.data();
66
-
67
- console.log('fileupload', model);
68
- }
69
-
70
- function handleFilesSelect(e: any) {
71
- //console.log('handleFilesSelect', e);
72
- console.log('files', files);
73
-
74
- const { acceptedFiles, fileRejections } = e.detail;
75
-
76
- files.accepted = [...files.accepted, ...acceptedFiles];
77
- files.rejected = [...files.rejected, ...fileRejections];
78
-
79
- //console.log('acceptedFiles', acceptedFiles);
80
- console.log('files.accepted', files.accepted);
81
-
82
- if (fileRejections.length > 0) {
83
- //alert("the dropped file is not supported");
84
- //console.log('the dropped file is not supported.');
85
- console.log(files.rejected);
86
-
87
- let messages = [''];
88
-
89
- for (let index = 0; index < fileRejections.length; index++) {
90
- const element = fileRejections[index];
91
- messages.push(getErrorMessage(element));
92
- }
93
-
94
- //console.log(messages);
95
-
96
- dispatch('error', { messages });
97
- //list up the errors somewhere
98
- files.rejected = [];
99
- }
100
-
101
- if (acceptedFiles.length > 0) {
102
- document.getElementById(submitBt)?.click();
103
- }
104
- }
105
-
106
- function getErrorMessage(rejected) {
107
- let message = '';
108
- message = rejected.file.path + ' : ';
109
- let errors = rejected.errors;
110
- for (let index = 0; index < errors.length; index++) {
111
- const error = errors[index];
112
- message += error.message;
113
- }
114
-
115
- return message;
116
- }
117
-
118
- async function handleSubmit() {
119
- //console.log('SUBMIT');
120
-
121
- dispatch('submit');
122
-
123
- let url = submit + '?id=' + id;
124
-
125
- // //console.log(model);
126
- // //console.log(url);
127
- //console.log('SUBMIT');
128
-
129
- if (files.accepted.length > 0) {
130
- //console.log(files);
131
-
132
- const formData = new FormData();
133
- formData.append('files', '123');
134
- // Looping over all files and add it to FormData object
135
- for (var i = 0; i < files.accepted.length; i++) {
136
- formData.append(files.accepted[i].name, files.accepted[i]);
137
- }
138
-
139
- const response = await Api.post(url, formData);
140
-
141
- if (response.status == 200) {
142
- dispatch('submited');
143
-
144
- let message = files.accepted.length + ' is/are uploaded';
145
- dispatch('success', { text: message });
146
-
147
- files.accepted = [];
148
- }
149
- }
150
- }
151
- </script>
152
-
153
- <form on:submit|preventDefault={handleSubmit}>
154
- {#if model}
155
- <!--if model exist -->
156
- <div>
157
- <DropZone
158
- on:drop={handleFilesSelect}
159
- accept={model.accept}
160
- multiple={model.multiple}
161
- {maxSize}
162
- >
163
- <b style="font-size:xx-large"><Fa icon={faFileUpload} /></b>
164
- <span
165
- ><b>Drag 'n' drop some files here, or click to select files</b>
166
- <b>max file : {model.maxSize} mb</b></span
167
- >
168
- <p>
169
- {#if model.accept}
170
- {#each model.accept as ext}
171
- {ext} ,
172
- {/each}
173
- {/if}
174
- </p>
175
- </DropZone>
176
- </div>
177
-
178
- <button id={submitBt} color="primary" style="display:none"><Fa icon={faSave} /></button>
179
- {:else}
180
- <!-- while data is not loaded show a loading information -->
181
-
182
- <Spinner />
183
- {/if}
184
- </form>
1
+ <script lang="ts">
2
+ import type {
3
+ fileUploaderModel,
4
+ fileInfoType,
5
+ filesType,
6
+ fileUploaderType
7
+ } from '../../models/Models.js';
8
+
9
+ import DropZone from 'svelte-file-dropzone/Dropzone.svelte';
10
+ import Fa from 'svelte-fa/src/fa.svelte';
11
+
12
+ import Spinner from '../page/Spinner.svelte';
13
+ import { createEventDispatcher } from 'svelte';
14
+ import { faTrash } from '@fortawesome/free-solid-svg-icons';
15
+ import { faSave } from '@fortawesome/free-regular-svg-icons';
16
+ import { faFileUpload } from '@fortawesome/free-solid-svg-icons';
17
+
18
+ import { Api } from '../../services/Api.js';
19
+
20
+ export let id = 0;
21
+ export let version = 1;
22
+
23
+ import { onMount } from 'svelte';
24
+
25
+ // export let description="";
26
+ // export let status=0;
27
+
28
+ //action to load fileupload model
29
+ export let start = '';
30
+ //action to save selected file
31
+ export let submit = '';
32
+
33
+ export let context = '';
34
+
35
+ export let data: fileUploaderType | undefined;
36
+
37
+ $: model = data;
38
+ $: submitBt = 'submit';
39
+
40
+ let maxSize = 0;
41
+
42
+ const dispatch = createEventDispatcher();
43
+
44
+ let fx: fileInfoType[];
45
+
46
+ let files: filesType = { accepted: [], rejected: [] };
47
+ $: files;
48
+
49
+ onMount(async () => {
50
+ //console.log('fileupload - OnMount', data);
51
+
52
+ if (!data) {
53
+ load();
54
+ } else {
55
+ model = data;
56
+ }
57
+
58
+ if (model) {
59
+ submitBt += context;
60
+ maxSize = model.maxSize * 1024 * 1024;
61
+ }
62
+ });
63
+
64
+ // load modal from server
65
+ async function load() {
66
+ let url = start + '?id=' + id + '&version=' + version;
67
+
68
+ // load menu froms server
69
+ const res = await Api.get(url);
70
+ model = await res.data();
71
+
72
+ console.log('fileupload', model);
73
+ }
74
+
75
+ function handleFilesSelect(e: any) {
76
+ //console.log('handleFilesSelect', e);
77
+ console.log('files', files);
78
+
79
+ const { acceptedFiles, fileRejections } = e.detail;
80
+
81
+ files.accepted = [...files.accepted, ...acceptedFiles];
82
+ files.rejected = [...files.rejected, ...fileRejections];
83
+
84
+ //console.log('acceptedFiles', acceptedFiles);
85
+ console.log('files.accepted', files.accepted);
86
+
87
+ if (fileRejections.length > 0) {
88
+ //alert("the dropped file is not supported");
89
+ //console.log('the dropped file is not supported.');
90
+ console.log(files.rejected);
91
+
92
+ let messages = [''];
93
+
94
+ for (let index = 0; index < fileRejections.length; index++) {
95
+ const element = fileRejections[index];
96
+ messages.push(getErrorMessage(element));
97
+ }
98
+
99
+ //console.log(messages);
100
+
101
+ dispatch('error', { messages });
102
+ //list up the errors somewhere
103
+ files.rejected = [];
104
+ }
105
+
106
+ if (acceptedFiles.length > 0) {
107
+ document.getElementById(submitBt)?.click();
108
+ }
109
+ }
110
+
111
+ function getErrorMessage(rejected) {
112
+ let message = '';
113
+ message = rejected.file.path + ' : ';
114
+ let errors = rejected.errors;
115
+ for (let index = 0; index < errors.length; index++) {
116
+ const error = errors[index];
117
+ message += error.message;
118
+ }
119
+
120
+ return message;
121
+ }
122
+
123
+ async function handleSubmit() {
124
+ //console.log('SUBMIT');
125
+
126
+ dispatch('submit');
127
+
128
+ let url = submit + '?id=' + id;
129
+
130
+ // //console.log(model);
131
+ // //console.log(url);
132
+ //console.log('SUBMIT');
133
+
134
+ if (files.accepted.length > 0) {
135
+ //console.log(files);
136
+
137
+ const formData = new FormData();
138
+ formData.append('files', '123');
139
+ // Looping over all files and add it to FormData object
140
+ for (var i = 0; i < files.accepted.length; i++) {
141
+ formData.append(files.accepted[i].name, files.accepted[i]);
142
+ }
143
+
144
+ const response = await Api.post(url, formData);
145
+
146
+ if (response.status == 200) {
147
+ dispatch('submited');
148
+
149
+ let message = files.accepted.length + ' is/are uploaded';
150
+ dispatch('success', { text: message });
151
+
152
+ files.accepted = [];
153
+ }
154
+ }
155
+ }
156
+ </script>
157
+
158
+ <form on:submit|preventDefault={handleSubmit}>
159
+ {#if model}
160
+ <!--if model exist -->
161
+ <div>
162
+ <DropZone
163
+ on:drop={handleFilesSelect}
164
+ accept={model.accept}
165
+ multiple={model.multiple}
166
+ {maxSize}
167
+ >
168
+ <b style="font-size:xx-large"><Fa icon={faFileUpload} /></b>
169
+ <span
170
+ ><b>Drag 'n' drop some files here, or click to select files</b>
171
+ <b>max file : {model.maxSize} mb</b></span
172
+ >
173
+ <p>
174
+ {#if model.accept}
175
+ {#each model.accept as ext}
176
+ {ext} ,
177
+ {/each}
178
+ {/if}
179
+ </p>
180
+ </DropZone>
181
+ </div>
182
+
183
+ <button id={submitBt} color="primary" style="display:none"><Fa icon={faSave} /></button>
184
+ {:else}
185
+ <!-- while data is not loaded show a loading information -->
186
+
187
+ <Spinner />
188
+ {/if}
189
+ </form>
@@ -26,11 +26,13 @@
26
26
 
27
27
  $: value = null;
28
28
  $: updateTarget(value);
29
+ $: target, setValue(target);
29
30
 
30
31
  let groupBy;
31
32
  $: groupBy;
32
33
 
33
34
  function updateTarget(selection) {
35
+ console.log("UPDATE target",selection);
34
36
  //different cases
35
37
  //a) source is complex model is simple return array
36
38
  if (complexSource && !complexTarget && isLoaded && isMulti) {
@@ -45,8 +47,9 @@
45
47
 
46
48
  if (!complexSource && !complexTarget && isLoaded && isMulti) {
47
49
  target = [];
50
+
48
51
  for (let i in selection) {
49
- target.push(selection[i].value);
52
+ target.push(selection[i]);
50
53
  }
51
54
  }
52
55
 
@@ -73,14 +76,15 @@
73
76
  }
74
77
 
75
78
  onMount(async () => {
76
- console.log('on mount multiselect');
77
- ////console.log(source);
79
+ setValue(target);
80
+ });
78
81
 
82
+ function setValue(t) {
79
83
  //a) source is complex model is simple
80
84
  if (complexSource && !complexTarget && isMulti) {
81
85
  let items = [];
82
86
  // event.detail will be null unless isMulti is true and user has removed a single item
83
- for (let i in target) {
87
+ for (let i in t) {
84
88
  let t = target[i];
85
89
  items.push(source.find((item) => item[itemId] === t));
86
90
  }
@@ -94,19 +98,21 @@
94
98
  }
95
99
 
96
100
  if (complexSource && complexTarget && isMulti) {
97
- value = target;
101
+ value = t;
98
102
  isLoaded = true;
99
103
  groupBy = (item) => item[itemGroup];
100
104
  }
101
105
 
102
106
  //b) simple liust and simple model
103
107
  if (!complexSource && !complexTarget && isMulti) {
104
- ////console.log("source", source);
105
- ////console.log("target",target);
108
+ console.log('b) simple liust and simple model');
109
+ console.log('source', source);
110
+ //console.log("target",t);
106
111
  isLoaded = true;
107
112
  //set target only if its nit empty
108
- if (target != null && target !== undefined && target != '') {
109
- value = target;
113
+ if (t != null && t !== undefined && t != '') {
114
+ console.log('target', t);
115
+ value = t;
110
116
  }
111
117
  }
112
118
 
@@ -114,13 +120,13 @@
114
120
  //console.log("onmount",complexSource,complexTarget,value,target)
115
121
  if (!complexSource && !complexTarget) {
116
122
  value = {
117
- value: target,
118
- label: target
123
+ value: t,
124
+ label: t
119
125
  };
120
126
  }
121
127
 
122
128
  if (complexSource && complexTarget) {
123
- value = target;
129
+ value = t;
124
130
  groupBy = (item) => item[itemGroup];
125
131
  }
126
132
 
@@ -136,7 +142,7 @@
136
142
 
137
143
  isLoaded = true;
138
144
  }
139
- });
145
+ }
140
146
  </script>
141
147
 
142
148
  <InputContainer {id} label={title} {feedback} {required} {help}>
@@ -0,0 +1,12 @@
1
+ <script lang="ts">
2
+ import { Toast } from '@skeletonlabs/skeleton';
3
+ import { notificationStore } from '$store/pageStores';
4
+
5
+ let btnStyle: string;
6
+ $: btnStyle =
7
+ $notificationStore === undefined || $notificationStore.btnStyle === undefined
8
+ ? notificationStore.getBtnStyle()
9
+ : $notificationStore.btnStyle;
10
+ </script>
11
+
12
+ <Toast position="t" buttonDismiss={btnStyle} />
@@ -11,6 +11,7 @@
11
11
  import Header from './Header.svelte';
12
12
  import HelpPopUp from './HelpPopUp.svelte';
13
13
  import Breadcrumb from './breadcrumb/Breadcrumb.svelte';
14
+ import Notification from './Notification.svelte';
14
15
 
15
16
  //popup
16
17
  import { computePosition, autoUpdate, offset, shift, flip, arrow } from '@floating-ui/dom';
@@ -93,4 +94,5 @@
93
94
  </div>
94
95
 
95
96
  <HelpPopUp active={help} />
97
+ <Notification />
96
98
  </AppShell>
@@ -0,0 +1,17 @@
1
+ <script lang="ts">
2
+ export let cols: number = 1;
3
+ export let rows: number = 10;
4
+ </script>
5
+
6
+ <div class="placeholder animate-pulse w-full h-10 sp" />
7
+ <div class="table-container w-full">
8
+ <table class="table table-compact w-full">
9
+ {#each Array(rows) as _}
10
+ <tr class="w-full">
11
+ {#each Array(cols) as _}
12
+ <td class="p-3"><div class="placeholder animate-pulse h-9 w-full" /></td>
13
+ {/each}
14
+ </tr>
15
+ {/each}
16
+ </table>
17
+ </div>
@@ -17,7 +17,6 @@
17
17
  let hamburger = true;
18
18
  </script>
19
19
 
20
-
21
20
  {#if $menuStore !== undefined}
22
21
  <div
23
22
  class="sm:flex h-min flex-row w-full justify-between items-center md:flex px-3 py-2 bg-tertiary-50 text-surface-800 z-50 shadow-md"