Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styled Languages #40

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 27 additions & 37 deletions app/views/languages/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
<%= form_with(model: language) do |form| %>
<% if language.errors.any? %>
<div style="color: red">
<h2><%= pluralize(language.errors.count, "error") %> prohibited this language from being saved:</h2>

<ul>
<% language.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>


<div class="form-body">
<div class="row">
<div class="col-md-4">
<%= form.label :name, style: "display: block" %>
<div class="card-content">
<div class="card-body">
<p>Languages should ... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.</p>
<%= form_with(model: @language, local: true, class: "form") do |f| %>
<div class="row">
<div class="col-md-12 col-12">
<div class="form-group">
<%= f.label :name, "Language Name" %>
<%= f.text_field :name, class: "form-control", placeholder: "Language" %>
</div>
</div>
<div class="col-md-8 form-group">
<%= form.text_field :name %>
<div class="row">
<div class="col-md-12 col-12">
<div class="form-group">
<%= f.label :file_share_folder, style: "display: block" %>
<%= f.text_field :file_share_folder, class: "form-control", placeholder: "File Share Folder" %>
</div>
</div>
<div class="col-12 d-flex justify-content-end">
<%= submit_button(f) %>
<%= link_to "Cancel", languages_path, class: "btn btn-light-secondary me-1 mb-1" %>
</div>
</div>
</div>
<% end %>
</div>

<div class="form-body">
<div class="row">
<div class="col-md-4">
<%= form.label :file_share_folder, style: "display: block" %>
</div>
<div class="col-md-8 form-group">
<%= form.text_field :file_share_folder %>
</div>
</div>
</div>

<div class="col-sm-12 d-flex justify-content-end">
<%= form.submit class: "btn btn-primary me-1 mb-1" %>
</div>
<% end %>
</div>
22 changes: 12 additions & 10 deletions app/views/languages/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<% content_for :title, "Editing language" %>

<h1>Editing language</h1>

<%= render "form", language: @language %>

<br>

<div>
<%= link_to "Show this language", @language %> |
<%= link_to "Back to languages", languages_path %>
</div>
<section id="multiple-column-form">
<div class="row match-height">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3>Edit Language</h3>
</div>
<%= render "form", language:@language %>
</div>
</div>
</div>
</section>
67 changes: 51 additions & 16 deletions app/views/languages/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,51 @@
<p style="color: green"><%= notice %></p>

<% content_for :title, "Languages" %>

<h1>Languages</h1>

<div id="languages">
<% @languages.each do |language| %>
<%= render language %>
<p>
<%= link_to "Show this language", language %>
</p>
<% end %>
</div>

<%= link_to "New language", new_language_path %>
<section class="section">
<div class="row" id="table-striped">
<div class="col-12 cold-md-12">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h2>Languages</h2>
<%= link_to new_language_path, class: "btn btn-primary" do %>
<i class="bi bi-plus-circle-fill"></i> Add New Language
<% end %>
</div>
<div class="card-content">
<div class="card-body">
<p class="card-text">
Lorem ipsum dolor sit amet, <code>consectetur adipiscing</code> elit. Sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in <code>reprehenderit</code> in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint <code>occaecat cupidatat</code> non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
<!-- table striped -->
<div class="table-responsive">
<table class="table table-lg table-striped mb-0">
<thead>
<tr>
<th>Language</th>
<th>File Share Folder</th>
<th class="text-end">Language Actions</th>
</tr>
</thead>
<tbody>
<% @languages.each do |language| %>
<tr id="<%= dom_id(language) %>" class="language-listing">
<td class="text-bold-500"><%= language.name %></td>
<td><%= language.file_share_folder %></td>
<td class="text-end">
<%= show_page_tool_link(language, "Show Language Details") %>
<%= link_to edit_language_path(language), class: "btn btn-secondary btn-sm" do %>
<i class="bi bi-pencil"></i>
<% end %>
<%= delete_tool_link(language, "Delete Language") %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
23 changes: 12 additions & 11 deletions app/views/languages/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<% content_for :title, "New language" %>

<h1>New language</h1>

<%= render "form", language: @language %>

<br>

<div>
<%= link_to "Back to languages", languages_path %>
</div>
<section id="multiple-column-form">
<div class="row match-height">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3>Create New Language</h3>
</div>
<%= render "form", language:@language %>
</div>
</div>
</div>
</section>
28 changes: 22 additions & 6 deletions app/views/languages/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
<p style="color: green"><%= notice %></p>

<%= render @language %>
<section id="multiple-column-form">
<div class="row match-height">
<div class="col-12">
<div class="card">
<div class="card-header">
<h2>Languages</h2>
<h4><%= @language.name %></h4>
</div>
<div class="card-content">
<div class="card-body">
<%= render @language %>

<div>
<%= link_to "Edit this language", edit_language_path(@language) %> |
<%= link_to "Back to languages", languages_path %>
<div>
<%= link_to "Edit this language", edit_language_path(@language) %> |
<%= link_to "Back to languages", languages_path %>

<%= button_to "Destroy this language", @language, method: :delete %>
</div>
<%= button_to "Destroy this language", @language, method: :delete %>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
2 changes: 1 addition & 1 deletion spec/views/languages/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

it "renders a list of languages" do
render
cell_selector = 'div>p'
cell_selector = 'tr.language-listing > td'
assert_select cell_selector, text: Regexp.new("Name".to_s), count: 2
assert_select cell_selector, text: Regexp.new("File Share Folder".to_s), count: 2
end
Expand Down
Loading