PageSourceSearch

https://www.bernstein.io/assets/controllers/apex/elements/pager_view_save_controller-1fbcc296.js

js bernstein.io collected 2026-10-04 08:54:47 UTC 1,457 bytes, 44 lines download raw bytes

1import { Controller } from '@hotwired/stimulus';
2
3// "Save view": captures the table's current filter state (the whole pager query string — search,
4// filters, tab, sort) and POSTs it as a new saved view via the TableViews endpoint. Reproducing the
5// view later is just navigating back to that query string.
6export default class PagerViewSaveController extends Controller {
7
8  static values = { url: String, entityKind: String };
9  static targets = ['name'];
10
11  toggle() {
12    if (!this.hasNameTarget) return;
13    const input = this.nameTarget;
14    const showing = input.style.display !== 'none';
15    input.style.display = showing ? 'none' : '';
16    if (!showing) input.focus();
17  }
18
19  onKeydown(event) {
20    if (event.key === 'Enter') { event.preventDefault(); this.save(); }
21    if (event.key === 'Escape') { this.nameTarget.style.display = 'none'; }
22  }
23
24  save() {
25    const name = this.nameTarget.value.trim();
26    if (!name || !this.urlValue) return;
27
28    const params = window.location.search.replace(/^\?/, '');
29    const token = document.querySelector('meta[name="csrf-token"]')?.content;
30
31    fetch(this.urlValue, {
32      method: 'POST',
33      headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': token || '' },
34      body: JSON.stringify({
35        entity_kind: this.entityKindValue,
36        name: name,
37        config: { params },
38      }),
39    }).then((response) => {
40      if (response.ok) window.location.reload();
41    });
42  }
43
44}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.