@lavalogic/scoria 0.9.1 → 0.9.2

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.
@@ -273,6 +273,14 @@
273
273
  let showFromDateModal = $state(false);
274
274
  let showToDateModal = $state(false);
275
275
 
276
+ function generateOnChangeObject(label: string) {
277
+ return (newValue: SelectOption<string | number> | null) => {
278
+ tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
279
+ tableContext.dataRepo.__queryValues.set(label, newValue);
280
+ value = newValue;
281
+ };
282
+ }
283
+
276
284
  function generateOnChangePrimitive(label: string) {
277
285
  return (newValue: SelectOption<string | number> | null) => {
278
286
  tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
@@ -339,25 +347,49 @@
339
347
  {/if}
340
348
  {:else if isSelect}
341
349
  {#if hasQuery}
342
- {@const label =
343
- customFilter?.id ??
344
- customFilter?.label ??
345
- customFilter?.objectName ??
346
- customFilter?.queryKey ??
347
- def.id}
348
- <!-- TODO: multiselect -->
349
-
350
- <QuerySelect
351
- valueAsObject={false}
352
- clearable
353
- name={customFilter?.objectName ?? 'Item'}
354
- valueProp="value"
355
- labelProp="label"
356
- value={value as string | number | null}
357
- query={customFilter!.query!}
358
- bind:options={lastQueryOptions}
359
- onchange={generateOnChangePrimitive(label)}
360
- />
350
+ {#if customFilter!.valueAsObject == false}
351
+ {@const label =
352
+ customFilter?.id ??
353
+ customFilter?.label ??
354
+ customFilter?.objectName ??
355
+ customFilter?.queryKey ??
356
+ def.id}
357
+
358
+ <!-- TODO: multiselect -->
359
+
360
+ <QuerySelect
361
+ valueAsObject={false}
362
+ clearable
363
+ name={customFilter?.objectName ?? 'Item'}
364
+ valueProp="value"
365
+ labelProp="label"
366
+ value={value as string | number | null}
367
+ query={customFilter!.query!}
368
+ bind:options={lastQueryOptions}
369
+ onchange={generateOnChangePrimitive(label)}
370
+ />
371
+ {:else}
372
+ {@const label =
373
+ customFilter?.id ??
374
+ customFilter?.label ??
375
+ customFilter?.objectName ??
376
+ customFilter?.queryKey ??
377
+ def.id}
378
+
379
+ <!-- TODO: multiselect -->
380
+
381
+ <QuerySelect
382
+ valueAsObject={true}
383
+ clearable
384
+ name={customFilter?.objectName ?? 'Item'}
385
+ valueProp="value"
386
+ labelProp="label"
387
+ value={value as null}
388
+ query={customFilter!.query!}
389
+ bind:options={lastQueryOptions}
390
+ onchange={generateOnChangeObject(label)}
391
+ />
392
+ {/if}
361
393
  {:else}
362
394
  {#await options then options}
363
395
  <MultiSelect
@@ -297,11 +297,18 @@
297
297
  let showFromDateModal = $state(false);
298
298
  let showToDateModal = $state(false);
299
299
 
300
+ function generateOnChangeObject(label: string) {
301
+ return (newValue: SelectOption<string | number> | null) => {
302
+ tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
303
+ tableContext.dataRepo.__queryValues.set(label, newValue ?? null);
304
+ value = newValue ?? null;
305
+ };
306
+ }
307
+
300
308
  function generateOnChangePrimitive(label: string) {
301
309
  return (newValue: SelectOption<string | number> | null) => {
302
310
  tableContext.paginationRepo?.filterBy(def.id, newValue?.value ?? null);
303
311
  tableContext.dataRepo.__queryValues.set(label, newValue?.value ?? null);
304
- // FIXME <T> is lost when autoformatting. why?
305
312
  value = newValue?.value ?? null;
306
313
  };
307
314
  }
@@ -393,26 +400,51 @@
393
400
  <div class="contents">
394
401
  {#await options then options}
395
402
  {#if hasQuery}
396
- {@const label =
397
- customFilter?.id ??
398
- customFilter?.label ??
399
- customFilter?.objectName ??
400
- customFilter?.queryKey ??
401
- def.id}
402
- <!-- TODO: multiselect -->
403
+ {#if customFilter!.valueAsObject == false}
404
+ {@const label =
405
+ customFilter?.id ??
406
+ customFilter?.label ??
407
+ customFilter?.objectName ??
408
+ customFilter?.queryKey ??
409
+ def.id}
403
410
 
404
- <QuerySelect
405
- valueAsObject={false}
406
- {label}
407
- clearable
408
- name={customFilter?.objectName ?? 'Item'}
409
- valueProp="value"
410
- labelProp="label"
411
- value={value as string | number | null}
412
- query={customFilter!.query!}
413
- bind:options={lastQueryOptions}
414
- onchange={generateOnChangePrimitive(label)}
415
- />
411
+ <!-- TODO: multiselect -->
412
+
413
+ <QuerySelect
414
+ valueAsObject={false}
415
+ {label}
416
+ clearable
417
+ name={customFilter?.objectName ?? 'Item'}
418
+ valueProp="value"
419
+ labelProp="label"
420
+ value={value as string | number | null}
421
+ query={customFilter!.query!}
422
+ bind:options={lastQueryOptions}
423
+ onchange={generateOnChangePrimitive(label)}
424
+ />
425
+ {:else}
426
+ {@const label =
427
+ customFilter?.id ??
428
+ customFilter?.label ??
429
+ customFilter?.objectName ??
430
+ customFilter?.queryKey ??
431
+ def.id}
432
+
433
+ <!-- TODO: multiselect -->
434
+
435
+ <QuerySelect
436
+ valueAsObject={true}
437
+ {label}
438
+ clearable
439
+ name={customFilter?.objectName ?? 'Item'}
440
+ valueProp="value"
441
+ labelProp="label"
442
+ value={value as null}
443
+ query={customFilter!.query!}
444
+ bind:options={lastQueryOptions}
445
+ onchange={generateOnChangeObject(label)}
446
+ />
447
+ {/if}
416
448
  {:else}
417
449
  <MultiSelect
418
450
  label={customFilter?.id ??
@@ -8,5 +8,6 @@ export interface CustomFilter {
8
8
  multiSelect?: boolean;
9
9
  objectName?: string;
10
10
  label?: string;
11
+ valueAsObject: boolean;
11
12
  query?: (value: unknown) => Promise<Array<SelectOption<number>>>;
12
13
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lavalogic/scoria",
3
3
  "description": "Svelte components used for the FloWMS Web Frontend",
4
- "version": "0.9.1",
4
+ "version": "0.9.2",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },