|
| 1 | +<html lang="en"> |
| 2 | +<head> |
| 3 | + <meta charset="utf-8"> |
| 4 | + <meta http-equiv="x-ua-compatible" content="ie=edge"> |
| 5 | + <title>Vue.js CRUD application</title> |
| 6 | + <meta name="description" content=""> |
| 7 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 8 | + <link rel="stylesheet" media="all" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" /> |
| 9 | + |
| 10 | +<style> |
| 11 | +.logo { |
| 12 | + width: 75px; |
| 13 | + float: left; |
| 14 | + margin-right: 15px; |
| 15 | +} |
| 16 | +
|
| 17 | +.form-group { |
| 18 | + max-width: 500px; |
| 19 | +} |
| 20 | +
|
| 21 | +.actions { |
| 22 | + padding: 10px 0; |
| 23 | +} |
| 24 | +
|
| 25 | +.glyphicon-euro { |
| 26 | + font-size: 12px; |
| 27 | +} |
| 28 | +</style> |
| 29 | +</head> |
| 30 | +<body> |
| 31 | + |
| 32 | +<div class="container"> |
| 33 | + <header class="page-header"> |
| 34 | + <div class="branding"> |
| 35 | + <img src="https://vuejs.org/images/logo.png" alt="Logo" title="Home page" class="logo"/> |
| 36 | + <h1>Vue.js 2 CRUD application</h1> |
| 37 | + </div> |
| 38 | + </header> |
| 39 | + <main id="app"> |
| 40 | + <router-view></router-view> |
| 41 | + </main> |
| 42 | +</div> |
| 43 | + |
| 44 | +<template id="product-list"> |
| 45 | + <div> |
| 46 | + <div class="actions"> |
| 47 | + <router-link class="btn btn-default" v-bind:to="{path: '/add-product'}"> |
| 48 | + <span class="glyphicon glyphicon-plus"></span> |
| 49 | + Add product |
| 50 | + </router-link> |
| 51 | + </div> |
| 52 | + <div class="filters row"> |
| 53 | + <div class="form-group col-sm-3"> |
| 54 | + <label for="search-element">Product name</label> |
| 55 | + <input v-model="searchKey" class="form-control" id="search-element" requred/> |
| 56 | + </div> |
| 57 | + </div> |
| 58 | + <table class="table"> |
| 59 | + <thead> |
| 60 | + <tr> |
| 61 | + <th>Name</th> |
| 62 | + <th>Description</th> |
| 63 | + <th>Price</th> |
| 64 | + <th class="col-sm-2">Actions</th> |
| 65 | + </tr> |
| 66 | + </thead> |
| 67 | + <tbody> |
| 68 | + <tr v-for="product in filteredProducts"> |
| 69 | + <td> |
| 70 | + <router-link v-bind:to="{name: 'product', params: {product_id: product.id}}">{{ product.name }}</router-link> |
| 71 | + </td> |
| 72 | + <td>{{ product.description }}</td> |
| 73 | + <td> |
| 74 | + {{ product.price }} |
| 75 | + <span class="glyphicon glyphicon-euro" aria-hidden="true"></span> |
| 76 | + </td> |
| 77 | + <td> |
| 78 | + <router-link class="btn btn-warning btn-xs" v-bind:to="{name: 'product-edit', params: {product_id: product.id}}">Edit</router-link> |
| 79 | + <router-link class="btn btn-danger btn-xs" v-bind:to="{name: 'product-delete', params: {product_id: product.id}}">Delete</router-link> |
| 80 | + </td> |
| 81 | + </tr> |
| 82 | + </tbody> |
| 83 | + </table> |
| 84 | + </div> |
| 85 | +</template> |
| 86 | + |
| 87 | +<template id="add-product"> |
| 88 | + <div> |
| 89 | + <h2>Add new product</h2> |
| 90 | + <form v-on:submit="createProduct"> |
| 91 | + <div class="form-group"> |
| 92 | + <label for="add-name">Name</label> |
| 93 | + <input class="form-control" id="add-name" v-model="product.name" required/> |
| 94 | + </div> |
| 95 | + <div class="form-group"> |
| 96 | + <label for="add-description">Description</label> |
| 97 | + <textarea class="form-control" id="add-description" rows="10" v-model="product.description"></textarea> |
| 98 | + </div> |
| 99 | + <div class="form-group"> |
| 100 | + <label for="add-price">Price, <span class="glyphicon glyphicon-euro"></span></label> |
| 101 | + <input type="number" class="form-control" id="add-price" v-model="product.price"/> |
| 102 | + </div> |
| 103 | + <button type="submit" class="btn btn-primary">Create</button> |
| 104 | + <router-link class="btn btn-default" v-bind:to="'/'">Cancel</router-link> |
| 105 | + </form> |
| 106 | + </div> |
| 107 | +</template> |
| 108 | + |
| 109 | +<template id="product"> |
| 110 | + <div> |
| 111 | + <h2>{{ product.name }}</h2> |
| 112 | + <b>Description: </b> |
| 113 | + <div>{{ product.description }}</div> |
| 114 | + <b>Price:</b> |
| 115 | + <div>{{ product.price }}<span class="glyphicon glyphicon-euro"></span></div> |
| 116 | + <br/> |
| 117 | + <span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> |
| 118 | + <router-link v-bind:to="'/'">Back to product list</router-link> |
| 119 | + </div> |
| 120 | +</template> |
| 121 | + |
| 122 | +<template id="product-edit"> |
| 123 | + <div> |
| 124 | + <h2>Edit product</h2> |
| 125 | + <form v-on:submit="updateProduct"> |
| 126 | + <div class="form-group"> |
| 127 | + <label for="edit-name">Name</label> |
| 128 | + <input class="form-control" id="edit-name" v-model="product.name" required/> |
| 129 | + </div> |
| 130 | + <div class="form-group"> |
| 131 | + <label for="edit-description">Description</label> |
| 132 | + <textarea class="form-control" id="edit-description" rows="3" v-model="product.description"></textarea> |
| 133 | + </div> |
| 134 | + <div class="form-group"> |
| 135 | + <label for="edit-price">Price, <span class="glyphicon glyphicon-euro"></span></label> |
| 136 | + <input type="number" class="form-control" id="edit-price" v-model="product.price"/> |
| 137 | + </div> |
| 138 | + <button type="submit" class="btn btn-primary">Save</button> |
| 139 | + <router-link class="btn btn-default" v-bind:to="'/'">Cancel</router-link> |
| 140 | + </form> |
| 141 | + </div> |
| 142 | +</template> |
| 143 | + |
| 144 | +<template id="product-delete"> |
| 145 | + <div> |
| 146 | + <h2>Delete product {{ product.name }}</h2> |
| 147 | + <form v-on:submit="deleteProduct"> |
| 148 | + <p>The action cannot be undone.</p> |
| 149 | + <button type="submit" class="btn btn-danger">Delete</button> |
| 150 | + <router-link class="btn btn-default" v-bind:to="'/'">Cancel</router-link> |
| 151 | + </form> |
| 152 | + </div> |
| 153 | +</template> |
| 154 | + |
| 155 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.js"></script> |
| 156 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/vue-router/2.2.1/vue-router.js"></script> |
| 157 | + < script src= "https://cdn.jsdelivr.net/npm/[email protected]"></ script> |
| 158 | + <script src="{!BASE_URL!}/assets/js/vueapp.js"></script> |
| 159 | + |
| 160 | +</body> |
| 161 | +</html> |
0 commit comments