mensa 0.6.14 → 0.6.15

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: a3d23dc5f37173fea8736de1271cd1c55f192f9bf28df2b2df7bc6d5c8e0d922
4
- data.tar.gz: 190e32dd6e3d9b8e8cd3fb34875535dc494873a923895a6306289df521a17ae3
3
+ metadata.gz: cd9ef2e0b14473937b5da9f4e7d82628501bb106e03dc892c3f055a15e2c562f
4
+ data.tar.gz: 8b088073a2fcc12813252c42e04ba277b97c44126e786c157a7090c253f4868a
5
5
  SHA512:
6
- metadata.gz: 9b5913385d0de9990422c6a897631d8a3f119e025f48a994f976a30c94f7655f04874da6626e02d4aa6e88f4f45d952089b87784fb8228e2f24c14030342f950
7
- data.tar.gz: ef17f02b50efaa802a7dbdbfe0fde4f8463da3c8c16fd3aa87b5344c2bbfcd21d52a36a072515a43d34caa21894bd3d4f7c75e6ac71ee613264d5692299c43c5
6
+ metadata.gz: 949a19530126d3a298bd4c34b10ea1c3db21c86555565f0ea7db3289cba10067f82a9ca289384c940358a34bf98d1109f364723333e9420e0c663318fffca6f7
7
+ data.tar.gz: 7670004d48f01f5aeec0e56772f51a4eee30d9b910c9c11bccb57b82d22c56ae62ea4d763d5ae1fbfd99c50ac1486f055774d1bda6af2dcc390b757c534322db
data/.shipkit.yml CHANGED
@@ -1,2 +1,2 @@
1
1
  ---
2
- previous_version: 0.6.13
2
+ previous_version: 0.6.14
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.15
4
+
5
+ - Custom filter `scope` blocks now work. Applied filters are built from the
6
+ column's `filter do ... end` definition (`scope`, `operators`, `multiple`,
7
+ `collection`, `having`, ...) with the requested `value` and `operator`
8
+ layered on top, and `Mensa::Filter#scope` returns the proc instead of
9
+ calling it without arguments. Host apps can remove workarounds that patch
10
+ `Mensa::Base#active_filters` or `Mensa::Filter#scope`.
11
+ - Only `value` and `operator` are taken from the request for applied filters;
12
+ other filter options come from the column definition.
13
+ - Exports are refused (403) for tables with `exportable false`, instead of
14
+ being created and failing in `Mensa::ExportJob`.
15
+
3
16
  ## 0.6.12
4
17
 
5
18
  - Tables built with `params` (`table :name, params: {...}`) now work in filters,
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mensa (0.6.13)
4
+ mensa (0.6.14)
5
5
  csv
6
6
  importmap-rails
7
7
  pagy (>= 43)
@@ -21,6 +21,8 @@ module Mensa
21
21
  # Creates a new export for the current user and enqueues the job that
22
22
  # generates and attaches the CSV.
23
23
  def create
24
+ return head :forbidden unless table.exportable?
25
+
24
26
  export = Mensa::Export.new(
25
27
  table_name: params[:table_id],
26
28
  table_view_id: params[:table_view_id].presence,
@@ -108,6 +110,12 @@ module Mensa
108
110
  @table_params ||= Mensa::TableParams.from_request(params)
109
111
  end
110
112
 
113
+ def table
114
+ @table ||= Mensa.for_name(params[:table_id], params: table_params).tap do |table|
115
+ table.original_view_context = helpers
116
+ end
117
+ end
118
+
111
119
  def list_stream
112
120
  turbo_stream.replace(Mensa::Export.list_dom_id(params[:table_id], current_mensa_user, params: table_params),
113
121
  partial: "mensa/exports/list", locals: list_locals)
@@ -107,12 +107,15 @@ module Mensa
107
107
  columns.any?(&:filter?)
108
108
  end
109
109
 
110
- # Returns the active filters, skipping any whose column no longer exists.
111
110
  def active_filters
112
111
  (config[:filters] || {}).filter_map do |column_name, filter_config|
113
112
  col = column(column_name)
114
113
  next unless col
115
- Mensa::Filter.new(column: col, config: filter_config, table: self)
114
+
115
+ definition = config.dig(:columns, col.name, :filter)
116
+ definition = {} unless definition.is_a?(Hash)
117
+ requested = (filter_config || {}).to_h.symbolize_keys.slice(:value, :operator)
118
+ Mensa::Filter.new(column: col, config: definition.merge(requested), table: self)
116
119
  end
117
120
  end
118
121
 
@@ -10,7 +10,7 @@ module Mensa
10
10
 
11
11
  config_reader :operator, cast: :to_sym
12
12
  config_reader :value
13
- config_reader :scope
13
+ config_reader :scope, call: false
14
14
  config_reader :multiple
15
15
  config_reader :having?
16
16
 
@@ -88,7 +88,7 @@ module Mensa
88
88
  return record_scope if value.is_a?(Array) && value.compact_blank.empty?
89
89
 
90
90
  query, hash = query_and_hash_for_operator
91
- record_scope = (column.filter.having? ? record_scope.having(query, hash) : record_scope.where(query, hash)) if query.present?
91
+ record_scope = (having? ? record_scope.having(query, hash) : record_scope.where(query, hash)) if query.present?
92
92
  record_scope
93
93
  end
94
94
  end
data/lib/mensa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mensa
2
- VERSION = "0.6.14"
2
+ VERSION = "0.6.15"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mensa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.14
4
+ version: 0.6.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-10 00:00:00.000000000 Z
11
+ date: 2026-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails