-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow updating of visa information by admin
- Loading branch information
1 parent
f63cd96
commit a86ca4a
Showing
8 changed files
with
156 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.edit-visa-form { | ||
height: 100%; | ||
|
||
position: sticky; | ||
top: 5rem; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module VisaInformationsHelper | ||
def helper_edit_visa_info_heading(location:, visa_information:) | ||
heading = "Editing visa information for #{location.country.name}" | ||
if visa_information.citizenship.present? | ||
heading << " for citizens of #{visa_information.citizenship.name}" | ||
end | ||
|
||
heading | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
app/views/visa_informations/_update_visa_info_form.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,26 @@ | ||
<%= turbo_frame_tag "update-visa-info-form" do %> | ||
<% if flash[:success_update_visa].present? %> | ||
<div class="alert alert-success alert-dismissible fade show" role="alert"> | ||
<%= flash[:success_update_visa] %> | ||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> | ||
</div> | ||
<% end %> | ||
|
||
<% if flash[:error_update_visa].present? %> | ||
<div class="alert alert-success alert-dismissible fade show" role="alert"> | ||
<%= flash[:error_update_visa] %> | ||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> | ||
</div> | ||
<% end %> | ||
|
||
<%= form_for [@location, @visa_information] do |f| %> | ||
<% | ||
# Need to set the ID as the route is `resource`, not | ||
# `resources` | ||
%> | ||
<%= hidden_field_tag :id, @visa_information.id %> | ||
|
||
<%= f.text_area :body, class: "form-control mb-3", rows: 15 %> | ||
<%= f.submit "Save", class: "btn btn-success" %> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<div class="container mt-3"> | ||
<%= link_to location_visa_information_path(@location) do %> | ||
<i class="bi bi-chevron-left"></i> | ||
Back | ||
<% end %> | ||
|
||
<div class="row"> | ||
<div class="col-2 mt-2"> | ||
<strong>For citizens of...</strong> | ||
|
||
<ul class="nav nav-pills flex-column"> | ||
<% @visa_informations.each do |visa_info| %> | ||
<li class="nav-item"> | ||
<%= link_to( | ||
visa_info.citizenship&.name || "Generic", | ||
edit_location_visa_information_path( | ||
location_id: @location.id, | ||
id: visa_info.id | ||
), | ||
class: "nav-link#{ visa_info.id == @visa_information&.id ? " active" : nil}" | ||
) %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
|
||
<div class="edit-visa-form col"> | ||
<h1 class="fs-3 mt-2 mb-3"> | ||
<%= helper_edit_visa_info_heading( | ||
location: @location, | ||
visa_information: @visa_information | ||
) %> | ||
</h1> | ||
|
||
<%= render partial: "visa_informations/update_visa_info_form", | ||
locals: { | ||
location: @location, | ||
visa_information: @visa_information | ||
} | ||
%> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<% | ||
set_meta_tags( | ||
index: false, | ||
follow: false | ||
) | ||
%> |
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