@lavalogic/scoria 0.5.4 → 0.5.5
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.
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
let valueMax: number | null = $state(null);
|
|
92
92
|
|
|
93
93
|
let selectedOptions: Array<SelectOption<unknown>> = $state([]);
|
|
94
|
-
let lastQueryOptions: Array<SelectOption<
|
|
94
|
+
let lastQueryOptions: Array<SelectOption<string | number>> = $state([]);
|
|
95
95
|
|
|
96
96
|
const inputId = $derived(`${tableContext.tableName}-cell-quicksearch-${column.id}`);
|
|
97
97
|
|
|
@@ -230,6 +230,21 @@
|
|
|
230
230
|
|
|
231
231
|
let showFromDateModal = $state(false);
|
|
232
232
|
let showToDateModal = $state(false);
|
|
233
|
+
|
|
234
|
+
function generateOnChangeObject(label: string) {
|
|
235
|
+
return (newValue: SelectOption<string | number> | null) => {
|
|
236
|
+
tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
|
|
237
|
+
tableContext.dataRepo.__queryValues.set(label, newValue);
|
|
238
|
+
value = newValue;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function generateOnChangePrimitive(label: string) {
|
|
242
|
+
return (newValue: SelectOption<string | number> | null) => {
|
|
243
|
+
tableContext.paginationRepo?.filterBy(def.id, newValue ?? null);
|
|
244
|
+
tableContext.dataRepo.__queryValues.set(label, newValue);
|
|
245
|
+
value = newValue as string | number | null;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
233
248
|
</script>
|
|
234
249
|
|
|
235
250
|
<td class="input-cell {inputId}">
|
|
@@ -289,7 +304,7 @@
|
|
|
289
304
|
{/if}
|
|
290
305
|
{:else if isSelect}
|
|
291
306
|
{#if hasQuery}
|
|
292
|
-
{#if
|
|
307
|
+
{#if customFilter!.valueAsObject == false}
|
|
293
308
|
{@const label =
|
|
294
309
|
customFilter?.id ??
|
|
295
310
|
customFilter?.label ??
|
|
@@ -299,22 +314,38 @@
|
|
|
299
314
|
<!-- TODO: multiselect -->
|
|
300
315
|
|
|
301
316
|
<QuerySelect
|
|
302
|
-
valueAsObject
|
|
317
|
+
valueAsObject={false}
|
|
318
|
+
{label}
|
|
303
319
|
clearable
|
|
304
320
|
name={customFilter?.objectName ?? 'Item'}
|
|
305
321
|
valueProp="value"
|
|
306
322
|
labelProp="label"
|
|
307
|
-
{value}
|
|
323
|
+
value={value as string | number | null}
|
|
308
324
|
query={customFilter!.query!}
|
|
309
325
|
bind:options={lastQueryOptions}
|
|
310
|
-
onchange={(
|
|
311
|
-
tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
|
|
312
|
-
tableContext.dataRepo.__queryValues.set(label, newValue);
|
|
313
|
-
value = newValue as SelectOption<T> | null;
|
|
314
|
-
}}
|
|
326
|
+
onchange={generateOnChangePrimitive(label)}
|
|
315
327
|
/>
|
|
316
328
|
{:else}
|
|
317
|
-
{@
|
|
329
|
+
{@const label =
|
|
330
|
+
customFilter?.id ??
|
|
331
|
+
customFilter?.label ??
|
|
332
|
+
customFilter?.objectName ??
|
|
333
|
+
customFilter?.queryKey ??
|
|
334
|
+
def.id}
|
|
335
|
+
<!-- TODO: multiselect -->
|
|
336
|
+
|
|
337
|
+
<QuerySelect
|
|
338
|
+
valueAsObject={true}
|
|
339
|
+
{label}
|
|
340
|
+
clearable
|
|
341
|
+
name={customFilter?.objectName ?? 'Item'}
|
|
342
|
+
valueProp="value"
|
|
343
|
+
labelProp="label"
|
|
344
|
+
value={value as null}
|
|
345
|
+
query={customFilter!.query!}
|
|
346
|
+
bind:options={lastQueryOptions}
|
|
347
|
+
onchange={generateOnChangeObject(label)}
|
|
348
|
+
/>
|
|
318
349
|
{/if}
|
|
319
350
|
{:else}
|
|
320
351
|
{#await options then options}
|
|
@@ -84,18 +84,16 @@
|
|
|
84
84
|
|
|
85
85
|
const { def, customFilters }: FilterInputProps<T> = $props();
|
|
86
86
|
|
|
87
|
-
const _uuid = generateShortUUID();
|
|
88
|
-
|
|
89
87
|
const customFilter = $derived(customFilters?.get(def.id));
|
|
90
88
|
const isRemoteSelect = $derived(customFilter?.type === CustomFilterType.Select);
|
|
91
89
|
const isValueAsObject = $derived(!(customFilter?.valueAsObject == false));
|
|
92
90
|
|
|
93
|
-
let value: SelectOption<unknown> |
|
|
91
|
+
let value: SelectOption<unknown> | unknown | null | undefined = $state(null);
|
|
94
92
|
let valueMin: number | null = $state(null);
|
|
95
93
|
let valueMax: number | null = $state(null);
|
|
96
94
|
|
|
97
95
|
let selectedOptions: Array<SelectOption<unknown>> = $state([]);
|
|
98
|
-
let lastQueryOptions: Array<SelectOption<
|
|
96
|
+
let lastQueryOptions: Array<SelectOption<string | number>> = $state([]);
|
|
99
97
|
|
|
100
98
|
const isNumeric = $derived(
|
|
101
99
|
def instanceof NumberInputDef || customFilter?.type === CustomFilterType.Number
|
|
@@ -163,17 +161,17 @@
|
|
|
163
161
|
if (filteringStateValue != undefined) {
|
|
164
162
|
console.log(`query values:`, tableContext.dataRepo.__queryValues);
|
|
165
163
|
const x = tableContext.dataRepo.__queryValues.get(
|
|
166
|
-
customFilter?.id ??
|
|
164
|
+
customFilter?.id ??
|
|
165
|
+
customFilter?.label ??
|
|
167
166
|
customFilter?.objectName ??
|
|
168
167
|
customFilter?.queryKey ??
|
|
169
|
-
def.id
|
|
170
|
-
_uuid
|
|
168
|
+
def.id
|
|
171
169
|
);
|
|
172
170
|
|
|
173
171
|
if (def.debug) {
|
|
174
172
|
console.log('value:', $state.snapshot(x));
|
|
175
173
|
}
|
|
176
|
-
value = (x ?? null) as SelectOption<
|
|
174
|
+
value = (x ?? null) as SelectOption<string | number> | null;
|
|
177
175
|
} else if (def.debug) {
|
|
178
176
|
console.log(
|
|
179
177
|
'filtering state value was undefined',
|
|
@@ -295,6 +293,23 @@
|
|
|
295
293
|
|
|
296
294
|
let showFromDateModal = $state(false);
|
|
297
295
|
let showToDateModal = $state(false);
|
|
296
|
+
|
|
297
|
+
function generateOnChangeObject(label: string) {
|
|
298
|
+
return (newValue: SelectOption<string | number> | null) => {
|
|
299
|
+
tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
|
|
300
|
+
tableContext.dataRepo.__queryValues.set(label, newValue);
|
|
301
|
+
// FIXME <T> is lost when autoformatting. why?
|
|
302
|
+
value = newValue;
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function generateOnChangePrimitive(label: string) {
|
|
306
|
+
return (newValue: SelectOption<string | number> | null) => {
|
|
307
|
+
tableContext.paginationRepo?.filterBy(def.id, newValue ?? null);
|
|
308
|
+
tableContext.dataRepo.__queryValues.set(label, newValue);
|
|
309
|
+
// FIXME <T> is lost when autoformatting. why?
|
|
310
|
+
value = newValue as string | number | null;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
298
313
|
</script>
|
|
299
314
|
|
|
300
315
|
{#if isSearchable}
|
|
@@ -355,7 +370,8 @@
|
|
|
355
370
|
<div class="maxwidth">
|
|
356
371
|
{#await optionsPromise then options}
|
|
357
372
|
<MultiSelect
|
|
358
|
-
label={customFilter?.id ??
|
|
373
|
+
label={customFilter?.id ??
|
|
374
|
+
customFilter?.label ??
|
|
359
375
|
customFilter?.objectName ??
|
|
360
376
|
customFilter?.queryKey ??
|
|
361
377
|
def.id}
|
|
@@ -382,34 +398,53 @@
|
|
|
382
398
|
<div class="contents">
|
|
383
399
|
{#await options then options}
|
|
384
400
|
{#if hasQuery}
|
|
385
|
-
{#if
|
|
386
|
-
{@const label =
|
|
387
|
-
customFilter?.
|
|
401
|
+
{#if customFilter!.valueAsObject == false}
|
|
402
|
+
{@const label =
|
|
403
|
+
customFilter?.id ??
|
|
404
|
+
customFilter?.label ??
|
|
405
|
+
customFilter?.objectName ??
|
|
406
|
+
customFilter?.queryKey ??
|
|
407
|
+
def.id}
|
|
388
408
|
<!-- TODO: multiselect -->
|
|
389
409
|
|
|
390
410
|
<QuerySelect
|
|
391
|
-
valueAsObject={
|
|
411
|
+
valueAsObject={false}
|
|
392
412
|
{label}
|
|
393
413
|
clearable
|
|
394
414
|
name={customFilter?.objectName ?? 'Item'}
|
|
395
415
|
valueProp="value"
|
|
396
416
|
labelProp="label"
|
|
397
|
-
{value}
|
|
417
|
+
value={value as string | number | null}
|
|
398
418
|
query={customFilter!.query!}
|
|
399
419
|
bind:options={lastQueryOptions}
|
|
400
|
-
onchange={(
|
|
401
|
-
tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
|
|
402
|
-
tableContext.dataRepo.__queryValues.set(label ?? _uuid, newValue);
|
|
403
|
-
// FIXME <T> is lost when autoformatting. why?
|
|
404
|
-
value = newValue as SelectOption<T> | null;
|
|
405
|
-
}}
|
|
420
|
+
onchange={generateOnChangePrimitive(label)}
|
|
406
421
|
/>
|
|
407
422
|
{:else}
|
|
408
|
-
{@
|
|
423
|
+
{@const label =
|
|
424
|
+
customFilter?.id ??
|
|
425
|
+
customFilter?.label ??
|
|
426
|
+
customFilter?.objectName ??
|
|
427
|
+
customFilter?.queryKey ??
|
|
428
|
+
def.id}
|
|
429
|
+
<!-- TODO: multiselect -->
|
|
430
|
+
|
|
431
|
+
<QuerySelect
|
|
432
|
+
valueAsObject={true}
|
|
433
|
+
{label}
|
|
434
|
+
clearable
|
|
435
|
+
name={customFilter?.objectName ?? 'Item'}
|
|
436
|
+
valueProp="value"
|
|
437
|
+
labelProp="label"
|
|
438
|
+
value={value as null}
|
|
439
|
+
query={customFilter!.query!}
|
|
440
|
+
bind:options={lastQueryOptions}
|
|
441
|
+
onchange={generateOnChangeObject(label)}
|
|
442
|
+
/>
|
|
409
443
|
{/if}
|
|
410
444
|
{:else}
|
|
411
445
|
<MultiSelect
|
|
412
|
-
label={customFilter?.id ??
|
|
446
|
+
label={customFilter?.id ??
|
|
447
|
+
customFilter?.label ??
|
|
413
448
|
customFilter?.objectName ??
|
|
414
449
|
customFilter?.queryKey ??
|
|
415
450
|
def.id}
|