mensa 0.6.8 → 0.6.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cc6a4c7a0cbea3b05559bad2910becc5458e74137015835b0d8a753d1e8012e
4
- data.tar.gz: 65afa4de844a8741a342bbd38e8e717eaa59c35650eef0b4297e8420cd380821
3
+ metadata.gz: f67c16d331466d5a35135268bbf062b7727c81a7c64c4f583bd52de51789665e
4
+ data.tar.gz: bbf9bf9d3d632d8dff57ac7705d8bbf9c24655bd15988b5867184d85dd0be4a3
5
5
  SHA512:
6
- metadata.gz: 3282238437abbc28f4896ff086241eb5a8ff6fb12202691bb7f3f8c85c5cda4677a28406c6f367c582660335853a496c7c7f42ab0ef98518512350d6ef2ff479
7
- data.tar.gz: 82374fe57fdf48bae11d6c784bbcc7f4ad2380fc739565500b70a6df49bfbc2392bb1cfde5dba69e23222a85bf3d33a0c38cd1e35dcd4d5d3b33ba47ba65ccaf
6
+ metadata.gz: 1bd546e773170582c0d0ca268648452b19bfc3e046bffcffebddc12f9c93437addcfa8b6ff784e5028abfaeef5a85ac27b4d5869b4a389af12919a8e22377ad9
7
+ data.tar.gz: aca9e53dc7448a6c041bbd658812f17cecd16fc322f969eb5a7d1426edeaf0b126d3470a2e4688ce7f8327f38d7168aa0b5bfd085ac21556186aac9fb00adab6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mensa (0.6.7)
4
+ mensa (0.6.8)
5
5
  csv
6
6
  importmap-rails
7
7
  pagy (>= 43)
@@ -160,19 +160,19 @@ export default class FilterPillListComponentController extends ApplicationContro
160
160
  // Called by the search controller when the query is submitted or reset.
161
161
  setQuery(query) {
162
162
  if (query && query.length > 0) this._notifyUnsavedState();
163
- this.applyState({
164
- filters: this.collectFilters(),
163
+ const state = {
165
164
  query,
166
165
  view: this.loadView(),
167
166
  order: this.loadOrder(),
168
167
  page: "",
169
- });
168
+ };
169
+ if (this.hasPersistedFilters()) state.filters = this.loadFilters();
170
+ this.applyState(state);
170
171
  }
171
172
 
172
173
  // Called by the views controller when a view tab is selected.
173
174
  viewSelected(view) {
174
175
  const state = {
175
- filters: {},
176
176
  query: "",
177
177
  view,
178
178
  order: this.loadOrder(),
@@ -267,7 +267,6 @@ export default class FilterPillListComponentController extends ApplicationContro
267
267
  // buildUrl reads column_order/hidden_columns from localStorage — now empty,
268
268
  // so the server receives a completely clean request for the current view.
269
269
  this.requestState({
270
- filters: {},
271
270
  query: "",
272
271
  view,
273
272
  order: {},
@@ -278,6 +277,7 @@ export default class FilterPillListComponentController extends ApplicationContro
278
277
  restoreState() {
279
278
  const table = this.mensaTableOutlet;
280
279
  const filters = this.loadFilters();
280
+ const filtersProvided = this.hasPersistedFilters();
281
281
  const query = this.loadQuery();
282
282
  const view = this.loadView();
283
283
  const page = this.loadPage();
@@ -288,6 +288,7 @@ export default class FilterPillListComponentController extends ApplicationContro
288
288
  // Show save/reset if any persistent state exists (order, column layout, filters, search)
289
289
  if (
290
290
  Object.keys(filters).length > 0 ||
291
+ filtersProvided ||
291
292
  query.length > 0 ||
292
293
  Object.keys(order).length > 0 ||
293
294
  columnOrder.length > 0 ||
@@ -297,7 +298,9 @@ export default class FilterPillListComponentController extends ApplicationContro
297
298
  }
298
299
 
299
300
  const hasFilterOrSearch =
300
- Object.keys(filters).length > 0 || query.length > 0;
301
+ Object.keys(filters).length > 0 ||
302
+ filtersProvided ||
303
+ query.length > 0;
301
304
  const hasState =
302
305
  hasFilterOrSearch ||
303
306
  view.length > 0 ||
@@ -319,7 +322,8 @@ export default class FilterPillListComponentController extends ApplicationContro
319
322
  this.setSearchField(query);
320
323
  this.setViewHighlight(view);
321
324
 
322
- const state = { filters, query, view, page, order };
325
+ const state = { query, view, page, order };
326
+ if (filtersProvided) state.filters = filters;
323
327
 
324
328
  // No need to show/hide the filter bar — it's always visible.
325
329
  // Just apply state and load the frame.
@@ -377,6 +381,12 @@ export default class FilterPillListComponentController extends ApplicationContro
377
381
  url.searchParams.set(`order[${columnName}]`, direction);
378
382
  });
379
383
 
384
+ if (
385
+ Object.prototype.hasOwnProperty.call(state, "filters") &&
386
+ Object.keys(state.filters || {}).length === 0
387
+ ) {
388
+ url.searchParams.set("filters", "");
389
+ }
380
390
  if (state.query) url.searchParams.set("query", state.query);
381
391
  if (state.view) url.searchParams.set("table_view_id", state.view);
382
392
  if (state.page) url.searchParams.set("page", state.page);
@@ -576,7 +586,9 @@ export default class FilterPillListComponentController extends ApplicationContro
576
586
  // --- Persistence ---
577
587
 
578
588
  persistState(state) {
579
- this.persistFilters(state.filters || {});
589
+ if (Object.prototype.hasOwnProperty.call(state, "filters")) {
590
+ this.persistFilters(state.filters || {});
591
+ }
580
592
  this.persistQuery(state.query || "");
581
593
  this.persistView(state.view || "");
582
594
  this.persistPage(state.page || "");
@@ -584,10 +596,7 @@ export default class FilterPillListComponentController extends ApplicationContro
584
596
  }
585
597
 
586
598
  persistFilters(filters) {
587
- this.writeStorage(
588
- this.filtersStorageKey,
589
- Object.keys(filters).length > 0 ? JSON.stringify(filters) : null,
590
- );
599
+ this.writeStorage(this.filtersStorageKey, JSON.stringify(filters));
591
600
  }
592
601
 
593
602
  loadFilters() {
@@ -600,6 +609,10 @@ export default class FilterPillListComponentController extends ApplicationContro
600
609
  }
601
610
  }
602
611
 
612
+ hasPersistedFilters() {
613
+ return this.readStorage(this.filtersStorageKey) !== null;
614
+ }
615
+
603
616
  persistQuery(query) {
604
617
  this.writeStorage(
605
618
  this.searchStorageKey,
@@ -41,7 +41,6 @@ export default class TableComponentController extends ApplicationController {
41
41
  clearTimeout(this.frameLoadFallback);
42
42
  this.frameLoadFallback = null;
43
43
  }
44
-
45
44
  }
46
45
 
47
46
  saveDropdownOutsideHandler(event) {
@@ -149,12 +148,13 @@ export default class TableComponentController extends ApplicationController {
149
148
  if (this.hasMensaFilterPillListOutlet) {
150
149
  const outlet = this.mensaFilterPillListOutlet;
151
150
  const state = {
152
- filters: outlet.loadFilters(),
153
151
  query: outlet.loadQuery(),
154
152
  view: outlet.loadView(),
155
153
  order: outlet.loadOrder(),
156
154
  page: outlet.loadPage(),
157
155
  };
156
+ if (outlet.hasPersistedFilters())
157
+ state.filters = outlet.loadFilters();
158
158
  this.turboFrameTarget.setAttribute(
159
159
  "src",
160
160
  outlet.buildUrl(state).toString(),
@@ -1,7 +1,9 @@
1
1
  module Mensa
2
2
  class TablesController < ApplicationController
3
3
  def show
4
+ filters_provided = params.key?(:filters)
4
5
  config = params.permit(:format, :query, :id, :page, :table_view_id, :turbo_frame_id, order: {}, column_order: [], hidden_columns: [], params: {}, filters: {}).to_h
6
+ config[:filters] = {} if filters_provided && !config.key?(:filters)
5
7
 
6
8
  @table = Mensa.for_name(params[:id], config)
7
9
 
data/lib/mensa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mensa
2
- VERSION = "0.6.8"
2
+ VERSION = "0.6.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mensa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.8
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt