added friends
This commit is contained in:
42
app/views/friends/_form.html.erb
Normal file
42
app/views/friends/_form.html.erb
Normal file
@ -0,0 +1,42 @@
|
||||
<%= form_with(model: friend, class: "contents") do |form| %>
|
||||
<% if friend.errors.any? %>
|
||||
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-md mt-3">
|
||||
<h2><%= pluralize(friend.errors.count, "error") %> prohibited this friend from being saved:</h2>
|
||||
|
||||
<ul class="list-disc ml-6">
|
||||
<% friend.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :firstname %>
|
||||
<%= form.text_field :firstname, class: [{"border-gray-400 focus:outline-blue-600": friend.errors[:firstname].none?, "border-red-400 focus:outline-red-600": friend.errors[:firstname].any?}] %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :lastname %>
|
||||
<%= form.text_field :lastname, class: [{"border-gray-400 focus:outline-blue-600": friend.errors[:lastname].none?, "border-red-400 focus:outline-red-600": friend.errors[:lastname].any?}] %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :email %>
|
||||
<%= form.text_field :email, class: [{"border-gray-400 focus:outline-blue-600": friend.errors[:email].none?, "border-red-400 focus:outline-red-600": friend.errors[:email].any?}] %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :telefon %>
|
||||
<%= form.text_field :telefon, class: [{"border-gray-400 focus:outline-blue-600": friend.errors[:telefon].none?, "border-red-400 focus:outline-red-600": friend.errors[:telefon].any?}] %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :level %>
|
||||
<%= form.number_field :level, class: [{"border-gray-400 focus:outline-blue-600": friend.errors[:level].none?, "border-red-400 focus:outline-red-600": friend.errors[:level].any?}] %>
|
||||
</div>
|
||||
|
||||
<div class="inline">
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
22
app/views/friends/_friend.html.erb
Normal file
22
app/views/friends/_friend.html.erb
Normal file
@ -0,0 +1,22 @@
|
||||
<div id="<%= dom_id friend %>" class="w-full sm:w-auto my-5 space-y-5">
|
||||
<div>
|
||||
<strong class="block font-medium mb-1">Firstname:</strong>
|
||||
<%= friend.firstname %>
|
||||
</div>
|
||||
<div>
|
||||
<strong class="block font-medium mb-1">Lastname:</strong>
|
||||
<%= friend.lastname %>
|
||||
</div>
|
||||
<div>
|
||||
<strong class="block font-medium mb-1">Email:</strong>
|
||||
<%= friend.email %>
|
||||
</div>
|
||||
<div>
|
||||
<strong class="block font-medium mb-1">Telefon:</strong>
|
||||
<%= friend.telefon %>
|
||||
</div>
|
||||
<div>
|
||||
<strong class="block font-medium mb-1">Level:</strong>
|
||||
<%= friend.level %>
|
||||
</div>
|
||||
</div>
|
||||
10
app/views/friends/edit.html.erb
Normal file
10
app/views/friends/edit.html.erb
Normal file
@ -0,0 +1,10 @@
|
||||
<% content_for :title, "Editing friend" %>
|
||||
|
||||
<div class="md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">Freund bearbeiten</h1>
|
||||
|
||||
<%= render "form", friend: @friend %>
|
||||
|
||||
<%= link_to "Anzeigen", @friend, class: "btn-show" %>
|
||||
<%= link_to "Liste", friends_path, class: "btn-show" %>
|
||||
</div>
|
||||
29
app/views/friends/index.html.erb
Normal file
29
app/views/friends/index.html.erb
Normal file
@ -0,0 +1,29 @@
|
||||
<% content_for :title, "Freunde" %>
|
||||
|
||||
<div class="w-full notice">
|
||||
<% if notice.present? %>
|
||||
<p id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<h1 class="font-bold text-4xl">Freunde</h1>
|
||||
<%= link_to "Neuer Freund", new_friend_path, class: "btn-new" %>
|
||||
</div>
|
||||
|
||||
<div id="friends" class="min-w-full divide-y divide-gray-200 space-y-5">
|
||||
<% if @friends.any? %>
|
||||
<% @friends.each do |friend| %>
|
||||
<div class="flex flex-col sm:flex-row justify-between items-center pb-5 sm:pb-0">
|
||||
<%= render friend %>
|
||||
<div class="w-full sm:w-auto flex flex-col sm:flex-row space-x-2 space-y-2">
|
||||
<%= link_to "Anzeigen", friend, class: "btn-show" %>
|
||||
<%= link_to "Bearbeiten", edit_friend_path(friend), class: "btn-show" %>
|
||||
<%= button_to "Löschen", friend, method: :delete, class: "btn-destroy", data: { turbo_confirm: "Sind Sie sich sicher?" } %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p class="text-center my-10">Bisher kein Freund eingegeben.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
7
app/views/friends/new.html.erb
Normal file
7
app/views/friends/new.html.erb
Normal file
@ -0,0 +1,7 @@
|
||||
<% content_for :title, "Neuer Freund" %>
|
||||
|
||||
<div class="md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">Neuer Freund</h1>
|
||||
<%= render "form", friend: @friend %>
|
||||
<%= link_to "Back to friends", friends_path, class: "btn-empty" %>
|
||||
</div>
|
||||
17
app/views/friends/show.html.erb
Normal file
17
app/views/friends/show.html.erb
Normal file
@ -0,0 +1,17 @@
|
||||
<% content_for :title, "Freund anzeigen" %>
|
||||
|
||||
<div class="md:w-2/3 w-full">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-md inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<h1 class="font-bold text-4xl">Freund anzeigen</h1>
|
||||
|
||||
<%= render @friend %>
|
||||
|
||||
<%= link_to "Bearbeiten", edit_friend_path(@friend), class: "btn-show" %>
|
||||
<%= link_to "Liste anzeigen", friends_path, class: "btn-show" %>
|
||||
<%= button_to "Löschen", @friend, method: :delete, form_class: "sm:inline-block mt-2 sm:mt-0 sm:ml-2",
|
||||
class: "btn-destroy",
|
||||
data: { turbo_confirm: "Are you sure?" } %>
|
||||
</div>
|
||||
Reference in New Issue
Block a user