tramway 2.3.1 → 2.3.1.2
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: afb266e8ff0e57296500fc2181b623ef4abffbe184be90bbb3a6a61431cfcbc8
|
|
4
|
+
data.tar.gz: 7e23e932ff24c6f5c93bbc3a3cd2365c2f66e7b121a690f9c56e51cfe5c3ac60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48eca5f7a2a9c24681f73f164b997e59b21e75efd761fd99f8f765752ed16b226d8823ee124c60fca08c2944c49b91b38d2e8b4808faf424fc804dfb0b8aec40
|
|
7
|
+
data.tar.gz: 11835fac94f5d47052e64a8a6de159eb53385b1ee9dc78f1a0500c8a7b4329eb1f0f607ff8e84c078a66becd1387f0403d78f3b9fe6e43dd6c905ab695c3b50b
|
data/README.md
CHANGED
|
@@ -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
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
- waiting_placeholder = t('tramway.chat.placeholders.waiting')
|
|
14
14
|
- typing_placeholder = t('tramway.chat.placeholders.type')
|
|
15
15
|
= f.text_field :text,
|
|
16
|
-
class: 'flex-1 md:rounded-full rounded-bl-2xl md:border border-gray-300 px-4 py-2 text-sm text-gray-900 shadow-sm placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed
|
|
16
|
+
class: 'flex-1 md:rounded-full rounded-bl-2xl md:border border-gray-300 px-4 py-2 text-sm text-gray-900 shadow-sm placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed border-gray-600 bg-gray-800 text-white focus:border-blue-400 focus:ring-blue-500/30',
|
|
17
17
|
placeholder: send_messages_enabled ? typing_placeholder : waiting_placeholder,
|
|
18
18
|
disabled: !send_messages_enabled
|
|
19
19
|
|
|
@@ -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
|
|
@@ -77,7 +77,7 @@ module Tramway
|
|
|
77
77
|
component 'tramway/flash', text:, type:, options:
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
def tramway_chat(chat_id:, messages:, message_form:, send_message_path
|
|
80
|
+
def tramway_chat(chat_id:, messages:, message_form:, send_message_path:, **)
|
|
81
81
|
unless messages.all? { _1[:id].present? && _1[:type].present? }
|
|
82
82
|
raise ArgumentError, 'Each message must have :id and :type keys'
|
|
83
83
|
end
|
|
@@ -86,7 +86,7 @@ module Tramway
|
|
|
86
86
|
raise ArgumentError, 'Message :type must be either :sent or :received'
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
component 'tramway/chat', chat_id:, messages:, message_form:, send_message_path
|
|
89
|
+
component 'tramway/chat', chat_id:, messages:, message_form:, send_message_path:, **
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
private
|
data/lib/tramway/version.rb
CHANGED