Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions frontend/src/components/CheckInPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@
</template>

<script setup>
import { createResource, createListResource, toast, FeatherIcon } from "frappe-ui"
import { createListResource, toast, FeatherIcon } from "frappe-ui"
import { computed, inject, ref, onMounted, onBeforeUnmount } from "vue"
import { IonModal, modalController } from "@ionic/vue"

import { formatTimestamp } from "@/utils/formatters"
import { settings } from "@/data/settings"

const DOCTYPE = "Employee Checkin"

Expand All @@ -93,10 +94,6 @@ const checkinTimestamp = ref(null)
const latitude = ref(0)
const longitude = ref(0)
const locationStatus = ref("")
const settings = createResource({
url: "hrms.api.get_hr_settings",
auto: true,
})

const checkins = createListResource({
doctype: DOCTYPE,
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/components/RequestActionSheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ import FilePreviewModal from "@/components/FilePreviewModal.vue"
import WorkflowActionSheet from "@/components/WorkflowActionSheet.vue"

import { getCompanyCurrency } from "@/data/currencies"
import { settings } from "@/data/settings"
import { formatCurrency } from "@/utils/formatters"

import useWorkflow from "@/composables/workflow"
Expand Down Expand Up @@ -231,9 +232,16 @@ const permittedWriteFields = createResource({
auto: true,
})

const sessionEmployee = inject("$employee")

function hasPermission(action) {
if (action === "approval")
if (action === "approval" && props.modelValue.doctype === "Leave Application"){
// prevent self leave approval
const isSelfLeave = document?.doc?.employee === sessionEmployee?.data?.name
if (isSelfLeave && settings.data?.prevent_self_leave_approval)
return false
return permittedWriteFields.data?.includes(approvalField.value)
}
return docPermissions.data?.permissions[action]
}

Expand Down Expand Up @@ -337,6 +345,7 @@ const openFormView = () => {
onMounted(() => {
workflow.value = useWorkflow(props.modelValue.doctype)
})

</script>

<style scoped>
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/RequestList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
:initial-breakpoint="1"
:breakpoints="[0, 1]"
>
<RequestActionSheet :fields="fieldsMap[selectedRequest?.doctype]" v-model="selectedRequest" />
<RequestActionSheet
:fields="fieldsMap[selectedRequest?.doctype]"
v-model="selectedRequest"
/>
</ion-modal>
</template>

Expand Down
6 changes: 6 additions & 0 deletions frontend/src/data/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createResource } from "frappe-ui"

export const settings = createResource({
url: "hrms.api.get_hr_settings",
auto: true,
})
1 change: 1 addition & 0 deletions hrms/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def get_hr_settings() -> dict:
return frappe._dict(
allow_employee_checkin_from_mobile_app=settings.allow_employee_checkin_from_mobile_app,
allow_geolocation_tracking=settings.allow_geolocation_tracking,
prevent_self_leave_approval=settings.prevent_self_leave_approval,
)


Expand Down
Loading