hotwire_datatables 0.1.0
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 +7 -0
- data/README.md +125 -0
- data/Rakefile +4 -0
- data/lib/hotwire_datatables/version.rb +5 -0
- data/lib/hotwire_datatables.rb +8 -0
- metadata +174 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f5c84200f972eff2640380af43571a74c722bbe8e1e03d8ed63eabe03969b64a
|
4
|
+
data.tar.gz: 183ba63a958b6b98e1e6950e3c0de2cff2e95dbe454710c7cd6d5bc4b538f44e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c6702f8b08b8c0c865221e9fcd740cbb342538da66cacd7339917398eef166577b25bffa7b2df94b2ac8e10a231671771b30074f6151e058cb94b33ffc69536e
|
7
|
+
data.tar.gz: 5a00851240e78a6caf99fa9c7228ab30d8ccee76c3737aeedecaee417e679f6c941f2c6f659948f411e873f90fe7ceb81a2d8d4cb07547f431012bed5a15cfd4
|
data/README.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# HotwireDatatables
|
2
|
+
|
3
|
+
HotwireDatatables is a modern, Hotwire-powered DataTables implementation for Ruby on Rails that provides sorting, searching, and pagination capabilities with a beautiful UI.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- 🚀 Fast, server-side processing
|
8
|
+
- 🔍 Real-time search with PostgreSQL full-text search
|
9
|
+
- ↕️ Column sorting
|
10
|
+
- 📄 Pagination with Pagy
|
11
|
+
- 🎨 Beautiful UI with Tailwind CSS
|
12
|
+
- ⚡ Hotwire/Turbo powered for smooth updates
|
13
|
+
- 🛠️ Easy to customize and extend
|
14
|
+
|
15
|
+
## Requirements
|
16
|
+
|
17
|
+
- Ruby >= 3.0.0
|
18
|
+
- Rails >= 7.0
|
19
|
+
- PostgreSQL database
|
20
|
+
- Turbo Rails
|
21
|
+
- Tailwind CSS
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem 'hotwire_datatables'
|
29
|
+
```
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
$ bundle install
|
35
|
+
```
|
36
|
+
|
37
|
+
Or install it yourself as:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
$ gem install hotwire_datatables
|
41
|
+
```
|
42
|
+
|
43
|
+
Then run the installer:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
$ rails generate hotwire_datatables:install
|
47
|
+
```
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
1. Include the Datatable concern in your model:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
class Employee < ApplicationRecord
|
55
|
+
include Datatable
|
56
|
+
|
57
|
+
datatable_columns :name, :position, { age: "Employee Age" }
|
58
|
+
datatable_search_columns :name, :position, :office
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
2. Set up your controller:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
class EmployeesController < ApplicationController
|
66
|
+
include Pagy::Backend
|
67
|
+
|
68
|
+
def index
|
69
|
+
@employees = Employee.all
|
70
|
+
@employees = @employees.search(params[:query]) if params[:query].present?
|
71
|
+
@pagy, @employees = pagy @employees.reorder(sort_column(Employee.get_datatable_columns.map(&:name)) => sort_direction)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
3. Add the datatable to your view:
|
77
|
+
|
78
|
+
```erb
|
79
|
+
<%= render partial: "hotwire_datatables/datatable", locals: {
|
80
|
+
collection: @employees,
|
81
|
+
columns: Employee.get_datatable_columns,
|
82
|
+
frame_id: "employees_table",
|
83
|
+
row_partial: "employee_row",
|
84
|
+
pagy: @pagy
|
85
|
+
} %>
|
86
|
+
```
|
87
|
+
|
88
|
+
4. Create a row partial for your records (_employee_row.html.erb):
|
89
|
+
|
90
|
+
```erb
|
91
|
+
<%= render partial: "hotwire_datatables/datatable_row", locals: {
|
92
|
+
record: record,
|
93
|
+
columns: columns
|
94
|
+
} %>
|
95
|
+
```
|
96
|
+
|
97
|
+
## Configuration
|
98
|
+
|
99
|
+
You can configure HotwireDatatables in `config/initializers/hotwire_datatables.rb`:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
HotwireDatatables.configure do |config|
|
103
|
+
config.per_page = 10
|
104
|
+
config.per_page_options = [10, 25, 50, 100]
|
105
|
+
config.default_direction = :asc
|
106
|
+
config.enable_search = true
|
107
|
+
config.enable_sorting = true
|
108
|
+
config.table_class = "table"
|
109
|
+
config.header_class = "table-header-group"
|
110
|
+
config.row_class = "table-row-group"
|
111
|
+
config.cell_class = "table-cell pr-4"
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
115
|
+
## Contributing
|
116
|
+
|
117
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yourusername/hotwire_datatables.
|
118
|
+
|
119
|
+
## License
|
120
|
+
|
121
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
122
|
+
|
123
|
+
## Code of Conduct
|
124
|
+
|
125
|
+
Everyone interacting in the HotwireDatatables project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/hotwire_datatables/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hotwire_datatables
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alan Maciel
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: rails
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '7.0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '7.0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: turbo-rails
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.0'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: tailwindcss-rails
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: pagy
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '6.0'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '6.0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: pg_search
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '2.3'
|
75
|
+
type: :runtime
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '2.3'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: pg
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: rspec-rails
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: factory_bot_rails
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: faker
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
description: A modern, Hotwire-powered DataTables implementation for Ruby on Rails
|
139
|
+
that provides sorting, searching, and pagination capabilities with a beautiful UI
|
140
|
+
email:
|
141
|
+
- alan.maciel.salcedo@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- README.md
|
147
|
+
- Rakefile
|
148
|
+
- lib/hotwire_datatables.rb
|
149
|
+
- lib/hotwire_datatables/version.rb
|
150
|
+
homepage: https://github.com/alanmaciel/hotwire_datatables
|
151
|
+
licenses:
|
152
|
+
- MIT
|
153
|
+
metadata:
|
154
|
+
homepage_uri: https://github.com/alanmaciel/hotwire_datatables
|
155
|
+
source_code_uri: https://github.com/alanmaciel/hotwire_datatables
|
156
|
+
changelog_uri: https://github.com/alanmaciel/hotwire_datatables/blob/main/CHANGELOG.md
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: 3.0.0
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubygems_version: 3.6.7
|
172
|
+
specification_version: 4
|
173
|
+
summary: DataTables implementation for Ruby on Rails using Hotwire
|
174
|
+
test_files: []
|