Skip to content

Commit 3c9164f

Browse files
committed
add kanban authorization and installation steps
1 parent 6706c60 commit 3c9164f

File tree

1 file changed

+62
-5
lines changed

1 file changed

+62
-5
lines changed

docs/3.0/kanban-boards.md

+62-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,34 @@ Some of these requirements might change over time.
2727
- [`acts_as_list`](https://github.com/brendon/acts_as_list) gem (comes automatically as a requirement)
2828
- [`hotwire_combobox`](https://github.com/josefarias/hotwire_combobox) gem (comes automatically as a requirement)
2929

30+
## Installation
31+
32+
To install the `avo-kanban` gem, follow the steps below:
33+
34+
1. Add the following line to your Gemfile:
35+
```ruby
36+
gem "avo-kanban", source: "https://packager.dev/avo-hq/"
37+
```
38+
39+
2. Run the `bundle install` command to install the gem:
40+
```bash
41+
bundle install
42+
```
43+
44+
3. Generate the necessary resources and controllers by running:
45+
```bash
46+
rails generate avo:kanban install
47+
```
48+
49+
This command will create pre-configured resources and controllers for managing boards, columns, and items in your application. You can further customize the generated code to suit your needs.
50+
51+
This command will also generate the item's partial and a migration.
52+
53+
4. Run the migration to apply the database changes:
54+
```bash
55+
rails db:migrate
56+
```
57+
3058
## DB schema
3159
3260
`Avo::Kanban::Board` -> has_many `Avo::Kanban::Column` -> has_many `Avo::Kanban::Item`
@@ -54,8 +82,6 @@ We can configure what kind of resources can be added to the board.
5482
5583
Similar we can change the column names and the value from the settings screen.
5684
57-
Only the admins (`user.is_admin?`) can see the setting button and screen.
58-
5985
## Adding items to the board
6086
6187
This is best done on the board. Under each column you'll find the new field. This will search throught the resources that you've selected in the configuration.
@@ -107,12 +133,12 @@ Now, if we move the item to the `In progress` column, it will change the status
107133
### Items without that property
108134

109135
Some models might belong on the same board but have different properties to show the status.
110-
Some omodels might use a timestamp like `published_at` to show the status.
136+
Some models might use a timestamp like `published_at` to show the status.
111137
Or some models might belong to a a status but that isn't dictated by a single property but a collection of properties.
112138
113-
In order to mititgate that we can create virtual properties on the model.
139+
In order to mitigate that we can create virtual properties on the model.
114140
115-
Let's imagine that a new baord that displays the posts in columns based on their "published" status. the board uses the `status` property to but the `Post` model doesn't have the `status` property as a column in the database.
141+
Let's imagine that a new board that displays the posts in columns based on their "published" status. the board uses the `status` property to but the `Post` model doesn't have the `status` property as a column in the database.
116142
We can create a virtual property on the model.
117143
118144
```ruby
@@ -157,3 +183,34 @@ In order to customize the card, you can add this partial to your `app/views/avo/
157183
```
158184
159185
The `item` is the `Avo::Kanban::Item` and the `record` is the actual record from the database.
186+
187+
## Authorization
188+
189+
This section assumes that you have already set up [authorization](authorization.html) in your application using Pundit.
190+
191+
1. Generate a policy for the `Board` resource by running:
192+
```bash
193+
rails generate pundit:policy board
194+
```
195+
196+
### Authorization Methods
197+
198+
You can control access to various parts of the Kanban board by defining the following methods in your `BoardPolicy`:
199+
200+
- `manage_column?`
201+
202+
Controls the visibility of the three-dot menu on each column (used for column management).
203+
204+
- `edit?`
205+
206+
Controls the "Edit board" button on the board itself.
207+
:::warning
208+
Also controls the ability to edit the board in the resource view.
209+
:::
210+
211+
- `add_item?`
212+
213+
Controls the visibility of the "Add item" button on the board, which allows users to add new items to a column.
214+
:::warning
215+
Doesn't impact the ability to add items via the bottom of each column.
216+
:::

0 commit comments

Comments
 (0)