mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-23 20:10:52 +00:00
Restyling / refactoring ITEM
This commit is contained in:
parent
d407e5d109
commit
a3a7821578
@ -6,8 +6,13 @@
|
||||
<div class="col-md-8">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
Item: <strong>{{$item->name}}</strong>
|
||||
@include ('item.buttons')
|
||||
<strong>{{$item->name}}</strong>
|
||||
<span class="d-inline-block text-truncat float-right">
|
||||
<div class="btn-group" role="group">
|
||||
@include ('item.editButton')
|
||||
@include ('item.deleteButton')
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@ -16,61 +21,15 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<strong>Other items from the same product:</strong>
|
||||
<ul>
|
||||
@forelse ($otherItems as $otherItem)
|
||||
@if (!$otherItem->used_by)
|
||||
<li><a href="/item/{{ $otherItem->id }}">{{ $otherItem->name }}</a></li>
|
||||
@endif
|
||||
@empty
|
||||
<p>There are no items yet. Include one with the form above.</p>
|
||||
@endforelse
|
||||
</ul>
|
||||
@include('item.users')
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
Users of this item
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<strong>Users that has access to this item:</strong>
|
||||
<ul>
|
||||
@forelse ($users as $user)
|
||||
<hr>
|
||||
<li>
|
||||
{{ $user->name }} ({{ $user->email}})
|
||||
<div class="form-inline float-right">
|
||||
<form method="POST" action="/user" class="form-inline"> <div class="form-group">
|
||||
{{ csrf_field() }}
|
||||
@method('DELETE')
|
||||
<input type="hidden" class="form-control" name="user_id" id="user_id" value="{{$user->id}}">
|
||||
<input type="hidden" name="item_id" id="item_id" value="{{ $item['id'] }}">
|
||||
<button type="submit" class="btn-xm btn-danger">Delete</button>
|
||||
</form></div>
|
||||
</li>
|
||||
@empty
|
||||
<p>There are no items yet. Include one with the form above.</p>
|
||||
@endforelse
|
||||
</ul>
|
||||
|
||||
<div class="mt-4">
|
||||
<strong>Add user</strong>
|
||||
<form method="POST" action="/user" class="form-inline">
|
||||
<div class="form-group">
|
||||
{{ csrf_field() }}
|
||||
<div class="col"><label for="name">E-mail: </label></div>
|
||||
<div class="col-6"><input type="email" class="form-control" name="email" id="email" placeholder="name@domain.com" required></div>
|
||||
<input type="hidden" name="item_id" id="item_id" value="{{ $item['id'] }}" required>
|
||||
<div class="col ml-3"><button type="submit" class="btn btn-primary">Insert</button></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@include ('layouts.errors')
|
||||
@include ('item.otherItems')
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="float-right mt-2 mr-4"><a href="{{ URL::previous() }}">BACK</a></div>
|
||||
|
||||
<div class="float-right mt-2"><a class="btn btn-secondary" href="/product/{{ $item->product->id }}">BACK</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,24 +0,0 @@
|
||||
<span class="d-inline-block text-truncat float-right">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
|
||||
|
||||
<!-- EDIT BUTTON -->
|
||||
@if ($item->product->user_id == \Auth::id())
|
||||
<form action="/item/{{$item->id}}" method="POST">
|
||||
@method('PATCH')
|
||||
<button type="button" class="btn-sm btn-secondary mr-1">Edit</button>
|
||||
</form>
|
||||
@endif
|
||||
|
||||
|
||||
<!-- DELETE BUTTON -->
|
||||
<form action="/item/" method="POST">
|
||||
@method('DELETE')
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn-sm btn-danger">Delete</button>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</span>
|
28
resources/views/item/deleteButton.blade.php
Normal file
28
resources/views/item/deleteButton.blade.php
Normal file
@ -0,0 +1,28 @@
|
||||
<button type="button" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#deleteModal">Delete</button>
|
||||
|
||||
<!-- MODAL - DELETE CONFIRMATION -->
|
||||
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteModalLabel">Confirmation...</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Would you like to delete the item <strong>{{$item->name}}</strong>?</p>
|
||||
<p>You will not be able to restore it after deletion.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<form action="/item/" method="POST">
|
||||
@method('DELETE')
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn btn-danger">Delete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
32
resources/views/item/editButton.blade.php
Normal file
32
resources/views/item/editButton.blade.php
Normal file
@ -0,0 +1,32 @@
|
||||
<button type="button" class="btn btn-sm btn-secondary mr-1" data-toggle="modal" data-target="#editModal">Edit</button>
|
||||
|
||||
<!-- MODAL - CHANGE WINDOW -->
|
||||
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editModalLabel">Edit item</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form action="/item" method="POST">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-form-label">New name: </label>
|
||||
<input type="text" name="name" id="name" class="form-control" value="{{$item->name}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@method('PATCH')
|
||||
{{ csrf_field() }}
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-danger">Delete</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
17
resources/views/item/otherItems.blade.php
Normal file
17
resources/views/item/otherItems.blade.php
Normal file
@ -0,0 +1,17 @@
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
Other items from the same product
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<ul>
|
||||
@forelse ($otherItems as $otherItem)
|
||||
@if (!$otherItem->used_by)
|
||||
<li><a href="/item/{{ $otherItem->id }}">{{ $otherItem->name }}</a></li>
|
||||
@endif
|
||||
@empty
|
||||
<p>There are no items yet. Include one with the form above.</p>
|
||||
@endforelse
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
37
resources/views/item/users.blade.php
Normal file
37
resources/views/item/users.blade.php
Normal file
@ -0,0 +1,37 @@
|
||||
<p><strong>Users:</strong></p>
|
||||
@forelse ($users as $user)
|
||||
@if (!$loop->first)
|
||||
<hr>
|
||||
@endif
|
||||
{{ $user->name }} ({{ $user->email}})
|
||||
<div class="form-inline float-right">
|
||||
<form method="POST" action="/user" class="form-inline">
|
||||
<div class="form-group">
|
||||
{{ csrf_field() }}
|
||||
@method('DELETE')
|
||||
<input type="hidden" class="form-control" name="user_id" id="user_id" value="{{$user->id}}">
|
||||
<input type="hidden" name="item_id" id="item_id" value="{{ $item['id'] }}">
|
||||
<button type="submit" class="btn btn-sm btn-danger">Delete</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@empty
|
||||
<p>There are no items yet. Include one with the form above.</p>
|
||||
@endforelse
|
||||
|
||||
|
||||
<!-- ADD USERS -->
|
||||
<div class="mt-5 mb-5">
|
||||
<hr>
|
||||
<p><strong>Add user</strong></p>
|
||||
<form method="POST" action="/user" class="form-inline">
|
||||
<div class="form-group">
|
||||
{{ csrf_field() }}
|
||||
<div class="col"><label for="name">E-mail: </label></div>
|
||||
<div class="col-6"><input type="email" class="form-control" name="email" id="email" placeholder="name@domain.com" required></div>
|
||||
<input type="hidden" name="item_id" id="item_id" value="{{ $item['id'] }}" required>
|
||||
<div class="col ml-3"><button type="submit" class="btn btn-primary">Insert</button></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@include ('layouts.errors')
|
Loading…
Reference in New Issue
Block a user