|
| 1 | +<!-- |
| 2 | +/** |
| 3 | + * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures |
| 4 | + * all the essential functionalities required for any enterprise. |
| 5 | + * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com |
| 6 | + * |
| 7 | + * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of |
| 8 | + * the GNU General Public License as published by the Free Software Foundation; either |
| 9 | + * version 2 of the License, or (at your option) any later version. |
| 10 | + * |
| 11 | + * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 12 | + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | + * See the GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License along with this program; |
| 16 | + * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | + * Boston, MA 02110-1301, USA |
| 18 | + */ |
| 19 | + --> |
| 20 | +<template> |
| 21 | + <div |
| 22 | + :class="{ |
| 23 | + 'orangehrm-action-button-container': allowedActions.length < 2, |
| 24 | + 'orangehrm-action-buttons-container': allowedActions.length > 1, |
| 25 | + }" |
| 26 | + > |
| 27 | + <oxd-button |
| 28 | + display-type="ghost" |
| 29 | + class="orangehrm-sm-button" |
| 30 | + :label="$t('general.back')" |
| 31 | + @click="onBack" |
| 32 | + /> |
| 33 | + <oxd-button |
| 34 | + v-if="isCancelAllowed" |
| 35 | + display-type="danger" |
| 36 | + class="orangehrm-sm-button" |
| 37 | + :label="$t('general.cancel')" |
| 38 | + @click="onClaimAction('CANCEL')" |
| 39 | + /> |
| 40 | + <oxd-button |
| 41 | + v-if="isRejectAllowed" |
| 42 | + display-type="danger" |
| 43 | + class="orangehrm-sm-button" |
| 44 | + :label="$t('general.reject')" |
| 45 | + @click="onClaimAction('REJECT')" |
| 46 | + /> |
| 47 | + <oxd-button |
| 48 | + v-if="isApproveAllowed" |
| 49 | + display-type="secondary" |
| 50 | + class="orangehrm-sm-button" |
| 51 | + :label="$t('general.approve')" |
| 52 | + @click="onClaimAction('APPROVE')" |
| 53 | + /> |
| 54 | + <oxd-button |
| 55 | + v-if="isPayAllowed" |
| 56 | + display-type="secondary" |
| 57 | + class="orangehrm-sm-button" |
| 58 | + :label="$t('claim.pay')" |
| 59 | + @click="onClaimAction('PAY')" |
| 60 | + /> |
| 61 | + <oxd-button |
| 62 | + v-if="isSubmitAllowed" |
| 63 | + display-type="secondary" |
| 64 | + class="orangehrm-sm-button" |
| 65 | + :label="$t('general.submit')" |
| 66 | + @click="onClaimAction('SUBMIT')" |
| 67 | + /> |
| 68 | + </div> |
| 69 | +</template> |
| 70 | + |
| 71 | +<script> |
| 72 | +import {APIService} from '@/core/util/services/api.service'; |
| 73 | +import {navigate} from '@ohrm/core/util/helper/navigation'; |
| 74 | + |
| 75 | +export default { |
| 76 | + name: 'ClaimActionButtons', |
| 77 | + props: { |
| 78 | + requestId: { |
| 79 | + type: Number, |
| 80 | + required: true, |
| 81 | + }, |
| 82 | + allowedActions: { |
| 83 | + type: Array, |
| 84 | + required: true, |
| 85 | + }, |
| 86 | + }, |
| 87 | + setup(props) { |
| 88 | + const http = new APIService( |
| 89 | + window.appGlobal.baseUrl, |
| 90 | + `/api/v2/claim/requests/${props.requestId}/action`, |
| 91 | + ); |
| 92 | + return { |
| 93 | + http, |
| 94 | + }; |
| 95 | + }, |
| 96 | + computed: { |
| 97 | + isCancelAllowed() { |
| 98 | + return this.allowedActions.includes('Cancel'); |
| 99 | + }, |
| 100 | + isSubmitAllowed() { |
| 101 | + return this.allowedActions.includes('Submit'); |
| 102 | + }, |
| 103 | + isApproveAllowed() { |
| 104 | + return this.allowedActions.includes('Approve'); |
| 105 | + }, |
| 106 | + isRejectAllowed() { |
| 107 | + return this.allowedActions.includes('Reject'); |
| 108 | + }, |
| 109 | + isPayAllowed() { |
| 110 | + return this.allowedActions.includes('Pay'); |
| 111 | + }, |
| 112 | + }, |
| 113 | + methods: { |
| 114 | + onClaimAction(action) { |
| 115 | + this.http |
| 116 | + .request({ |
| 117 | + method: 'PUT', |
| 118 | + data: { |
| 119 | + action: action, |
| 120 | + }, |
| 121 | + }) |
| 122 | + .then(() => { |
| 123 | + return this.$toast.saveSuccess(); |
| 124 | + }) |
| 125 | + .then(() => { |
| 126 | + navigate(`/claim/submitClaim/id/${this.requestId}`); |
| 127 | + }); |
| 128 | + }, |
| 129 | + onBack() { |
| 130 | + navigate('/claim/submitClaim'); |
| 131 | + }, |
| 132 | + }, |
| 133 | +}; |
| 134 | +</script> |
| 135 | + |
| 136 | +<style scoped lang="scss"> |
| 137 | +.orangehrm-action-buttons-container { |
| 138 | + display: flex; |
| 139 | + flex-direction: row; |
| 140 | + flex-wrap: wrap; |
| 141 | + justify-content: flex-end; |
| 142 | + padding: 25px; |
| 143 | + @media screen and (max-width: 600px) { |
| 144 | + display: flex; |
| 145 | + flex-direction: column; |
| 146 | + align-items: center; |
| 147 | + } |
| 148 | +} |
| 149 | +.orangehrm-action-button-container { |
| 150 | + display: flex; |
| 151 | + flex-direction: row; |
| 152 | + flex-wrap: wrap; |
| 153 | + justify-content: flex-end; |
| 154 | + padding: 25px; |
| 155 | +} |
| 156 | +.orangehrm-sm-button { |
| 157 | + margin-left: 1rem; |
| 158 | + @media screen and (max-width: 600px) { |
| 159 | + margin-bottom: 1rem; |
| 160 | + } |
| 161 | +} |
| 162 | +</style> |
0 commit comments