angsa 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -0
- data/README.md +76 -12
- data/angsa-0.1.0.gem +0 -0
- data/angsa-0.1.1.gem +0 -0
- data/angsa-0.1.2.gem +0 -0
- data/lib/angsa/base.rb +6 -2
- data/lib/angsa/version.rb +1 -1
- data/lib/generators/angsa/templates/angsa_stimulus_controller.js +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e640d5e5f43554d5986e6e12c961d5a0e96b436f4b229c07db31f8272e4076f
|
4
|
+
data.tar.gz: 83a91a05ac6723f92239cd513424bd1ddaee2785bdcfce01944b6457ace73201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 182d42455c9c3c4f6cab831087643f1251fb6807e9ef0aad0ee15d4e5689603ced9cda605d0d174bc6364efa6cc00b3ef18accc87f63a7320a72ec604ea70d8d
|
7
|
+
data.tar.gz: a6bececf5e09c90fdd909f65d0b28427486278b26c53e4b59b17e59883990575739f5bd7f304fa1227001f09c0650104e4f8cb1b90c13ee5a8506b77fa6bf984
|
data/Gemfile.lock
ADDED
data/README.md
CHANGED
@@ -1,37 +1,101 @@
|
|
1
|
+
|
1
2
|
# Angsa
|
2
3
|
|
3
|
-
|
4
|
+
Angsa is a comprehensive server-side Ruby gem designed for Ruby on Rails applications. It delivers essential functionalities including pagination, sorting, and search capabilities for ActiveRecord models. The design of Angsa is catered to align smoothly with Grid.js, a powerful JavaScript library engineered for table grid layouts.
|
5
|
+
|
6
|
+
## Prerequisites
|
7
|
+
|
8
|
+
For Angsa to function properly, it requires specific versions of various software. It has been tested with:
|
9
|
+
|
10
|
+
1. Grid.js
|
11
|
+
2. Rails 7
|
12
|
+
3. Importmap
|
13
|
+
4. Ruby 3.1.3
|
4
14
|
|
5
|
-
|
15
|
+
Please ensure that your environment meets these prerequisites.
|
6
16
|
|
7
17
|
## Installation
|
8
18
|
|
9
|
-
|
19
|
+
### Step 1: Install Grid.js with Importmap
|
20
|
+
|
21
|
+
To get started, install Grid.js by following the instructions provided on the official Grid.js website. Alternatively, you can add Grid.js to your Rails project by executing the following command:
|
22
|
+
|
23
|
+
`bin/importmap pin gridjs`
|
24
|
+
|
25
|
+
Next, apply the basic styling for Grid.js available from the official website. Ensure that Grid.js is added to your `javascript/application.js`:
|
10
26
|
|
11
|
-
|
27
|
+
`import 'gridjs'`
|
12
28
|
|
13
|
-
|
29
|
+
### Step 2: Install Angsa
|
14
30
|
|
15
|
-
|
31
|
+
Add the Angsa gem to your application's Gemfile:
|
32
|
+
|
33
|
+
`gem "angsa", "~> 0.1.1"`
|
34
|
+
|
35
|
+
To install the gem, execute:
|
36
|
+
|
37
|
+
`bundle install`
|
16
38
|
|
17
39
|
## Usage
|
40
|
+
### Generators
|
41
|
+
Begin by installing the base JavaScript for Grid.js using the command:
|
42
|
+
|
43
|
+
`rails generate angsa:install`
|
44
|
+
|
45
|
+
Next, generate a setup for a model in your project using the command:
|
46
|
+
|
47
|
+
`rails generate angsa:table YourModel`
|
48
|
+
|
49
|
+
For instance, if you have a `Post` model, the command will be:
|
50
|
+
|
51
|
+
`rails generate angsa:table Post`
|
52
|
+
|
53
|
+
Having declared the required columns, proceed to generate the Stimulus controller with:
|
54
|
+
|
55
|
+
`rails generate angsa:js YourModel`
|
56
|
+
|
57
|
+
For example, for the `Post` model, it will be:
|
58
|
+
|
59
|
+
`rails generate angsa:js Post`
|
60
|
+
|
61
|
+
|
62
|
+
### Configuring the API URL
|
63
|
+
|
64
|
+
The API URL acts as a data source for Grid.js. To generate this URL, include the following code in your target controller. This will facilitate fetching data in JSON format:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
respond_to do |format|
|
68
|
+
format.html
|
69
|
+
format.json { render json: YourModelAngsa.new(params) }
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
Replace `YourModel` with the name of the model you are working with. For example, for a `Post` model, the line would read `PostAngsa.new(params)`.
|
74
|
+
|
75
|
+
### Integrating with Your Views
|
76
|
+
|
77
|
+
The subsequent step is to implement the functionality in your views. Here's an example using Slim syntax. Simply append the attributes illustrated below to your table. Grid.js and Angsa will handle the rest:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
table#gridjs data-controller='your-model-angsa'
|
81
|
+
```
|
18
82
|
|
19
|
-
|
83
|
+
Replace `'your-model'` with the name of your model. Remember to use hyphen-case (lowercase with hyphens separating words). For a `Post` model, the line would read `data-controller='post-angsa'`.
|
20
84
|
|
21
85
|
## Development
|
22
86
|
|
23
|
-
|
87
|
+
Clone the repository and execute `bin/setup` to install dependencies. Use `bin/console` for an interactive session to experiment.
|
24
88
|
|
25
|
-
To install this gem
|
89
|
+
To install this gem locally, use `bundle exec rake install`. If you wish to release a new version, modify the version number in `version.rb`, and execute `bundle exec rake release`. This command creates a git tag for the version, pushes git commits and the created tag, and finally pushes the `.gem` file to [rubygems.org](https://rubygems.org/).
|
26
90
|
|
27
91
|
## Contributing
|
28
92
|
|
29
|
-
|
93
|
+
We welcome bug reports and pull requests on [GitHub](https://github.com/kennedywee/angsa). We are committed to fostering an environment of collaboration. All contributors are expected to adhere to our [code of conduct](https://github.com/kennedywee/angsa/blob/main/CODE_OF_CONDUCT.md).
|
30
94
|
|
31
95
|
## License
|
32
96
|
|
33
|
-
|
97
|
+
Angsa is open-source, licensed under the [MIT License](https://opensource.org/licenses/MIT).
|
34
98
|
|
35
99
|
## Code of Conduct
|
36
100
|
|
37
|
-
|
101
|
+
We expect everyone interacting in the Angsa project's codebases, issue trackers, chat rooms, and mailing lists to adhere to our [code of conduct](https://github.com/kennedywee/angsa/blob/master/CODE_OF_CONDUCT.md).
|
data/angsa-0.1.0.gem
ADDED
Binary file
|
data/angsa-0.1.1.gem
ADDED
Binary file
|
data/angsa-0.1.2.gem
ADDED
Binary file
|
data/lib/angsa/base.rb
CHANGED
@@ -40,8 +40,12 @@ module Angsa
|
|
40
40
|
def extract_records(records)
|
41
41
|
records.map do |record|
|
42
42
|
columns.map do |column|
|
43
|
-
|
44
|
-
|
43
|
+
if column[:source].include?('custom_')
|
44
|
+
[column[:name], send(column[:source], record)]
|
45
|
+
else
|
46
|
+
source = column[:source].split('.')
|
47
|
+
[column[:name], source.size == 1 ? record.send(source.first) : record.send(source.first).send(source.last)]
|
48
|
+
end
|
45
49
|
end.to_h
|
46
50
|
end
|
47
51
|
end
|
data/lib/angsa/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { html } from 'gridjs';
|
2
|
-
import AngsaGridjsController from '
|
2
|
+
import AngsaGridjsController from 'controllers/angsa_gridjs_controller';
|
3
3
|
|
4
4
|
export default class <%= stimulus_controller_name %> extends AngsaGridjsController {
|
5
5
|
columnsConfig(){
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angsa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kennedy Wee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The Angsa gem is a server-side tool for Ruby on Rails applications that
|
14
14
|
provides pagination, sorting, and search capabilities for ActiveRecord models. It
|
@@ -23,9 +23,13 @@ files:
|
|
23
23
|
- CHANGELOG.md
|
24
24
|
- CODE_OF_CONDUCT.md
|
25
25
|
- Gemfile
|
26
|
+
- Gemfile.lock
|
26
27
|
- LICENSE.txt
|
27
28
|
- README.md
|
28
29
|
- Rakefile
|
30
|
+
- angsa-0.1.0.gem
|
31
|
+
- angsa-0.1.1.gem
|
32
|
+
- angsa-0.1.2.gem
|
29
33
|
- lib/angsa.rb
|
30
34
|
- lib/angsa/base.rb
|
31
35
|
- lib/angsa/pagination.rb
|