BenBack #8
@@ -71,6 +71,7 @@ nav {
|
||||
.nav-element {
|
||||
line-height: 2.5;
|
||||
padding: 10px;
|
||||
margin: 4px;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
@@ -292,9 +293,8 @@ ul {
|
||||
/*image*/
|
||||
.recette-image {
|
||||
background-color: red;
|
||||
aspect-ratio: 1/1;
|
||||
max-height: calc( 30vh + 30vw );
|
||||
max-width: calc( 30vh + 30vw );
|
||||
max-height: calc( 20vh + 20vw );
|
||||
max-width: calc( 20vh + 20vw );
|
||||
border: 1px solid white;
|
||||
border-radius: 30px;
|
||||
}
|
||||
@@ -304,6 +304,35 @@ ul {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
|
||||
.recette-liste-ingr-div {
|
||||
margin-left: 120px;
|
||||
padding-left: 100px;
|
||||
width: 75%;
|
||||
border: 1px solid black;
|
||||
border-radius: 200px;
|
||||
box-shadow: 7px 4px 7px black;
|
||||
}
|
||||
|
||||
.recette-liste-ingr-elem {
|
||||
display: flex;
|
||||
padding-left: 50px;
|
||||
}
|
||||
|
||||
.ingr-image-prev {
|
||||
max-height: 50px;
|
||||
max-width: 50px;
|
||||
border: 1px solid black;
|
||||
border-radius: 10px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.recette-liste-ingr-elem-nom {
|
||||
height: 100%;
|
||||
width: 15%;
|
||||
line-height: 50px;
|
||||
}
|
||||
|
||||
.recette-div-info {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -496,12 +525,53 @@ ul {
|
||||
box-shadow: 1px 1px 1px black;
|
||||
}
|
||||
|
||||
.liste-ingr-elem:hover {
|
||||
border:3px solid #007054;
|
||||
box-shadow: 2px 2px 10px black;
|
||||
}
|
||||
|
||||
.liste-ingr-elem-text {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex:12;
|
||||
padding-left: 20px;
|
||||
line-height: 100px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.liste-ingr-elem-modif {
|
||||
line-height: 100px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.liste-tag-elem {
|
||||
display: flex;
|
||||
height: 40px;
|
||||
padding:5px;
|
||||
background-color: #c6fdefe0;
|
||||
color: #000000;
|
||||
border: 1px solid black;
|
||||
border-radius: 10px;
|
||||
box-shadow: 1px 1px 1px black;
|
||||
}
|
||||
|
||||
.liste-tag-elem:hover {
|
||||
border:3px solid #007054;
|
||||
box-shadow: 2px 2px 10px black;
|
||||
}
|
||||
|
||||
.liste-tag-elem-text {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex:12;
|
||||
padding-left: 20px;
|
||||
line-height: 40px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.liste-tag-elem-modif {
|
||||
line-height: 40px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.ingr-image {
|
||||
@@ -510,6 +580,11 @@ ul {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
|
||||
/*Footer et son contenue*/
|
||||
footer{
|
||||
padding: 25px;
|
||||
|
||||
62
public/assets/js/manage-ingredients.js
Normal file
62
public/assets/js/manage-ingredients.js
Normal file
@@ -0,0 +1,62 @@
|
||||
document.addEventListener("DOMContentLoaded", function(){
|
||||
|
||||
|
||||
let modifier_button = document.getElementsByClassName("ingr-modifier");
|
||||
|
||||
console.log(modifier_button);
|
||||
|
||||
for (const element of modifier_button) {
|
||||
element.addEventListener('click', function ( e ) {
|
||||
let modif = element.parentElement.previousSibling.previousSibling;
|
||||
|
||||
let data = e.target.getAttribute("data-id");
|
||||
|
||||
let form = document.createElement("form");
|
||||
|
||||
form.setAttribute("method", "POST");
|
||||
form.setAttribute("action", "/ingredients/edit/" + data);
|
||||
form.setAttribute("class","liste-ingr-elem-text")
|
||||
|
||||
let input = document.createElement("input");
|
||||
|
||||
input.setAttribute("type", "text");
|
||||
input.setAttribute("class", "form-control");
|
||||
input.setAttribute("name","modif_ingr");
|
||||
input.setAttribute("placeholder", "modificiation");
|
||||
|
||||
let hidden = document.createElement("input");
|
||||
|
||||
hidden.setAttribute("type","hidden");
|
||||
hidden.setAttribute("name","id");
|
||||
hidden.setAttribute("value", data);
|
||||
|
||||
let button = document.createElement("button");
|
||||
|
||||
button.setAttribute("type", "submit");
|
||||
button.setAttribute("class", "btn btn-primary");
|
||||
button.innerText = "Submit Modification";
|
||||
|
||||
form.append(input)
|
||||
form.append(hidden)
|
||||
form.append(button)
|
||||
|
||||
modif.replaceWith(form);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
let suppr = document.getElementsByClassName("ingr-suppr");
|
||||
|
||||
for (const element of suppr) {
|
||||
element.addEventListener('click', function ( e ) {
|
||||
let confirm = window.confirm("Voulez vous supprimez ?");
|
||||
|
||||
let data = e.target.getAttribute("data-id");
|
||||
|
||||
if (confirm) {
|
||||
window.location.href = "/ingredients/delete/" + data;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
62
public/assets/js/manage-tags.js
Normal file
62
public/assets/js/manage-tags.js
Normal file
@@ -0,0 +1,62 @@
|
||||
document.addEventListener("DOMContentLoaded", function(){
|
||||
|
||||
|
||||
let modifier_button = document.getElementsByClassName("tag-modifier");
|
||||
|
||||
console.log(modifier_button);
|
||||
|
||||
for (const element of modifier_button) {
|
||||
element.addEventListener('click', function ( e ) {
|
||||
let modif = element.parentElement.previousSibling.previousSibling;
|
||||
|
||||
let data = e.target.getAttribute("data-id");
|
||||
|
||||
let form = document.createElement("form");
|
||||
|
||||
form.setAttribute("method", "POST");
|
||||
form.setAttribute("action", "/tags/edit/" + data);
|
||||
form.setAttribute("class","liste-tag-elem-text")
|
||||
|
||||
let input = document.createElement("input");
|
||||
|
||||
input.setAttribute("type", "text");
|
||||
input.setAttribute("class", "form-control");
|
||||
input.setAttribute("name","modif_tag");
|
||||
input.setAttribute("placeholder", "modificiation");
|
||||
|
||||
let hidden = document.createElement("input");
|
||||
|
||||
hidden.setAttribute("type","hidden");
|
||||
hidden.setAttribute("name","id");
|
||||
hidden.setAttribute("value", data);
|
||||
|
||||
let button = document.createElement("button");
|
||||
|
||||
button.setAttribute("type", "submit");
|
||||
button.setAttribute("class", "btn btn-primary");
|
||||
button.innerText = "Submit Modification";
|
||||
|
||||
form.append(input)
|
||||
form.append(hidden)
|
||||
form.append(button)
|
||||
|
||||
modif.replaceWith(form);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
let suppr = document.getElementsByClassName("tag-suppr");
|
||||
|
||||
for (const element of suppr) {
|
||||
element.addEventListener('click', function ( e ) {
|
||||
let confirm = window.confirm("Voulez vous supprimez ?");
|
||||
|
||||
let data = e.target.getAttribute("data-id");
|
||||
|
||||
if (confirm) {
|
||||
window.location.href = "/tags/delete/" + data;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
70
src/Domain/Ingredients/IngredientManagementController.php
Normal file
70
src/Domain/Ingredients/IngredientManagementController.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Ingredients;
|
||||
|
||||
use App\Domain\Controller;
|
||||
use App\Domain\Ingredients\IngredientRepository;
|
||||
use App\Domain\Tags\TagRepository;
|
||||
use App\Helpers\Authentification;
|
||||
use App\Http\JSONResponse;
|
||||
use App\Http\Request;
|
||||
use App\Infrastructure\View;
|
||||
|
||||
class IngredientManagementController extends Controller {
|
||||
|
||||
public static function defineRoutes(): array
|
||||
{
|
||||
return [
|
||||
self::Route( routeUrl: '/manage/ingredients', routeName: 'manage->ingredients', routeAction: 'index' ),
|
||||
self::Route( routeUrl: '/ingredients/edit/{int}', routeName: 'ingredients->edit', routeAction: 'edit', routeMethods: [ 'POST' ] ),
|
||||
self::Route( routeUrl: '/ingredients/delete/{int}', routeName: 'ingredients->delete', routeAction: 'delete' ),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function index(){
|
||||
|
||||
if( !Authentification::isLoggedIn() )
|
||||
die( "Not logged in" );
|
||||
|
||||
$tags = new IngredientRepository()->getAll();
|
||||
return new View( 'ingredients/index', [
|
||||
'ingredients' => $tags,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function edit( int $idIngredient ): never {
|
||||
if( !Authentification::isLoggedIn() )
|
||||
die( "Not logged in" );
|
||||
|
||||
$ing = new IngredientRepository()->getByID( $idIngredient );
|
||||
if( !$ing )
|
||||
die( "Ingredient not found" );
|
||||
|
||||
$name = Request::post( 'modif_ingr' );
|
||||
if( !$name || $name == "" )
|
||||
JSONResponse::sendError( [ 'error' => 'Name not defined' ] );
|
||||
|
||||
$ing->nom_ingredient = $name;
|
||||
|
||||
if( !new IngredientRepository()->update( $ing ) )
|
||||
JSONResponse::sendError( [ 'error' => 'An error occured while updating ingredient' ] );
|
||||
|
||||
Request::redirectTo( 'manage->ingredients');
|
||||
}
|
||||
|
||||
public function delete( int $idIngredient ): never {
|
||||
if( !Authentification::isLoggedIn() )
|
||||
die( "Not logged in" );
|
||||
|
||||
$ing = new IngredientRepository()->getByID( $idIngredient );
|
||||
if( !$ing )
|
||||
die( "Tag not found" );
|
||||
|
||||
if( !new IngredientRepository()->delete( $ing ) )
|
||||
JSONResponse::sendError( [ 'error' => 'An error occured while deleting ingredient' ] );
|
||||
|
||||
Request::redirectTo( 'manage->ingredients' );
|
||||
}
|
||||
}
|
||||
69
src/Domain/Tags/TagManagementController.php
Normal file
69
src/Domain/Tags/TagManagementController.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Tags;
|
||||
|
||||
use App\Domain\Controller;
|
||||
use App\Domain\Ingredients\IngredientRepository;
|
||||
use App\Domain\Tags\TagRepository;
|
||||
use App\Helpers\Authentification;
|
||||
use App\Http\JSONResponse;
|
||||
use App\Http\Request;
|
||||
use App\Infrastructure\View;
|
||||
|
||||
class TagManagementController extends Controller {
|
||||
|
||||
public static function defineRoutes(): array
|
||||
{
|
||||
return [
|
||||
self::Route( routeUrl: '/manage/tags', routeName: 'manage->tags', routeAction: 'index' ),
|
||||
self::Route( routeUrl: '/tags/edit/{int}', routeName: 'tags->edit', routeAction: 'edit', routeMethods: [ 'POST' ] ),
|
||||
self::Route( routeUrl: '/tags/delete/{int}', routeName: 'tags->delete', routeAction: 'delete' ),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function index(){
|
||||
|
||||
if( !Authentification::isLoggedIn() )
|
||||
die( "Not logged in" );
|
||||
|
||||
$tags = new TagRepository()->getAll();
|
||||
return new View( 'tags/index', [
|
||||
'tags' => $tags,
|
||||
]);
|
||||
|
||||
}
|
||||
public function edit( int $idTag ): never {
|
||||
if( !Authentification::isLoggedIn() )
|
||||
die( "Not logged in" );
|
||||
|
||||
$tag = new TagRepository()->getByID( $idTag );
|
||||
if( !$tag )
|
||||
die( "Tag not found" );
|
||||
|
||||
$name = Request::post( 'modif_tag' );
|
||||
if( !$name || $name == "" )
|
||||
JSONResponse::sendError( [ 'error' => 'Name not defined' ] );
|
||||
|
||||
$tag->nom_tag = $name;
|
||||
|
||||
if( !new TagRepository()->update( $tag ) )
|
||||
JSONResponse::sendError( [ 'error' => 'An error occured while updating tag' ] );
|
||||
|
||||
Request::redirectTo( 'manage->tags');
|
||||
}
|
||||
|
||||
public function delete( int $idTag ): never {
|
||||
if( !Authentification::isLoggedIn() )
|
||||
die( "Not logged in" );
|
||||
|
||||
$tag = new \App\Domain\Tags\TagRepository()->getByID( $idTag );
|
||||
if( !$tag )
|
||||
die( "Tag not found" );
|
||||
|
||||
if( !new TagRepository()->delete( $tag ) )
|
||||
JSONResponse::sendError( [ 'error' => 'An error occured while deleting tag' ] );
|
||||
|
||||
Request::redirectTo( 'manage->tags' );
|
||||
}
|
||||
}
|
||||
18
views/ingredients/index.php
Normal file
18
views/ingredients/index.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php use App\Domain\Tags\Tag;
|
||||
use App\Infrastructure\View as V; ?>
|
||||
|
||||
<div class="content">
|
||||
<?php foreach (V::arg( 'ingredients') as $ing): ?>
|
||||
<div class="liste-ingr-elem">
|
||||
<img class="ingr-image" src="<?php echo $ing->photo_ingredient; ?>">
|
||||
<div class="liste-ingr-elem-text">
|
||||
<?php echo $ing->nom_ingredient; ?>
|
||||
</div>
|
||||
<div class="liste-ingr-elem-modif">
|
||||
<a class="recette-button ingr-modifier" data-id="<?php echo $ing->getId(); ?>">Modifier</a>
|
||||
<a class="recette-button ingr-suppr" data-id="<?php echo $ing->getId(); ?>">Supprimer</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<script src="<?php V::assetUrl( 'js/manage-ingredients.js' ); ?>" ></script>
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
<footer id="footer">
|
||||
<div class="src">
|
||||
<a href="google.com">Une source</a>
|
||||
<a href="https://code.romhackplaza.org/Benjamin/LesRecettesDePapis" target="_blank">Notre Gitea</a>
|
||||
</div>
|
||||
<div class="Contact">
|
||||
Front end : Bousquet Sébastien
|
||||
--- Back end : Thorel Benjamin
|
||||
--- Base de donné : Glaudis Jordan
|
||||
--- Base de données : Glaudis Jordan
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
<?php if( \App\Helpers\Authentification::isLoggedIn() ): ?>
|
||||
<li><a id="login" class= "nav-element" href="<?php V::routeUrl( 'logout'); ?>">Logout</a></li>
|
||||
<li><a id="addBouton" class="nav-element" href="<?php V::routeUrl( 'recettes->create'); ?>">Ajouter une Recette</a></li>
|
||||
<li><a id="ingrManage" class="nav-element" href="<?php V::routeUrl( 'manage->ingredients'); ?>">Gérer les ingrédients</a></li>
|
||||
<li><a id="tagManage" class="nav-element" href="<?php V::routeUrl( 'manage->tags'); ?>">Gérer les tags</a></li>
|
||||
|
||||
<?php else: ?>
|
||||
<li><a id="login" class= "nav-element" href="<?php V::routeUrl( 'login'); ?>">Login</a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -30,13 +30,15 @@ use App\Infrastructure\View as V; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "recette-desc">
|
||||
<h3>Ingrédients :</h3>
|
||||
<ul>
|
||||
<div class="recette-liste-ingr-div">
|
||||
<h3>Liste des ingrédients</h3>
|
||||
<ul class="recette-liste-ingr">
|
||||
<?php foreach( $R->getAllLinkedIngredients() as $ingr ): ?>
|
||||
<li><?php echo $ingr->nom_ingredient; ?></li>
|
||||
<li class="recette-liste-ingr-elem"><img class="ingr-image-prev" src="<?php echo $ingr->photo_ingredient; ?>"> <div class="recette-liste-ingr-elem-nom"><?php echo $ingr->nom_ingredient; ?></div></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class = "recette-desc">
|
||||
<div id="description">
|
||||
<?php echo $R->getHTMLDescription(); ?>
|
||||
</div>
|
||||
|
||||
17
views/tags/index.php
Normal file
17
views/tags/index.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php use App\Domain\Tags\Tag;
|
||||
use App\Infrastructure\View as V; ?>
|
||||
|
||||
<div class="content">
|
||||
<?php foreach( V::arg( 'tags' ) as $tag ): ?>
|
||||
<div class="liste-tag-elem">
|
||||
<div class="liste-tag-elem-text">
|
||||
<?php echo $tag->nom_tag; ?>
|
||||
</div>
|
||||
<div class="liste-tag-elem-modif">
|
||||
<a class="recette-button tag-modifier" data-id="<?php echo $tag->num_tag; ?>">Modifier</a>
|
||||
<a class="recette-button tag-suppr" data-id="<?php echo $tag->num_tag; ?>">Supprimer</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<script src="<?php V::assetUrl( 'js/manage-tags.js' ); ?>" ></script>
|
||||
Reference in New Issue
Block a user