mensa 0.2.2 → 0.2.4
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/.devcontainer/compose.yaml +1 -1
- data/.devcontainer/devcontainer.json +1 -1
- data/.gitignore +2 -0
- data/Gemfile +10 -1
- data/Gemfile.lock +145 -81
- data/Procfile +2 -2
- data/README.md +60 -8
- data/app/assets/stylesheets/mensa/application.css +1 -1
- data/app/components/mensa/add_filter/component.html.slim +2 -2
- data/app/components/mensa/filter_list/component.html.slim +1 -1
- data/app/components/mensa/view/paging.css +1 -1
- data/app/components/mensa/views/component.css +10 -1
- data/app/components/mensa/views/component.html.slim +2 -2
- data/app/components/mensa/views/component.rb +1 -1
- data/app/components/mensa/views/component_controller.js +22 -0
- data/app/controllers/mensa/tables_controller.rb +9 -11
- data/app/javascript/mensa/controllers/index.js +3 -0
- data/app/tables/mensa/action.rb +1 -1
- data/app/tables/mensa/base.rb +10 -3
- data/app/tables/mensa/config/table_dsl.rb +9 -2
- data/app/tables/mensa/config/view_dsl.rb +9 -0
- data/app/tables/mensa/system_view.rb +25 -0
- data/app/views/mensa/tables/show.html.slim +0 -3
- data/bin/overmind +27 -0
- data/bin/setup +5 -2
- data/db/migrate/20251112143558_add_description_to_table_view.rb +6 -0
- data/docs/filters.png +0 -0
- data/docs/table.png +0 -0
- data/lib/mensa/version.rb +1 -1
- data/mensa.gemspec +21 -21
- data/package-lock.json +4967 -0
- data/package.json +2 -2
- data/rubocop.yml +94 -0
- metadata +25 -4
- data/app/views/mensa/tables/index.html.slim +0 -93
- data/yarn.lock +0 -837
|
@@ -2,17 +2,15 @@ module Mensa
|
|
|
2
2
|
class TablesController < ::ApplicationController
|
|
3
3
|
layout :decide_layout
|
|
4
4
|
|
|
5
|
-
def index
|
|
6
|
-
render layout: 'mensa/application'
|
|
7
|
-
end
|
|
8
|
-
|
|
9
5
|
def show
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
@table = Mensa.for_name(params[:id])
|
|
7
|
+
|
|
8
|
+
config = {}
|
|
9
|
+
if params[:table_view_id]
|
|
10
|
+
@view = Mensa::TableView.find_by(table_name: params[:id], id: params[:table_view_id])
|
|
11
|
+
@view ||= @table.system_views.find { |v| v.id == params[:table_view_id].to_sym }
|
|
12
|
+
config = @view&.config
|
|
13
|
+
end
|
|
16
14
|
|
|
17
15
|
config = config.merge(params.permit!.to_h)
|
|
18
16
|
config = config.merge(params.permit(:format, :query, :id, :page, :table_view_id, :turbo_frame_id, order: {}, filters: {}).to_h)
|
|
@@ -33,7 +31,7 @@ module Mensa
|
|
|
33
31
|
end
|
|
34
32
|
|
|
35
33
|
def decide_layout
|
|
36
|
-
|
|
34
|
+
false if params[:turbo_frame_id]
|
|
37
35
|
end
|
|
38
36
|
end
|
|
39
37
|
end
|
|
@@ -18,6 +18,9 @@ application.register("mensa-search", SearchComponentController);
|
|
|
18
18
|
import TableComponentController from 'mensa/components/table/component_controller'
|
|
19
19
|
application.register("mensa-table", TableComponentController);
|
|
20
20
|
|
|
21
|
+
import ViewsComponentController from 'mensa/components/views/component_controller'
|
|
22
|
+
application.register("mensa-views", ViewsComponentController);
|
|
23
|
+
|
|
21
24
|
// Eager load all controllers defined in the import map under controllers/**/*_controller
|
|
22
25
|
// import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
|
23
26
|
// eagerLoadControllersFrom("controllers", application)
|
data/app/tables/mensa/action.rb
CHANGED
|
@@ -10,6 +10,7 @@ module Mensa
|
|
|
10
10
|
# end
|
|
11
11
|
class Action
|
|
12
12
|
include ConfigReaders
|
|
13
|
+
|
|
13
14
|
attr_reader :name, :table, :config
|
|
14
15
|
|
|
15
16
|
def initialize(name, config:, table:)
|
|
@@ -23,6 +24,5 @@ module Mensa
|
|
|
23
24
|
config_reader :link_attributes
|
|
24
25
|
config_reader :icon
|
|
25
26
|
config_reader :show, call: false
|
|
26
|
-
|
|
27
27
|
end
|
|
28
28
|
end
|
data/app/tables/mensa/base.rb
CHANGED
|
@@ -54,9 +54,14 @@ module Mensa
|
|
|
54
54
|
ordered_scope.map { |row| Mensa::Row.new(self, row) }
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
def system_views
|
|
58
|
+
[Mensa::SystemView.new(:all, config: {name: I18n.t("mensa.views.all")}, table: self)] +
|
|
59
|
+
(config[:views] || {}).keys.map { |view_name| Mensa::SystemView.new(view_name, config: config.dig(:views, view_name), table: self) }
|
|
60
|
+
end
|
|
61
|
+
|
|
57
62
|
# Returns true if the table has filters
|
|
58
63
|
def filters?
|
|
59
|
-
|
|
64
|
+
columns.any?(&:filter?)
|
|
60
65
|
end
|
|
61
66
|
|
|
62
67
|
def actions?
|
|
@@ -82,7 +87,9 @@ module Mensa
|
|
|
82
87
|
end
|
|
83
88
|
|
|
84
89
|
def all_views
|
|
85
|
-
|
|
90
|
+
views = system_views
|
|
91
|
+
views += TableView.where(table_name: name).where(user: [nil, Current.user])
|
|
92
|
+
views
|
|
86
93
|
end
|
|
87
94
|
|
|
88
95
|
def active_filters
|
|
@@ -103,7 +110,7 @@ module Mensa
|
|
|
103
110
|
|
|
104
111
|
class << self
|
|
105
112
|
def definition(&)
|
|
106
|
-
@definition ||= Mensa::Config::TableDsl.new(
|
|
113
|
+
@definition ||= Mensa::Config::TableDsl.new(name, &).config
|
|
107
114
|
end
|
|
108
115
|
end
|
|
109
116
|
end
|
|
@@ -48,9 +48,14 @@ module Mensa::Config
|
|
|
48
48
|
class TableDsl
|
|
49
49
|
include DslLogic
|
|
50
50
|
|
|
51
|
-
option :model, default: -> {
|
|
51
|
+
option :model, default: -> {
|
|
52
|
+
begin
|
|
53
|
+
self.class.name.demodulize.to_s.classify.gsub("Table", "").singularize.constantize
|
|
54
|
+
rescue
|
|
55
|
+
raise "No model found for #{self.class.name}"
|
|
56
|
+
end
|
|
57
|
+
}
|
|
52
58
|
option :column, dsl_hash: Mensa::Config::ColumnDsl
|
|
53
|
-
option :internal, dsl_hash: Mensa::Config::ColumnDsl, default: {internal: true}
|
|
54
59
|
option :link
|
|
55
60
|
|
|
56
61
|
option :exportable, default: true
|
|
@@ -74,5 +79,7 @@ module Mensa::Config
|
|
|
74
79
|
option :view_columns_sorting, default: true
|
|
75
80
|
option :view_condensed, default: false
|
|
76
81
|
option :view_condensed_toggle, default: true
|
|
82
|
+
|
|
83
|
+
option :view, dsl_hash: Mensa::Config::ViewDsl
|
|
77
84
|
end
|
|
78
85
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mensa
|
|
4
|
+
# Provide additional links at the end of the row, with an icon, link and a name
|
|
5
|
+
#
|
|
6
|
+
# action :delete do
|
|
7
|
+
# link { |contact| delete_contact_path(contact) }
|
|
8
|
+
# link_attributes "data-turbo-method" => "delete"
|
|
9
|
+
# icon "fa-xmark"
|
|
10
|
+
# end
|
|
11
|
+
class SystemView
|
|
12
|
+
include ConfigReaders
|
|
13
|
+
|
|
14
|
+
attr_reader :id, :config
|
|
15
|
+
|
|
16
|
+
def initialize(id, config:, table:)
|
|
17
|
+
@id = id
|
|
18
|
+
@table = table
|
|
19
|
+
@config = config
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
config_reader :name
|
|
23
|
+
config_reader :description
|
|
24
|
+
end
|
|
25
|
+
end
|
data/bin/overmind
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'overmind' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
12
|
+
|
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
|
14
|
+
|
|
15
|
+
if File.file?(bundle_binstub)
|
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
|
17
|
+
load(bundle_binstub)
|
|
18
|
+
else
|
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require "rubygems"
|
|
25
|
+
require "bundler/setup"
|
|
26
|
+
|
|
27
|
+
load Gem.bin_path("overmind", "overmind")
|
data/bin/setup
CHANGED
|
@@ -31,7 +31,7 @@ FileUtils.chdir GEM_ROOT do
|
|
|
31
31
|
system("bundle config set --local path 'vendor/bundle'")
|
|
32
32
|
system("bundle check") || system!("bundle install")
|
|
33
33
|
|
|
34
|
-
system!("
|
|
34
|
+
system!("npm install")
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
FileUtils.chdir APP_ROOT do
|
|
@@ -57,6 +57,9 @@ FileUtils.chdir APP_ROOT do
|
|
|
57
57
|
puts "\n== Removing old logs and tempfiles =="
|
|
58
58
|
system! "bin/rails log:clear tmp:clear"
|
|
59
59
|
|
|
60
|
+
puts "\n== Configuring tailwindcss =="
|
|
61
|
+
system! "bin/rails app:tailwindcss:config && pushd test/dummy && bin/rails tailwindcss:build && popd"
|
|
62
|
+
|
|
60
63
|
puts "\n== Done, welcome to Mensa =="
|
|
61
|
-
puts "To start the application, run '
|
|
64
|
+
puts "To start the application, run 'bin/overmind s'"
|
|
62
65
|
end
|
data/docs/filters.png
ADDED
|
Binary file
|
data/docs/table.png
ADDED
|
Binary file
|
data/lib/mensa/version.rb
CHANGED
data/mensa.gemspec
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
require_relative "lib/mensa/version"
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
|
-
spec.name
|
|
5
|
-
spec.version
|
|
6
|
-
spec.authors
|
|
7
|
-
spec.email
|
|
8
|
-
spec.homepage
|
|
9
|
-
spec.summary
|
|
4
|
+
spec.name = "mensa"
|
|
5
|
+
spec.version = Mensa::VERSION
|
|
6
|
+
spec.authors = ["Tom de Grunt"]
|
|
7
|
+
spec.email = ["tom@degrunt.nl"]
|
|
8
|
+
spec.homepage = "https://github.com/entdec/mensa"
|
|
9
|
+
spec.summary = "Fast and awesome tables"
|
|
10
10
|
spec.description = "Fast and awesome tables, with pagination, sorting, filtering and custom views."
|
|
11
|
-
spec.license
|
|
11
|
+
spec.license = "MIT"
|
|
12
12
|
|
|
13
13
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host"
|
|
14
14
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
15
15
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
16
16
|
|
|
17
17
|
spec.post_install_message = <<~MESSAGE
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
Mensa requires additional setup. Please run the following
|
|
19
|
+
command to install the necessary files:
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
bin/rails mensa:install:migrations
|
|
22
|
+
MESSAGE
|
|
23
23
|
|
|
24
24
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
25
25
|
spec.metadata["source_code_uri"] = "https://github.com/entdec/mensa"
|
|
@@ -29,17 +29,17 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
spec.add_dependency
|
|
32
|
+
spec.add_dependency "caxlsx_rails", "~> 0"
|
|
33
33
|
spec.add_dependency "rails", ">= 7.1"
|
|
34
|
-
spec.add_dependency
|
|
35
|
-
spec.add_dependency
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
spec.add_dependency
|
|
39
|
-
spec.add_dependency
|
|
40
|
-
spec.add_dependency
|
|
41
|
-
spec.add_dependency
|
|
42
|
-
spec.add_dependency
|
|
34
|
+
spec.add_dependency "pagy", ">=43"
|
|
35
|
+
spec.add_dependency "textacular", ">=5"
|
|
36
|
+
spec.add_dependency "view_component", "~> 3.11"
|
|
37
|
+
|
|
38
|
+
spec.add_dependency "slim"
|
|
39
|
+
spec.add_dependency "tailwindcss-rails", "~> 3.3"
|
|
40
|
+
spec.add_dependency "importmap-rails"
|
|
41
|
+
spec.add_dependency "turbo-rails"
|
|
42
|
+
spec.add_dependency "stimulus-rails"
|
|
43
43
|
|
|
44
44
|
spec.add_development_dependency "sqlite3", "~> 2.8"
|
|
45
45
|
end
|