wad-lab 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/controller/CompanyController.java +88 -74
- package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/model/Employee.java +73 -73
- package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/service/CompanyService.java +90 -60
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +429 -405
- package/templates/fullstack-springboot-vue/frontend/vue-axios-interceptor/src/App.vue +177 -159
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +441 -427
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/stores/companyStore.js +126 -96
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/App.vue +84 -69
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/App.vue +191 -167
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentForm.vue +98 -98
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentList.vue +92 -91
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeForm.vue +128 -128
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeList.vue +95 -94
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +90 -90
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/AddEmployeeView.vue +247 -247
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +296 -273
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +219 -196
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/HomeDashboardView.vue +263 -263
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/App.vue +59 -59
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/components/DataCard.vue +72 -53
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/controller/CompanyController.java +88 -74
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/model/Employee.java +73 -73
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/service/CompanyService.java +90 -60
- package/templates/springboot-course-registration/src/main/java/com/example/coursereg/controller/CourseController.java +46 -42
- package/templates/springboot-course-registration/src/main/java/com/example/coursereg/service/CourseService.java +70 -60
- package/templates/springboot-hospital-api/src/main/java/com/example/hospital/controller/HospitalController.java +54 -50
- package/templates/springboot-hospital-api/src/main/java/com/example/hospital/service/HospitalService.java +65 -54
- package/templates/springboot-library-api/src/main/java/com/example/library/controller/LibraryController.java +57 -51
- package/templates/springboot-library-api/src/main/java/com/example/library/service/LibraryService.java +70 -60
- package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/controller/ItemController.java +45 -41
- package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/service/ItemService.java +48 -38
- package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
- package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/service/ItemService.java +48 -38
- package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/controller/ItemController.java +45 -41
- package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/service/ItemService.java +48 -38
- package/templates/springboot-mongo-crud/src/main/java/com/example/crud/controller/ItemController.java +45 -41
- package/templates/springboot-mongo-crud/src/main/java/com/example/crud/service/ItemService.java +48 -38
- package/templates/vue-axios/src/App.vue +264 -243
- package/templates/vue-axios/src/services/ItemService.js +27 -21
- package/templates/vue-axios-basic/src/App.vue +24 -0
- package/templates/vue-axios-interceptor/src/App.vue +177 -159
- package/templates/vue-axios-pinia/src/App.vue +14 -0
- package/templates/vue-axios-pinia/src/stores/companyStore.js +126 -96
- package/templates/vue-axios-pinia-props/src/App.vue +84 -69
- package/templates/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
- package/templates/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
- package/templates/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
- package/templates/vue-axios-props-emits/src/App.vue +24 -0
- package/templates/vue-axios-props-emits/src/components/DepartmentList.vue +2 -1
- package/templates/vue-axios-props-emits/src/components/EmployeeList.vue +2 -1
- package/templates/vue-axios-router/src/views/DepartmentView.vue +23 -0
- package/templates/vue-axios-router/src/views/EmployeeView.vue +23 -0
- package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
- package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
- package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
- package/templates/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
- package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
- package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
- package/templates/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
- package/templates/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
- package/templates/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
- package/templates/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
- package/templates/vue-axios-router-props/src/components/DataCard.vue +72 -53
- package/templates/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
- package/templates/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
- package/templates/vue-fetch/src/App.vue +285 -259
- package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
- package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
- package/templates/vue-router-pinia-springboot/frontend/src/services/ItemService.js +24 -21
- package/templates/vue-router-pinia-springboot/frontend/src/stores/itemStore.js +42 -37
- package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +76 -67
- package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
- package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/service/ItemService.java +45 -35
- package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
- package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
- package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +158 -149
- package/templates/vue-springboot-mongo-crud/frontend/src/services/ItemService.js +24 -21
|
@@ -1,116 +1,128 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { ref, computed, onMounted } from 'vue'
|
|
3
|
-
import api from '../services/api'
|
|
4
|
-
import EntryForm from '../components/EntryForm.vue'
|
|
5
|
-
import DataCard from '../components/DataCard.vue'
|
|
6
|
-
|
|
7
|
-
const employees = ref([])
|
|
8
|
-
const departments = ref([])
|
|
9
|
-
|
|
10
|
-
const empFields = computed(() => {
|
|
11
|
-
if (departments.value.length > 0) {
|
|
12
|
-
return [
|
|
13
|
-
{ key: 'name', label: 'Employee Name', placeholder: 'e.g. Jane Doe' },
|
|
14
|
-
{ key: 'email', label: 'Email Address', type: 'email', placeholder: 'e.g. jane@example.com' },
|
|
15
|
-
{
|
|
16
|
-
key: 'departmentId',
|
|
17
|
-
label: 'Department',
|
|
18
|
-
type: 'select',
|
|
19
|
-
placeholder: 'Select Department',
|
|
20
|
-
options: departments.value.map(d => ({ value: d.id, label: `${d.name} (${d.code})` }))
|
|
21
|
-
},
|
|
22
|
-
{ key: 'salary', label: 'Salary', type: 'number', placeholder: 'e.g. 75000' }
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
return [
|
|
26
|
-
{ key: 'name', label: 'Employee Name', placeholder: 'e.g. Jane Doe' },
|
|
27
|
-
{ key: 'email', label: 'Email Address', type: 'email', placeholder: 'e.g. jane@example.com' },
|
|
28
|
-
{ key: 'departmentId', label: 'Department ID', placeholder: 'e.g. 1' },
|
|
29
|
-
{ key: 'salary', label: 'Salary', type: 'number', placeholder: 'e.g. 75000' }
|
|
30
|
-
]
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const fetchEmployees = async () => {
|
|
34
|
-
try {
|
|
35
|
-
const res = await api.get('/employees')
|
|
36
|
-
employees.value = res.data
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.error(error)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const fetchDepartments = async () => {
|
|
43
|
-
try {
|
|
44
|
-
const res = await api.get('/departments')
|
|
45
|
-
departments.value = res.data
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.error(error)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const handleCreateEmployee = async (formData) => {
|
|
52
|
-
try {
|
|
53
|
-
const payload = {
|
|
54
|
-
...formData,
|
|
55
|
-
salary: Number(formData.salary)
|
|
56
|
-
}
|
|
57
|
-
const res = await api.post('/employees', payload)
|
|
58
|
-
employees.value.push(res.data)
|
|
59
|
-
} catch (error) {
|
|
60
|
-
console.error(error)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const handleRemoveEmployee = async (id) => {
|
|
65
|
-
try {
|
|
66
|
-
await api.delete(`/employees/${id}`)
|
|
67
|
-
employees.value = employees.value.filter(emp => emp.id !== id)
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error(error)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, computed, onMounted } from 'vue'
|
|
3
|
+
import api from '../services/api'
|
|
4
|
+
import EntryForm from '../components/EntryForm.vue'
|
|
5
|
+
import DataCard from '../components/DataCard.vue'
|
|
6
|
+
|
|
7
|
+
const employees = ref([])
|
|
8
|
+
const departments = ref([])
|
|
9
|
+
|
|
10
|
+
const empFields = computed(() => {
|
|
11
|
+
if (departments.value.length > 0) {
|
|
12
|
+
return [
|
|
13
|
+
{ key: 'name', label: 'Employee Name', placeholder: 'e.g. Jane Doe' },
|
|
14
|
+
{ key: 'email', label: 'Email Address', type: 'email', placeholder: 'e.g. jane@example.com' },
|
|
15
|
+
{
|
|
16
|
+
key: 'departmentId',
|
|
17
|
+
label: 'Department',
|
|
18
|
+
type: 'select',
|
|
19
|
+
placeholder: 'Select Department',
|
|
20
|
+
options: departments.value.map(d => ({ value: d.id, label: `${d.name} (${d.code})` }))
|
|
21
|
+
},
|
|
22
|
+
{ key: 'salary', label: 'Salary', type: 'number', placeholder: 'e.g. 75000' }
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
return [
|
|
26
|
+
{ key: 'name', label: 'Employee Name', placeholder: 'e.g. Jane Doe' },
|
|
27
|
+
{ key: 'email', label: 'Email Address', type: 'email', placeholder: 'e.g. jane@example.com' },
|
|
28
|
+
{ key: 'departmentId', label: 'Department ID', placeholder: 'e.g. 1' },
|
|
29
|
+
{ key: 'salary', label: 'Salary', type: 'number', placeholder: 'e.g. 75000' }
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const fetchEmployees = async () => {
|
|
34
|
+
try {
|
|
35
|
+
const res = await api.get('/employees')
|
|
36
|
+
employees.value = res.data
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error(error)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const fetchDepartments = async () => {
|
|
43
|
+
try {
|
|
44
|
+
const res = await api.get('/departments')
|
|
45
|
+
departments.value = res.data
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error(error)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const handleCreateEmployee = async (formData) => {
|
|
52
|
+
try {
|
|
53
|
+
const payload = {
|
|
54
|
+
...formData,
|
|
55
|
+
salary: Number(formData.salary)
|
|
56
|
+
}
|
|
57
|
+
const res = await api.post('/employees', payload)
|
|
58
|
+
employees.value.push(res.data)
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(error)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const handleRemoveEmployee = async (id) => {
|
|
65
|
+
try {
|
|
66
|
+
await api.delete(`/employees/${id}`)
|
|
67
|
+
employees.value = employees.value.filter(emp => emp.id !== id)
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(error)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const handlePatch = async (id, salary) => {
|
|
74
|
+
const newSalary = prompt('New salary:', salary)
|
|
75
|
+
if (!newSalary || Number(newSalary) === Number(salary)) return
|
|
76
|
+
try {
|
|
77
|
+
await api.patch(`/employees/${id}`, { salary: Number(newSalary) })
|
|
78
|
+
await fetchEmployees()
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(error)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const getSubtitle = (emp) => {
|
|
85
|
+
const dept = departments.value.find(d => d.id === emp.departmentId)
|
|
86
|
+
const deptLabel = dept ? `${dept.name} (${dept.code})` : emp.departmentId
|
|
87
|
+
return `${emp.email} | Dept: ${deptLabel} | $${Number(emp.salary).toLocaleString()}`
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onMounted(() => {
|
|
91
|
+
fetchDepartments()
|
|
92
|
+
fetchEmployees()
|
|
93
|
+
})
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<template>
|
|
97
|
+
<div class="page-container">
|
|
98
|
+
<h2>Employees</h2>
|
|
99
|
+
<EntryForm :fields="empFields" @submit-data="handleCreateEmployee" />
|
|
100
|
+
<div class="card-list">
|
|
101
|
+
<p v-if="employees.length === 0" class="empty-state">No employees available.</p>
|
|
102
|
+
<DataCard
|
|
103
|
+
v-for="emp in employees"
|
|
104
|
+
:key="emp.id"
|
|
105
|
+
:id="emp.id"
|
|
106
|
+
:title="emp.name"
|
|
107
|
+
:subtitle="getSubtitle(emp)"
|
|
108
|
+
@remove="handleRemoveEmployee"
|
|
109
|
+
@patch="handlePatch(emp.id, emp.salary)"
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</template>
|
|
114
|
+
|
|
115
|
+
<style scoped>
|
|
116
|
+
.page-container {
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: column;
|
|
119
|
+
}
|
|
120
|
+
.empty-state {
|
|
121
|
+
color: #a0aec0;
|
|
122
|
+
font-style: italic;
|
|
123
|
+
}
|
|
124
|
+
.card-list {
|
|
125
|
+
display: flex;
|
|
126
|
+
flex-direction: column;
|
|
127
|
+
}
|
|
128
|
+
</style>
|