@kodaris/krubble-components 1.0.16 → 1.0.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.
@@ -2384,7 +2384,25 @@ let KRTable = class KRTable extends i$2 {
2384
2384
  case 'opensearch':
2385
2385
  throw Error('Opensearch not supported yet');
2386
2386
  case 'db':
2387
- throw Error('DB not supported yet');
2387
+ request = {
2388
+ page: this._page - 1,
2389
+ size: this._pageSize,
2390
+ sorts: [],
2391
+ filterFields: [],
2392
+ queryFields: [],
2393
+ facetFields: []
2394
+ };
2395
+ if (this._searchQuery?.trim().length) {
2396
+ this._def.columns.filter(col => col.searchable).forEach(col => {
2397
+ request.queryFields.push({
2398
+ name: col.id,
2399
+ operation: 'IS',
2400
+ value: this._searchQuery,
2401
+ and: false
2402
+ });
2403
+ });
2404
+ }
2405
+ break;
2388
2406
  default: // solr
2389
2407
  request = {
2390
2408
  page: this._page - 1,
@@ -2410,7 +2428,12 @@ let KRTable = class KRTable extends i$2 {
2410
2428
  throw Error('Opensearch not supported yet');
2411
2429
  }
2412
2430
  case 'db': {
2413
- throw Error('DB not supported yet');
2431
+ const res = response;
2432
+ this._data = res.data.content;
2433
+ this._totalItems = res.data.totalElements;
2434
+ this._totalPages = res.data.totalPages;
2435
+ this._pageSize = res.data.size;
2436
+ break;
2414
2437
  }
2415
2438
  default: { // solr
2416
2439
  const res = response;
@@ -2738,24 +2761,26 @@ let KRTable = class KRTable extends i$2 {
2738
2761
  return b `
2739
2762
  <div class="header">
2740
2763
  <div class="title">${this._def.title ?? ''}</div>
2741
- <div class="search">
2742
- <!-- TODO: Saved views dropdown
2743
- <div class="views">
2744
- <span>Default View</span>
2745
- <svg viewBox="0 0 24 24" fill="currentColor"><path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"/></svg>
2746
- </div>
2747
- -->
2748
- <div class="search-field">
2749
- <svg class="search-icon" viewBox="0 -960 960 960" fill="currentColor"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>
2750
- <input
2751
- type="text"
2752
- class="search-input"
2753
- placeholder="Search..."
2754
- .value=${this._searchQuery}
2755
- @input=${this._handleSearch}
2756
- />
2764
+ ${this._def.dataSource?.mode === 'db' && !this._def.columns.some(col => col.searchable) ? b `<div class="search"></div>` : b `
2765
+ <div class="search">
2766
+ <!-- TODO: Saved views dropdown
2767
+ <div class="views">
2768
+ <span>Default View</span>
2769
+ <svg viewBox="0 0 24 24" fill="currentColor"><path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"/></svg>
2770
+ </div>
2771
+ -->
2772
+ <div class="search-field">
2773
+ <svg class="search-icon" viewBox="0 -960 960 960" fill="currentColor"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/></svg>
2774
+ <input
2775
+ type="text"
2776
+ class="search-input"
2777
+ placeholder="Search..."
2778
+ .value=${this._searchQuery}
2779
+ @input=${this._handleSearch}
2780
+ />
2781
+ </div>
2757
2782
  </div>
2758
- </div>
2783
+ `}
2759
2784
  <div class="tools">
2760
2785
  ${this._renderPagination()}
2761
2786
  <span class="refresh" title="Refresh" @click=${() => this.refresh()}>