Skeleton MVC Crud Node Js + Express Js + MongoDB - 5ta Parte
/* begin /views/product/create.twig */
<!DOCTYPE html>
<html>
<head>
<title>Create Product</title>
</head>
<body>
<div class="container">
<h3><a href="/products">Product List</a></h3>
<h1>Create New Product</h1>
<form action="/products/save" method="post">
<table>
<tbody>
<tr>
<td>Name</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td>Price</td>
<td><input type="text" name="price" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Save" /></td>
</tr>
</tbody>
</table>
</form>
</div>
</body>
</html>
/* end /views/product/create.twig */
/* begin /views/product/edit.twig */
<!DOCTYPE html>
<html>
<head>
<title>Edit Product</title>
</head>
<body>
<div class="container">
<h3><a href="/products">Product List</a></h3>
<h1>Edit Product</h1>
<form action="/products/update/{{ product._id }}" method="post">
<table>
<tbody>
<tr>
<td>Name</td>
<td><input type="text" name="name" value="{{ product.name }}" /></td>
</tr>
<tr>
<td>Price</td>
<td><input type="text" name="price" value="{{ product.price }}" /></td>
</tr>
<tr>
<td colspan="2"><button type="submit">Update</button></td>
</tr>
</tbody>
</table>
</form>
</div>
</body>
</html>
/* end /views/product/edit.twig */
/* begin /views/product/index.twig */
<!DOCTYPE html>
<html>
<head>
<title>Product List</title>
</head>
<body>
<div class="container">
<h3><a href="/products/create">Create Product</a></h3>
<h1>Product List</h1>
{% if products is not empty %}
<table>
<thead>
<tr>
<th>Employee Name</th>
<th>Position</th>
</tr>
</thead>
<tbody>
{% for product in products %}
<tr>
<td><a href="/products/show/{{ product._id }}">{{ product.name }}</a></td>
<td>{{ product.price }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div>No products found.</div>
{% endif %}
</div>
</body>
</html>
/* end /views/product/index.twig */
/* begin /views/product/show.twig */
<!DOCTYPE html>
<html>
<head>
<title>Product Detail</title>
</head>
<body>
<div class="container">
<h3><a href="/products">Product List</a></h3>
<h1>Product Detail</h1>
<table>
<tbody>
<tr>
<td>Name</td>
<td>{{ product.name }}</td>
</tr>
<tr>
<td>Address</td>
<td>{{ product.price }}</td>
</tr>
</tbody>
</table>
<h3><a href="/products/edit/{{ product._id }}">EDIT</a></h3>
<form action="/products/delete/{{ product._id }}" method="post">
<button type="submit">DELETE</button>
</form>
</div>
</body>
</html>
/* end /views/product/show.twig */
Comentarios
Publicar un comentario