mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
export default {
|
|
computed: {
|
|
employeesOptions() {
|
|
const selectedEmployees = [...this.mastertask.employees].map(employee => employee.id)
|
|
|
|
return this.enrichedEmployees.filter(
|
|
(employee) => !selectedEmployees.includes(employee.id)
|
|
) || []
|
|
},
|
|
|
|
projectsOptions() {
|
|
// Added to "paginate" projects, because v-autocomplete was unable to handle so many projects at once
|
|
|
|
const projects = this.projects.filter(project => project.code.includes(this.projectCodeSearch))
|
|
return projects?.length ? projects.slice(0, 10) : this.projects.slice(0, 10)
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
// onProjectSelected(id) {
|
|
// const project = this.projects.find(project => project.id == id)
|
|
// this.mastertask.project_code = project.code
|
|
// this.mastertask.project_id = project.id
|
|
// },
|
|
|
|
onEmployeeSelected(id) {
|
|
const employee = this.enrichedEmployees.find(employee => employee.id == id)
|
|
this.mastertask.employees.push(employee)
|
|
this.showAddEmployeeInput = false
|
|
},
|
|
|
|
onEmployeeDurationChanged() {
|
|
let totalDuration = 0
|
|
|
|
this.mastertask.employees = this.mastertask.employees.map(employee => {
|
|
if (typeof employee.duration == 'string') {
|
|
totalDuration += parseInt(employee.duration)
|
|
employee.duration = parseInt(employee.duration)
|
|
}
|
|
else if (typeof employee.duration == 'number') {
|
|
totalDuration += employee.duration
|
|
}
|
|
|
|
return employee
|
|
})
|
|
|
|
this.mastertask.duration = totalDuration
|
|
}
|
|
},
|
|
|
|
watch: {
|
|
'mastertask.team_id'(value) {
|
|
if (!value) return
|
|
|
|
this.mastertask.team = this.teams.find(team => team.id == value)
|
|
this.mastertask.employees = this.mastertask.team.employees
|
|
},
|
|
}
|
|
} |