wad-lab 1.2.2 → 1.2.4

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.
Files changed (207) hide show
  1. package/bin/index.js +477 -627
  2. package/package.json +1 -1
  3. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +241 -429
  4. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
  5. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
  6. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemTable.vue +177 -0
  7. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +150 -441
  8. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
  9. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemStats.vue +64 -0
  10. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemTable.vue +195 -0
  11. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +41 -90
  12. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemFormModal.vue +173 -0
  13. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemTable.vue +102 -0
  14. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/NavBar.vue +57 -0
  15. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +132 -296
  16. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +126 -219
  17. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
  18. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemTable.vue +104 -0
  19. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/SideBar.vue +59 -0
  20. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
  21. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
  22. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
  23. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
  24. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/App.vue +19 -70
  25. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
  26. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
  27. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
  28. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
  29. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
  30. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
  31. package/templates/game-bingo/script.js +1 -1
  32. package/templates/game-memory-cards/script.js +2 -2
  33. package/templates/game-rock-paper-scissors/index.html +3 -3
  34. package/templates/game-rock-paper-scissors/script.js +2 -2
  35. package/templates/game-tic-tac-toe/script.js +2 -2
  36. package/templates/game-whack-a-mole/index.html +9 -9
  37. package/templates/servlet-basic/WEB-INF/ItemServlet.java +13 -0
  38. package/templates/servlet-basic/WEB-INF/classes/ItemServlet.class +0 -0
  39. package/templates/servlet-flow/WEB-INF/HelloServlet.java +34 -25
  40. package/templates/servlet-flow/WEB-INF/classes/HelloServlet.class +0 -0
  41. package/templates/servlet-jdbc/WEB-INF/JdbcItemServlet.java +13 -0
  42. package/templates/servlet-jdbc/WEB-INF/classes/JdbcItemServlet.class +0 -0
  43. package/templates/snippets/mongo-queries-cheatsheet.txt +105 -0
  44. package/templates/springboot-2model-aggregation-join/.mvn/wrapper/maven-wrapper.properties +3 -0
  45. package/templates/springboot-2model-aggregation-join/mvnw +295 -0
  46. package/templates/springboot-2model-aggregation-join/mvnw.cmd +189 -0
  47. package/templates/springboot-2model-aggregation-join/pom.xml +54 -0
  48. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/AggregationApplication.java +11 -0
  49. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/DepartmentController.java +65 -0
  50. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/EmployeeController.java +65 -0
  51. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/DepartmentStatsDTO.java +15 -0
  52. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/EmployeeJoinDTO.java +19 -0
  53. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Department.java +20 -0
  54. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Employee.java +21 -0
  55. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/DepartmentRepository.java +9 -0
  56. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/EmployeeRepository.java +9 -0
  57. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/DepartmentService.java +81 -0
  58. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/EmployeeService.java +80 -0
  59. package/templates/springboot-2model-aggregation-join/src/main/resources/application.properties +2 -0
  60. package/templates/springboot-2model-aggregation-join/src/test/java/com/example/aggregation/AggregationApplicationTests.java +13 -0
  61. package/templates/vue-2model-crud-patch/README.md +64 -0
  62. package/templates/vue-2model-crud-patch/index.html +12 -0
  63. package/templates/vue-2model-crud-patch/package-lock.json +1785 -0
  64. package/templates/vue-2model-crud-patch/package.json +21 -0
  65. package/templates/vue-2model-crud-patch/src/App.vue +63 -0
  66. package/templates/vue-2model-crud-patch/src/components/AnalyticsBoard.vue +291 -0
  67. package/templates/vue-2model-crud-patch/src/components/DepartmentFormModal.vue +138 -0
  68. package/templates/vue-2model-crud-patch/src/components/DepartmentPatchModal.vue +210 -0
  69. package/templates/vue-2model-crud-patch/src/components/DepartmentTable.vue +133 -0
  70. package/templates/vue-2model-crud-patch/src/components/EmployeeFormModal.vue +177 -0
  71. package/templates/vue-2model-crud-patch/src/components/EmployeePatchModal.vue +221 -0
  72. package/templates/vue-2model-crud-patch/src/components/EmployeeTable.vue +171 -0
  73. package/templates/vue-2model-crud-patch/src/components/NavBar.vue +156 -0
  74. package/templates/vue-2model-crud-patch/src/main.js +12 -0
  75. package/templates/vue-2model-crud-patch/src/router/index.js +33 -0
  76. package/templates/vue-2model-crud-patch/src/services/api.js +64 -0
  77. package/templates/vue-2model-crud-patch/src/stores/departmentStore.js +149 -0
  78. package/templates/vue-2model-crud-patch/src/stores/employeeStore.js +143 -0
  79. package/templates/vue-2model-crud-patch/src/style.css +415 -0
  80. package/templates/vue-2model-crud-patch/src/views/AnalyticsView.vue +59 -0
  81. package/templates/vue-2model-crud-patch/src/views/DepartmentsView.vue +135 -0
  82. package/templates/vue-2model-crud-patch/src/views/EmployeesView.vue +143 -0
  83. package/templates/vue-2model-crud-patch/vite.config.js +9 -0
  84. package/templates/vue-axios/src/App.vue +255 -264
  85. package/templates/vue-axios/src/components/ItemFormModal.vue +183 -0
  86. package/templates/vue-axios/src/components/ItemPatchModal.vue +193 -0
  87. package/templates/vue-axios/src/components/ItemTable.vue +177 -0
  88. package/templates/vue-axios-basic/src/App.vue +241 -429
  89. package/templates/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
  90. package/templates/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
  91. package/templates/vue-axios-basic/src/components/ItemTable.vue +177 -0
  92. package/templates/vue-axios-pinia/src/App.vue +150 -441
  93. package/templates/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
  94. package/templates/vue-axios-pinia/src/components/ItemStats.vue +64 -0
  95. package/templates/vue-axios-pinia/src/components/ItemTable.vue +195 -0
  96. package/templates/vue-axios-router/src/App.vue +41 -90
  97. package/templates/vue-axios-router/src/components/ItemFormModal.vue +173 -0
  98. package/templates/vue-axios-router/src/components/ItemTable.vue +102 -0
  99. package/templates/vue-axios-router/src/components/NavBar.vue +57 -0
  100. package/templates/vue-axios-router/src/views/DepartmentView.vue +132 -296
  101. package/templates/vue-axios-router/src/views/EmployeeView.vue +126 -219
  102. package/templates/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
  103. package/templates/vue-axios-router-children/src/components/ItemTable.vue +104 -0
  104. package/templates/vue-axios-router-children/src/components/SideBar.vue +59 -0
  105. package/templates/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
  106. package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
  107. package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
  108. package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
  109. package/templates/vue-axios-router-pinia/src/App.vue +19 -70
  110. package/templates/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
  111. package/templates/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
  112. package/templates/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
  113. package/templates/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
  114. package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
  115. package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
  116. package/templates/vue-banking-app/src/components/AccountOverview.vue +75 -0
  117. package/templates/vue-banking-app/src/components/TransactionForm.vue +89 -0
  118. package/templates/vue-banking-app/src/components/TransactionTable.vue +113 -0
  119. package/templates/vue-banking-app/src/stores/bankStore.js +16 -3
  120. package/templates/vue-banking-app/src/views/DashboardView.vue +23 -71
  121. package/templates/vue-banking-app/src/views/StatementView.vue +11 -158
  122. package/templates/vue-banking-app/src/views/TransactionFormView.vue +23 -121
  123. package/templates/vue-basics/src/App.vue +105 -76
  124. package/templates/vue-basics/src/components/CounterCard.vue +107 -0
  125. package/templates/vue-basics/src/components/ItemList.vue +99 -0
  126. package/templates/vue-basics/src/components/UserForm.vue +138 -0
  127. package/templates/vue-cart-router-pinia/src/components/CartSummary.vue +139 -0
  128. package/templates/vue-cart-router-pinia/src/components/CheckoutModal.vue +149 -0
  129. package/templates/vue-cart-router-pinia/src/components/ProductCard.vue +63 -0
  130. package/templates/vue-cart-router-pinia/src/stores/cartStore.js +11 -0
  131. package/templates/vue-cart-router-pinia/src/views/CartView.vue +52 -118
  132. package/templates/vue-cart-router-pinia/src/views/CheckoutView.vue +2 -5
  133. package/templates/vue-cart-router-pinia/src/views/ProductCatalogView.vue +20 -56
  134. package/templates/vue-employee-system/src/App.vue +75 -344
  135. package/templates/vue-employee-system/src/components/DepartmentFilter.vue +108 -0
  136. package/templates/vue-employee-system/src/components/EmployeeModal.vue +183 -0
  137. package/templates/vue-employee-system/src/components/EmployeeTable.vue +91 -0
  138. package/templates/vue-employee-system/src/stores/employeeStore.js +12 -0
  139. package/templates/vue-fetch/src/App.vue +261 -285
  140. package/templates/vue-fetch/src/components/FetchFormModal.vue +183 -0
  141. package/templates/vue-fetch/src/components/FetchPatchModal.vue +193 -0
  142. package/templates/vue-fetch/src/components/FetchTable.vue +177 -0
  143. package/templates/vue-food-ordering/src/components/CartSummary.vue +134 -0
  144. package/templates/vue-food-ordering/src/components/FoodMenu.vue +126 -0
  145. package/templates/vue-food-ordering/src/components/OrderModal.vue +150 -0
  146. package/templates/vue-food-ordering/src/views/MenuView.vue +11 -132
  147. package/templates/vue-food-ordering/src/views/OrderCartView.vue +31 -164
  148. package/templates/vue-game-rps/src/App.vue +29 -88
  149. package/templates/vue-game-tictactoe/src/App.vue +23 -53
  150. package/templates/vue-game-whackamole/src/App.vue +44 -63
  151. package/templates/vue-hospital-portal/src/components/AppointmentForm.vue +144 -0
  152. package/templates/vue-hospital-portal/src/components/DoctorCard.vue +73 -0
  153. package/templates/vue-hospital-portal/src/components/PatientTable.vue +123 -0
  154. package/templates/vue-hospital-portal/src/stores/hospitalStore.js +10 -1
  155. package/templates/vue-hospital-portal/src/views/OPDRegistrationView.vue +40 -416
  156. package/templates/vue-hospital-portal/src/views/PatientListView.vue +11 -301
  157. package/templates/vue-library-system/src/components/BookForm.vue +125 -0
  158. package/templates/vue-library-system/src/components/BookTable.vue +112 -0
  159. package/templates/vue-library-system/src/components/BorrowModal.vue +131 -0
  160. package/templates/vue-library-system/src/stores/libraryStore.js +26 -1
  161. package/templates/vue-library-system/src/views/BookCatalogView.vue +34 -415
  162. package/templates/vue-memory-game/src/App.vue +36 -40
  163. package/templates/vue-memory-game/src/stores/memoryStore.js +32 -37
  164. package/templates/vue-router/src/App.vue +24 -14
  165. package/templates/vue-router/src/components/AboutCard.vue +38 -0
  166. package/templates/vue-router/src/components/HomeHero.vue +75 -0
  167. package/templates/vue-router/src/components/NavBar.vue +54 -0
  168. package/templates/vue-router/src/views/ItemsLayout.vue +17 -9
  169. package/templates/vue-router/src/views/ListView.vue +106 -18
  170. package/templates/vue-router-pinia/src/App.vue +24 -14
  171. package/templates/vue-router-pinia/src/components/ItemFormModal.vue +163 -0
  172. package/templates/vue-router-pinia/src/components/ItemTable.vue +90 -0
  173. package/templates/vue-router-pinia/src/components/NavBar.vue +54 -0
  174. package/templates/vue-router-pinia/src/stores/itemStore.js +8 -1
  175. package/templates/vue-router-pinia/src/views/ListView.vue +78 -14
  176. package/templates/vue-router-pinia-springboot/frontend/src/App.vue +25 -8
  177. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemFormModal.vue +183 -0
  178. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemPatchModal.vue +193 -0
  179. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemTable.vue +177 -0
  180. package/templates/vue-router-pinia-springboot/frontend/src/components/NavBar.vue +54 -0
  181. package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +92 -76
  182. package/templates/vue-springboot-mongo-aggregation/frontend/src/App.vue +184 -193
  183. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/AnalyticsCards.vue +56 -0
  184. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/CategorySummaryTable.vue +71 -0
  185. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/ItemTable.vue +114 -0
  186. package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +228 -158
  187. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemFormModal.vue +183 -0
  188. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemPatchModal.vue +193 -0
  189. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemTable.vue +177 -0
  190. package/templates/vue-symposium-system/src/App.vue +41 -256
  191. package/templates/vue-symposium-system/src/components/AttendeeTable.vue +100 -0
  192. package/templates/vue-symposium-system/src/components/EventCard.vue +67 -0
  193. package/templates/vue-symposium-system/src/components/RegistrationForm.vue +118 -0
  194. package/templates/vue-symposium-system/src/stores/symposiumStore.js +10 -0
  195. package/templates/vue-todo-pinia/src/App.vue +40 -138
  196. package/templates/vue-todo-pinia/src/components/TodoFilter.vue +74 -0
  197. package/templates/vue-todo-pinia/src/components/TodoInput.vue +53 -0
  198. package/templates/vue-todo-pinia/src/components/TodoList.vue +101 -0
  199. package/templates/vue-todo-pinia/src/stores/todoStore.js +6 -0
  200. package/templates/vue-todo-router/src/App.vue +5 -36
  201. package/templates/vue-todo-router/src/components/TodoForm.vue +78 -0
  202. package/templates/vue-todo-router/src/components/TodoList.vue +84 -0
  203. package/templates/vue-todo-router/src/components/TodoNavBar.vue +47 -0
  204. package/templates/vue-todo-router/src/data/todoState.js +7 -0
  205. package/templates/vue-todo-router/src/views/AddTodoView.vue +7 -66
  206. package/templates/vue-todo-router/src/views/TodoDetailView.vue +15 -1
  207. package/templates/vue-todo-router/src/views/TodoListView.vue +22 -64
@@ -1,158 +1,228 @@
1
- <script setup>
2
- import { ref, onMounted } from 'vue';
3
- import ItemService from './services/ItemService';
4
-
5
- const items = ref([]);
6
- const isEditing = ref(false);
7
- const form = ref({
8
- id: '',
9
- name: '',
10
- description: '',
11
- price: 0
12
- });
13
- const searchId = ref('');
14
- const selectedItem = ref(null);
15
-
16
- const loadItems = async () => {
17
- const res = await ItemService.getAll();
18
- items.value = res.data;
19
- };
20
-
21
- const saveItem = async () => {
22
- if (isEditing.value) {
23
- await ItemService.update(form.value.id, {
24
- id: form.value.id,
25
- name: form.value.name,
26
- description: form.value.description,
27
- price: form.value.price
28
- });
29
- } else {
30
- await ItemService.create({
31
- id: form.value.id,
32
- name: form.value.name,
33
- description: form.value.description,
34
- price: form.value.price
35
- });
36
- }
37
- resetForm();
38
- loadItems();
39
- };
40
-
41
- const editItem = (item) => {
42
- isEditing.value = true;
43
- form.value = { ...item };
44
- };
45
-
46
- const resetForm = () => {
47
- isEditing.value = false;
48
- form.value = { id: '', name: '', description: '', price: 0 };
49
- };
50
-
51
- const deleteItem = async (id) => {
52
- await ItemService.delete(id);
53
- if (selectedItem.value && selectedItem.value.id === id) {
54
- selectedItem.value = null;
55
- }
56
- loadItems();
57
- };
58
-
59
- const patchItem = async (item) => {
60
- const price = prompt('Enter new price:');
61
- if (price !== null && price !== '') {
62
- await ItemService.patch(item.id, { price: Number(price) });
63
- loadItems();
64
- }
65
- };
66
-
67
- const fetchSingleItem = async (id) => {
68
- const targetId = id || searchId.value;
69
- if (!targetId) return;
70
- const res = await ItemService.getById(targetId);
71
- selectedItem.value = res.data;
72
- };
73
-
74
- onMounted(loadItems);
75
- </script>
76
-
77
- <template>
78
- <h2>Item Management</h2>
79
-
80
- <h3>{{ isEditing ? 'Edit Item' : 'Add New Item' }}</h3>
81
- <form @submit.prevent="saveItem">
82
- <label>Custom ID (Optional):</label>
83
- <br>
84
- <input v-model="form.id" placeholder="ID (e.g. 101 or leave blank for auto)" :disabled="isEditing" />
85
- <br><br>
86
-
87
- <label>Name:</label>
88
- <br>
89
- <input v-model="form.name" placeholder="Name" required />
90
- <br><br>
91
-
92
- <label>Description:</label>
93
- <br>
94
- <input v-model="form.description" placeholder="Description" required />
95
- <br><br>
96
-
97
- <label>Price:</label>
98
- <br>
99
- <input v-model.number="form.price" type="number" step="0.01" placeholder="Price" required />
100
- <br><br>
101
-
102
- <button type="submit">{{ isEditing ? 'Update Item (PUT)' : 'Create Item (POST)' }}</button>
103
- <button type="button" v-if="isEditing" @click="resetForm">Cancel</button>
104
- </form>
105
-
106
- <hr>
107
-
108
- <h3>Fetch Single Item By ID (GET /api/items/:id)</h3>
109
- <input v-model="searchId" placeholder="Enter Item ID" />
110
- <button type="button" @click="fetchSingleItem(searchId)">Fetch Detail</button>
111
-
112
- <div v-if="selectedItem">
113
- <br>
114
- <b>Item Details:</b>
115
- <br>
116
- ID: {{ selectedItem.id }}
117
- <br>
118
- Name: {{ selectedItem.name }}
119
- <br>
120
- Description: {{ selectedItem.description }}
121
- <br>
122
- Price: {{ selectedItem.price }}
123
- <br>
124
- <button type="button" @click="selectedItem = null">Close Details</button>
125
- </div>
126
-
127
- <hr>
128
-
129
- <h3>Item List (GET /api/items)</h3>
130
- <button type="button" @click="loadItems">Refresh List</button>
131
- <br><br>
132
-
133
- <table>
134
- <thead>
135
- <tr>
136
- <th>ID</th>
137
- <th>Name</th>
138
- <th>Description</th>
139
- <th>Price</th>
140
- <th>Actions</th>
141
- </tr>
142
- </thead>
143
- <tbody>
144
- <tr v-for="item in items" :key="item.id">
145
- <td>{{ item.id }}</td>
146
- <td>{{ item.name }}</td>
147
- <td>{{ item.description }}</td>
148
- <td>{{ item.price }}</td>
149
- <td>
150
- <button type="button" @click="fetchSingleItem(item.id)">View</button>
151
- <button type="button" @click="editItem(item)">Edit</button>
152
- <button type="button" @click="deleteItem(item.id)">Delete</button>
153
- <button type="button" @click="patchItem(item)">Patch</button>
154
- </td>
155
- </tr>
156
- </tbody>
157
- </table>
158
- </template>
1
+ <script setup>
2
+ import { ref, onMounted } from 'vue'
3
+ import ItemService from './services/ItemService'
4
+ import ItemTable from './components/ItemTable.vue'
5
+ import ItemFormModal from './components/ItemFormModal.vue'
6
+ import ItemPatchModal from './components/ItemPatchModal.vue'
7
+
8
+ const items = ref([])
9
+ const loading = ref(false)
10
+ const errorMessage = ref('')
11
+ const selectedItem = ref(null)
12
+
13
+ const isFormModalOpen = ref(false)
14
+ const isEditMode = ref(false)
15
+ const activeItemData = ref(null)
16
+
17
+ const isPatchModalOpen = ref(false)
18
+ const activePatchItem = ref(null)
19
+
20
+ async function fetchAll() {
21
+ loading.value = true
22
+ errorMessage.value = ''
23
+ try {
24
+ const res = await ItemService.getAll()
25
+ items.value = res.data || []
26
+ } catch (err) {
27
+ errorMessage.value = err.message || 'Failed to load items'
28
+ } finally {
29
+ loading.value = false
30
+ }
31
+ }
32
+
33
+ function openCreateModal() {
34
+ isEditMode.value = false
35
+ activeItemData.value = { name: '', description: '', price: 0 }
36
+ isFormModalOpen.value = true
37
+ }
38
+
39
+ function openEditModal(item) {
40
+ isEditMode.value = true
41
+ activeItemData.value = { ...item }
42
+ isFormModalOpen.value = true
43
+ }
44
+
45
+ function openPatchModal(item) {
46
+ activePatchItem.value = item
47
+ isPatchModalOpen.value = true
48
+ }
49
+
50
+ async function handleFormSubmit(payload) {
51
+ loading.value = true
52
+ errorMessage.value = ''
53
+ try {
54
+ if (isEditMode.value) {
55
+ await ItemService.update(payload.id, payload)
56
+ } else {
57
+ await ItemService.create(payload)
58
+ }
59
+ isFormModalOpen.value = false
60
+ await fetchAll()
61
+ } catch (err) {
62
+ errorMessage.value = err.message || 'Failed to save item'
63
+ } finally {
64
+ loading.value = false
65
+ }
66
+ }
67
+
68
+ async function handlePatchSubmit({ id, partial }) {
69
+ loading.value = true
70
+ errorMessage.value = ''
71
+ try {
72
+ await ItemService.patch(id, partial)
73
+ isPatchModalOpen.value = false
74
+ await fetchAll()
75
+ } catch (err) {
76
+ errorMessage.value = err.message || 'Failed to patch item'
77
+ } finally {
78
+ loading.value = false
79
+ }
80
+ }
81
+
82
+ async function handleDelete(id) {
83
+ if (!confirm('Are you sure you want to delete this item?')) return
84
+ loading.value = true
85
+ errorMessage.value = ''
86
+ try {
87
+ await ItemService.delete(id)
88
+ if (selectedItem.value && selectedItem.value.id === id) {
89
+ selectedItem.value = null
90
+ }
91
+ await fetchAll()
92
+ } catch (err) {
93
+ errorMessage.value = err.message || 'Failed to delete item'
94
+ } finally {
95
+ loading.value = false
96
+ }
97
+ }
98
+
99
+ function handleViewDetails(item) {
100
+ selectedItem.value = item
101
+ }
102
+
103
+ onMounted(() => {
104
+ fetchAll()
105
+ })
106
+ </script>
107
+
108
+ <template>
109
+ <div class="app-container">
110
+ <header class="app-header">
111
+ <h1>Spring Boot + MongoDB CRUD</h1>
112
+ <p>Modular: ItemTable, ItemFormModal, ItemPatchModal</p>
113
+ </header>
114
+
115
+ <div v-if="errorMessage" class="error-banner">
116
+ {{ errorMessage }}
117
+ </div>
118
+
119
+ <div v-if="selectedItem" class="detail-card">
120
+ <div class="detail-header">
121
+ <h3>Selected Item</h3>
122
+ <button type="button" class="btn-close" @click="selectedItem = null">Close</button>
123
+ </div>
124
+ <div class="detail-body">
125
+ <p><strong>ID:</strong> {{ selectedItem.id }}</p>
126
+ <p><strong>Name:</strong> {{ selectedItem.name }}</p>
127
+ <p><strong>Description:</strong> {{ selectedItem.description || selectedItem.describtion || 'N/A' }}</p>
128
+ <p><strong>Price:</strong> ${{ Number(selectedItem.price).toFixed(2) }}</p>
129
+ </div>
130
+ </div>
131
+
132
+ <ItemTable
133
+ :items="items"
134
+ :loading="loading"
135
+ @open-create="openCreateModal"
136
+ @edit="openEditModal"
137
+ @patch="openPatchModal"
138
+ @delete="handleDelete"
139
+ @view-details="handleViewDetails"
140
+ @refresh="fetchAll"
141
+ />
142
+
143
+ <ItemFormModal
144
+ :show="isFormModalOpen"
145
+ :is-edit="isEditMode"
146
+ :item-data="activeItemData"
147
+ @close="isFormModalOpen = false"
148
+ @submit="handleFormSubmit"
149
+ />
150
+
151
+ <ItemPatchModal
152
+ :show="isPatchModalOpen"
153
+ :item="activePatchItem"
154
+ @close="isPatchModalOpen = false"
155
+ @submit="handlePatchSubmit"
156
+ />
157
+ </div>
158
+ </template>
159
+
160
+ <style>
161
+ * { box-sizing: border-box; }
162
+ body {
163
+ margin: 0;
164
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
165
+ background-color: #f8fafc;
166
+ color: #334155;
167
+ }
168
+ </style>
169
+
170
+ <style scoped>
171
+ .app-container {
172
+ max-width: 1000px;
173
+ margin: 0 auto;
174
+ padding: 32px 16px;
175
+ }
176
+
177
+ .app-header {
178
+ margin-bottom: 24px;
179
+ }
180
+
181
+ .app-header h1 {
182
+ font-size: 26px;
183
+ color: #0f172a;
184
+ }
185
+
186
+ .app-header p {
187
+ color: #64748b;
188
+ font-size: 14px;
189
+ }
190
+
191
+ .error-banner {
192
+ background-color: #ffebe9;
193
+ color: #cf222e;
194
+ border: 1px solid #ff818266;
195
+ padding: 12px 16px;
196
+ border-radius: 6px;
197
+ margin-bottom: 20px;
198
+ }
199
+
200
+ .detail-card {
201
+ background: #ffffff;
202
+ border: 1px solid #d0d7de;
203
+ border-radius: 8px;
204
+ padding: 16px;
205
+ margin-bottom: 20px;
206
+ }
207
+
208
+ .detail-header {
209
+ display: flex;
210
+ justify-content: space-between;
211
+ align-items: center;
212
+ border-bottom: 1px solid #eaecef;
213
+ padding-bottom: 8px;
214
+ margin-bottom: 12px;
215
+ }
216
+
217
+ .detail-header h3 {
218
+ font-size: 16px;
219
+ margin: 0;
220
+ }
221
+
222
+ .btn-close {
223
+ background: none;
224
+ border: none;
225
+ cursor: pointer;
226
+ color: #57606a;
227
+ }
228
+ </style>
@@ -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' : 'Create Item' }}</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>