tramway 2.3.1.1 → 2.3.1.3
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5de5b05b1753cdf48960fb5a7f8a98e63e42b95db21eda01d3f28a828d97b81f
|
|
4
|
+
data.tar.gz: 8bb86b14f367b4874ca04d92bc81daab8566109ebeb86033bc6dacf3061000fb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45bbf5d2b75437f5b55f3df5c8a8041fb7cc1db11b8ce275277012c1aea3027587e114986cf9b0773fc0f72a0a5a26fbf8702dbd4fb4f2ae5375dfc9634d5841
|
|
7
|
+
data.tar.gz: c9a4dcd50b189a79592ac6e50df049b8eb3ff33387644d0db2fc76672815197ae33d830025a2982c9f1064a97a2bae5ae2fcce6fddf30043e114ac3d8fa3eeac
|
data/README.md
CHANGED
|
@@ -51,7 +51,7 @@ bundle install
|
|
|
51
51
|
bin/rails g tramway:install
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
The install generator adds the required gems (`haml-rails`, `kaminari`, `view_component`, and `dry-
|
|
54
|
+
The install generator adds the required gems (`haml-rails`, `kaminari`, `view_component`, `dry-initializer`, and `dry-monads`) to your
|
|
55
55
|
application's Gemfile—if they are not present—and appends the Tailwind safelist configuration Tramway ships with.
|
|
56
56
|
|
|
57
57
|
## Getting Started
|
|
@@ -863,6 +863,9 @@ the Tailwind color family explicitly.
|
|
|
863
863
|
that receives new messages. Each message must include an `:id` and a `:type` (either `:sent` or `:received`). Additional
|
|
864
864
|
message fields like `text`, `data`, or `sent_at` are forwarded to `tramway/chats/message_component`.
|
|
865
865
|
|
|
866
|
+
Use `send_messages_enabled:` to control whether users can send new messages from the rendered form. It defaults to `true`.
|
|
867
|
+
When set to `false`, the text field is disabled and the waiting placeholder is shown.
|
|
868
|
+
|
|
866
869
|
```haml
|
|
867
870
|
-# Haml example
|
|
868
871
|
- messages = [
|
|
@@ -872,7 +875,8 @@ message fields like `text`, `data`, or `sent_at` are forwarded to `tramway/chats
|
|
|
872
875
|
= tramway_chat chat_id: 'support-chat',
|
|
873
876
|
messages: messages,
|
|
874
877
|
message_form: @message_form,
|
|
875
|
-
send_message_path: chat_messages_path
|
|
878
|
+
send_message_path: chat_messages_path,
|
|
879
|
+
send_messages_enabled: @chat.open?
|
|
876
880
|
```
|
|
877
881
|
|
|
878
882
|
```erb
|
|
@@ -881,7 +885,8 @@ message fields like `text`, `data`, or `sent_at` are forwarded to `tramway/chats
|
|
|
881
885
|
<%= tramway_chat chat_id: 'support-chat',
|
|
882
886
|
messages: messages,
|
|
883
887
|
message_form: @message_form,
|
|
884
|
-
send_message_path: chat_messages_path
|
|
888
|
+
send_message_path: chat_messages_path,
|
|
889
|
+
send_messages_enabled: @chat.open? %>
|
|
885
890
|
```
|
|
886
891
|
|
|
887
892
|
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
- if pending?
|
|
18
18
|
.pb-1
|
|
19
|
-
= inline_svg 'icons/spinner.svg', class: 'w-4 h-4 text-white animate-spin'
|
|
19
|
+
-# = inline_svg 'icons/spinner.svg', class: 'w-4 h-4 text-white animate-spin'
|
|
20
20
|
|
|
21
21
|
- if failed?
|
|
22
22
|
.pb-1
|
|
23
|
-
= inline_svg 'icons/cross.svg', class: 'w-6 h-6 text-red-200'
|
|
23
|
+
-# = inline_svg 'icons/cross.svg', class: 'w-6 h-6 text-red-200'
|
|
24
24
|
|
|
25
25
|
- if data_view == :table
|
|
26
26
|
= component 'tramway/chats/messages/table', data:
|
data/docs/AGENTS.md
CHANGED
|
@@ -131,6 +131,8 @@ Inherit all components from Tramway::BaseComponent
|
|
|
131
131
|
When you need chat UI, use the `tramway_chat` helper. Pass `chat_id`, `messages`, `message_form`, and `send_message_path`.
|
|
132
132
|
Each message must include `:id` and a `:type` of `:sent` or `:received`, and other keys (like `:text`, `:data`, `:sent_at`)
|
|
133
133
|
are forwarded to `tramway/chats/message_component`. Use `message_form: nil` when you only need read-only chat rendering.
|
|
134
|
+
Use `send_messages_enabled:` (defaults to `true`) to control whether the message input is enabled. Set it to `false`
|
|
135
|
+
when chat should be visible but sending is temporarily unavailable.
|
|
134
136
|
|
|
135
137
|
For live updates to a rendered `tramway_chat`, use `tramway_chat_append_message(chat_id:, message_type:, text:, sent_at:)`.
|
|
136
138
|
This method is included in all controllers and ActiveRecord models. `message_type` must be `:sent` or `:received`, otherwise
|
|
@@ -354,7 +356,12 @@ In case you need something that looks like enumerize but it's a process state, u
|
|
|
354
356
|
Use model scopes instead of creating private methods for object collections.
|
|
355
357
|
|
|
356
358
|
### Rule 23
|
|
357
|
-
Use `tramway_title` for the main title on pages
|
|
359
|
+
Use `tramway_title` for the main title on pages. `tramway_title text: 'Title'` OR
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
tramway_title do
|
|
363
|
+
More complicated title with HTML tags
|
|
364
|
+
```
|
|
358
365
|
|
|
359
366
|
Example
|
|
360
367
|
*app/models/user.rb*
|
|
@@ -456,7 +463,7 @@ In case, you need to make a one link in tramway_table on each row. Use `tramway_
|
|
|
456
463
|
Always use tramway decorated objects in views.
|
|
457
464
|
|
|
458
465
|
### Rule 30
|
|
459
|
-
For Tailwind classes with `/`, `[`, `]` characters use `{ class: 'here is the complicated class' }` in HAML.
|
|
466
|
+
For Tailwind classes with arbitrary values (with `/`, `[`, `]` characters) use `{ class: 'here is the complicated class' }` in HAML.
|
|
460
467
|
|
|
461
468
|
### Rule 31
|
|
462
469
|
Always `tramway_decorate` and `tramway_form` for creating these types of objects. Don't use decorator and form classes for this.
|
|
@@ -464,6 +471,9 @@ Always `tramway_decorate` and `tramway_form` for creating these types of objects
|
|
|
464
471
|
### Rule 32
|
|
465
472
|
In Tramway Decorators, use `delegate_attributes` method instead of `delegate :something, to: :object`
|
|
466
473
|
|
|
474
|
+
### Rule 33
|
|
475
|
+
In case you want to use container on the page, use `tramway_container` helper instead of creating a component for that or using a plain div with Tailwind classes.
|
|
476
|
+
|
|
467
477
|
## Controller Patterns
|
|
468
478
|
|
|
469
479
|
- Keep actions short and explicit with guard clauses.
|
|
@@ -16,7 +16,8 @@ module Tramway
|
|
|
16
16
|
{ name: 'haml-rails', declaration: 'gem "haml-rails"' },
|
|
17
17
|
{ name: 'kaminari', declaration: 'gem "kaminari"' },
|
|
18
18
|
{ name: 'view_component', declaration: 'gem "view_component"' },
|
|
19
|
-
{ name: 'dry-initializer', declaration: "gem 'dry-initializer'" }
|
|
19
|
+
{ name: 'dry-initializer', declaration: "gem 'dry-initializer'" },
|
|
20
|
+
{ name: 'dry-monads', declaration: "gem 'dry-monads'" }
|
|
20
21
|
]
|
|
21
22
|
end
|
|
22
23
|
|
data/lib/tramway/version.rb
CHANGED