wad-lab 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +472 -631
- package/package.json +1 -1
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +241 -429
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemTable.vue +177 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +150 -441
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemStats.vue +64 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemTable.vue +195 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +41 -90
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemFormModal.vue +173 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemTable.vue +102 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/NavBar.vue +57 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +132 -296
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +126 -219
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemTable.vue +104 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/SideBar.vue +59 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/App.vue +19 -70
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
- package/templates/game-bingo/script.js +1 -1
- package/templates/game-memory-cards/script.js +2 -2
- package/templates/game-rock-paper-scissors/index.html +3 -3
- package/templates/game-rock-paper-scissors/script.js +2 -2
- package/templates/game-tic-tac-toe/script.js +2 -2
- package/templates/game-whack-a-mole/index.html +9 -9
- package/templates/servlet-basic/WEB-INF/ItemServlet.java +13 -0
- package/templates/servlet-basic/WEB-INF/classes/ItemServlet.class +0 -0
- package/templates/servlet-flow/WEB-INF/HelloServlet.java +34 -25
- package/templates/servlet-flow/WEB-INF/classes/HelloServlet.class +0 -0
- package/templates/servlet-jdbc/WEB-INF/JdbcItemServlet.java +13 -0
- package/templates/servlet-jdbc/WEB-INF/classes/JdbcItemServlet.class +0 -0
- package/templates/snippets/mongo-queries-cheatsheet.txt +105 -0
- package/templates/springboot-2model-aggregation-join/.mvn/wrapper/maven-wrapper.properties +3 -0
- package/templates/springboot-2model-aggregation-join/mvnw +295 -0
- package/templates/springboot-2model-aggregation-join/mvnw.cmd +189 -0
- package/templates/springboot-2model-aggregation-join/pom.xml +54 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/AggregationApplication.java +11 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/DepartmentController.java +65 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/EmployeeController.java +65 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/DepartmentStatsDTO.java +15 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/EmployeeJoinDTO.java +19 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Department.java +20 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Employee.java +21 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/DepartmentRepository.java +9 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/EmployeeRepository.java +9 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/DepartmentService.java +81 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/EmployeeService.java +80 -0
- package/templates/springboot-2model-aggregation-join/src/main/resources/application.properties +2 -0
- package/templates/springboot-2model-aggregation-join/src/test/java/com/example/aggregation/AggregationApplicationTests.java +13 -0
- package/templates/vue-2model-crud-patch/README.md +64 -0
- package/templates/vue-2model-crud-patch/index.html +12 -0
- package/templates/vue-2model-crud-patch/package-lock.json +1785 -0
- package/templates/vue-2model-crud-patch/package.json +21 -0
- package/templates/vue-2model-crud-patch/src/App.vue +63 -0
- package/templates/vue-2model-crud-patch/src/components/AnalyticsBoard.vue +291 -0
- package/templates/vue-2model-crud-patch/src/components/DepartmentFormModal.vue +138 -0
- package/templates/vue-2model-crud-patch/src/components/DepartmentPatchModal.vue +210 -0
- package/templates/vue-2model-crud-patch/src/components/DepartmentTable.vue +133 -0
- package/templates/vue-2model-crud-patch/src/components/EmployeeFormModal.vue +177 -0
- package/templates/vue-2model-crud-patch/src/components/EmployeePatchModal.vue +221 -0
- package/templates/vue-2model-crud-patch/src/components/EmployeeTable.vue +171 -0
- package/templates/vue-2model-crud-patch/src/components/NavBar.vue +156 -0
- package/templates/vue-2model-crud-patch/src/main.js +12 -0
- package/templates/vue-2model-crud-patch/src/router/index.js +33 -0
- package/templates/vue-2model-crud-patch/src/services/api.js +64 -0
- package/templates/vue-2model-crud-patch/src/stores/departmentStore.js +149 -0
- package/templates/vue-2model-crud-patch/src/stores/employeeStore.js +143 -0
- package/templates/vue-2model-crud-patch/src/style.css +415 -0
- package/templates/vue-2model-crud-patch/src/views/AnalyticsView.vue +59 -0
- package/templates/vue-2model-crud-patch/src/views/DepartmentsView.vue +135 -0
- package/templates/vue-2model-crud-patch/src/views/EmployeesView.vue +143 -0
- package/templates/vue-2model-crud-patch/vite.config.js +9 -0
- package/templates/vue-axios/src/App.vue +255 -264
- package/templates/vue-axios/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-axios/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-axios/src/components/ItemTable.vue +177 -0
- package/templates/vue-axios-basic/src/App.vue +241 -429
- package/templates/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-axios-basic/src/components/ItemTable.vue +177 -0
- package/templates/vue-axios-pinia/src/App.vue +150 -441
- package/templates/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
- package/templates/vue-axios-pinia/src/components/ItemStats.vue +64 -0
- package/templates/vue-axios-pinia/src/components/ItemTable.vue +195 -0
- package/templates/vue-axios-router/src/App.vue +41 -90
- package/templates/vue-axios-router/src/components/ItemFormModal.vue +173 -0
- package/templates/vue-axios-router/src/components/ItemTable.vue +102 -0
- package/templates/vue-axios-router/src/components/NavBar.vue +57 -0
- package/templates/vue-axios-router/src/views/DepartmentView.vue +132 -296
- package/templates/vue-axios-router/src/views/EmployeeView.vue +126 -219
- package/templates/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
- package/templates/vue-axios-router-children/src/components/ItemTable.vue +104 -0
- package/templates/vue-axios-router-children/src/components/SideBar.vue +59 -0
- package/templates/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
- package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
- package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
- package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
- package/templates/vue-axios-router-pinia/src/App.vue +19 -70
- package/templates/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
- package/templates/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
- package/templates/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
- package/templates/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
- package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
- package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
- package/templates/vue-banking-app/src/components/AccountOverview.vue +75 -0
- package/templates/vue-banking-app/src/components/TransactionForm.vue +89 -0
- package/templates/vue-banking-app/src/components/TransactionTable.vue +113 -0
- package/templates/vue-banking-app/src/stores/bankStore.js +16 -3
- package/templates/vue-banking-app/src/views/DashboardView.vue +23 -71
- package/templates/vue-banking-app/src/views/StatementView.vue +11 -158
- package/templates/vue-banking-app/src/views/TransactionFormView.vue +23 -121
- package/templates/vue-basics/src/App.vue +105 -76
- package/templates/vue-basics/src/components/CounterCard.vue +107 -0
- package/templates/vue-basics/src/components/ItemList.vue +99 -0
- package/templates/vue-basics/src/components/UserForm.vue +138 -0
- package/templates/vue-cart-router-pinia/src/components/CartSummary.vue +139 -0
- package/templates/vue-cart-router-pinia/src/components/CheckoutModal.vue +149 -0
- package/templates/vue-cart-router-pinia/src/components/ProductCard.vue +63 -0
- package/templates/vue-cart-router-pinia/src/stores/cartStore.js +11 -0
- package/templates/vue-cart-router-pinia/src/views/CartView.vue +52 -118
- package/templates/vue-cart-router-pinia/src/views/CheckoutView.vue +2 -5
- package/templates/vue-cart-router-pinia/src/views/ProductCatalogView.vue +20 -56
- package/templates/vue-employee-system/src/App.vue +75 -344
- package/templates/vue-employee-system/src/components/DepartmentFilter.vue +108 -0
- package/templates/vue-employee-system/src/components/EmployeeModal.vue +183 -0
- package/templates/vue-employee-system/src/components/EmployeeTable.vue +91 -0
- package/templates/vue-employee-system/src/stores/employeeStore.js +12 -0
- package/templates/vue-fetch/src/App.vue +261 -285
- package/templates/vue-fetch/src/components/FetchFormModal.vue +183 -0
- package/templates/vue-fetch/src/components/FetchPatchModal.vue +193 -0
- package/templates/vue-fetch/src/components/FetchTable.vue +177 -0
- package/templates/vue-food-ordering/src/components/CartSummary.vue +134 -0
- package/templates/vue-food-ordering/src/components/FoodMenu.vue +126 -0
- package/templates/vue-food-ordering/src/components/OrderModal.vue +150 -0
- package/templates/vue-food-ordering/src/views/MenuView.vue +11 -132
- package/templates/vue-food-ordering/src/views/OrderCartView.vue +31 -164
- package/templates/vue-game-rps/src/App.vue +29 -88
- package/templates/vue-game-tictactoe/src/App.vue +23 -53
- package/templates/vue-game-whackamole/src/App.vue +44 -63
- package/templates/vue-hospital-portal/src/components/AppointmentForm.vue +144 -0
- package/templates/vue-hospital-portal/src/components/DoctorCard.vue +73 -0
- package/templates/vue-hospital-portal/src/components/PatientTable.vue +123 -0
- package/templates/vue-hospital-portal/src/stores/hospitalStore.js +10 -1
- package/templates/vue-hospital-portal/src/views/OPDRegistrationView.vue +40 -416
- package/templates/vue-hospital-portal/src/views/PatientListView.vue +11 -301
- package/templates/vue-library-system/src/components/BookForm.vue +125 -0
- package/templates/vue-library-system/src/components/BookTable.vue +112 -0
- package/templates/vue-library-system/src/components/BorrowModal.vue +131 -0
- package/templates/vue-library-system/src/stores/libraryStore.js +26 -1
- package/templates/vue-library-system/src/views/BookCatalogView.vue +34 -415
- package/templates/vue-memory-game/src/App.vue +36 -40
- package/templates/vue-memory-game/src/stores/memoryStore.js +32 -37
- package/templates/vue-router/src/App.vue +24 -14
- package/templates/vue-router/src/components/AboutCard.vue +38 -0
- package/templates/vue-router/src/components/HomeHero.vue +75 -0
- package/templates/vue-router/src/components/NavBar.vue +54 -0
- package/templates/vue-router/src/views/ItemsLayout.vue +17 -9
- package/templates/vue-router/src/views/ListView.vue +106 -18
- package/templates/vue-router-pinia/src/App.vue +24 -14
- package/templates/vue-router-pinia/src/components/ItemFormModal.vue +163 -0
- package/templates/vue-router-pinia/src/components/ItemTable.vue +90 -0
- package/templates/vue-router-pinia/src/components/NavBar.vue +54 -0
- package/templates/vue-router-pinia/src/stores/itemStore.js +8 -1
- package/templates/vue-router-pinia/src/views/ListView.vue +78 -14
- package/templates/vue-router-pinia-springboot/frontend/src/App.vue +25 -8
- package/templates/vue-router-pinia-springboot/frontend/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-router-pinia-springboot/frontend/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-router-pinia-springboot/frontend/src/components/ItemTable.vue +177 -0
- package/templates/vue-router-pinia-springboot/frontend/src/components/NavBar.vue +54 -0
- package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +92 -76
- package/templates/vue-springboot-mongo-aggregation/frontend/src/App.vue +184 -193
- package/templates/vue-springboot-mongo-aggregation/frontend/src/components/AnalyticsCards.vue +56 -0
- package/templates/vue-springboot-mongo-aggregation/frontend/src/components/CategorySummaryTable.vue +71 -0
- package/templates/vue-springboot-mongo-aggregation/frontend/src/components/ItemTable.vue +114 -0
- package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +228 -158
- package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemTable.vue +177 -0
- package/templates/vue-symposium-system/src/App.vue +41 -256
- package/templates/vue-symposium-system/src/components/AttendeeTable.vue +100 -0
- package/templates/vue-symposium-system/src/components/EventCard.vue +67 -0
- package/templates/vue-symposium-system/src/components/RegistrationForm.vue +118 -0
- package/templates/vue-symposium-system/src/stores/symposiumStore.js +10 -0
- package/templates/vue-todo-pinia/src/App.vue +40 -138
- package/templates/vue-todo-pinia/src/components/TodoFilter.vue +74 -0
- package/templates/vue-todo-pinia/src/components/TodoInput.vue +53 -0
- package/templates/vue-todo-pinia/src/components/TodoList.vue +101 -0
- package/templates/vue-todo-pinia/src/stores/todoStore.js +6 -0
- package/templates/vue-todo-router/src/App.vue +5 -36
- package/templates/vue-todo-router/src/components/TodoForm.vue +78 -0
- package/templates/vue-todo-router/src/components/TodoList.vue +84 -0
- package/templates/vue-todo-router/src/components/TodoNavBar.vue +47 -0
- package/templates/vue-todo-router/src/data/todoState.js +7 -0
- package/templates/vue-todo-router/src/views/AddTodoView.vue +7 -66
- package/templates/vue-todo-router/src/views/TodoDetailView.vue +15 -1
- package/templates/vue-todo-router/src/views/TodoListView.vue +22 -64
package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemFormModal.vue
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { reactive, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
show: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
},
|
|
9
|
+
isEdit: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false
|
|
12
|
+
},
|
|
13
|
+
itemData: {
|
|
14
|
+
type: Object,
|
|
15
|
+
default: () => ({ name: '', description: '', price: 0 })
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const emit = defineEmits(['close', 'submit'])
|
|
20
|
+
|
|
21
|
+
const form = reactive({
|
|
22
|
+
id: '',
|
|
23
|
+
name: '',
|
|
24
|
+
description: '',
|
|
25
|
+
price: 0
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
watch(
|
|
29
|
+
() => props.itemData,
|
|
30
|
+
(val) => {
|
|
31
|
+
if (val) {
|
|
32
|
+
form.id = val.id || ''
|
|
33
|
+
form.name = val.name || ''
|
|
34
|
+
form.description = val.description || val.describtion || ''
|
|
35
|
+
form.price = Number(val.price) || 0
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{ immediate: true }
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
function handleSubmit() {
|
|
42
|
+
if (!form.name.trim()) return
|
|
43
|
+
emit('submit', {
|
|
44
|
+
id: form.id,
|
|
45
|
+
name: form.name.trim(),
|
|
46
|
+
description: form.description.trim(),
|
|
47
|
+
describtion: form.description.trim(),
|
|
48
|
+
price: Number(form.price)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<div v-if="show" class="modal-overlay" @click.self="emit('close')">
|
|
55
|
+
<div class="modal-card">
|
|
56
|
+
<div class="modal-header">
|
|
57
|
+
<h3>{{ isEdit ? 'Update Item (PUT /api/items/:id)' : 'Create Item (POST /api/items)' }}</h3>
|
|
58
|
+
<button type="button" class="btn-close" @click="emit('close')">x</button>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<form @submit.prevent="handleSubmit" class="modal-form">
|
|
62
|
+
<div v-if="isEdit" class="form-group">
|
|
63
|
+
<label for="form-id">Item ID</label>
|
|
64
|
+
<input id="form-id" :value="form.id" disabled class="input-disabled" />
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div class="form-group">
|
|
68
|
+
<label for="form-name">Name</label>
|
|
69
|
+
<input id="form-name" v-model="form.name" required placeholder="Item Name" />
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div class="form-group">
|
|
73
|
+
<label for="form-desc">Description</label>
|
|
74
|
+
<input id="form-desc" v-model="form.description" required placeholder="Item Description" />
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div class="form-group">
|
|
78
|
+
<label for="form-price">Price ($)</label>
|
|
79
|
+
<input id="form-price" v-model.number="form.price" type="number" step="any" min="0" required placeholder="0.00" />
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div class="modal-actions">
|
|
83
|
+
<button type="button" class="btn btn-secondary" @click="emit('close')">Cancel</button>
|
|
84
|
+
<button type="submit" class="btn btn-primary">{{ isEdit ? 'Save Changes' : 'Create Item' }}</button>
|
|
85
|
+
</div>
|
|
86
|
+
</form>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
90
|
+
|
|
91
|
+
<style scoped>
|
|
92
|
+
.modal-overlay {
|
|
93
|
+
position: fixed;
|
|
94
|
+
inset: 0;
|
|
95
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
z-index: 1000;
|
|
100
|
+
padding: 16px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.modal-card {
|
|
104
|
+
background: #ffffff;
|
|
105
|
+
border-radius: 8px;
|
|
106
|
+
width: 100%;
|
|
107
|
+
max-width: 480px;
|
|
108
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
|
|
109
|
+
overflow: hidden;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.modal-header {
|
|
113
|
+
padding: 16px 20px;
|
|
114
|
+
border-bottom: 1px solid #e1e4e8;
|
|
115
|
+
display: flex;
|
|
116
|
+
justify-content: space-between;
|
|
117
|
+
align-items: center;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.modal-header h3 {
|
|
121
|
+
font-size: 16px;
|
|
122
|
+
margin: 0;
|
|
123
|
+
color: #24292f;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.btn-close {
|
|
127
|
+
background: none;
|
|
128
|
+
border: none;
|
|
129
|
+
font-size: 16px;
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
color: #57606a;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.modal-form {
|
|
135
|
+
padding: 20px;
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-direction: column;
|
|
138
|
+
gap: 14px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.form-group {
|
|
142
|
+
display: flex;
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
gap: 6px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.form-group label {
|
|
148
|
+
font-size: 13px;
|
|
149
|
+
font-weight: 600;
|
|
150
|
+
color: #444444;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.form-group input {
|
|
154
|
+
padding: 8px 12px;
|
|
155
|
+
border: 1px solid #d0d7de;
|
|
156
|
+
border-radius: 6px;
|
|
157
|
+
font-size: 14px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.input-disabled {
|
|
161
|
+
background-color: #f6f8fa;
|
|
162
|
+
color: #6e7781;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.modal-actions {
|
|
166
|
+
display: flex;
|
|
167
|
+
justify-content: flex-end;
|
|
168
|
+
gap: 10px;
|
|
169
|
+
margin-top: 10px;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.btn {
|
|
173
|
+
padding: 8px 16px;
|
|
174
|
+
border-radius: 6px;
|
|
175
|
+
font-size: 13px;
|
|
176
|
+
font-weight: 500;
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
border: 1px solid transparent;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.btn-primary { background: #0969da; color: #fff; }
|
|
182
|
+
.btn-secondary { background: #f6f8fa; border-color: #d0d7de; color: #24292f; }
|
|
183
|
+
</style>
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { reactive, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
show: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
},
|
|
9
|
+
item: {
|
|
10
|
+
type: Object,
|
|
11
|
+
default: null
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits(['close', 'submit'])
|
|
16
|
+
|
|
17
|
+
const patchData = reactive({
|
|
18
|
+
patchField: 'price',
|
|
19
|
+
price: 0,
|
|
20
|
+
name: '',
|
|
21
|
+
description: ''
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
watch(
|
|
25
|
+
() => props.item,
|
|
26
|
+
(val) => {
|
|
27
|
+
if (val) {
|
|
28
|
+
patchData.price = Number(val.price) || 0
|
|
29
|
+
patchData.name = val.name || ''
|
|
30
|
+
patchData.description = val.description || val.describtion || ''
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{ immediate: true }
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
function handleSubmit() {
|
|
37
|
+
if (!props.item) return
|
|
38
|
+
const partial = {}
|
|
39
|
+
if (patchData.patchField === 'price') {
|
|
40
|
+
partial.price = Number(patchData.price)
|
|
41
|
+
} else if (patchData.patchField === 'name') {
|
|
42
|
+
partial.name = patchData.name.trim()
|
|
43
|
+
} else if (patchData.patchField === 'description') {
|
|
44
|
+
partial.description = patchData.description.trim()
|
|
45
|
+
partial.describtion = patchData.description.trim()
|
|
46
|
+
}
|
|
47
|
+
emit('submit', { id: props.item.id, partial })
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<template>
|
|
52
|
+
<div v-if="show && item" class="modal-overlay" @click.self="emit('close')">
|
|
53
|
+
<div class="modal-card">
|
|
54
|
+
<div class="modal-header">
|
|
55
|
+
<h3>Patch Item (PATCH /api/items/:id)</h3>
|
|
56
|
+
<button type="button" class="btn-close" @click="emit('close')">x</button>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<form @submit.prevent="handleSubmit" class="modal-form">
|
|
60
|
+
<div class="info-banner">
|
|
61
|
+
Target Item: <strong>{{ item.name }}</strong> (ID: {{ item.id }})
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div class="form-group">
|
|
65
|
+
<label for="patch-field">Select Field to Patch</label>
|
|
66
|
+
<select id="patch-field" v-model="patchData.patchField">
|
|
67
|
+
<option value="price">Price</option>
|
|
68
|
+
<option value="name">Name</option>
|
|
69
|
+
<option value="description">Description</option>
|
|
70
|
+
</select>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div v-if="patchData.patchField === 'price'" class="form-group">
|
|
74
|
+
<label for="patch-price">New Price ($)</label>
|
|
75
|
+
<input id="patch-price" v-model.number="patchData.price" type="number" step="any" min="0" required />
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div v-if="patchData.patchField === 'name'" class="form-group">
|
|
79
|
+
<label for="patch-name">New Name</label>
|
|
80
|
+
<input id="patch-name" v-model="patchData.name" required />
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<div v-if="patchData.patchField === 'description'" class="form-group">
|
|
84
|
+
<label for="patch-desc">New Description</label>
|
|
85
|
+
<input id="patch-desc" v-model="patchData.description" required />
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div class="modal-actions">
|
|
89
|
+
<button type="button" class="btn btn-secondary" @click="emit('close')">Cancel</button>
|
|
90
|
+
<button type="submit" class="btn btn-primary">Apply Patch</button>
|
|
91
|
+
</div>
|
|
92
|
+
</form>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</template>
|
|
96
|
+
|
|
97
|
+
<style scoped>
|
|
98
|
+
.modal-overlay {
|
|
99
|
+
position: fixed;
|
|
100
|
+
inset: 0;
|
|
101
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
justify-content: center;
|
|
105
|
+
z-index: 1000;
|
|
106
|
+
padding: 16px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.modal-card {
|
|
110
|
+
background: #ffffff;
|
|
111
|
+
border-radius: 8px;
|
|
112
|
+
width: 100%;
|
|
113
|
+
max-width: 440px;
|
|
114
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.modal-header {
|
|
119
|
+
padding: 16px 20px;
|
|
120
|
+
border-bottom: 1px solid #e1e4e8;
|
|
121
|
+
display: flex;
|
|
122
|
+
justify-content: space-between;
|
|
123
|
+
align-items: center;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.modal-header h3 {
|
|
127
|
+
font-size: 15px;
|
|
128
|
+
margin: 0;
|
|
129
|
+
color: #24292f;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.btn-close {
|
|
133
|
+
background: none;
|
|
134
|
+
border: none;
|
|
135
|
+
font-size: 16px;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
color: #57606a;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.modal-form {
|
|
141
|
+
padding: 20px;
|
|
142
|
+
display: flex;
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
gap: 14px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.info-banner {
|
|
148
|
+
background-color: #f6f8fa;
|
|
149
|
+
padding: 10px 12px;
|
|
150
|
+
border-radius: 6px;
|
|
151
|
+
font-size: 13px;
|
|
152
|
+
border: 1px solid #d0d7de;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.form-group {
|
|
156
|
+
display: flex;
|
|
157
|
+
flex-direction: column;
|
|
158
|
+
gap: 6px;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.form-group label {
|
|
162
|
+
font-size: 13px;
|
|
163
|
+
font-weight: 600;
|
|
164
|
+
color: #444444;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.form-group input,
|
|
168
|
+
.form-group select {
|
|
169
|
+
padding: 8px 12px;
|
|
170
|
+
border: 1px solid #d0d7de;
|
|
171
|
+
border-radius: 6px;
|
|
172
|
+
font-size: 14px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.modal-actions {
|
|
176
|
+
display: flex;
|
|
177
|
+
justify-content: flex-end;
|
|
178
|
+
gap: 10px;
|
|
179
|
+
margin-top: 10px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.btn {
|
|
183
|
+
padding: 8px 16px;
|
|
184
|
+
border-radius: 6px;
|
|
185
|
+
font-size: 13px;
|
|
186
|
+
font-weight: 500;
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
border: 1px solid transparent;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.btn-primary { background: #8250df; color: #fff; }
|
|
192
|
+
.btn-secondary { background: #f6f8fa; border-color: #d0d7de; color: #24292f; }
|
|
193
|
+
</style>
|
package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemTable.vue
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, computed } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
items: {
|
|
6
|
+
type: Array,
|
|
7
|
+
required: true,
|
|
8
|
+
default: () => []
|
|
9
|
+
},
|
|
10
|
+
loading: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
default: false
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const emit = defineEmits(['open-create', 'edit', 'patch', 'delete', 'view-details', 'refresh'])
|
|
17
|
+
|
|
18
|
+
const searchId = ref('')
|
|
19
|
+
|
|
20
|
+
const filteredItems = computed(() => {
|
|
21
|
+
if (!searchId.value.trim()) return props.items
|
|
22
|
+
return props.items.filter(item =>
|
|
23
|
+
String(item.id).toLowerCase().includes(searchId.value.trim().toLowerCase()) ||
|
|
24
|
+
(item.name && item.name.toLowerCase().includes(searchId.value.trim().toLowerCase()))
|
|
25
|
+
)
|
|
26
|
+
})
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<div class="table-container">
|
|
31
|
+
<div class="table-header">
|
|
32
|
+
<div class="search-bar">
|
|
33
|
+
<input
|
|
34
|
+
v-model="searchId"
|
|
35
|
+
type="text"
|
|
36
|
+
placeholder="Filter by ID or Name..."
|
|
37
|
+
class="input-search"
|
|
38
|
+
/>
|
|
39
|
+
<button type="button" class="btn btn-secondary" @click="emit('refresh')">Refresh</button>
|
|
40
|
+
</div>
|
|
41
|
+
<button type="button" class="btn btn-primary" @click="emit('open-create')">Add New Item</button>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div v-if="loading" class="status-box">Loading items...</div>
|
|
45
|
+
|
|
46
|
+
<div class="table-wrapper">
|
|
47
|
+
<table class="data-table">
|
|
48
|
+
<thead>
|
|
49
|
+
<tr>
|
|
50
|
+
<th>ID</th>
|
|
51
|
+
<th>Name</th>
|
|
52
|
+
<th>Description</th>
|
|
53
|
+
<th>Price</th>
|
|
54
|
+
<th>Actions</th>
|
|
55
|
+
</tr>
|
|
56
|
+
</thead>
|
|
57
|
+
<tbody>
|
|
58
|
+
<tr v-if="filteredItems.length === 0">
|
|
59
|
+
<td colspan="5" class="empty-cell">No items available.</td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr v-for="item in filteredItems" :key="item.id">
|
|
62
|
+
<td>{{ item.id }}</td>
|
|
63
|
+
<td class="font-bold">{{ item.name }}</td>
|
|
64
|
+
<td>{{ item.description || item.describtion || 'N/A' }}</td>
|
|
65
|
+
<td>${{ Number(item.price).toFixed(2) }}</td>
|
|
66
|
+
<td class="actions-cell">
|
|
67
|
+
<button type="button" class="btn btn-sm btn-info" @click="emit('view-details', item)">View</button>
|
|
68
|
+
<button type="button" class="btn btn-sm btn-warning" @click="emit('edit', item)">Edit</button>
|
|
69
|
+
<button type="button" class="btn btn-sm btn-patch" @click="emit('patch', item)">Patch</button>
|
|
70
|
+
<button type="button" class="btn btn-sm btn-danger" @click="emit('delete', item.id)">Delete</button>
|
|
71
|
+
</td>
|
|
72
|
+
</tr>
|
|
73
|
+
</tbody>
|
|
74
|
+
</table>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<style scoped>
|
|
80
|
+
.table-container {
|
|
81
|
+
background: #ffffff;
|
|
82
|
+
border: 1px solid #e1e4e8;
|
|
83
|
+
border-radius: 8px;
|
|
84
|
+
padding: 20px;
|
|
85
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.table-header {
|
|
89
|
+
display: flex;
|
|
90
|
+
justify-content: space-between;
|
|
91
|
+
align-items: center;
|
|
92
|
+
flex-wrap: wrap;
|
|
93
|
+
gap: 12px;
|
|
94
|
+
margin-bottom: 16px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.search-bar {
|
|
98
|
+
display: flex;
|
|
99
|
+
gap: 8px;
|
|
100
|
+
align-items: center;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.input-search {
|
|
104
|
+
padding: 8px 12px;
|
|
105
|
+
border: 1px solid #d0d7de;
|
|
106
|
+
border-radius: 6px;
|
|
107
|
+
font-size: 14px;
|
|
108
|
+
min-width: 220px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.table-wrapper {
|
|
112
|
+
overflow-x: auto;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.data-table {
|
|
116
|
+
width: 100%;
|
|
117
|
+
border-collapse: collapse;
|
|
118
|
+
font-size: 14px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.data-table th,
|
|
122
|
+
.data-table td {
|
|
123
|
+
padding: 10px 14px;
|
|
124
|
+
border-bottom: 1px solid #e1e4e8;
|
|
125
|
+
text-align: left;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.data-table th {
|
|
129
|
+
background-color: #f6f8fa;
|
|
130
|
+
font-weight: 600;
|
|
131
|
+
color: #57606a;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.font-bold {
|
|
135
|
+
font-weight: 600;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.actions-cell {
|
|
139
|
+
display: flex;
|
|
140
|
+
gap: 6px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.empty-cell {
|
|
144
|
+
text-align: center;
|
|
145
|
+
color: #8c959f;
|
|
146
|
+
padding: 24px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.status-box {
|
|
150
|
+
padding: 10px 14px;
|
|
151
|
+
background-color: #ddf4ff;
|
|
152
|
+
color: #0969da;
|
|
153
|
+
border-radius: 6px;
|
|
154
|
+
margin-bottom: 12px;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.btn {
|
|
158
|
+
padding: 8px 14px;
|
|
159
|
+
font-size: 13px;
|
|
160
|
+
font-weight: 500;
|
|
161
|
+
border-radius: 6px;
|
|
162
|
+
border: 1px solid transparent;
|
|
163
|
+
cursor: pointer;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.btn-sm {
|
|
167
|
+
padding: 4px 8px;
|
|
168
|
+
font-size: 12px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.btn-primary { background: #0969da; color: #fff; }
|
|
172
|
+
.btn-secondary { background: #f6f8fa; border-color: #d0d7de; color: #24292f; }
|
|
173
|
+
.btn-info { background: #2da44e; color: #fff; }
|
|
174
|
+
.btn-warning { background: #bf8700; color: #fff; }
|
|
175
|
+
.btn-patch { background: #8250df; color: #fff; }
|
|
176
|
+
.btn-danger { background: #cf222e; color: #fff; }
|
|
177
|
+
</style>
|