-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from solver-it-sro/GO-293/forms_and_templates
GO-293 Forms and templates in UPVS domain
- Loading branch information
Showing
41 changed files
with
1,737 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
app/components/message_template_recipients_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<%= render Common::ModalComponent.new do |modal| %> | ||
<% modal.with_modal_content do %> | ||
<div class="flex flex-col gap-2 mb-4"> | ||
<%= form_with url: message_template_search_recipients_list_path, class: "flex justify-start items-center self-stretch flex-grow-0 flex-shrink-0 mt-4" do |form| %> | ||
<div class="flex w-full items-center rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600"> | ||
<div class="p-2"> | ||
<%= render Icons::MagnifyingGlassComponent.gray(size: "4") %> | ||
</div> | ||
<%= tag.turbo_frame id: "recipients-search-results" %> | ||
<%= form.search_field :search, value: params[:search], placeholder: "Vyhľadajte prijímateľa", | ||
oninput: "this.form.requestSubmit()", | ||
onreset: "this.form.requestSubmit()", | ||
autofocus: true, | ||
class: "block w-full flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6" | ||
%> | ||
</div> | ||
<% end %> | ||
|
||
<%= tag.turbo_frame id: "recipients-list", class: "flex-col self-stretch mt-2" do %> | ||
<% @recipients_list.each do |recipient| %> | ||
<%= button_to message_template_recipient_selected_path, method: 'post', params: { recipient_uri: recipient[:uri], recipient_name: recipient[:name] }, | ||
class: "flex justify-between items-center self-stretch flex-grow-0 flex-shrink-0 py-2", data: { turbo_frame: "_top" } do %> | ||
<div class="flex justify-start items-center flex-grow-0 flex-shrink-0 relative gap-3"> | ||
<span class="flex-grow-0 flex-shrink-0 text-base font-medium text-left text-gray-900"><%= recipient[:name] %></span> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
|
||
<%= render Common::ModalActionsComponent.new %> | ||
<% end %> | ||
<% end %> |
2 changes: 1 addition & 1 deletion
2
...components/message_template_recipients.rb → .../message_template_recipients_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,77 @@ | ||
<div class="w-full p-4 flex-col justify-start items-start gap-4 inline-flex"> | ||
<div class="self-stretch bg-white rounded-md border border-gray-200 flex-col justify-start items-start flex"> | ||
<div class="self-stretch p-6 border-b border-gray-200 justify-start items-center gap-4 inline-flex"> | ||
<div class="grow shrink basis-0 text-gray-900 text-xl font-semibold leading-[35px]">Nová správa</div> | ||
</div> | ||
<div class="self-stretch p-6 flex-col justify-start items-start flex"> | ||
<%= form_with(url: message_drafts_path, method: :post, local: true) do %> | ||
<% if @boxes.count > 1 %> | ||
<label for="sender" class="block mb-2 text-base font-medium text-gray-900">Odosielateľ</label> | ||
<%= select_tag(:sender, options_for_select(@boxes, [Current.box&.name, Current.box&.id]), required: true, prompt: "Zvoľte odosielateľa", class: "mb-4 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5") %> | ||
<% else %> | ||
<%= hidden_field :sender, @boxes.first %> | ||
<% end %> | ||
<div id="new_message" is="turbo-frame" class="w-full"> | ||
<div class="w-full p-4 flex-col justify-start items-start gap-4 inline-flex"> | ||
<div class="self-stretch bg-white rounded-md border border-gray-200 flex-col justify-start items-start flex"> | ||
<div class="self-stretch p-6 border-b border-gray-200 justify-start items-center gap-4 inline-flex"> | ||
<div class="grow shrink basis-0 text-gray-900 text-xl font-semibold leading-[35px]">Nová správa</div> | ||
</div> | ||
<% | ||
form_id = "create_draft" | ||
sender_element_id = "sender_id" | ||
template_element_id = "message_template_id" | ||
%> | ||
|
||
<%= content_tag(:div, { "data-controller": "message-drafts", class: "w-full" }) do %> | ||
<label for="message_template" class="block mb-2 text-base font-medium text-gray-900">Typ správy</label> | ||
<%= select_tag(:message_template, options_for_select(@templates_list), required: true, prompt: "Zvoľte typ správy", "data-action": "change->message-drafts#loadTemplateRecipients", class: "mb-4 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5") %> | ||
<% end %> | ||
<%= form_with url: message_drafts_path, id: form_id, class: 'w-full' do |f| %> | ||
<div class="self-stretch px-6 pt-6 flex-col justify-start items-start flex"> | ||
<div class="mb-4 w-full"> | ||
<% if @boxes.count > 1 %> | ||
<label for="<%= sender_element_id %>" class="block mb-2 text-base font-medium text-gray-900">Odosielateľ</label> | ||
<%= select_tag(sender_element_id, options_for_select(@boxes, ([Current.box&.name, Current.box&.id] if Current.box) || [@selected_box&.name, @selected_box&.id]), prompt: "Zvoľte odosielateľa", class: "text-sm rounded-lg block w-full p-2.5 #{@message.errors[:sender_name].any? && !@selected_box ? ERROR_CLASSES : DEFAULT_CLASSES}") %> | ||
<% if @message.errors[:sender_name].any? && !@selected_box %> | ||
<p class="mt-2 text-sm text-red-600 dark:text-red-500"> | ||
<span class="font-medium"><%= @message.errors.full_messages_for(:sender_name).to_sentence %></span> | ||
</p> | ||
<% end %> | ||
<% else %> | ||
<%= hidden_field_tag sender_element_id, @boxes.first %> | ||
<% end %> | ||
</div> | ||
|
||
<div id="recipients_list" is="turbo-frame"></div> | ||
<%= content_tag(:div, { "data-controller": "message-drafts", class: "mb-4 w-full" }) do %> | ||
<label for="<%= template_element_id %>" class="block mb-2 text-base font-medium text-gray-900">Typ správy</label> | ||
<%= select_tag(template_element_id, options_for_select(@templates_list, [@selected_message_template&.name, @selected_message_template&.id]), prompt: "Zvoľte typ správy", "data-action": "change->message-drafts#loadTemplateRecipients", class: "text-sm rounded-lg block w-full p-2.5 #{@message.errors[:metadata].any? ? ERROR_CLASSES : DEFAULT_CLASSES}") %> | ||
<% if @message.errors[:metadata].any? %> | ||
<p class="mt-2 text-sm text-red-600 dark:text-red-500"> | ||
<span class="font-medium"><%= @message.errors[:metadata].to_sentence %></span> | ||
</p> | ||
<% end %> | ||
<% end %> | ||
|
||
<div class="gap-2 border-t-0 border-r-0 border-b-0 border-l-0 border-gray-200"> | ||
<%= submit_tag "Vytvoriť správu", class: "flex justify-strech items-start self-stretch flex-grow-0 flex-shrink-0 gap-2 mt-6 text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-3.5 py-2.5 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800" %> | ||
<div id="selected_recipient" is="turbo-frame"> | ||
<%= hidden_field_tag 'recipient_name', params[:recipient_name] %> | ||
<%= hidden_field_tag 'recipient_uri', params[:recipient_uri] %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<div class="self-stretch px-6 pb-6 flex-col justify-start items-start flex"> | ||
<div id="recipients_list" is="turbo-frame" class="w-full"> | ||
<% if @recipients_list && @recipients_list.count > 1 %> | ||
<div> | ||
<label for="recipient" class="block mb-2 text-base font-medium text-gray-900">Príjímateľ</label> | ||
</div> | ||
<%= button_to message_template_recipient_selector_path(@selected_message_template), method: 'get', data: { turbo_frame: "modal" }, class: "text-gray-500 hover:text-gray-900 w-full" do %> | ||
<div id="recipient" class="text-sm rounded-lg block w-full p-2.5 <%= @message.errors[:recipient_name].any? ? ERROR_CLASSES : DEFAULT_CLASSES %>"> | ||
<p class="text-left"><%= params[:recipient_name].presence || 'Zvoľte príjemateľa' %></p> | ||
</div> | ||
<% if @message.errors[:recipient_name].any? %> | ||
<p class="mt-2 text-left text-sm text-red-600 dark:text-red-500"> | ||
<span class="font-medium"><%= @message.errors.full_messages_for(:recipient_name).to_sentence %></span> | ||
</p> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
|
||
<%= content_tag(:div, { | ||
"data-controller": "message-drafts", | ||
"data-message-drafts-form-id": form_id, | ||
class: "gap-2 border-t-0 border-r-0 border-b-0 border-l-0 border-gray-200 w-full" | ||
}) do %> | ||
<button data-action="click->message-drafts#create" class="flex justify-strech items-start self-stretch flex-grow-0 flex-shrink-0 gap-2 mt-6 text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-3.5 py-2.5 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800"> | ||
Vytvoriť správu | ||
</button> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
class NewMessageComponent < ViewComponent::Base | ||
def initialize(templates_list:, boxes:) | ||
DEFAULT_CLASSES = 'bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500' | ||
ERROR_CLASSES = 'bg-red-50 border border-red-500 text-red-900 placeholder-red-700 focus:ring-red-500 focus:border-red-500' | ||
|
||
def initialize(message:, templates_list:, boxes:, recipients_list: nil, selected_box: nil, selected_message_template: nil) | ||
@message = message | ||
@templates_list = templates_list | ||
@boxes = boxes | ||
@recipients_list = recipients_list | ||
@selected_box = selected_box | ||
@selected_message_template = selected_message_template | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.