![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ts.corals.io/frontend/components/Entries/ |
<template> <CRUDIndex ref="entriesTable" :columns="columns" :deleteHref="deleteHref" :editHref="editHref" :resourceURL="entriesResource" :options="options" :form="form" :labels="labels" :form-size="'lg'"> <template v-slot:default="{form}"> <entry-fields :form="form"/> </template> <template v-slot:invoice="{object}"> <nuxt-link :to="'/invoices/'+object.row.invoice_id" v-if="object.row.invoice_id && object.row.invoice_id !== '-'"> {{ object.row.invoice_code }} </nuxt-link> <span v-else>-</span> </template> <template v-slot:description="{object}"> <small v-html="object.row.activity_info"></small> <div v-html="$getTextWithLinks(object.row.description)"></div> </template> <template v-slot:has_reviewed="{object}"> <fa icon="check" class="text-success" v-if="object.row.has_reviewed"/> <span v-else>-</span> </template> <template v-slot:user_id="{object}"> <nuxt-link :to="`/users/${object.row.user_id}`"> {{ object.row.user }} </nuxt-link> </template> <template v-slot:project="{object}"> <span> <nuxt-link :to="`/projects/${object.row.project_id}`"> {{ object.row.project }} </nuxt-link> </span> </template> <template v-slot:client="{object}"> <span> <nuxt-link :to="`/clients/${object.row.client_id}`"> {{ object.row.client_name }} </nuxt-link> </span> </template> <template v-slot:extra-actions="{object}"> <b-link class="text-danger" @click.prevent="markEntryAsReviewed(object)" title="Mark As Reviewed" v-if="object.markAsReviewed && evaluationEnabled"> <fa icon="check" class="text-success"/> </b-link> </template> </CRUDIndex> </template> <script> import CRUDIndex from "@/components/layout/CRUDIndex"; import EntryFields from "@/components/Entries/EntryFields"; import commonMixin from "@/mixins/commonMixin"; export default { name: "EntriesIndex", mixins: [commonMixin], props: { entriesResource: { required: true }, withoutActions: { default: false, type: Boolean, } }, components: { CRUDIndex, EntryFields }, data() { return { labels: { title: 'Entries', singularTitle: 'Entry', }, options: { listColumns: { user_id: [], }, initFilters: { 'client': this.$route.query.client ?? '', 'project': this.$route.query.project ?? '', }, sortable: ['spent_at'], filterable: ['user_id', 'project', 'client', 'spent_at', 'description', 'invoice'], customColumns: ['project', 'client', 'user_id', 'description', 'invoice'], hideCreate: true, headings: { 'evaluation_time': 'Evaluation', 'user_id': 'User', } }, form: this.$form({ activity_id: '', user_id: '', project_id: '', spent_at: new Date(), hours: '', minutes: '', description: '', evaluation_minutes: '', evaluation_hours: '', has_reviewed: 0, }, { fetchFormDataURL: 'timesheet/entries/get-form-data', model: 'entry', loadFormDataCallBack: () => { this.options.listColumns.user_id = this.getOptions(this.form.formData.users); } }) } }, methods: { getOptions(list) { let allOption = {id: '', text: 'All'}; let options = []; options.push(allOption); list.map(row => { let label = row.label.split(","); options.push({id: row.id ?? row.value, text: label[0]}); }); return options; }, markEntryAsReviewed(entry) { this.$axios.post(`timesheet/projects/${entry.project_id}/entries/${entry.id}/mark-entry-as-reviewed`) .then(response => { this.$refs.entriesTable.refresh(); }).catch(err => { let message = err.message; if (err.response && err.response.data && err.response.data.message) { message = err.response.data.message; } this.$toast.error(message); }) }, }, computed: { evaluationEnabled() { return this.$store.getters.settings('evaluation_enabled'); }, columns() { let columns = [ 'description', 'activity', 'spent_at', 'user_id', 'project', 'client' ]; if (this.$isAdmin()) { columns.push('time'); columns.push('cost'); columns.push('amount'); } columns.push('evaluation_time'); if (!this.entriesResource.includes('invoice')) { columns.push('invoice'); } if (!this.withoutActions) { columns.push('actions'); } return columns; }, deleteHref() { return `timesheet/entries`; }, editHref() { return `timesheet/entries` }, isTimesheetAdministration() { return this.$auth.user && this.$auth.user.is_timesheet_administration; }, } } </script> <style scoped> </style>