mensa 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mensa might be problematic. Click here for more details.
- data/.document +5 -0
- data/.gitignore +7 -12
- data/{MIT-LICENSE → LICENSE} +1 -1
- data/README.md +26 -83
- data/Rakefile +50 -5
- data/VERSION +1 -0
- data/bin/mensa +10 -0
- data/config/canteens.rb +5 -0
- data/fixtures/canteens.rb +5 -0
- data/fixtures/mensa-dieburg.html +132 -0
- data/fixtures/mensa-haardtring.html +128 -0
- data/fixtures/mensa-lichtwiese.html +136 -0
- data/fixtures/mensa-schofferstrase.html +120 -0
- data/fixtures/mensa-stadtmitte.html +134 -0
- data/fixtures/output.txt +54 -0
- data/lib/ext/string.rb +7 -0
- data/lib/mensa/canteen.rb +114 -0
- data/lib/mensa/client.rb +121 -0
- data/lib/mensa/document.rb +21 -0
- data/lib/mensa/exceptions.rb +11 -0
- data/lib/mensa/fare.rb +90 -0
- data/lib/mensa.rb +56 -22
- data/mensa.gemspec +72 -36
- data/spec/mensa/canteen_spec.rb +97 -0
- data/spec/mensa/client_spec.rb +92 -0
- data/spec/mensa/document_spec.rb +31 -0
- data/spec/mensa/fare_spec.rb +106 -0
- data/spec/mensa_spec.rb +31 -0
- data/spec/spec_helper.rb +39 -0
- metadata +81 -263
- checksums.yaml +0 -7
- data/.github/workflows/gem-push.yml +0 -11
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -299
- data/Procfile +0 -2
- data/app/assets/config/mensa_manifest.js +0 -5
- data/app/assets/images/mensa/.keep +0 -0
- data/app/assets/stylesheets/mensa/application.css +0 -11
- data/app/components/mensa/add_filter/component.css +0 -13
- data/app/components/mensa/add_filter/component.html.slim +0 -16
- data/app/components/mensa/add_filter/component.rb +0 -13
- data/app/components/mensa/add_filter/component_controller.js +0 -84
- data/app/components/mensa/application_component.rb +0 -12
- data/app/components/mensa/cell/component.css +0 -0
- data/app/components/mensa/cell/component.html.slim +0 -1
- data/app/components/mensa/cell/component.rb +0 -15
- data/app/components/mensa/control_bar/component.css +0 -5
- data/app/components/mensa/control_bar/component.html.slim +0 -15
- data/app/components/mensa/control_bar/component.rb +0 -21
- data/app/components/mensa/filters/component.css +0 -14
- data/app/components/mensa/filters/component.html.slim +0 -14
- data/app/components/mensa/filters/component.rb +0 -13
- data/app/components/mensa/filters/component_controller.js +0 -14
- data/app/components/mensa/header/component.css +0 -54
- data/app/components/mensa/header/component.html.slim +0 -8
- data/app/components/mensa/header/component.rb +0 -19
- data/app/components/mensa/row_action/component.css +0 -0
- data/app/components/mensa/row_action/component.html.slim +0 -6
- data/app/components/mensa/row_action/component.rb +0 -19
- data/app/components/mensa/search/component.css +0 -13
- data/app/components/mensa/search/component.html.slim +0 -17
- data/app/components/mensa/search/component.rb +0 -13
- data/app/components/mensa/search/component_controller.js +0 -62
- data/app/components/mensa/table/component.css +0 -0
- data/app/components/mensa/table/component.html.slim +0 -7
- data/app/components/mensa/table/component.rb +0 -16
- data/app/components/mensa/table/component_controller.js +0 -72
- data/app/components/mensa/table_row/component.css +0 -0
- data/app/components/mensa/table_row/component.html.slim +0 -6
- data/app/components/mensa/table_row/component.rb +0 -19
- data/app/components/mensa/view/component.css +0 -78
- data/app/components/mensa/view/component.html.slim +0 -17
- data/app/components/mensa/view/component.rb +0 -16
- data/app/components/mensa/views/component.css +0 -13
- data/app/components/mensa/views/component.html.slim +0 -18
- data/app/components/mensa/views/component.rb +0 -14
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/mensa/application_controller.rb +0 -4
- data/app/controllers/mensa/tables/filters_controller.rb +0 -29
- data/app/controllers/mensa/tables_controller.rb +0 -37
- data/app/helpers/mensa/application_helper.rb +0 -5
- data/app/helpers/mensa/tables_helper.rb +0 -5
- data/app/javascript/mensa/application.js +0 -3
- data/app/javascript/mensa/controllers/alert_controller.js +0 -7
- data/app/javascript/mensa/controllers/application.js +0 -8
- data/app/javascript/mensa/controllers/application_controller.js +0 -57
- data/app/javascript/mensa/controllers/index.js +0 -24
- data/app/jobs/mensa/application_job.rb +0 -7
- data/app/jobs/mensa/export_job.rb +0 -91
- data/app/models/concerns/.keep +0 -0
- data/app/models/mensa/application_record.rb +0 -5
- data/app/models/mensa/table_view.rb +0 -5
- data/app/tables/mensa/action.rb +0 -26
- data/app/tables/mensa/base.rb +0 -103
- data/app/tables/mensa/cell.rb +0 -50
- data/app/tables/mensa/column.rb +0 -85
- data/app/tables/mensa/config/action_dsl.rb +0 -12
- data/app/tables/mensa/config/column_dsl.rb +0 -23
- data/app/tables/mensa/config/dsl_logic.rb +0 -90
- data/app/tables/mensa/config/filter_dsl.rb +0 -8
- data/app/tables/mensa/config/render_dsl.rb +0 -8
- data/app/tables/mensa/config/table_dsl.rb +0 -71
- data/app/tables/mensa/config_readers.rb +0 -13
- data/app/tables/mensa/filter.rb +0 -31
- data/app/tables/mensa/row.rb +0 -36
- data/app/tables/mensa/scope.rb +0 -99
- data/app/views/layouts/mensa/application.html.slim +0 -11
- data/app/views/mensa/tables/filters/show.turbo_stream.slim +0 -8
- data/app/views/mensa/tables/index.html.slim +0 -93
- data/app/views/mensa/tables/show.html.slim +0 -5
- data/app/views/mensa/tables/show.turbo_stream.slim +0 -5
- data/bin/importmap +0 -4
- data/bin/rails +0 -14
- data/config/importmap.rb +0 -8
- data/config/locales/en.yml +0 -8
- data/config/locales/nl.yml +0 -11
- data/config/routes.rb +0 -7
- data/db/migrate/20240201184752_create_mensa_table_views.rb +0 -15
- data/lib/generators/mensa/install_generator.rb +0 -24
- data/lib/generators/mensa/tailwind_config_generator.rb +0 -24
- data/lib/generators/mensa/templates/config/initializers/mensa.rb +0 -22
- data/lib/mensa/configuration.rb +0 -90
- data/lib/mensa/engine.rb +0 -37
- data/lib/mensa/version.rb +0 -3
- data/lib/tasks/mensa_tasks.rake +0 -13
- data/package.json +0 -10
- data/vendor/javascript/@rails--request.js.js +0 -2
- data/yarn.lock +0 -837
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mensa
|
4
|
-
module RowAction
|
5
|
-
class Component < ::Mensa::ApplicationComponent
|
6
|
-
with_collection_parameter :action
|
7
|
-
|
8
|
-
attr_reader :table
|
9
|
-
attr_reader :row
|
10
|
-
attr_reader :action
|
11
|
-
|
12
|
-
def initialize(table:, row:, action:)
|
13
|
-
@table = table
|
14
|
-
@row = row
|
15
|
-
@action = action
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
.mensa-table {
|
2
|
-
&__search {
|
3
|
-
@apply dark:bg-gray-800 dark:border-gray-800 border-b p-2;
|
4
|
-
|
5
|
-
&__button {
|
6
|
-
@apply cursor-pointer w-6 h-full text-gray-400;
|
7
|
-
}
|
8
|
-
|
9
|
-
input&__input {
|
10
|
-
@apply pl-2 h-6 w-full border-0 bg-transparent pr-4 text-gray-600 dark:text-gray-400 placeholder:text-gray-400 focus:ring-0 text-sm;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
.mensa-table__search data-mensa-table-target="search" data-controller="mensa-search" data-mensa-search-target="search" class="#{table.supports_views? ? 'hidden' : ''}" data-mensa-search-mensa-table-outlet=".mensa-table#table-#{table.table_id}"
|
2
|
-
.flex
|
3
|
-
.flex-none.w-6.h-22.text-right.text-gray-500.dark:text-gray-400
|
4
|
-
i.cursor-pointer class=Mensa.config.icons[:search]
|
5
|
-
.flex-1
|
6
|
-
input.mensa-table__search__input type="text" name="search_query" placeholder=t("search", default: "Search") data-mensa-search-target="searchInput" data-action="mensa-search#monitorSearch keydown.enter->mensa-search#search keydown.esc->mensa-search#resetSearch" value=params[:query]
|
7
|
-
.flex.space-x-2.justify-right.pr-2
|
8
|
-
button.mensa-table__search__button.hidden.pr-6 data-mensa-search-target="resetSearchButton" data-action="mensa-search#resetSearch"
|
9
|
-
i.fas.fa-xmark
|
10
|
-
.view-buttons.space-x-2.hidden data-mensa-table-target="viewButtons"
|
11
|
-
button class="rounded bg-white px-2 py-1 text-xs font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50" data-action="mensa-table#cancelFiltersAndSearch"
|
12
|
-
= t('.cancel')
|
13
|
-
button class="rounded bg-white px-2 py-1 text-xs font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50" data-action="mensa-table#saveFiltersAndSearch"
|
14
|
-
= t('.save')
|
15
|
-
- unless table.supports_views?
|
16
|
-
= render Mensa::ControlBar::Component.new(table: table)
|
17
|
-
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import ApplicationController from 'mensa/controllers/application_controller'
|
2
|
-
|
3
|
-
import { get } from '@rails/request.js'
|
4
|
-
|
5
|
-
export default class SearchComponentController extends ApplicationController {
|
6
|
-
static targets = [
|
7
|
-
'resetSearchButton',
|
8
|
-
'searchInput'
|
9
|
-
]
|
10
|
-
static outlets = [
|
11
|
-
"mensa-table"
|
12
|
-
]
|
13
|
-
connect () {
|
14
|
-
super.connect()
|
15
|
-
this.monitorSearch()
|
16
|
-
}
|
17
|
-
|
18
|
-
monitorSearch (event) {
|
19
|
-
if (this.searchInputTarget.value.length >= 1) {
|
20
|
-
this.resetSearchButtonTarget.classList.remove('hidden')
|
21
|
-
this.searchInputTarget.focus();
|
22
|
-
} else {
|
23
|
-
this.resetSearchButtonTarget.classList.add('hidden')
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
resetSearch (event) {
|
28
|
-
this.searchInputTarget.value = ''
|
29
|
-
this.searchInputTarget.focus()
|
30
|
-
this.resetSearchButtonTarget.classList.add('hidden')
|
31
|
-
|
32
|
-
let turboFrame = this.element.closest('turbo-frame')
|
33
|
-
let url = this.ourUrl
|
34
|
-
url.searchParams.delete('query')
|
35
|
-
|
36
|
-
get(url, {
|
37
|
-
responseKind: 'turbo-stream'
|
38
|
-
})
|
39
|
-
}
|
40
|
-
|
41
|
-
search (event) {
|
42
|
-
if (this.query.length < 3) {
|
43
|
-
return
|
44
|
-
}
|
45
|
-
|
46
|
-
// FIXME: This doesn't prevent searching twice on enter, the turbo-frame URL doesn't change
|
47
|
-
let url = this.ourUrl
|
48
|
-
if(url.searchParams.get('query') === this.query) {
|
49
|
-
return
|
50
|
-
}
|
51
|
-
|
52
|
-
url.searchParams.append('query', this.query)
|
53
|
-
|
54
|
-
get(url, {
|
55
|
-
responseKind: 'turbo-stream'
|
56
|
-
})
|
57
|
-
}
|
58
|
-
|
59
|
-
get query() {
|
60
|
-
return this.searchInputTarget.value
|
61
|
-
}
|
62
|
-
}
|
File without changes
|
@@ -1,7 +0,0 @@
|
|
1
|
-
.mensa-table id="table-#{table.table_id}" data-mensa-table-view-condensed-value="#{table.view_condensed?}" data-mensa-table-supports-views-value="#{table.supports_views?}" data-controller="mensa-table"
|
2
|
-
= render Mensa::Search::Component.new(table: table)
|
3
|
-
div id="filters-#{table.table_id}"
|
4
|
-
= render Mensa::Filters::Component.new(table: table)
|
5
|
-
- if table.supports_views? && table.show_header?
|
6
|
-
= render Mensa::Views::Component.new(table: table)
|
7
|
-
turbo-frame id=table.table_id src=helpers.mensa.table_path(table.name, turbo_frame_id: table.table_id) target="_top" loading="lazy" data-mensa-table-target="turboFrame"
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mensa
|
4
|
-
module Table
|
5
|
-
class Component < ::Mensa::ApplicationComponent
|
6
|
-
include TablesHelper
|
7
|
-
|
8
|
-
attr_reader :table
|
9
|
-
|
10
|
-
def initialize(table_name, config = {}, **options)
|
11
|
-
@table = Mensa.for_name(table_name, config)
|
12
|
-
@table.component = self
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
import ApplicationController from 'mensa/controllers/application_controller'
|
2
|
-
import { get } from '@rails/request.js'
|
3
|
-
|
4
|
-
export default class TableComponentController extends ApplicationController {
|
5
|
-
static targets = [
|
6
|
-
'controlBar', // Bar with buttons
|
7
|
-
'condenseExpandIcon', // Icon
|
8
|
-
'filters', // Tabs or list of filters
|
9
|
-
'views', // Tabs or list of views
|
10
|
-
'viewButtons', // Cancel and save buttons for views
|
11
|
-
'search', // Search bar
|
12
|
-
'view', // View contains table element
|
13
|
-
'turboFrame' // The turbo-frame
|
14
|
-
]
|
15
|
-
static values = {
|
16
|
-
supportsViews: Boolean
|
17
|
-
}
|
18
|
-
|
19
|
-
connect () {
|
20
|
-
super.connect()
|
21
|
-
}
|
22
|
-
|
23
|
-
openFiltersAndSearch(event) {
|
24
|
-
if(this.supportsViewsValue) {
|
25
|
-
this.viewButtonsTarget.classList.remove('hidden')
|
26
|
-
this.searchTarget.classList.remove('hidden')
|
27
|
-
this.viewsTarget.classList.add('hidden')
|
28
|
-
this.filtersTarget.classList.remove('hidden')
|
29
|
-
} else {
|
30
|
-
this.controlBarTarget.classList.add('hidden')
|
31
|
-
this.viewButtonsTarget.classList.remove('hidden')
|
32
|
-
this.filtersTarget.classList.remove('hidden')
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
cancelFiltersAndSearch(event) {
|
37
|
-
if(this.supportsViewsValue) {
|
38
|
-
this.searchTarget.classList.add('hidden')
|
39
|
-
this.viewButtonsTarget.classList.add('hidden')
|
40
|
-
this.filtersTarget.classList.add('hidden')
|
41
|
-
this.viewsTarget.classList.remove('hidden')
|
42
|
-
} else {
|
43
|
-
this.controlBarTarget.classList.remove('hidden')
|
44
|
-
this.viewButtonsTarget.classList.add('hidden')
|
45
|
-
this.filtersTarget.classList.add('hidden')
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
saveFiltersAndSearch(event) {
|
50
|
-
|
51
|
-
}
|
52
|
-
|
53
|
-
condenseExpand (event) {
|
54
|
-
if (this.viewTarget.classList.contains('mensa-table__condensed')) {
|
55
|
-
this.viewTarget.classList.remove('mensa-table__condensed')
|
56
|
-
this.condenseExpandIconTarget.classList.add('fa-compress')
|
57
|
-
this.condenseExpandIconTarget.classList.remove('fa-expand')
|
58
|
-
} else {
|
59
|
-
this.viewTarget.classList.add('mensa-table__condensed')
|
60
|
-
this.condenseExpandIconTarget.classList.remove('fa-compress')
|
61
|
-
this.condenseExpandIconTarget.classList.add('fa-expand')
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
export(event) {
|
66
|
-
let url = this.ourUrl
|
67
|
-
url.pathname += ".xlsx"
|
68
|
-
get(url, {
|
69
|
-
}).then(() => {
|
70
|
-
})
|
71
|
-
}
|
72
|
-
}
|
File without changes
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mensa
|
4
|
-
module TableRow
|
5
|
-
class Component < ::Mensa::ApplicationComponent
|
6
|
-
with_collection_parameter :row
|
7
|
-
|
8
|
-
include TablesHelper
|
9
|
-
|
10
|
-
attr_reader :table
|
11
|
-
attr_reader :row
|
12
|
-
|
13
|
-
def initialize(table:, row:)
|
14
|
-
@table = table
|
15
|
-
@row = row
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
.mensa-table {
|
2
|
-
@apply bg-white dark:bg-gray-500 dark:border-gray-700;
|
3
|
-
|
4
|
-
.badge {
|
5
|
-
@apply bg-primary-100 text-primary-600 hidden ml-3 rounded-full text-xs font-medium md:inline-block py-0.5 px-2.5;
|
6
|
-
}
|
7
|
-
|
8
|
-
table {
|
9
|
-
@apply min-w-full divide-y divide-gray-50 dark:divide-gray-800 border-0;
|
10
|
-
|
11
|
-
thead {
|
12
|
-
@apply bg-gray-100 top-0 dark:bg-gray-700 dark:font-medium dark:text-gray-400 dark:lowercase;
|
13
|
-
|
14
|
-
/* tr and th moved to header */
|
15
|
-
}
|
16
|
-
|
17
|
-
tbody {
|
18
|
-
|
19
|
-
@apply divide-y divide-gray-200 dark:divide-gray-600;
|
20
|
-
|
21
|
-
tr {
|
22
|
-
@apply cursor-pointer bg-white dark:bg-gray-800 divide-x divide-gray-400 divide-opacity-25 hover:bg-gray-100 dark:hover:bg-gray-700;
|
23
|
-
|
24
|
-
&:nth-child(even) {
|
25
|
-
@apply bg-gray-50 dark:bg-gray-900 hover:bg-gray-200 dark:hover:bg-gray-700;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
td {
|
30
|
-
@apply px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400;
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
.paging {
|
36
|
-
@apply flex items-center justify-between border-t border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 px-4 py-3 sm:px-6;
|
37
|
-
|
38
|
-
|
39
|
-
.pagy {
|
40
|
-
@apply flex space-x-1 text-sm text-gray-500;
|
41
|
-
|
42
|
-
a:not(.gap) {
|
43
|
-
@apply block rounded-lg px-3 py-1 bg-gray-200 no-underline;
|
44
|
-
|
45
|
-
&:hover {
|
46
|
-
@apply bg-gray-300;
|
47
|
-
}
|
48
|
-
|
49
|
-
&:not([href]) {
|
50
|
-
/* disabled links */
|
51
|
-
@apply text-gray-300 bg-gray-100 cursor-default;
|
52
|
-
}
|
53
|
-
|
54
|
-
&.current {
|
55
|
-
@apply text-white bg-primary-600;
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
label {
|
60
|
-
@apply inline-block whitespace-nowrap bg-gray-200 rounded-lg px-3 py-0.5;
|
61
|
-
|
62
|
-
input {
|
63
|
-
@apply bg-gray-100 border-none rounded-md;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
&__condensed {
|
69
|
-
table {
|
70
|
-
tbody {
|
71
|
-
td {
|
72
|
-
@apply pl-4 py-2;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
77
|
-
}
|
78
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
.overflow-y-auto class=(table.view_condensed? ? "mensa-table__condensed" : "") data-mensa-table-target="view"
|
2
|
-
table.w-full
|
3
|
-
- if table.show_header?
|
4
|
-
thead
|
5
|
-
tr
|
6
|
-
= render(Mensa::Header::Component.with_collection(table.columns.select(&:visible?).reject(&:internal?), table: table))
|
7
|
-
- if table.actions?
|
8
|
-
th
|
9
|
-
|
10
|
-
tbody
|
11
|
-
= render(Mensa::TableRow::Component.with_collection(table.rows, table: table))
|
12
|
-
|
13
|
-
- if table.pagy_details&.pages > 1 || table.pagy_details.count == 0
|
14
|
-
.paging
|
15
|
-
== pagy_info(table.pagy_details)
|
16
|
-
- if table.pagy_details&.pages > 1
|
17
|
-
== pagy_nav(table.pagy_details)
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Presents a single table-view, also in use when just one table is in view
|
4
|
-
module Mensa
|
5
|
-
module View
|
6
|
-
class Component < ::Mensa::ApplicationComponent
|
7
|
-
include TablesHelper
|
8
|
-
|
9
|
-
attr_reader :table
|
10
|
-
|
11
|
-
def initialize(table)
|
12
|
-
@table = table
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
.mensa-table {
|
2
|
-
&__views {
|
3
|
-
@apply p-2 pl-4 shadow-lg border-b dark:bg-gray-700 dark:border-gray-600;
|
4
|
-
|
5
|
-
a.view {
|
6
|
-
@apply bg-gray-100 text-gray-600 dark:text-gray-400 hover:text-gray-800 hover:bg-gray-200 rounded-md px-3 py-1.5 text-sm;
|
7
|
-
}
|
8
|
-
|
9
|
-
a.view.selected {
|
10
|
-
@apply bg-gray-300 text-gray-800 dark:bg-gray-500 hover:bg-gray-400;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
.mensa-table__views data-mensa-table-target="views"
|
2
|
-
.sm:hidden
|
3
|
-
label.sr-only[for="tabs"]
|
4
|
-
| Select a tab
|
5
|
-
select#tabs.block.w-full.rounded-md.border-gray-300.focus:border-indigo-500.focus:ring-indigo-500[name="tabs"]
|
6
|
-
- table.all_views.each.with_index do |view, index|
|
7
|
-
option = view.name
|
8
|
-
.hidden.sm:block
|
9
|
-
nav.flex.justify-between[aria-label="Tabs"]
|
10
|
-
.flex.space-x-2.overflow-x-auto.whitespace-nowrap.scroll-p-0
|
11
|
-
- table.all_views.each.with_index do |view, index|
|
12
|
-
= link_to(table.path(table_view_id: view.id, turbo_frame_id: table.table_id), "data-turbo-frame": table.table_id, class: "view #{(view == table.table_view) || (!view.persisted? && table.table_view.blank?) ? 'selected' : ''}") do
|
13
|
-
= view.name
|
14
|
-
|
15
|
-
a.text-gray-600.dark:text-gray-400.hover:text-gray-800.hover:bg-gray-200.rounded-md.px-3.py-1.5.text-sm[href="#" title=t("new_view", default: "New view")]
|
16
|
-
.fal.fa-plus
|
17
|
-
- if table.supports_views?
|
18
|
-
= render Mensa::ControlBar::Component.new(table: table)
|
File without changes
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Mensa
|
2
|
-
module Tables
|
3
|
-
class FiltersController < ::ApplicationController
|
4
|
-
layout false
|
5
|
-
|
6
|
-
class Filter
|
7
|
-
include ActiveModel::Model
|
8
|
-
attr_accessor :value
|
9
|
-
end
|
10
|
-
|
11
|
-
def index
|
12
|
-
config = {}.merge(params.permit(:id, :page, :table_id, :target, :table_view_id, :turbo_frame_id, order: {}, filters: {}).to_h)
|
13
|
-
@table = Mensa.for_name(params[:table_id], config)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Returns the filter information on the column-name
|
17
|
-
def show
|
18
|
-
config = {}.merge(params.permit(:id, :page, :table_id, :target, :table_view_id, :turbo_frame_id, order: {}, filters: {}).to_h)
|
19
|
-
@table = Mensa.for_name(params[:table_id], config)
|
20
|
-
@table.original_view_context = helpers
|
21
|
-
@column = @table.column(params[:id])
|
22
|
-
respond_to do |format|
|
23
|
-
format.turbo_stream
|
24
|
-
format.html
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Mensa
|
2
|
-
class TablesController < ::ApplicationController
|
3
|
-
layout :decide_layout
|
4
|
-
|
5
|
-
def index
|
6
|
-
render layout: 'mensa/application'
|
7
|
-
end
|
8
|
-
|
9
|
-
def show
|
10
|
-
config = if params[:table_view_id]
|
11
|
-
@view = Mensa::TableView.find_by(table_name: params[:id], id: params[:table_view_id])
|
12
|
-
@view&.data || {}
|
13
|
-
else
|
14
|
-
{}
|
15
|
-
end
|
16
|
-
|
17
|
-
config = config.merge(params.permit(:format, :query, :id, :page, :table_view_id, :turbo_frame_id, order: {}, filters: {}).to_h)
|
18
|
-
|
19
|
-
@table = Mensa.for_name(params[:id], config)
|
20
|
-
@table.table_view = @view
|
21
|
-
@table.original_view_context = helpers
|
22
|
-
|
23
|
-
respond_to do |format|
|
24
|
-
format.turbo_stream
|
25
|
-
format.html
|
26
|
-
format.xlsx do
|
27
|
-
Mensa::ExportJob.perform_async(current_user.id, params[:id])
|
28
|
-
head 200
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def decide_layout
|
34
|
-
return false if params[:turbo_frame_id]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
// application_controller.js
|
2
|
-
import { Controller } from '@hotwired/stimulus'
|
3
|
-
|
4
|
-
export default class ApplicationController extends Controller {
|
5
|
-
connect () {
|
6
|
-
this.element[this.identifier] = this
|
7
|
-
}
|
8
|
-
|
9
|
-
getController (element, identifier) {
|
10
|
-
return this.application.getControllerForElementAndIdentifier(element, identifier)
|
11
|
-
}
|
12
|
-
|
13
|
-
triggerEvent (el, name, data) {
|
14
|
-
let event
|
15
|
-
if (typeof window.CustomEvent === 'function') {
|
16
|
-
event = new CustomEvent(name, { detail: data, cancelable: true, bubbles: true })
|
17
|
-
} else {
|
18
|
-
event = document.createEvent('CustomEvent')
|
19
|
-
event.initCustomEvent(name, true, true, data)
|
20
|
-
}
|
21
|
-
el.dispatchEvent(event)
|
22
|
-
}
|
23
|
-
|
24
|
-
elementScrolled (element) {
|
25
|
-
if (element.scrollHeight - Math.round(element.scrollTop) === element.clientHeight) {
|
26
|
-
return true
|
27
|
-
}
|
28
|
-
return false
|
29
|
-
}
|
30
|
-
|
31
|
-
debouncedHover (element, timeout, handler) {
|
32
|
-
var timeoutId = null
|
33
|
-
element.addEventListener(marker, 'mouseover', function () {
|
34
|
-
timeoutId = setTimeout(handler, timeout)
|
35
|
-
})
|
36
|
-
|
37
|
-
element.addEventListener(marker, 'mouseout', function () {
|
38
|
-
clearTimeout(timeoutId)
|
39
|
-
})
|
40
|
-
}
|
41
|
-
|
42
|
-
get ourUrl () {
|
43
|
-
// This requires the mensaTableOutlet
|
44
|
-
let turboFrame = this.mensaTableOutlet?.turboFrameTarget
|
45
|
-
if(!turboFrame) {
|
46
|
-
turboFrame = this.turboFrameTarget
|
47
|
-
}
|
48
|
-
let url
|
49
|
-
|
50
|
-
if (turboFrame && turboFrame.getAttribute('src')) {
|
51
|
-
url = new URL(turboFrame.getAttribute('src'))
|
52
|
-
} else {
|
53
|
-
url = new URL(window.location.href)
|
54
|
-
}
|
55
|
-
return url
|
56
|
-
}
|
57
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import { application } from "mensa/controllers/application"
|
2
|
-
|
3
|
-
// import AddFilterComponentController from 'components/add_filter/component_controller';
|
4
|
-
// application.register('mensa-add-filter', AddFilterComponentController)
|
5
|
-
|
6
|
-
import AddFilterComponentController from "mensa/components/add_filter/component_controller";
|
7
|
-
application.register("mensa-add-filter", AddFilterComponentController);
|
8
|
-
|
9
|
-
import FiltersComponentController from "mensa/components/filters/component_controller";
|
10
|
-
application.register("mensa-filters", FiltersComponentController);
|
11
|
-
|
12
|
-
import SearchComponentController from "mensa/components/search/component_controller";
|
13
|
-
application.register("mensa-search", SearchComponentController);
|
14
|
-
|
15
|
-
import TableComponentController from 'mensa/components/table/component_controller'
|
16
|
-
application.register("mensa-table", TableComponentController);
|
17
|
-
|
18
|
-
// Eager load all controllers defined in the import map under controllers/**/*_controller
|
19
|
-
// import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
20
|
-
// eagerLoadControllersFrom("controllers", application)
|
21
|
-
|
22
|
-
// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
|
23
|
-
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
|
24
|
-
// lazyLoadControllersFrom("controllers", application)
|