-
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.
Merge PR#12 from franenlanube/feature/crud-alternatives
Feature/crud alternatives
- Loading branch information
Showing
6 changed files
with
150 additions
and
102 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
52 changes: 24 additions & 28 deletions
52
...Sprint4-Laravel/ArgentineElections/resources/views/entities/alternatives/create.blade.php
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,42 +1,38 @@ | ||
@extends('layouts.main-layout') | ||
|
||
@section('content') | ||
<h2 class="text-2xl font-semibold text-center mt-10">Add an Alternative</h2> | ||
<form action="/alternatives/store" method="POST" class="mt-auto mx-auto max-w-md space-y-4"> | ||
<h2 class="text-2xl font-semibold text-center m-10">Add an Alternative</h2> | ||
<form action="{{ route('alternatives.store') }}" method="POST" class="border p-5 m-auto mx-auto max-w-md space-y-4"> | ||
@csrf | ||
|
||
<div> | ||
<label for="name" class="block text-gray-700">Name</label> | ||
<input id="name" name="name" type="text" | ||
class="border rounded px-3 py-2 w-full | ||
<label for="name" class="block text-gray-700">Name</label> | ||
<input id="name" name="name" type="text" | ||
class="border px-3 py-2 w-full | ||
@error('name') border-red-500 @enderror" | ||
value="{{ old('name') }}" tabindex="1"> | ||
@error('name') | ||
<small class="text-red-500">{{ $message }}</small> | ||
@enderror | ||
</div> | ||
value="{{ old('name') }}" tabindex="1"> | ||
@error('name') | ||
<small class="text-red-500">{{ $message }}</small> | ||
@enderror | ||
|
||
<div> | ||
<label for="candidates" class="block text-gray-700">President and Vice candidates</label> | ||
<input id="candidates" name="candidates" type="text" | ||
class="border rounded px-3 py-2 w-full | ||
@error('candidates') border-red-500 @enderror" | ||
value="{{ old('candidates') }}" tabindex="2"> | ||
</div> | ||
<label for="presi_vice" class="block text-gray-700">President and Vice candidates</label> | ||
<input id="presi_vice" name="presi_vice" type="text" | ||
class="border rounded px-3 py-2 w-full | ||
@error('presi_vice') border-red-500 @enderror" | ||
value="{{ old('presi_vice') }}" tabindex="2"> | ||
|
||
<label for="logo" class="block text-gray-700">URL-Logo</label> | ||
<input id="logo" name="logo" type="text" | ||
class="border rounded px-3 py-2 w-full | ||
@error('logo') border-red-500 @enderror" | ||
value="{{ old('logo') }}" tabindex="3"> | ||
|
||
<div> | ||
<label for="logo" class="block text-gray-700">URL-Logo</label> | ||
<input id="logo" name="logo" type="text" | ||
class="border rounded px-3 py-2 w-full | ||
@error('candidates') border-red-500 @enderror" | ||
value="{{ old('logo') }}" tabindex="3"> | ||
</div> | ||
<div class="flex justify-between"> | ||
<a href="/" class="bg-blue-400 hover:bg-blue-700 text-white font-bold py-2 px-4 m-4 rounded inline-block" | ||
tabindex="5">Cancel</a> | ||
<a href="/alternatives" | ||
class="bg-blue-400 hover:bg-blue-700 text-white font-bold py-2 px-4 m-4 rounded inline-block" | ||
tabindex="4">Cancel</a> | ||
<button type="submit" | ||
class="bg-blue-400 hover:bg-blue-700 text-white font-bold py-2 px-4 m-4 rounded inline-block" | ||
tabindex="6">Submit</button> | ||
tabindex="5">Submit</button> | ||
</div> | ||
</form> | ||
@endsection |
29 changes: 17 additions & 12 deletions
29
...P-Sprint4-Laravel/ArgentineElections/resources/views/entities/alternatives/edit.blade.php
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
99 changes: 64 additions & 35 deletions
99
...-Sprint4-Laravel/ArgentineElections/resources/views/entities/alternatives/index.blade.php
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,41 +1,70 @@ | ||
@extends('layouts.main-layout') | ||
|
||
@section('content') | ||
<h2 class="text-2xl font-semibold text-center mt-10">Alternatives</h2> | ||
<div class="mt-4 mx-auto p-20"> | ||
<table class="min-w-full border-collapse border"> | ||
<thead> | ||
<tr> | ||
<th | ||
class="px-6 py-3 bg-gray-200 text-left text-xs leading-4 font-medium text-gray-600 uppercase tracking-wider"> | ||
Name</th> | ||
<th class="px-6 py-3 bg-gray-200"></th> | ||
<h2 class="text-2xl font-semibold text-center m-5">Alternatives</h2> | ||
@if (session('error')) | ||
<div class="flex max-w-3xl mx-auto mb-3 bg-yellow-400 text-black text-center p-4 rounded-lg shadow-md justify-around"> | ||
<form action="{{ route('alternatives.destroy', session('id')) }}" method="POST"> | ||
@csrf | ||
@method('DELETE') | ||
<p>{{ session('error') }}</p> | ||
<input type="checkbox" name="confirm-delete" id="confirm-delete"> | ||
<label for="confirm-delete">Yes, I'm sure</label> | ||
<button type="submit" | ||
class="text-white bg-red-600 hover:bg-red-900 font-bold m-4 py-2 px-4 rounded">Delete</button> | ||
<a href="/alternatives" | ||
class="bg-blue-400 hover:bg-blue-700 text-white font-bold py-2 px-4 m-4 rounded inline-block" | ||
tabindex="4">Cancel</a> | ||
</form> | ||
</div> | ||
@endif | ||
@if (session('error-2')) | ||
<div class="max-w-3xl mx-auto mb-3 bg-red-400 text-white text-center p-4 rounded-lg shadow-md"> | ||
{{ session('error-2') }} | ||
</div> | ||
@endif | ||
<table class="max-w-3xl border-collapse border mx-auto p-10"> | ||
<thead> | ||
<tr> | ||
<th | ||
class="px-6 py-3 bg-gray-200 text-left text-base leading-4 font-medium text-gray-700 uppercase tracking-wider"> | ||
Name | ||
</th> | ||
<th class="px-6 py-3 bg-gray-200"></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach ($alternatives as $alternative) | ||
<tr class="border border-collapse"> | ||
@if (!($alternative->isblank() || $alternative->isSpoiled())) | ||
<td class="border px-6 py-5">{{ $alternative->name }}</td> | ||
<td class="m-2 my-4 flex justify-around h-full"> | ||
<a href="{{ route('alternatives.show', $alternative->id) }}" | ||
class="text-white bg-blue-400 hover-bg-blue-700 font-bold mx-2 py-2 px-4 rounded h-full">View</a> | ||
<a href="{{ route('alternatives.edit', $alternative->id) }}" | ||
class="text-white bg-blue-600 hover-bg-blue-900 font-bold mx-2 py-2 px-4 rounded h-full">Edit</a> | ||
<form action="{{ route('alternatives.destroy', $alternative->id) }}" method="POST" | ||
class="inline"> | ||
@csrf | ||
@method('DELETE') | ||
<button type="submit" | ||
class="text-white bg-red-600 hover-bg-red-900 font-bold mx-2 py-2 px-4 rounded h-full" | ||
onclick="return confirm('Are you sure you want to delete this alternative?')">Delete</button> | ||
</form> | ||
</td> | ||
@endif | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach ($alternatives as $alternative) | ||
<tr> | ||
<td class="border px-6 py-4">{{ $alternative->name }}</td> | ||
<td class="border px-6 py-4 text-right"> | ||
@if (!($alternative->isblank() || $alternative->isSpoiled())) | ||
<a href="{{ route('alternatives.edit', $alternative->id) }}" | ||
class="text-white bg-blue-400 hover:bg-blue-700 font-bold py-2 px-4 m-4 rounded mr-3">Edit</a> | ||
<form action="{{ route('alternatives.destroy', $alternative->id) }}" method="POST" | ||
class="inline"> | ||
@csrf | ||
@method('DELETE') | ||
<button type="submit" | ||
class="text-white bg-red-600 hover:bg-red-900 font-bold py-2 px-4 m-4 rounded mr-3">Delete</button> | ||
</form> | ||
@endif | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<div class="text-center mt-4"> | ||
<a href="/" class="bg-blue-400 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded inline-block">Back</a> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
<div class="max-w-3xl mx-auto my-5 flex justify-around"> | ||
<div class="text-center"> | ||
<a href="/" | ||
class="bg-blue-400 hover-bg-blue-700 text-white font-bold py-2 px-4 rounded inline-block">Back</a> | ||
</div> | ||
<div class="text-center"> | ||
<a href="{{ route('alternatives.create') }}" | ||
class="bg-blue-400 hover-bg-blue-700 text-white font-bold py-2 px-4 rounded inline-block">Create</a> | ||
</div> | ||
</div> | ||
@endsection |
39 changes: 20 additions & 19 deletions
39
...P-Sprint4-Laravel/ArgentineElections/resources/views/entities/alternatives/show.blade.php
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,35 +1,36 @@ | ||
@extends('layouts.main-layout') | ||
|
||
@section('content') | ||
<h2 class="text-2xl font-semibold text-center mt-10">Alternative</h2> | ||
<div class="mt-auto mx-auto max-w-md space-y-4"> | ||
<table> | ||
<div> | ||
<h2 class="text-2xl font-semibold text-center m-8">Alternative</h2> | ||
<div class="border rounded p-5 my-10 mx-auto max-w-md space-y-4"> | ||
<table class="border rounded px-3 py-2"> | ||
<label for="name" class="block text-gray-700">Name</label> | ||
<div id="name" name="name" type="text" class="border rounded px-3 py-2 w-full"> | ||
{{ $alternative->name }} | ||
</div> | ||
{{-- TODO: Abstract this concept in default alternatives to avoid this if --}} | ||
@if (!($alternative->isblank() || $alternative->isSpoiled())) | ||
<div> | ||
<label for="candidates" class="block text-gray-700">President and Vice candidates</label> | ||
<div id="name" name="name" type="text" class="border rounded px-3 py-2 w-full"> | ||
{{ $alternative->presi_vice }} | ||
</div> | ||
</div> | ||
@if (!($alternative->isblank() || $alternative->isSpoiled() || empty($alternative->presi_vice))) | ||
<label for="presi_vice" class="block text-gray-700">President and Vice candidates</label> | ||
<div class="border rounded px-3 py-2 w-full"> | ||
{{ $alternative->presi_vice }} | ||
</div> | ||
@endif | ||
@if (!empty($alternative->logo)) | ||
<div> | ||
<label for="candidates" class="block text-gray-700">President and Vice candidates</label> | ||
<div id="name" name="name" type="text" class="border rounded px-3 py-2 w-full"> | ||
<div class="border rounded px-3 py-2"> | ||
<label for="logo" class="block text-gray-700">URL-Logo</label> | ||
<div id="logo" name="logo" type="text" class="px-3 py-2 w-full"> | ||
{{ $alternative->logo }} | ||
</div> | ||
</div> | ||
@endif | ||
</div> | ||
</table> | ||
<div class="text-center mt-4"> | ||
<a href="/" | ||
class="bg-blue-400 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded inline-block">Back</a> | ||
<div class="text-center flex justify-around mt-4 space-x-2"> | ||
<a href="/alternatives" | ||
class="bg-blue-400 hover-bg-blue-700 text-white font-bold py-2 px-4 rounded inline-block">Back</a> | ||
@if (!($alternative->isblank() || $alternative->isSpoiled())) | ||
<a href="/alternatives/{{ $alternative->id }}/edit" | ||
class="bg-blue-400 hover-bg-blue-700 text-white font-bold py-2 px-4 rounded inline-block">Edit</a> | ||
@endif | ||
</div> | ||
@endsection | ||
</div> | ||
@endsection |
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