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
@@ -0,0 +1,210 @@
1
+ <template>
2
+ <div v-if="show" class="modal-overlay" @click.self="$emit('close')">
3
+ <div class="modal-container">
4
+ <div class="modal-header">
5
+ <h3 class="modal-title">Partial Update Department (PATCH)</h3>
6
+ <button type="button" class="modal-close-btn" @click="$emit('close')">&times;</button>
7
+ </div>
8
+
9
+ <form @submit.prevent="handlePatch">
10
+ <div class="modal-body">
11
+ <div class="alert alert-info">
12
+ Select the specific field(s) you wish to update via HTTP PATCH. Only checked fields will be included in the request payload.
13
+ </div>
14
+
15
+ <div class="form-group">
16
+ <label class="form-label">Department ID</label>
17
+ <input
18
+ type="text"
19
+ class="form-control"
20
+ :value="department ? department.id : ''"
21
+ disabled
22
+ />
23
+ </div>
24
+
25
+ <!-- Name Field -->
26
+ <div class="form-group">
27
+ <div class="form-check">
28
+ <input
29
+ type="checkbox"
30
+ id="patchDeptName"
31
+ class="form-check-input"
32
+ v-model="fieldsToPatch.name"
33
+ />
34
+ <label for="patchDeptName" class="form-label" style="margin-bottom: 0; cursor: pointer;">
35
+ Patch Department Name
36
+ </label>
37
+ </div>
38
+ <input
39
+ type="text"
40
+ class="form-control"
41
+ v-model="patchValues.name"
42
+ :disabled="!fieldsToPatch.name"
43
+ placeholder="New department name"
44
+ />
45
+ <small class="card-subtitle" v-if="department">
46
+ Current: {{ department.name }}
47
+ </small>
48
+ </div>
49
+
50
+ <!-- Location Field -->
51
+ <div class="form-group">
52
+ <div class="form-check">
53
+ <input
54
+ type="checkbox"
55
+ id="patchDeptLocation"
56
+ class="form-check-input"
57
+ v-model="fieldsToPatch.location"
58
+ />
59
+ <label for="patchDeptLocation" class="form-label" style="margin-bottom: 0; cursor: pointer;">
60
+ Patch Location
61
+ </label>
62
+ </div>
63
+ <input
64
+ type="text"
65
+ class="form-control"
66
+ v-model="patchValues.location"
67
+ :disabled="!fieldsToPatch.location"
68
+ placeholder="New location"
69
+ />
70
+ <small class="card-subtitle" v-if="department">
71
+ Current: {{ department.location }}
72
+ </small>
73
+ </div>
74
+
75
+ <!-- Budget Field -->
76
+ <div class="form-group">
77
+ <div class="form-check">
78
+ <input
79
+ type="checkbox"
80
+ id="patchDeptBudget"
81
+ class="form-check-input"
82
+ v-model="fieldsToPatch.budget"
83
+ />
84
+ <label for="patchDeptBudget" class="form-label" style="margin-bottom: 0; cursor: pointer;">
85
+ Patch Annual Budget
86
+ </label>
87
+ </div>
88
+ <input
89
+ type="number"
90
+ class="form-control"
91
+ v-model.number="patchValues.budget"
92
+ :disabled="!fieldsToPatch.budget"
93
+ placeholder="New annual budget"
94
+ min="0"
95
+ step="1000"
96
+ />
97
+ <small class="card-subtitle" v-if="department">
98
+ Current: ${{ Number(department.budget || 0).toLocaleString() }}
99
+ </small>
100
+ </div>
101
+
102
+ <!-- JSON Payload Preview -->
103
+ <div class="form-group">
104
+ <label class="form-label">HTTP PATCH Payload Preview</label>
105
+ <pre class="code-preview">{{ jsonPayload }}</pre>
106
+ </div>
107
+ </div>
108
+
109
+ <div class="modal-footer">
110
+ <button type="button" class="btn btn-secondary" @click="$emit('close')">
111
+ Cancel
112
+ </button>
113
+ <button
114
+ type="submit"
115
+ class="btn btn-patch"
116
+ :disabled="submitting || isPayloadEmpty"
117
+ >
118
+ {{ submitting ? 'Applying...' : 'Apply Patch (PATCH)' }}
119
+ </button>
120
+ </div>
121
+ </form>
122
+ </div>
123
+ </div>
124
+ </template>
125
+
126
+ <script>
127
+ export default {
128
+ name: 'DepartmentPatchModal',
129
+ props: {
130
+ show: {
131
+ type: Boolean,
132
+ default: false
133
+ },
134
+ department: {
135
+ type: Object,
136
+ default: null
137
+ }
138
+ },
139
+ emits: ['close', 'patch'],
140
+ data() {
141
+ return {
142
+ fieldsToPatch: {
143
+ name: false,
144
+ location: false,
145
+ budget: false
146
+ },
147
+ patchValues: {
148
+ name: '',
149
+ location: '',
150
+ budget: 0
151
+ },
152
+ submitting: false
153
+ }
154
+ },
155
+ computed: {
156
+ payload() {
157
+ const result = {}
158
+ if (this.fieldsToPatch.name) {
159
+ result.name = this.patchValues.name
160
+ }
161
+ if (this.fieldsToPatch.location) {
162
+ result.location = this.patchValues.location
163
+ }
164
+ if (this.fieldsToPatch.budget) {
165
+ result.budget = Number(this.patchValues.budget)
166
+ }
167
+ return result
168
+ },
169
+ jsonPayload() {
170
+ return JSON.stringify(this.payload, null, 2)
171
+ },
172
+ isPayloadEmpty() {
173
+ return Object.keys(this.payload).length === 0
174
+ }
175
+ },
176
+ watch: {
177
+ department: {
178
+ immediate: true,
179
+ handler(val) {
180
+ this.fieldsToPatch = {
181
+ name: false,
182
+ location: false,
183
+ budget: false
184
+ }
185
+ if (val) {
186
+ this.patchValues = {
187
+ name: val.name || '',
188
+ location: val.location || '',
189
+ budget: val.budget !== undefined ? Number(val.budget) : 0
190
+ }
191
+ }
192
+ }
193
+ }
194
+ },
195
+ methods: {
196
+ async handlePatch() {
197
+ if (this.isPayloadEmpty || !this.department) return
198
+ this.submitting = true
199
+ try {
200
+ await this.$emit('patch', {
201
+ id: this.department.id,
202
+ patchData: { ...this.payload }
203
+ })
204
+ } finally {
205
+ this.submitting = false
206
+ }
207
+ }
208
+ }
209
+ }
210
+ </script>
@@ -0,0 +1,133 @@
1
+ <template>
2
+ <div class="card">
3
+ <div class="card-header">
4
+ <div>
5
+ <h2 class="card-title">Departments</h2>
6
+ <p class="card-subtitle">Manage organizational departments and budgets</p>
7
+ </div>
8
+ <button type="button" class="btn btn-primary" @click="$emit('create')">
9
+ Add Department
10
+ </button>
11
+ </div>
12
+
13
+ <div class="search-bar">
14
+ <input
15
+ type="text"
16
+ class="form-control search-input"
17
+ placeholder="Search departments by name or location..."
18
+ v-model="searchTerm"
19
+ />
20
+ <span class="badge badge-secondary">
21
+ {{ filteredDepartments.length }} Department{{ filteredDepartments.length === 1 ? '' : 's' }}
22
+ </span>
23
+ </div>
24
+
25
+ <div v-if="loading" class="alert alert-info">
26
+ Loading departments...
27
+ </div>
28
+
29
+ <div v-else-if="filteredDepartments.length === 0" class="alert alert-info">
30
+ No departments found. Click "Add Department" to create one.
31
+ </div>
32
+
33
+ <div v-else class="table-responsive">
34
+ <table class="data-table">
35
+ <thead>
36
+ <tr>
37
+ <th>ID</th>
38
+ <th>Department Name</th>
39
+ <th>Location</th>
40
+ <th>Allocated Budget</th>
41
+ <th style="text-align: right;">Actions</th>
42
+ </tr>
43
+ </thead>
44
+ <tbody>
45
+ <tr v-for="dept in filteredDepartments" :key="dept.id">
46
+ <td>
47
+ <code>{{ dept.id }}</code>
48
+ </td>
49
+ <td>
50
+ <strong>{{ dept.name }}</strong>
51
+ </td>
52
+ <td>{{ dept.location || 'N/A' }}</td>
53
+ <td>
54
+ <span class="badge badge-success">
55
+ {{ formatCurrency(dept.budget) }}
56
+ </span>
57
+ </td>
58
+ <td style="text-align: right;">
59
+ <div class="btn-group" style="justify-content: flex-end;">
60
+ <button
61
+ type="button"
62
+ class="btn btn-secondary btn-sm"
63
+ title="Full Update (PUT)"
64
+ @click="$emit('edit', dept)"
65
+ >
66
+ Edit
67
+ </button>
68
+ <button
69
+ type="button"
70
+ class="btn btn-patch btn-sm"
71
+ title="Partial Update (PATCH)"
72
+ @click="$emit('patch', dept)"
73
+ >
74
+ Patch
75
+ </button>
76
+ <button
77
+ type="button"
78
+ class="btn btn-danger btn-sm"
79
+ title="Delete (DELETE)"
80
+ @click="$emit('delete', dept.id)"
81
+ >
82
+ Delete
83
+ </button>
84
+ </div>
85
+ </td>
86
+ </tr>
87
+ </tbody>
88
+ </table>
89
+ </div>
90
+ </div>
91
+ </template>
92
+
93
+ <script>
94
+ export default {
95
+ name: 'DepartmentTable',
96
+ props: {
97
+ departments: {
98
+ type: Array,
99
+ default: () => []
100
+ },
101
+ loading: {
102
+ type: Boolean,
103
+ default: false
104
+ }
105
+ },
106
+ emits: ['create', 'edit', 'patch', 'delete'],
107
+ data() {
108
+ return {
109
+ searchTerm: ''
110
+ }
111
+ },
112
+ computed: {
113
+ filteredDepartments() {
114
+ if (!this.searchTerm.trim()) {
115
+ return this.departments
116
+ }
117
+ const term = this.searchTerm.toLowerCase()
118
+ return this.departments.filter((dept) => {
119
+ const name = (dept.name || '').toLowerCase()
120
+ const location = (dept.location || '').toLowerCase()
121
+ return name.includes(term) || location.includes(term)
122
+ })
123
+ }
124
+ },
125
+ methods: {
126
+ formatCurrency(val) {
127
+ const num = Number(val)
128
+ if (isNaN(num)) return '$0'
129
+ return '$' + num.toLocaleString()
130
+ }
131
+ }
132
+ }
133
+ </script>
@@ -0,0 +1,177 @@
1
+ <template>
2
+ <div v-if="show" class="modal-overlay" @click.self="$emit('close')">
3
+ <div class="modal-container">
4
+ <div class="modal-header">
5
+ <h3 class="modal-title">
6
+ {{ isEdit ? 'Edit Employee (PUT)' : 'Create Employee (POST)' }}
7
+ </h3>
8
+ <button type="button" class="modal-close-btn" @click="$emit('close')">&times;</button>
9
+ </div>
10
+
11
+ <form @submit.prevent="handleSubmit">
12
+ <div class="modal-body">
13
+ <div v-if="isEdit" class="form-group">
14
+ <label class="form-label">Employee ID</label>
15
+ <input
16
+ type="text"
17
+ class="form-control"
18
+ :value="formData.id"
19
+ disabled
20
+ />
21
+ </div>
22
+
23
+ <div class="form-group">
24
+ <label class="form-label">Full Name</label>
25
+ <input
26
+ type="text"
27
+ class="form-control"
28
+ v-model="formData.name"
29
+ placeholder="e.g. John Doe"
30
+ required
31
+ />
32
+ </div>
33
+
34
+ <div class="form-group">
35
+ <label class="form-label">Email Address</label>
36
+ <input
37
+ type="email"
38
+ class="form-control"
39
+ v-model="formData.email"
40
+ placeholder="e.g. john.doe@example.com"
41
+ required
42
+ />
43
+ </div>
44
+
45
+ <div class="form-group">
46
+ <label class="form-label">Job Role</label>
47
+ <input
48
+ type="text"
49
+ class="form-control"
50
+ v-model="formData.role"
51
+ placeholder="e.g. Software Engineer, Manager, Designer"
52
+ required
53
+ />
54
+ </div>
55
+
56
+ <div class="form-group">
57
+ <label class="form-label">Annual Salary (USD)</label>
58
+ <input
59
+ type="number"
60
+ class="form-control"
61
+ v-model.number="formData.salary"
62
+ placeholder="e.g. 85000"
63
+ min="0"
64
+ step="1000"
65
+ required
66
+ />
67
+ </div>
68
+
69
+ <div class="form-group">
70
+ <label class="form-label">Department</label>
71
+ <select
72
+ class="form-control"
73
+ v-model="formData.departmentId"
74
+ required
75
+ >
76
+ <option value="" disabled>Select Department</option>
77
+ <option
78
+ v-for="dept in departments"
79
+ :key="dept.id"
80
+ :value="dept.id"
81
+ >
82
+ {{ dept.name }} ({{ dept.location || 'N/A' }})
83
+ </option>
84
+ </select>
85
+ </div>
86
+ </div>
87
+
88
+ <div class="modal-footer">
89
+ <button type="button" class="btn btn-secondary" @click="$emit('close')">
90
+ Cancel
91
+ </button>
92
+ <button type="submit" class="btn btn-primary" :disabled="submitting">
93
+ {{ submitting ? 'Saving...' : (isEdit ? 'Save Changes (PUT)' : 'Create Employee (POST)') }}
94
+ </button>
95
+ </div>
96
+ </form>
97
+ </div>
98
+ </div>
99
+ </template>
100
+
101
+ <script>
102
+ export default {
103
+ name: 'EmployeeFormModal',
104
+ props: {
105
+ show: {
106
+ type: Boolean,
107
+ default: false
108
+ },
109
+ employee: {
110
+ type: Object,
111
+ default: null
112
+ },
113
+ departments: {
114
+ type: Array,
115
+ default: () => []
116
+ }
117
+ },
118
+ emits: ['close', 'save'],
119
+ data() {
120
+ return {
121
+ formData: {
122
+ id: '',
123
+ name: '',
124
+ email: '',
125
+ role: '',
126
+ salary: 0,
127
+ departmentId: ''
128
+ },
129
+ submitting: false
130
+ }
131
+ },
132
+ computed: {
133
+ isEdit() {
134
+ return !!(this.employee && this.employee.id)
135
+ }
136
+ },
137
+ watch: {
138
+ employee: {
139
+ immediate: true,
140
+ handler(val) {
141
+ if (val && val.id) {
142
+ this.formData = {
143
+ id: val.id,
144
+ name: val.name || '',
145
+ email: val.email || '',
146
+ role: val.role || '',
147
+ salary: val.salary !== undefined ? Number(val.salary) : 0,
148
+ departmentId: val.departmentId || ''
149
+ }
150
+ } else {
151
+ this.formData = {
152
+ id: '',
153
+ name: '',
154
+ email: '',
155
+ role: 'Software Engineer',
156
+ salary: 75000,
157
+ departmentId: this.departments.length > 0 ? this.departments[0].id : ''
158
+ }
159
+ }
160
+ }
161
+ }
162
+ },
163
+ methods: {
164
+ async handleSubmit() {
165
+ this.submitting = true
166
+ try {
167
+ await this.$emit('save', {
168
+ data: { ...this.formData },
169
+ isEdit: this.isEdit
170
+ })
171
+ } finally {
172
+ this.submitting = false
173
+ }
174
+ }
175
+ }
176
+ }
177
+ </script>