mensa 0.6.6 → 0.6.8
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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/components/mensa/table/component.rb +7 -1
- data/app/controllers/mensa/tables_controller.rb +11 -8
- data/app/tables/mensa/base.rb +5 -1
- data/app/tables/mensa/config/filter_dsl.rb +8 -6
- data/app/tables/mensa/filter.rb +6 -4
- data/lib/mensa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cc6a4c7a0cbea3b05559bad2910becc5458e74137015835b0d8a753d1e8012e
|
|
4
|
+
data.tar.gz: 65afa4de844a8741a342bbd38e8e717eaa59c35650eef0b4297e8420cd380821
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3282238437abbc28f4896ff086241eb5a8ff6fb12202691bb7f3f8c85c5cda4677a28406c6f367c582660335853a496c7c7f42ab0ef98518512350d6ef2ff479
|
|
7
|
+
data.tar.gz: 82374fe57fdf48bae11d6c784bbcc7f4ad2380fc739565500b70a6df49bfbc2392bb1cfde5dba69e23222a85bf3d33a0c38cd1e35dcd4d5d3b33ba47ba65ccaf
|
data/Gemfile.lock
CHANGED
|
@@ -10,7 +10,13 @@ module Mensa
|
|
|
10
10
|
|
|
11
11
|
def initialize(table_name, params: {}, **options)
|
|
12
12
|
@params = params
|
|
13
|
-
|
|
13
|
+
config = {params: params}
|
|
14
|
+
view_lookup_table = Mensa.for_name(table_name, config)
|
|
15
|
+
view = view_lookup_table.default_system_view
|
|
16
|
+
|
|
17
|
+
table_config = (view&.config&.deep_transform_keys(&:to_sym) || {}).merge(config)
|
|
18
|
+
@table = Mensa.for_name(table_name, table_config)
|
|
19
|
+
@table.table_view = view
|
|
14
20
|
@table.original_view_context = options[:original_view_context]
|
|
15
21
|
@table.component = self
|
|
16
22
|
end
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
module Mensa
|
|
2
2
|
class TablesController < ApplicationController
|
|
3
3
|
def show
|
|
4
|
-
config = params.permit(:format, :query, :id, :page, :table_view_id, :turbo_frame_id, order: {}, column_order: [], hidden_columns: [], params: {}).to_h
|
|
5
|
-
config[:filters] = params[:filters].to_unsafe_h if params.key?(:filters)
|
|
6
|
-
config[:params] = params[:params]&.to_unsafe_h || {}
|
|
4
|
+
config = params.permit(:format, :query, :id, :page, :table_view_id, :turbo_frame_id, order: {}, column_order: [], hidden_columns: [], params: {}, filters: {}).to_h
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
@table = Mensa.for_name(params[:id], config)
|
|
7
|
+
|
|
8
|
+
view_lookup_table = Mensa.for_name(params[:id], config)
|
|
9
|
+
@view = if params[:table_view_id]
|
|
10
|
+
Mensa::TableView.find_by(table_name: params[:id], id: params[:table_view_id]) ||
|
|
11
|
+
view_lookup_table.system_views.find { |v| v.id == params[:table_view_id].to_sym }
|
|
12
|
+
else
|
|
13
|
+
view_lookup_table.default_system_view
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
config = (@view&.config&.deep_transform_keys(&:to_sym) || {}).merge(config)
|
|
17
|
+
|
|
15
18
|
@table = Mensa.for_name(params[:id], config)
|
|
16
19
|
@table.request = request
|
|
17
20
|
@table.table_view = @view
|
data/app/tables/mensa/base.rb
CHANGED
|
@@ -85,6 +85,10 @@ module Mensa
|
|
|
85
85
|
views + (config[:views] || {}).keys.map { |view_name| Mensa::SystemView.new(view_name, config: config.dig(:views, view_name), table: self) }
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
def default_system_view
|
|
89
|
+
system_views.find { |view| view.id == :default }
|
|
90
|
+
end
|
|
91
|
+
|
|
88
92
|
# Returns true if the table has filters
|
|
89
93
|
def filters?
|
|
90
94
|
columns.any?(&:filter?)
|
|
@@ -143,7 +147,7 @@ module Mensa
|
|
|
143
147
|
end
|
|
144
148
|
|
|
145
149
|
def views?
|
|
146
|
-
all_views.reject{
|
|
150
|
+
all_views.reject { it.id == :default }.present?
|
|
147
151
|
end
|
|
148
152
|
|
|
149
153
|
# The user that owns custom views. Returns nil when the host application has
|
|
@@ -2,12 +2,14 @@ module Mensa::Config
|
|
|
2
2
|
class FilterDsl
|
|
3
3
|
include DslLogic
|
|
4
4
|
|
|
5
|
-
option :operator, default: :is
|
|
6
|
-
option :value
|
|
7
|
-
|
|
8
|
-
option :
|
|
9
|
-
option :
|
|
5
|
+
option :operator, default: :is # Operator for filtering
|
|
6
|
+
option :value # Value for filtering
|
|
7
|
+
|
|
8
|
+
option :collection # Collection shown in filtering
|
|
9
|
+
option :scope # Scope for filtering
|
|
10
|
+
option :multiple, default: false # Multiple values allowed
|
|
10
11
|
option :as
|
|
11
|
-
option :operators
|
|
12
|
+
option :operators, default: [] # Supported operators
|
|
13
|
+
option :having, default: false # Needs having when filtering
|
|
12
14
|
end
|
|
13
15
|
end
|
data/app/tables/mensa/filter.rb
CHANGED
|
@@ -12,6 +12,7 @@ module Mensa
|
|
|
12
12
|
config_reader :value
|
|
13
13
|
config_reader :scope
|
|
14
14
|
config_reader :multiple
|
|
15
|
+
config_reader :having?
|
|
15
16
|
|
|
16
17
|
class << self
|
|
17
18
|
def OPERATORS
|
|
@@ -80,7 +81,7 @@ module Mensa
|
|
|
80
81
|
record_scope.instance_exec(normalize(value), &scope)
|
|
81
82
|
else
|
|
82
83
|
query, hash = query_and_hash_for_operator
|
|
83
|
-
record_scope = record_scope.where(query, hash) if query.present?
|
|
84
|
+
record_scope = (column.filter.having? ? record_scope.having(query, hash) : record_scope.where(query, hash)) if query.present?
|
|
84
85
|
record_scope
|
|
85
86
|
end
|
|
86
87
|
end
|
|
@@ -99,14 +100,15 @@ module Mensa
|
|
|
99
100
|
operators
|
|
100
101
|
end
|
|
101
102
|
|
|
103
|
+
# Used in the where clause
|
|
102
104
|
def query_and_hash_for_operator
|
|
103
|
-
hash = {
|
|
105
|
+
hash = {column: column.attribute_for_condition, value: normalize(value)}
|
|
104
106
|
|
|
105
107
|
query = case operator
|
|
106
108
|
when :is_empty
|
|
107
|
-
column.type == :string ? ":column IS NULL OR :column = ''" : ":column IS NULL"
|
|
109
|
+
(column.type == :string) ? ":column IS NULL OR :column = ''" : ":column IS NULL"
|
|
108
110
|
when :isnt_empty
|
|
109
|
-
column.type == :string ? ":column IS NOT NULL AND :column != ''" : ":column IS NOT NULL"
|
|
111
|
+
(column.type == :string) ? ":column IS NOT NULL AND :column != ''" : ":column IS NOT NULL"
|
|
110
112
|
when :is_current
|
|
111
113
|
":column = :value"
|
|
112
114
|
when :matches
|
data/lib/mensa/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.6.8
|
|
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-06-
|
|
11
|
+
date: 2026-06-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|