user kann versendete dienstübertragungsanfragen löschen

This commit is contained in:
Tim Gröger 2020-06-03 12:29:37 +02:00
parent 2401b949ce
commit 4d6db01bd3
5 changed files with 227 additions and 84 deletions

View File

@ -1,55 +1,60 @@
<template> <template>
<div> <div>
<v-row align="center" justify="center" v-if="jobInvitesLoading"> <v-card tile :loading="jobInvitesLoading">
<v-progress-circular indeterminate color="grey" /> <v-card-title>
</v-row> Eingehende Einladungen
<v-expansion-panels> </v-card-title>
<v-expansion-panel <v-card-text>
v-for="jobInvite in jobInvitesToMe" <v-expansion-panels>
:key="jobInvite.id" <v-expansion-panel
@click.once="seenJobIvnite(jobInvite)" v-for="jobInvite in jobInvitesToMe"
> :key="jobInvite.id"
<v-expansion-panel-header> @click.once="seenJobIvnite(jobInvite)"
<div>
{{ jobInvite.on_date.getDate() }}.{{
jobInvite.on_date.getMonth() + 1
}}.{{ jobInvite.on_date.getFullYear() }} von
{{ jobInvite.from_user.firstname }}
{{ jobInvite.from_user.lastname }}
</div>
<v-row
class="text-right"
style="margin-right: 5px"
v-show="userInWorker(jobInvite)"
> >
<v-col> <v-expansion-panel-header>
<v-icon color="green"> <div>
{{ check }} {{ jobInvite.on_date.getDate() }}.{{
</v-icon> jobInvite.on_date.getMonth() + 1
<v-progress-circular indeterminate v-if="jobInvitesLoading"></v-progress-circular> }}.{{ jobInvite.on_date.getFullYear() }} von
</v-col> {{ jobInvite.from_user.firstname }}
</v-row> {{ jobInvite.from_user.lastname }}
</v-expansion-panel-header> </div>
<v-expansion-panel-content :eager="true"> <v-row class="text-right" style="margin-right: 5px">
<v-row class="text-right"> <v-col>
<v-col> <v-progress-circular
<v-btn icon @click="updatingJobInvite(jobInvite)"> indeterminate
<v-icon> v-if="jobInvitesLoading"
{{ jobInvite.watched ? seen : notSeen }} ></v-progress-circular>
</v-icon> </v-col>
</v-btn> <v-col>
</v-col> <v-icon color="green" v-show="userInWorker(jobInvite)">
</v-row> {{ check }}
<Day </v-icon>
:day="jobInvite.day" </v-col>
:long="true" </v-row>
:loading="jobInvite.day.loading" </v-expansion-panel-header>
@addingJob="addingJob(jobInvite, $event)" <v-expansion-panel-content :eager="true">
@deletingJob="deletingJob(jobInvite, $event)" <v-row class="text-right">
/> <v-col>
</v-expansion-panel-content> <v-btn icon @click="updatingJobInvite(jobInvite)">
</v-expansion-panel> <v-icon>
</v-expansion-panels> {{ jobInvite.watched ? seen : notSeen }}
</v-icon>
</v-btn>
</v-col>
</v-row>
<Day
:day="jobInvite.day"
:long="true"
:loading="jobInvite.day.loading"
@addingJob="addingJob(jobInvite, $event)"
@deletingJob="deletingJob(jobInvite, $event)"
/>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</v-card-text>
</v-card>
</div> </div>
</template> </template>
@ -75,7 +80,7 @@ export default {
getJobInvites: 'jobInvites/getJobInvites', getJobInvites: 'jobInvites/getJobInvites',
addJob: 'jobInvites/addJob', addJob: 'jobInvites/addJob',
updateJobInviteToMe: 'jobInvites/updateJobInviteToMe', updateJobInviteToMe: 'jobInvites/updateJobInviteToMe',
deleteJob: 'jobInvites/deleteJob', deleteJob: 'jobInvites/deleteJob'
}), }),
forceRender() { forceRender() {
setTimeout(() => { setTimeout(() => {
@ -101,7 +106,6 @@ export default {
this.seenJobIvnite(jobInvite) this.seenJobIvnite(jobInvite)
this.deleteJob(event) this.deleteJob(event)
this.forceRender() this.forceRender()
}, },
userInWorker(jobinvite) { userInWorker(jobinvite) {
var jobkinddate = jobinvite.day.jobkinddate.find(item => { var jobkinddate = jobinvite.day.jobkinddate.find(item => {

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<v-card tile> <v-card tile :loading="jobRequestsLoading">
<v-card-title> <v-card-title>
Eingehende Anfragen Eingehende Anfragen
</v-card-title> </v-card-title>
@ -11,18 +11,25 @@
:key="index" :key="index"
> >
<v-expansion-panel-header @click.once="seenJobRequest(jobrequest)"> <v-expansion-panel-header @click.once="seenJobRequest(jobrequest)">
{{ jobrequest.on_date.getDate() }}.{{ <div>
jobrequest.on_date.getMonth() + 1 {{ jobrequest.on_date.getDate() }}.{{
}}.{{ jobrequest.on_date.getFullYear() }} von jobrequest.on_date.getMonth() + 1
{{ jobrequest.from_user.firstname }} }}.{{ jobrequest.on_date.getFullYear() }} von
{{ jobrequest.from_user.lastname }} {{ jobrequest.from_user.firstname }}
<v-row class="text-right"> {{ jobrequest.from_user.lastname }}
</div>
<v-row class="text-right" style="margin-right: 5px">
<v-col> <v-col>
<v-progress-circular <v-progress-circular
indeterminate indeterminate
v-if="jobRequestsLoading" v-if="jobRequestsLoading"
></v-progress-circular> ></v-progress-circular>
</v-col> </v-col>
<v-col>
<v-icon color="green" v-show="userInWorker(jobrequest)">
{{ check }}
</v-icon>
</v-col>
</v-row> </v-row>
</v-expansion-panel-header> </v-expansion-panel-header>
<v-expansion-panel-content> <v-expansion-panel-content>
@ -35,7 +42,11 @@
</v-btn> </v-btn>
</v-col> </v-col>
</v-row> </v-row>
<Day :day="jobrequest.day" :long="true" /> <Day
:day="jobrequest.day"
:long="true"
@sendRequests="sendingJobRequests(jobrequest, $event)"
/>
<v-row class="text-right"> <v-row class="text-right">
<v-col> <v-col>
<v-btn <v-btn
@ -51,18 +62,74 @@
</v-expansion-panels> </v-expansion-panels>
</v-card-text> </v-card-text>
</v-card> </v-card>
<h1> <v-card tile :loading="jobRequestsLoading">
fromme <v-card-title>
</h1> Ausgehende Anfragen
<div v-for="(jobrequest, index) in jobRequestsFromMe" :key="index"> </v-card-title>
{{ jobrequest }} <v-card-text>
</div> <v-expansion-panels>
<v-expansion-panel
v-for="(jobrequest, index) in jobRequestsFromMe"
:key="index"
>
<v-expansion-panel-header>
<div>
{{ jobrequest.on_date.getDate() }}.{{
jobrequest.on_date.getMonth() + 1
}}.{{ jobrequest.on_date.getFullYear() }} an
{{ jobrequest.to_user.firstname }}
{{ jobrequest.to_user.lastname }}
</div>
<v-row class="text-right" style="margin-right: 5px">
<v-col>
<v-progress-circular
indeterminate
v-if="jobRequestsLoading"
></v-progress-circular>
</v-col>
<v-col>
<v-icon color="green" v-show="jobrequest.accepted">
{{ check }}
</v-icon>
</v-col>
</v-row>
</v-expansion-panel-header>
<v-expansion-panel-content>
<v-row class="text-right">
<v-col>
<v-btn icon @click="deleteJobRequestFromMe(jobrequest)">
<v-icon>
{{trashCan}}
</v-icon>
</v-btn>
</v-col>
</v-row>
<Day
:day="jobrequest.day"
:long="true"
@sendRequests="sendingJobRequests(jobrequest, $event)"
/>
<v-row class="text-right">
<v-col>
<v-btn
v-show="!jobrequest.accepted"
text
@click="updatingAcceptedJobRequest(jobrequest)"
>Annehmen
</v-btn>
</v-col>
</v-row>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
</v-card-text>
</v-card>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from 'vuex'
import { mdiEyeOff, mdiEyeCheck } from '@mdi/js' import { mdiEyeOff, mdiEyeCheck, mdiCheck, mdiTrashCan } from '@mdi/js'
import Day from '@/components/user/Jobs/Day' import Day from '@/components/user/Jobs/Day'
export default { export default {
name: 'JobTransfer', name: 'JobTransfer',
@ -71,31 +138,47 @@ export default {
data() { data() {
return { return {
notSeen: mdiEyeOff, notSeen: mdiEyeOff,
seen: mdiEyeCheck seen: mdiEyeCheck,
check: mdiCheck,
trashCan: mdiTrashCan,
} }
}, },
methods: { methods: {
...mapActions({ ...mapActions({
getJobRequests: 'jobRequests/getJobRequests', getJobRequests: 'jobRequests/getJobRequests',
updateJobRequestToMe: 'jobRequests/updateJobRequestToMe' updateJobRequestToMe: 'jobRequests/updateJobRequestToMe',
setJobRequests: 'jobRequests/setJobRequests',
deleteJobRequestFromMe: 'jobRequests/deleteJobRequestFromMe'
}), }),
updatingAcceptedJobRequest(jobRequest) { updatingAcceptedJobRequest(jobRequest) {
jobRequest.accepted = true jobRequest.accepted = true
jobRequest.answered = true jobRequest.answered = true
this.updateJobRequestToMe({ ...jobRequest }) this.updateJobRequestToMe({ ...jobRequest })
setTimeout(() => { setTimeout(() => {
this.getJobRequests(), 200 this.getJobRequests(), 200
}) })
}, },
updatingSeenJobRequest(jobRequest) { updatingSeenJobRequest(jobRequest) {
jobRequest.watched = !jobRequest.watched jobRequest.watched = !jobRequest.watched
this.updateJobRequestToMe({...jobRequest}) this.updateJobRequestToMe({ ...jobRequest })
}, },
seenJobRequest(jobRequest) { seenJobRequest(jobRequest) {
if (!jobRequest.watched) { if (!jobRequest.watched) {
jobRequest.watched = true jobRequest.watched = true
this.updateJobRequestToMe(jobRequest) this.updateJobRequestToMe(jobRequest)
} }
},
userInWorker(jobrequest) {
var jobkinddate = jobrequest.day.jobkinddate.find(item => {
return item.worker.find(workeritem => {
return workeritem.id === this.activeUser.id
})
})
return !!jobkinddate
},
sendingJobRequests(jobrequest, event) {
this.seenJobRequest(jobrequest)
this.setJobRequests(event)
} }
}, },
computed: { computed: {
@ -103,7 +186,8 @@ export default {
jobRequestsToMe: 'jobRequests/jobRequestsToMe', jobRequestsToMe: 'jobRequests/jobRequestsToMe',
jobRequestsFromMe: 'jobRequests/jobRequestsFromMe', jobRequestsFromMe: 'jobRequests/jobRequestsFromMe',
jobRequestsLoading: 'jobRequests/jobRequestsLoading', jobRequestsLoading: 'jobRequests/jobRequestsLoading',
loading: 'user/loading' loading: 'user/loading',
activeUser: 'user/user'
}) })
}, },
created() { created() {

View File

@ -85,7 +85,6 @@ export default {
}, },
created() { created() {
this.getActiveUser() this.getActiveUser()
this.getJobInvites()
this.getAllJobKinds() this.getAllJobKinds()
this.createMonth(this.date) this.createMonth(this.date)
this.getDBUsers() this.getDBUsers()
@ -112,7 +111,8 @@ export default {
addJob: 'jobs/addJob', addJob: 'jobs/addJob',
deleteJob: 'jobs/deleteJob', deleteJob: 'jobs/deleteJob',
setJobInvites: 'jobInvites/setJobInvites', setJobInvites: 'jobInvites/setJobInvites',
getJobInvites: 'jobInvites/getJobInvites' getJobInvites: 'jobInvites/getJobInvites',
getJobRequests: 'jobRequests/getJobRequests'
}), }),
changeMonth(value) { changeMonth(value) {
if (value === -1) { if (value === -1) {
@ -139,13 +139,13 @@ export default {
...mapGetters({ ...mapGetters({
month: 'jobs/month', month: 'jobs/month',
startDate: 'jobs/getStartDate', startDate: 'jobs/getStartDate',
endDate: 'jobs/getEndDate' endDate: 'jobs/getEndDate',
loading: 'user/loading'
}) })
}, },
watch: { watch: {
$route() { $route() {
this.getActiveUser() this.getActiveUser()
this.getJobInvites()
this.date = new Date( this.date = new Date(
this.$route.params.year, this.$route.params.year,
this.$route.params.month - 1, this.$route.params.month - 1,
@ -166,6 +166,12 @@ export default {
day: this.endDate.getDate() day: this.endDate.getDate()
} }
}) })
},
loading(newValue) {
if(!newValue) {
this.getJobInvites()
this.getJobRequests()
}
} }
} }
} }

View File

@ -134,7 +134,7 @@
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-menu> </v-menu>
<v-menu v-model="menu_request" :close-on-content-click="false" offset-y> <v-menu v-model="menu_request" :close-on-content-click="false" offset-y v-if="day.locked && userInWorker()">
<template v-slot:activator="{ on }"> <template v-slot:activator="{ on }">
<v-btn v-show="day.locked && userInWorker()" text v-on="on"> <v-btn v-show="day.locked && userInWorker()" text v-on="on">
Abgeben Abgeben
@ -143,7 +143,7 @@
<v-card> <v-card>
<v-card-text> <v-card-text>
<v-autocomplete <v-autocomplete
v-model="job_invites" v-model="job_requests"
label="Einladungen senden an" label="Einladungen senden an"
return-object return-object
multiple multiple
@ -152,13 +152,13 @@
item-value="id" item-value="id"
chips chips
deletable-chips deletable-chips
:items="filteredDBUsers()" :items="filteredDBUsersWithJobKind()"
> >
</v-autocomplete> </v-autocomplete>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-spacer /> <v-spacer />
<v-btn text> <v-btn text @click="sendRequests()">
Anfragen Anfragen
</v-btn> </v-btn>
</v-card-actions> </v-card-actions>
@ -194,7 +194,8 @@ export default {
menu_invite: false, menu_invite: false,
menu_request: false, menu_request: false,
update: 0, update: 0,
job_invites: [] job_invites: [],
job_requests: []
} }
}, },
created() { created() {
@ -223,6 +224,26 @@ export default {
}, 200) }, 200)
this.menu_invite = false this.menu_invite = false
}, },
sendRequests() {
var sendData = []
this.job_requests.forEach(item => {
sendData.push({
from_user: this.activeUser,
to_user: item,
date: {
year: this.day.date.getFullYear(),
month: this.day.date.getMonth() + 1,
day: this.day.date.getDate()
},
job_kind: this.getJob_Kind()
})
})
this.$emit('sendRequests', sendData)
setTimeout(() => {
this.job_requests = []
}, 200)
this.menu_request = false
},
color: day => { color: day => {
if (day) { if (day) {
if (day.date.getDay() === 0 || day.date.getDay() === 1) { if (day.date.getDay() === 0 || day.date.getDay() === 1) {
@ -286,6 +307,34 @@ export default {
} }
this.deleteInvite(sendData) this.deleteInvite(sendData)
}, },
getJob_Kind() {
var jobkinddate = this.day.jobkinddate.find(item => {
return item.worker.find(user => {
return this.activeUser.id === user.id
})
})
return jobkinddate.job_kind
},
filteredDBUsersWithJobKind() {
console.log(this.day.jobkinddate)
var retVal = this.filteredDBUsers()
var job_kind = this.getJob_Kind()
retVal = retVal.filter(user => {
if (job_kind.workgroup ? job_kind.workgroup.if === null : true) {
return true
} else {
if (user.workgroups ? user.workgroups.length > 0 : false) {
return user.workgroups.find(wg => {
return wg.id === job_kind.workgroup.id
})
}
}
return false
})
return retVal
},
filteredDBUsers() { filteredDBUsers() {
var retVal = this.allUsers.filter(user => { var retVal = this.allUsers.filter(user => {
var test = this.day.jobkinddate.find(item => { var test = this.day.jobkinddate.find(item => {

View File

@ -1,6 +1,6 @@
//const main = 'https://192.168.5.128:5000/' //const main = 'https://192.168.5.128:5000/'
const main = 'http://localhost:5000/' //const main = 'http://localhost:5000/'
//const main = 'http://192.168.5.118:5000/' const main = 'http://192.168.5.118:5000/'
//const main = 'https://groeger-clan.duckdns.org:5000/' //const main = 'https://groeger-clan.duckdns.org:5000/'
const url = { const url = {