@bexis2/bexis2-core-ui 0.1.4 → 0.1.6
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 +148 -127
- package/dist/components/Table/Table.svelte +16 -11
- package/dist/components/Table/TableFilter.svelte +1 -1
- package/dist/components/file/FileUploader.svelte +34 -42
- package/dist/components/form/DropdownKvP.svelte +3 -3
- package/dist/components/form/DropdownKvP.svelte.d.ts +2 -2
- package/dist/components/form/MultiSelect.svelte +23 -23
- package/dist/components/form/MultiSelect.svelte.d.ts +6 -6
- package/dist/models/Models.d.ts +1 -0
- package/dist/stores/apistore.js +2 -2
- package/package.json +2 -2
- package/src/lib/components/Table/Table.svelte +22 -12
- package/src/lib/components/Table/TableFilter.svelte +1 -1
- package/src/lib/components/file/FileUploader.svelte +184 -184
- package/src/lib/components/form/DropdownKvP.svelte +3 -3
- package/src/lib/components/form/MultiSelect.svelte +23 -23
- package/src/lib/models/Models.ts +11 -13
- package/src/lib/stores/apistore.ts +32 -31
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
pageSizes = [5, 10, 15, 20]
|
|
29
29
|
} = config;
|
|
30
30
|
|
|
31
|
-
type AccessorType = keyof (typeof $data)[
|
|
31
|
+
type AccessorType = keyof (typeof $data)[number];
|
|
32
32
|
|
|
33
33
|
const dispatch = createEventDispatcher();
|
|
34
34
|
const actionDispatcher = (obj) => dispatch('action', obj);
|
|
@@ -67,13 +67,18 @@
|
|
|
67
67
|
disableSorting = false
|
|
68
68
|
} = columns[key];
|
|
69
69
|
|
|
70
|
-
const { toSortableValueFn, toFilterableValueFn, toStringFn } =
|
|
70
|
+
const { toSortableValueFn, toFilterableValueFn, toStringFn, renderComponent } =
|
|
71
|
+
instructions ?? {};
|
|
71
72
|
|
|
72
73
|
return table.column({
|
|
73
74
|
header: header ?? key,
|
|
74
75
|
accessor: accessor,
|
|
75
|
-
cell: ({ value }) => {
|
|
76
|
-
return
|
|
76
|
+
cell: ({ value, row }) => {
|
|
77
|
+
return renderComponent
|
|
78
|
+
? createRender(renderComponent, { value, row })
|
|
79
|
+
: toStringFn
|
|
80
|
+
? toStringFn(value)
|
|
81
|
+
: value;
|
|
77
82
|
},
|
|
78
83
|
plugins: {
|
|
79
84
|
sort: {
|
|
@@ -158,12 +163,14 @@
|
|
|
158
163
|
|
|
159
164
|
<div class="grid gap-2">
|
|
160
165
|
<div class="table-container">
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
{#if $data.length > 0}
|
|
167
|
+
<input
|
|
168
|
+
class="input p-2 mb-2 border border-primary-500"
|
|
169
|
+
type="text"
|
|
170
|
+
bind:value={$filterValue}
|
|
171
|
+
placeholder="Search rows..."
|
|
172
|
+
/>
|
|
173
|
+
{/if}
|
|
167
174
|
<table {...$tableAttrs} class="table table-compact bg-tertiary-200">
|
|
168
175
|
<thead>
|
|
169
176
|
{#each $headerRows as headerRow (headerRow.id)}
|
|
@@ -209,6 +216,8 @@
|
|
|
209
216
|
{/each}
|
|
210
217
|
</tr>
|
|
211
218
|
</Subscribe>
|
|
219
|
+
{:else}
|
|
220
|
+
<p class="items-center justify-center flex w-full p-10 italic">Nothing to show here.</p>
|
|
212
221
|
{/each}
|
|
213
222
|
</thead>
|
|
214
223
|
|
|
@@ -231,6 +240,7 @@
|
|
|
231
240
|
</tbody>
|
|
232
241
|
</table>
|
|
233
242
|
</div>
|
|
234
|
-
|
|
235
|
-
|
|
243
|
+
{#if $data.length > 0}
|
|
244
|
+
<TablePagination pageConfig={pluginStates.page} {pageSizes} />
|
|
245
|
+
{/if}
|
|
236
246
|
</div>
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
on:click|preventDefault={() => {
|
|
216
216
|
active = firstValue?.toString().length > 0 || secondValue?.toString().length > 0;
|
|
217
217
|
$filterValue = [firstOption, firstValue, secondOption, secondValue];
|
|
218
|
-
}}>
|
|
218
|
+
}}>Apply</button
|
|
219
219
|
>
|
|
220
220
|
</div>
|
|
221
221
|
</div>
|
|
@@ -1,184 +1,184 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { FileUploaderModel, FileInfo, Files } 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: FileUploaderModel | undefined;
|
|
31
|
-
|
|
32
|
-
$: model = data;
|
|
33
|
-
$: submitBt = 'submit';
|
|
34
|
-
|
|
35
|
-
let maxSize = 0;
|
|
36
|
-
|
|
37
|
-
const dispatch = createEventDispatcher();
|
|
38
|
-
|
|
39
|
-
let fx: FileInfo[];
|
|
40
|
-
|
|
41
|
-
let files: Files = { 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
|
-
|
|
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 { FileUploaderModel, FileInfo, Files } 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: FileUploaderModel | undefined;
|
|
31
|
+
|
|
32
|
+
$: model = data;
|
|
33
|
+
$: submitBt = 'submit';
|
|
34
|
+
|
|
35
|
+
let maxSize = 0;
|
|
36
|
+
|
|
37
|
+
const dispatch = createEventDispatcher();
|
|
38
|
+
|
|
39
|
+
let fx: FileInfo[];
|
|
40
|
+
|
|
41
|
+
let files: Files = { 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>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
export let invalid = false;
|
|
10
10
|
export let feedback = [''];
|
|
11
11
|
export let required = false;
|
|
12
|
-
export let
|
|
12
|
+
export let complexTarget = false;
|
|
13
13
|
|
|
14
14
|
$: selected = null;
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
function updatedSelectedValue(selection) {
|
|
20
20
|
if (selection != null) {
|
|
21
|
-
if(
|
|
21
|
+
if(complexTarget)
|
|
22
22
|
{
|
|
23
23
|
selected = selection.id;
|
|
24
24
|
}
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function updatedTarget(id) {
|
|
33
|
-
if(
|
|
33
|
+
if(complexTarget)
|
|
34
34
|
{
|
|
35
35
|
target = source.find((opt) => opt.id === id);
|
|
36
36
|
}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
export let target;
|
|
9
9
|
export let title;
|
|
10
10
|
export let itemId = 'value';
|
|
11
|
-
export let
|
|
11
|
+
export let itemLabel = 'label';
|
|
12
12
|
export let isMulti = true;
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
13
|
+
export let complexSource = false;
|
|
14
|
+
export let complexTarget = false;
|
|
15
15
|
export let required = false;
|
|
16
16
|
export let feedback = [];
|
|
17
17
|
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
|
|
23
23
|
function updateTarget(selection) {
|
|
24
24
|
//diffrent cases
|
|
25
|
-
console.log('------');
|
|
26
|
-
console.log('isComplex',
|
|
27
|
-
console.log('
|
|
28
|
-
console.log('selection',selection);
|
|
25
|
+
//console.log('------');
|
|
26
|
+
//console.log('isComplex',complexSource);
|
|
27
|
+
//console.log('complexTarget',complexTarget);
|
|
28
|
+
//console.log('selection',selection);
|
|
29
29
|
|
|
30
30
|
//a) source is complex model is simple
|
|
31
|
-
if (
|
|
32
|
-
console.log('a) source is complex model is simple');
|
|
31
|
+
if (complexSource && !complexTarget && isLoaded) {
|
|
32
|
+
//console.log('a) source is complex model is simple');
|
|
33
33
|
|
|
34
34
|
target = [];
|
|
35
35
|
for (let i in selection) {
|
|
@@ -38,30 +38,30 @@
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
if (!
|
|
41
|
+
if (!complexSource && !complexTarget && isLoaded) {
|
|
42
42
|
target = [];
|
|
43
43
|
for (let i in selection) {
|
|
44
44
|
target.push(selection[i].value);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
if (
|
|
48
|
+
if (complexSource && complexTarget && isLoaded)
|
|
49
49
|
{
|
|
50
|
-
console.log("both complex",selection);
|
|
50
|
+
//console.log("both complex",selection);
|
|
51
51
|
target = selection;
|
|
52
52
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
// console.log('selection ' + title, selection);
|
|
56
|
-
// console.log('target ' + title, target);
|
|
55
|
+
// //console.log('selection ' + title, selection);
|
|
56
|
+
// //console.log('target ' + title, target);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
onMount(async () => {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
////console.log("on mount multiselect");
|
|
61
|
+
////console.log(source);
|
|
62
62
|
|
|
63
63
|
//a) source is complex model is simple
|
|
64
|
-
if (
|
|
64
|
+
if (complexSource && !complexTarget) {
|
|
65
65
|
let items = [];
|
|
66
66
|
// event.detail will be null unless isMulti is true and user has removed a single item
|
|
67
67
|
for (let i in target) {
|
|
@@ -73,19 +73,19 @@
|
|
|
73
73
|
if (items.length > 0) {
|
|
74
74
|
value = items;
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
////console.log(value);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
if (
|
|
79
|
+
if (complexSource && complexTarget)
|
|
80
80
|
{
|
|
81
81
|
value = target
|
|
82
82
|
isLoaded = true;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
//b) simple liust and simple model
|
|
86
|
-
if (!
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
if (!complexSource && !complexTarget) {
|
|
87
|
+
////console.log("source", source);
|
|
88
|
+
////console.log("target",target);
|
|
89
89
|
isLoaded = true;
|
|
90
90
|
//set target only if its nit empty
|
|
91
91
|
if (target != null && target !== undefined && target != '') {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
class="select variant-form-material"
|
|
101
101
|
items={source}
|
|
102
102
|
{itemId}
|
|
103
|
-
{
|
|
103
|
+
label = {itemLabel}
|
|
104
104
|
multiple={isMulti}
|
|
105
105
|
bind:value
|
|
106
106
|
placeholder="-- Please select --"
|
package/src/lib/models/Models.ts
CHANGED
|
@@ -3,13 +3,11 @@ import type { ColumnFilterFn } from 'svelte-headless-table/lib/plugins';
|
|
|
3
3
|
import type { Writable } from 'svelte/store';
|
|
4
4
|
|
|
5
5
|
// page
|
|
6
|
-
export interface Link
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
url:string
|
|
6
|
+
export interface Link {
|
|
7
|
+
label: string;
|
|
8
|
+
url: string;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
|
|
13
11
|
// Form
|
|
14
12
|
export interface Input {
|
|
15
13
|
id: string;
|
|
@@ -18,7 +16,7 @@ export interface Input {
|
|
|
18
16
|
invalid: boolean;
|
|
19
17
|
valid: boolean;
|
|
20
18
|
required: boolean;
|
|
21
|
-
placeholder:string;
|
|
19
|
+
placeholder: string;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
export interface FileInfo {
|
|
@@ -61,6 +59,7 @@ export interface ColumnInstructions {
|
|
|
61
59
|
toStringFn?: (value: any) => string;
|
|
62
60
|
toSortableValueFn?: (value: any) => string | number;
|
|
63
61
|
toFilterableValueFn?: (value: any) => string | number | Date;
|
|
62
|
+
renderComponent?: typeof SvelteComponent;
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
// Table column type
|
|
@@ -88,15 +87,14 @@ export interface TableConfig<T> {
|
|
|
88
87
|
optionsComponent?: typeof SvelteComponent;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
|
|
92
90
|
// lists
|
|
93
91
|
export interface KvP {
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
id: number;
|
|
93
|
+
text: string;
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
export interface ListItem {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
97
|
+
id: number;
|
|
98
|
+
text: string;
|
|
99
|
+
group: string;
|
|
100
|
+
}
|