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.
Files changed (207) hide show
  1. package/bin/index.js +472 -631
  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,315 +1,67 @@
1
- <template>
2
- <div class="employees-page">
3
- <header class="page-header">
4
- <h1>Employees</h1>
5
- <p>Manage company employees and view their profiles.</p>
6
- </header>
7
-
8
- <section class="card form-card">
9
- <h2>Add New Employee</h2>
10
- <form @submit.prevent="createEmployee" class="form">
11
- <div class="form-row">
12
- <div class="form-group">
13
- <label for="emp-name">Full Name</label>
14
- <input
15
- id="emp-name"
16
- v-model="form.name"
17
- type="text"
18
- required
19
- placeholder="e.g. Jane Doe"
20
- />
21
- </div>
22
- <div class="form-group">
23
- <label for="emp-email">Email</label>
24
- <input
25
- id="emp-email"
26
- v-model="form.email"
27
- type="email"
28
- required
29
- placeholder="e.g. jane@example.com"
30
- />
31
- </div>
32
- </div>
33
- <div class="form-row">
34
- <div class="form-group">
35
- <label for="emp-dept">Department</label>
36
- <select id="emp-dept" v-model="form.departmentId" required>
37
- <option value="" disabled>Select Department</option>
38
- <option v-for="dept in departments" :key="dept.id" :value="dept.id">
39
- {{ dept.name }} ({{ dept.code }})
40
- </option>
41
- </select>
42
- </div>
43
- <div class="form-group">
44
- <label for="emp-salary">Salary</label>
45
- <input
46
- id="emp-salary"
47
- v-model.number="form.salary"
48
- type="number"
49
- min="0"
50
- step="any"
51
- required
52
- placeholder="e.g. 75000"
53
- />
54
- </div>
55
- </div>
56
- <button type="submit" class="btn btn-primary">Add Employee</button>
57
- </form>
58
- </section>
59
-
60
- <section class="card table-card">
61
- <h2>All Employees</h2>
62
- <table class="data-table">
63
- <thead>
64
- <tr>
65
- <th>ID</th>
66
- <th>Name</th>
67
- <th>Email</th>
68
- <th>Department</th>
69
- <th>Salary</th>
70
- <th>Actions</th>
71
- </tr>
72
- </thead>
73
- <tbody>
74
- <tr v-if="employees.length === 0">
75
- <td colspan="6" class="empty">No employees found.</td>
76
- </tr>
77
- <tr v-for="emp in employees" :key="emp.id">
78
- <td>{{ emp.id }}</td>
79
- <td>{{ emp.name }}</td>
80
- <td>{{ emp.email }}</td>
81
- <td>{{ getDepartmentName(emp.departmentId) }}</td>
82
- <td>${{ Number(emp.salary).toLocaleString() }}</td>
83
- <td class="action-cell">
84
- <router-link :to="'/company/employees/' + emp.id" class="btn btn-info">View</router-link>
85
- <button @click="handlePatch(emp.id, emp.salary)" class="btn btn-warning">Patch</button>
86
- <button @click="deleteEmployee(emp.id)" class="btn btn-danger">Delete</button>
87
- </td>
88
- </tr>
89
- </tbody>
90
- </table>
91
- </section>
92
- </div>
93
- </template>
94
-
95
- <script setup>
96
- import { ref, reactive, onMounted } from 'vue'
97
- import api from '../services/api'
98
-
99
- const employees = ref([])
100
- const departments = ref([])
101
-
102
- const form = reactive({
103
- name: '',
104
- email: '',
105
- departmentId: '',
106
- salary: ''
107
- })
108
-
109
- const fetchDepartments = async () => {
110
- try {
111
- const res = await api.get('/departments')
112
- departments.value = Array.isArray(res.data) ? res.data : []
113
- } catch (err) {
114
- departments.value = []
115
- }
116
- }
117
-
118
- const fetchEmployees = async () => {
119
- try {
120
- const res = await api.get('/employees')
121
- employees.value = Array.isArray(res.data) ? res.data : []
122
- } catch (err) {
123
- employees.value = []
124
- }
125
- }
126
-
127
- const createEmployee = async () => {
128
- try {
129
- await api.post('/employees', {
130
- name: form.name,
131
- email: form.email,
132
- departmentId: Number(form.departmentId),
133
- salary: Number(form.salary)
134
- })
135
- form.name = ''
136
- form.email = ''
137
- form.departmentId = ''
138
- form.salary = ''
139
- await fetchEmployees()
140
- } catch (err) {
141
- alert('Failed to add employee')
142
- }
143
- }
144
-
145
- const deleteEmployee = async (id) => {
146
- try {
147
- await api.delete(`/employees/${id}`)
148
- await fetchEmployees()
149
- } catch (err) {
150
- alert('Failed to delete employee')
151
- }
152
- }
153
-
154
- const handlePatch = async (id, salary) => {
155
- const newSalary = prompt('New salary:', salary)
156
- if (newSalary !== null && newSalary !== '') {
157
- try {
158
- await api.patch(`/employees/${id}`, { salary: Number(newSalary) })
159
- await fetchEmployees()
160
- } catch (err) {
161
- alert('Failed to patch employee')
162
- }
163
- }
164
- }
165
-
166
- const getDepartmentName = (deptId) => {
167
- const dept = departments.value.find((d) => d.id === deptId)
168
- return dept ? dept.name : `Dept #${deptId}`
169
- }
170
-
171
- onMounted(() => {
172
- fetchDepartments()
173
- fetchEmployees()
174
- })
175
- </script>
176
-
177
- <style scoped>
178
- .employees-page {
179
- max-width: 960px;
180
- }
181
-
182
- .page-header {
183
- margin-bottom: 24px;
184
- }
185
-
186
- .page-header h1 {
187
- font-size: 1.75rem;
188
- margin-bottom: 6px;
189
- color: #1e293b;
190
- }
191
-
192
- .page-header p {
193
- color: #64748b;
194
- }
195
-
196
- .card {
197
- background: #ffffff;
198
- padding: 24px;
199
- border-radius: 8px;
200
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
201
- margin-bottom: 24px;
202
- }
203
-
204
- .card h2 {
205
- font-size: 1.2rem;
206
- margin-bottom: 16px;
207
- color: #334155;
208
- }
209
-
210
- .form-row {
211
- display: flex;
212
- gap: 16px;
213
- margin-bottom: 16px;
214
- }
215
-
216
- .form-group {
217
- flex: 1;
218
- display: flex;
219
- flex-direction: column;
220
- gap: 6px;
221
- }
222
-
223
- label {
224
- font-size: 0.875rem;
225
- font-weight: 500;
226
- color: #475569;
227
- }
228
-
229
- input,
230
- select {
231
- padding: 8px 12px;
232
- border: 1px solid #cbd5e1;
233
- border-radius: 6px;
234
- font-size: 0.95rem;
235
- }
236
-
237
- input:focus,
238
- select:focus {
239
- outline: none;
240
- border-color: #2563eb;
241
- }
242
-
243
- .btn {
244
- padding: 8px 16px;
245
- border: none;
246
- border-radius: 6px;
247
- cursor: pointer;
248
- font-weight: 500;
249
- text-decoration: none;
250
- display: inline-flex;
251
- align-items: center;
252
- justify-content: center;
253
- transition: opacity 0.2s;
254
- }
255
-
256
- .btn:hover {
257
- opacity: 0.9;
258
- }
259
-
260
- .btn-primary {
261
- background-color: #2563eb;
262
- color: #ffffff;
263
- }
264
-
265
- .btn-info {
266
- background-color: #0284c7;
267
- color: #ffffff;
268
- font-size: 0.875rem;
269
- padding: 6px 12px;
270
- }
271
-
272
- .btn-danger {
273
- background-color: #ef4444;
274
- color: #ffffff;
275
- font-size: 0.875rem;
276
- padding: 6px 12px;
277
- }
278
-
279
- .btn-warning {
280
- background-color: #f59e0b;
281
- color: #ffffff;
282
- font-size: 0.875rem;
283
- padding: 6px 12px;
284
- }
285
-
286
- .action-cell {
287
- display: flex;
288
- gap: 8px;
289
- }
290
-
291
- .data-table {
292
- width: 100%;
293
- border-collapse: collapse;
294
- }
295
-
296
- .data-table th,
297
- .data-table td {
298
- padding: 12px;
299
- text-align: left;
300
- border-bottom: 1px solid #e2e8f0;
301
- }
302
-
303
- .data-table th {
304
- background-color: #f8fafc;
305
- font-size: 0.875rem;
306
- color: #475569;
307
- font-weight: 600;
308
- }
309
-
310
- .empty {
311
- text-align: center;
312
- color: #94a3b8;
313
- padding: 24px;
314
- }
315
- </style>
1
+ <script setup>
2
+ import { ref, onMounted } from 'vue'
3
+ import api from '../services/api'
4
+ import ItemTable from '../components/ItemTable.vue'
5
+
6
+ const employees = ref([])
7
+ const departments = ref([])
8
+
9
+ const columns = [
10
+ { key: 'id', label: 'ID' },
11
+ { key: 'name', label: 'Name' },
12
+ { key: 'email', label: 'Email' },
13
+ {
14
+ key: 'salary',
15
+ label: 'Salary',
16
+ format: (val) => '$' + Number(val || 0).toLocaleString()
17
+ }
18
+ ]
19
+
20
+ async function fetchData() {
21
+ const [empRes, deptRes] = await Promise.all([
22
+ api.get('/employees'),
23
+ api.get('/departments').catch(() => ({ data: [] }))
24
+ ])
25
+ employees.value = empRes.data || []
26
+ departments.value = deptRes.data || []
27
+ }
28
+
29
+ async function handlePatch(emp) {
30
+ const salary = prompt('Enter new salary:', emp.salary)
31
+ if (!salary || Number(salary) === Number(emp.salary)) return
32
+ await api.patch('/employees/' + emp.id, { salary: Number(salary) })
33
+ await fetchData()
34
+ }
35
+
36
+ async function handleDelete(id) {
37
+ if (!confirm('Delete this employee?')) return
38
+ await api.delete('/employees/' + id)
39
+ await fetchData()
40
+ }
41
+
42
+ onMounted(() => {
43
+ fetchData()
44
+ })
45
+ </script>
46
+
47
+ <template>
48
+ <div class="emp-view">
49
+ <h2>Employees</h2>
50
+
51
+ <ItemTable
52
+ :columns="columns"
53
+ :items="employees"
54
+ detail-route-prefix="/company/employees"
55
+ @patch="handlePatch"
56
+ @delete="handleDelete"
57
+ />
58
+ </div>
59
+ </template>
60
+
61
+ <style scoped>
62
+ .emp-view {
63
+ display: flex;
64
+ flex-direction: column;
65
+ gap: 16px;
66
+ }
67
+ </style>
@@ -1,92 +1,41 @@
1
- <template>
2
- <div class="app-container">
3
- <header class="app-header">
4
- <div class="header-inner">
5
- <h1 class="logo">Company Admin</h1>
6
- <nav class="nav">
7
- <router-link to="/" class="nav-link">Dashboard</router-link>
8
- <router-link to="/departments" class="nav-link">Departments</router-link>
9
- <router-link to="/employees" class="nav-link">Employees</router-link>
10
- </nav>
11
- </div>
12
- </header>
1
+ <script setup>
2
+ import NavBar from './components/NavBar.vue'
3
+ </script>
13
4
 
5
+ <template>
6
+ <div class="app-layout">
7
+ <NavBar />
14
8
  <main class="main-content">
15
9
  <router-view />
16
10
  </main>
17
11
  </div>
18
12
  </template>
19
13
 
20
- <script setup>
21
- </script>
22
-
23
14
  <style>
24
15
  * {
25
16
  box-sizing: border-box;
26
- margin: 0;
27
- padding: 0;
28
17
  }
29
18
 
30
19
  body {
31
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
32
- background-color: #f4f5f7;
33
- color: #333333;
34
- line-height: 1.5;
20
+ margin: 0;
21
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
22
+ background-color: #f8fafc;
23
+ color: #334155;
35
24
  }
25
+ </style>
36
26
 
37
- .app-container {
27
+ <style scoped>
28
+ .app-layout {
38
29
  min-height: 100vh;
39
- }
40
-
41
- .app-header {
42
- background-color: #ffffff;
43
- border-bottom: 1px solid #e1e4e8;
44
- padding: 0 16px;
45
- }
46
-
47
- .header-inner {
48
- max-width: 1200px;
49
- margin: 0 auto;
50
- display: flex;
51
- justify-content: space-between;
52
- align-items: center;
53
- height: 60px;
54
- }
55
-
56
- .logo {
57
- font-size: 18px;
58
- font-weight: 700;
59
- color: #1a1a1a;
60
- }
61
-
62
- .nav {
63
30
  display: flex;
64
- gap: 16px;
65
- }
66
-
67
- .nav-link {
68
- text-decoration: none;
69
- color: #555555;
70
- font-weight: 600;
71
- font-size: 14px;
72
- padding: 6px 10px;
73
- border-radius: 4px;
74
- transition: all 0.2s ease;
75
- }
76
-
77
- .nav-link:hover {
78
- color: #0066cc;
79
- background-color: #f0f4f8;
80
- }
81
-
82
- .nav-link.router-link-exact-active {
83
- color: #0066cc;
84
- background-color: #e6f0fa;
31
+ flex-direction: column;
85
32
  }
86
33
 
87
34
  .main-content {
88
- max-width: 1200px;
89
- margin: 0 auto;
90
- padding: 24px 16px;
35
+ flex: 1;
36
+ max-width: 1000px;
37
+ width: 100%;
38
+ margin: 24px auto;
39
+ padding: 0 20px;
91
40
  }
92
41
  </style>
@@ -0,0 +1,173 @@
1
+ <script setup>
2
+ import { reactive, watch } from 'vue'
3
+
4
+ const props = defineProps({
5
+ show: {
6
+ type: Boolean,
7
+ default: false
8
+ },
9
+ title: {
10
+ type: String,
11
+ default: 'Form'
12
+ },
13
+ fields: {
14
+ type: Array,
15
+ default: () => []
16
+ },
17
+ initialData: {
18
+ type: Object,
19
+ default: () => ({})
20
+ }
21
+ })
22
+
23
+ const emit = defineEmits(['close', 'submit'])
24
+
25
+ const formData = reactive({})
26
+
27
+ watch(
28
+ () => [props.show, props.initialData],
29
+ () => {
30
+ if (props.show) {
31
+ props.fields.forEach(f => {
32
+ formData[f.key] = props.initialData[f.key] !== undefined ? props.initialData[f.key] : ''
33
+ })
34
+ }
35
+ },
36
+ { immediate: true }
37
+ )
38
+
39
+ function handleSubmit() {
40
+ emit('submit', { ...formData })
41
+ }
42
+ </script>
43
+
44
+ <template>
45
+ <div v-if="show" class="modal-overlay" @click.self="emit('close')">
46
+ <div class="modal-card">
47
+ <div class="modal-header">
48
+ <h3>{{ title }}</h3>
49
+ <button type="button" class="btn-close" @click="emit('close')">x</button>
50
+ </div>
51
+
52
+ <form @submit.prevent="handleSubmit" class="modal-form">
53
+ <div v-for="field in fields" :key="field.key" class="form-group">
54
+ <label :for="'f-' + field.key">{{ field.label }}</label>
55
+ <select
56
+ v-if="field.type === 'select'"
57
+ :id="'f-' + field.key"
58
+ v-model="formData[field.key]"
59
+ :required="field.required"
60
+ >
61
+ <option value="" disabled>{{ field.placeholder || 'Select...' }}</option>
62
+ <option v-for="opt in field.options" :key="opt.value" :value="opt.value">
63
+ {{ opt.label }}
64
+ </option>
65
+ </select>
66
+ <input
67
+ v-else
68
+ :id="'f-' + field.key"
69
+ v-model="formData[field.key]"
70
+ :type="field.type || 'text'"
71
+ :required="field.required"
72
+ :placeholder="field.placeholder || ''"
73
+ />
74
+ </div>
75
+
76
+ <div class="modal-actions">
77
+ <button type="button" class="btn btn-secondary" @click="emit('close')">Cancel</button>
78
+ <button type="submit" class="btn btn-primary">Submit</button>
79
+ </div>
80
+ </form>
81
+ </div>
82
+ </div>
83
+ </template>
84
+
85
+ <style scoped>
86
+ .modal-overlay {
87
+ position: fixed;
88
+ inset: 0;
89
+ background-color: rgba(0, 0, 0, 0.4);
90
+ display: flex;
91
+ align-items: center;
92
+ justify-content: center;
93
+ z-index: 1000;
94
+ padding: 16px;
95
+ }
96
+
97
+ .modal-card {
98
+ background: #ffffff;
99
+ border-radius: 8px;
100
+ width: 100%;
101
+ max-width: 440px;
102
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
103
+ overflow: hidden;
104
+ }
105
+
106
+ .modal-header {
107
+ padding: 16px 20px;
108
+ border-bottom: 1px solid #e1e4e8;
109
+ display: flex;
110
+ justify-content: space-between;
111
+ align-items: center;
112
+ }
113
+
114
+ .modal-header h3 {
115
+ font-size: 16px;
116
+ margin: 0;
117
+ color: #24292f;
118
+ }
119
+
120
+ .btn-close {
121
+ background: none;
122
+ border: none;
123
+ font-size: 16px;
124
+ cursor: pointer;
125
+ color: #57606a;
126
+ }
127
+
128
+ .modal-form {
129
+ padding: 20px;
130
+ display: flex;
131
+ flex-direction: column;
132
+ gap: 12px;
133
+ }
134
+
135
+ .form-group {
136
+ display: flex;
137
+ flex-direction: column;
138
+ gap: 4px;
139
+ }
140
+
141
+ .form-group label {
142
+ font-size: 13px;
143
+ font-weight: 600;
144
+ color: #444444;
145
+ }
146
+
147
+ .form-group input,
148
+ .form-group select {
149
+ padding: 8px 12px;
150
+ border: 1px solid #d0d7de;
151
+ border-radius: 6px;
152
+ font-size: 14px;
153
+ }
154
+
155
+ .modal-actions {
156
+ display: flex;
157
+ justify-content: flex-end;
158
+ gap: 10px;
159
+ margin-top: 10px;
160
+ }
161
+
162
+ .btn {
163
+ padding: 8px 16px;
164
+ border-radius: 6px;
165
+ font-size: 13px;
166
+ font-weight: 500;
167
+ cursor: pointer;
168
+ border: 1px solid transparent;
169
+ }
170
+
171
+ .btn-primary { background: #0969da; color: #fff; }
172
+ .btn-secondary { background: #f6f8fa; border-color: #d0d7de; color: #24292f; }
173
+ </style>