@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.
- package/README.md +303 -289
- package/dist/components/file/FileUploader.svelte +34 -34
- package/dist/components/form/MultiSelect.svelte +19 -13
- package/dist/components/page/Notification.svelte +8 -0
- package/dist/components/page/Notification.svelte.d.ts +14 -0
- package/dist/components/page/Page.svelte +2 -0
- package/dist/components/page/TablePlaceholder.svelte +16 -0
- package/dist/components/page/TablePlaceholder.svelte.d.ts +17 -0
- package/dist/components/page/menu/Menu.svelte +0 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +10 -0
- package/dist/models/Enums.d.ts +6 -0
- package/dist/models/Enums.js +8 -0
- package/dist/models/Models.d.ts +10 -1
- package/dist/models/Models.js +1 -1
- package/dist/stores/pageStores.d.ts +13 -2
- package/dist/stores/pageStores.js +106 -0
- package/package.json +101 -101
- package/src/lib/components/file/FileUploader.svelte +189 -184
- package/src/lib/components/form/MultiSelect.svelte +19 -13
- package/src/lib/components/page/Notification.svelte +12 -0
- package/src/lib/components/page/Page.svelte +2 -0
- package/src/lib/components/page/TablePlaceholder.svelte +17 -0
- package/src/lib/components/page/menu/Menu.svelte +0 -1
- package/src/lib/index.ts +99 -78
- package/src/lib/models/Enums.ts +40 -32
- package/src/lib/models/Models.ts +19 -3
- package/src/lib/stores/pageStores.ts +240 -121
|
@@ -1,184 +1,189 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
export let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
console.log('
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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]
|
|
52
|
+
target.push(selection[i]);
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
|
|
@@ -73,14 +76,15 @@
|
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
onMount(async () => {
|
|
76
|
-
|
|
77
|
-
|
|
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
|
|
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 =
|
|
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
|
-
|
|
105
|
-
|
|
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 (
|
|
109
|
-
|
|
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:
|
|
118
|
-
label:
|
|
123
|
+
value: t,
|
|
124
|
+
label: t
|
|
119
125
|
};
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
if (complexSource && complexTarget) {
|
|
123
|
-
value =
|
|
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>
|