angsa 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b7ac88bfda0d089508dedc70127219c25598afa1f987f08e724fc6bdcbd2320
4
- data.tar.gz: 47bb55cb83f05d9a991f6e2437f60dec4c103ebfbc591187a152dabf194017c4
3
+ metadata.gz: a45fad18d0808f91ff45aa6745e6409503693a523ff7b92ea97b78d3c1630f06
4
+ data.tar.gz: 90ecfe981aa19f4a738845a0c788b2a3eca2f2810e4985f379af34bfce6958bb
5
5
  SHA512:
6
- metadata.gz: 720ec9bf7509e0354722fb46a22df70f6ed1171544f4b2253363479effd43f936399fa2e831fd20ec86ca3df9b966e561fd89c5a55d6e62677c01cd08b716067
7
- data.tar.gz: 56b9368d85618471312599f2ffb215327a1214953b6c7b0ade745667fcd4cb4e865eed516de2ceab07bb917589d0b4470c093bb70ba360d016d9f93c03558a3b
6
+ metadata.gz: 73ff6ed9f04de20632201c142692fc0c2007d3102c367ede3734b34b987fd63c01b3694d2cab69c0da0ad3f4cf18791bda1a771d4db3585119df0c3df6a0ecbe
7
+ data.tar.gz: 33306732ce13e3002e852b1127062ab062e42c3181ca485250c25b588995e1230222b3ca7ad1d1351cdef8252dcb89c7830664ef915e5396b55a04ce75c3f139
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ angsa (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (13.0.6)
10
+
11
+ PLATFORMS
12
+ arm64-darwin-22
13
+
14
+ DEPENDENCIES
15
+ angsa!
16
+ rake (~> 13.0)
17
+
18
+ BUNDLED WITH
19
+ 2.3.26
data/README.md CHANGED
@@ -1,37 +1,101 @@
1
+
1
2
  # Angsa
2
3
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/angsa`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
15
+ Please ensure that your environment meets these prerequisites.
6
16
 
7
17
  ## Installation
8
18
 
9
- Install the gem and add to the application's Gemfile by executing:
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
- $ bundle add angsa
27
+ `import 'gridjs'`
12
28
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
29
+ ### Step 2: Install Angsa
14
30
 
15
- $ gem install angsa
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
- TODO: Write usage instructions here
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
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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 onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/angsa. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/angsa/blob/master/CODE_OF_CONDUCT.md).
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
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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
- Everyone interacting in the Angsa project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/angsa/blob/master/CODE_OF_CONDUCT.md).
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/lib/angsa/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Angsa
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -1,14 +1,15 @@
1
1
  import { html } from 'gridjs';
2
- import AngsaGridjsController from './angsa_gridjs_controller';
2
+ import AngsaGridjsController from 'controllers/angsa_gridjs_controller';
3
3
 
4
4
  export default class <%= stimulus_controller_name %> extends AngsaGridjsController {
5
5
  columnsConfig(){
6
6
  // TODO: Return the appropriate columns for your model
7
7
  return [
8
- <%= @columns.map { |column| ' \"#{column}\"' }.join(",\n") %>
8
+ <%= @columns.map { |column| " \"#{column}\"" }.join(",\n") %>
9
9
  // {
10
10
  // name: 'Actions',
11
- // formatter: (_, row) => html(`<a href='${this.apiUrl().replace('.json', '')}/${row.cells[3].data}'><i class='far fa-arrow-alt-circle-right'></></a>`)
11
+ // sort: false,
12
+ // formatter: (_, row) => html(`<a href='${this.apiUrl().replace('.json', '')}/${row.cells[<%= @columns.size - 1 %>].data}'><i class='far fa-arrow-alt-circle-right'></></a>`)
12
13
  // },
13
14
  ]
14
15
 
@@ -9,6 +9,10 @@ class <%= model_class_name %> < Angsa::Base
9
9
  # { name: :id, source: 'id', searchable: false, type: :integer },
10
10
  # { name: :name, source: 'name', searchable: true, type: :string },
11
11
  # { name: :available, source: 'available', searchable: true, type: :boolean },
12
+
13
+ # Actions: Important! Declare either id or slug
14
+ # { name: :id, source: 'id', searchable: false, type: :integer },
15
+ # { name: :slug, source: 'slug', searchable: false, type: :integer },
12
16
  ]
13
17
  end
14
18
  end
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.0
4
+ version: 0.1.2
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-05-29 00:00:00.000000000 Z
11
+ date: 2023-06-09 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,12 @@ 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
29
32
  - lib/angsa.rb
30
33
  - lib/angsa/base.rb
31
34
  - lib/angsa/pagination.rb